Skip to content

Commit

Permalink
Merge pull request #24 from Winfooz/mhamdan/code-style/2018-11-04
Browse files Browse the repository at this point in the history
Mhamdan/code style/2018 11 04
  • Loading branch information
winfoozmnayef authored Nov 5, 2018
2 parents 7cffae7 + fd52a36 commit 5edd3f3
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ repositories {
}
dependencies {
implementation 'com.winfooz.winanalytics:winanalytics:1.0.2-beta'
kapt 'com.winfooz.winanalytics:compiler:1.0.2-beta'
implementation 'com.winfooz.winanalytics:winanalytics:1.0.3-beta'
kapt 'com.winfooz.winanalytics:compiler:1.0.3-beta'
}
```

Expand Down
2 changes: 1 addition & 1 deletion annotations/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ POM_DESCRIPTION=Annotations for use in your project
POM_BINTRAY_NAME=com.winfooz.winanalytics:annotations
POM_ARTIFACT_ID=annotations
POM_PACKAGING=jar
POM_VERSION=1.0.2-beta
POM_VERSION=1.0.3-beta
2 changes: 1 addition & 1 deletion compiler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ dependencies {
implementation project(':annotations')

// Code generation library for kotlin.
implementation 'com.squareup:kotlinpoet:0.7.0'
implementation 'com.squareup:kotlinpoet:1.0.0-RC2'
}
apply from: rootProject.file('deploy.gradle')
2 changes: 1 addition & 1 deletion compiler/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ POM_DESCRIPTION=For proccess annotations and generate code
POM_BINTRAY_NAME=com.winfooz.winanalytics:compiler
POM_ARTIFACT_ID=compiler
POM_PACKAGING=jar
POM_VERSION=1.0.2-beta
POM_VERSION=1.0.3-beta
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class AnalyticsType(
private val constructorBuilder: FunSpec.Builder by lazy {
val funSpec = FunSpec.constructorBuilder()
funSpec.addModifiers(KModifier.PUBLIC)
funSpec.addParameter(ParameterSpec.builder("val context", CONTEXT, KModifier.PRIVATE).build())
funSpec.addParameter(ParameterSpec.builder("context", CONTEXT, KModifier.PRIVATE).build())
typBuilder.addProperty(PropertySpec.builder("context", CONTEXT, KModifier.PRIVATE).initializer("context").build())
addPram(configuration.firebaseEnabled, funSpec, FIREBASE_PREFIX, FIREBASE_ANALYTICS)
addPram(configuration.fabricEnabled, funSpec, FABRIC_PREFIX, FABRIC_ANALYTICS)
addPram(configuration.mixPanelEnabled, funSpec, MIXPANEL_PREFIX, MIXPANEL_ANALYTICS)
Expand Down Expand Up @@ -125,7 +126,8 @@ class AnalyticsType(
*/
private fun addPram(add: Boolean, funSpec: FunSpec.Builder, name: String, className: ClassName) {
if (add) {
funSpec.addParameter("val ${name.toLowerCase()}", className, KModifier.PRIVATE)
typBuilder.addProperty(PropertySpec.builder(name.toLowerCase(), className, KModifier.PRIVATE).initializer(name.toLowerCase()).build())
funSpec.addParameter(name.toLowerCase(), className, KModifier.PRIVATE)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.winfooz.winanalytics.compiler.models.Configuration
import com.winfooz.winanalytics.compiler.models.FieldData
import java.io.File
import javax.annotation.processing.ProcessingEnvironment
import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy

/**
* This type for generate class with name "Analytics" contains every object of analytics classes.
Expand All @@ -31,8 +32,7 @@ class ConfigurationType(private val processingEnv: ProcessingEnvironment,
* singleton pattern with context parameter
*/
private val singletonHolder: TypeSpec.Builder = TypeSpec.companionObjectBuilder()
.superclass(ParameterizedTypeName.get(
SINGLETON_HOLDER,
.superclass(SINGLETON_HOLDER.parameterizedBy(
ClassName(pkg, CLASS_NAME),
CONTEXT
))
Expand All @@ -45,7 +45,7 @@ class ConfigurationType(private val processingEnv: ProcessingEnvironment,
private val constructorBuilder: FunSpec.Builder = FunSpec.constructorBuilder()
.addModifiers(KModifier.PRIVATE)
.addParameter(ParameterSpec.builder(
"val context",
"context",
CONTEXT,
KModifier.PRIVATE
).build())
Expand All @@ -68,6 +68,7 @@ class ConfigurationType(private val processingEnv: ProcessingEnvironment,
* For generate Analytics class with singleton pattern
*/
override fun build() {
typBuilder.addProperty(PropertySpec.builder("context", CONTEXT, KModifier.PRIVATE).initializer("context").build())
typBuilder.primaryConstructor(constructorBuilder.build())
typBuilder.addType(singletonHolder.build())
val file = FileSpec.builder(pkg, CLASS_NAME)
Expand Down
2 changes: 1 addition & 1 deletion winanalytics/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ POM_DESCRIPTION=For log analytics to firebase,fabric,mixpanel etc...
POM_BINTRAY_NAME=com.winfooz.winanalytics:winanalytics
POM_ARTIFACT_ID=winanalytics
POM_PACKAGING=jar
POM_VERSION=1.0.2-beta
POM_VERSION=1.0.3-beta

0 comments on commit 5edd3f3

Please sign in to comment.