From 62e8919dfbf75a0279a81426466334f0b6c07aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sikora?= Date: Thu, 8 Oct 2020 09:06:36 +0200 Subject: [PATCH] Unify naming of generated functions. --- README.md | 2 +- .../SourcedFeatureStorageGenerator.kt | 2 +- .../generator/SourcedFeatureStorageModel.kt | 2 +- .../generator/SourcedFeatureStorageSpec.kt | 10 ++-- .../gradle/GenerateSourcedStorageTaskSpec.kt | 56 +++++++++---------- .../laboratory/sample/SampleApplication.kt | 2 +- 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 5d992e2a8..48d2e03bb 100644 --- a/README.md +++ b/README.md @@ -229,7 +229,7 @@ enum class PowerPlant(override val isFallbackValue: Boolean = false) : Feature

, ) { - internal val name = "GeneratedSourcedFeatureStorage" + internal val name = "sourcedGeneratedFeatureStorage" internal val fqcn = if (packageName.isEmpty()) name else "$packageName.$name" fun build(): Either { diff --git a/library/generator/src/test/java/io/mehow/laboratory/generator/SourcedFeatureStorageSpec.kt b/library/generator/src/test/java/io/mehow/laboratory/generator/SourcedFeatureStorageSpec.kt index 0307ebb96..6dcacd6d2 100644 --- a/library/generator/src/test/java/io/mehow/laboratory/generator/SourcedFeatureStorageSpec.kt +++ b/library/generator/src/test/java/io/mehow/laboratory/generator/SourcedFeatureStorageSpec.kt @@ -74,7 +74,7 @@ class SourcedFeatureStorageSpec : DescribeSpec({ |import kotlin.collections.mapOf |import kotlin.to | - |internal fun FeatureStorage.Companion.generatedSourced( + |internal fun FeatureStorage.Companion.sourcedGenerated( | localSource: FeatureStorage, | firebaseSource: FeatureStorage, | s3Source: FeatureStorage @@ -106,7 +106,7 @@ class SourcedFeatureStorageSpec : DescribeSpec({ |import kotlin.collections.mapOf |import kotlin.to | - |fun FeatureStorage.Companion.generatedSourced( + |fun FeatureStorage.Companion.sourcedGenerated( | localSource: FeatureStorage, | firebaseSource: FeatureStorage, | s3Source: FeatureStorage @@ -138,7 +138,7 @@ class SourcedFeatureStorageSpec : DescribeSpec({ |import kotlin.collections.mapOf |import kotlin.to | - |fun FeatureStorage.Companion.generatedSourced( + |fun FeatureStorage.Companion.sourcedGenerated( | localSource: FeatureStorage, | fooSource: FeatureStorage, | barSource: FeatureStorage, @@ -181,7 +181,7 @@ class SourcedFeatureStorageSpec : DescribeSpec({ |import kotlin.collections.mapOf |import kotlin.to | - |fun FeatureStorage.Companion.generatedSourced(localSource: FeatureStorage, + |fun FeatureStorage.Companion.sourcedGenerated(localSource: FeatureStorage, | fooSource: FeatureStorage): FeatureStorage = sourced( | localSource, | mapOf( @@ -208,7 +208,7 @@ class SourcedFeatureStorageSpec : DescribeSpec({ |import io.mehow.laboratory.FeatureStorage.Companion.sourced |import kotlin.collections.emptyMap | - |fun FeatureStorage.Companion.generatedSourced(localSource: FeatureStorage): FeatureStorage = + |fun FeatureStorage.Companion.sourcedGenerated(localSource: FeatureStorage): FeatureStorage = | sourced( | localSource, | emptyMap() diff --git a/library/gradle-plugin/src/test/java/io/mehow/laboratory/gradle/GenerateSourcedStorageTaskSpec.kt b/library/gradle-plugin/src/test/java/io/mehow/laboratory/gradle/GenerateSourcedStorageTaskSpec.kt index 2f757cc7c..1c6d20d1f 100644 --- a/library/gradle-plugin/src/test/java/io/mehow/laboratory/gradle/GenerateSourcedStorageTaskSpec.kt +++ b/library/gradle-plugin/src/test/java/io/mehow/laboratory/gradle/GenerateSourcedStorageTaskSpec.kt @@ -38,11 +38,11 @@ class GenerateSourcedStorageTaskSpec : StringSpec({ result.task(":generateSourcedFeatureStorage")!!.outcome shouldBe SUCCESS - val factory = fixture.sourcedStorageFile("GeneratedSourcedFeatureStorage") + val factory = fixture.sourcedStorageFile("sourcedGeneratedFeatureStorage") factory.shouldExist() factory.readText() shouldContain """ - |fun FeatureStorage.Companion.generatedSourced(localSource: FeatureStorage): FeatureStorage + |fun FeatureStorage.Companion.sourcedGenerated(localSource: FeatureStorage): FeatureStorage | = sourced( | localSource, | emptyMap() @@ -57,11 +57,11 @@ class GenerateSourcedStorageTaskSpec : StringSpec({ result.task(":generateSourcedFeatureStorage")!!.outcome shouldBe SUCCESS - val factory = fixture.sourcedStorageFile("GeneratedSourcedFeatureStorage") + val factory = fixture.sourcedStorageFile("sourcedGeneratedFeatureStorage") factory.shouldExist() factory.readText() shouldContain """ - |fun FeatureStorage.Companion.generatedSourced( + |fun FeatureStorage.Companion.sourcedGenerated( | localSource: FeatureStorage, | remoteASource: FeatureStorage, | remoteBSource: FeatureStorage @@ -80,7 +80,7 @@ class GenerateSourcedStorageTaskSpec : StringSpec({ gradleRunner.withProjectDir(fixture).build() - val factory = fixture.sourcedStorageFile("io.mehow.implicit.GeneratedSourcedFeatureStorage") + val factory = fixture.sourcedStorageFile("io.mehow.implicit.sourcedGeneratedFeatureStorage") factory.shouldExist() factory.readText() shouldContain "package io.mehow.implicit" @@ -91,7 +91,7 @@ class GenerateSourcedStorageTaskSpec : StringSpec({ gradleRunner.withProjectDir(fixture).build() - val factory = fixture.sourcedStorageFile("io.mehow.explicit.GeneratedSourcedFeatureStorage") + val factory = fixture.sourcedStorageFile("io.mehow.explicit.sourcedGeneratedFeatureStorage") factory.shouldExist() factory.readText() shouldContain "package io.mehow.explicit" @@ -102,7 +102,7 @@ class GenerateSourcedStorageTaskSpec : StringSpec({ gradleRunner.withProjectDir(fixture).build() - val factory = fixture.sourcedStorageFile("io.mehow.explicit.GeneratedSourcedFeatureStorage") + val factory = fixture.sourcedStorageFile("io.mehow.explicit.sourcedGeneratedFeatureStorage") factory.shouldExist() factory.readText() shouldContain "package io.mehow.explicit" @@ -113,10 +113,10 @@ class GenerateSourcedStorageTaskSpec : StringSpec({ gradleRunner.withProjectDir(fixture).build() - val factory = fixture.sourcedStorageFile("GeneratedSourcedFeatureStorage") + val factory = fixture.sourcedStorageFile("sourcedGeneratedFeatureStorage") factory.shouldExist() - factory.readText() shouldContain "internal fun FeatureStorage.Companion.generatedSourced(localSource: FeatureStorage)" + factory.readText() shouldContain "internal fun FeatureStorage.Companion.sourcedGenerated(localSource: FeatureStorage)" } "generates public storage" { @@ -124,14 +124,14 @@ class GenerateSourcedStorageTaskSpec : StringSpec({ gradleRunner.withProjectDir(fixture).build() - val factory = fixture.sourcedStorageFile("GeneratedSourcedFeatureStorage") + val factory = fixture.sourcedStorageFile("sourcedGeneratedFeatureStorage") factory.shouldExist() // Ensure public by checking a new line before enum declaration. // Change after https://github.com/square/kotlinpoet/pull/933 factory.readText() shouldContain """ | - |fun FeatureStorage.Companion.generatedSourced(localSource: FeatureStorage) + |fun FeatureStorage.Companion.sourcedGenerated(localSource: FeatureStorage) """.trimMargin("|") } @@ -141,9 +141,9 @@ class GenerateSourcedStorageTaskSpec : StringSpec({ val result = gradleRunner.withProjectDir(fixture).buildAndFail() result.task(":generateSourcedFeatureStorage")!!.outcome shouldBe FAILED - result.output shouldContain InvalidPackageName("!!!.GeneratedSourcedFeatureStorage").message + result.output shouldContain InvalidPackageName("!!!.sourcedGeneratedFeatureStorage").message - val feature = fixture.sourcedStorageFile("GeneratedSourcedFeatureStorage") + val feature = fixture.sourcedStorageFile("sourcedGeneratedFeatureStorage") feature.shouldNotExist() } @@ -155,7 +155,7 @@ class GenerateSourcedStorageTaskSpec : StringSpec({ result.task(":generateSourcedFeatureStorage")!!.outcome shouldBe FAILED result.output shouldContain NoFeatureValues("Feature").message - val feature = fixture.sourcedStorageFile("GeneratedSourcedFeatureStorage") + val feature = fixture.sourcedStorageFile("sourcedGeneratedFeatureStorage") feature.shouldNotExist() } @@ -167,7 +167,7 @@ class GenerateSourcedStorageTaskSpec : StringSpec({ result.task(":generateSourcedFeatureStorage")!!.outcome shouldBe FAILED result.output shouldContain FeatureValuesCollision("First".nel(), "Feature").message - val feature = fixture.sourcedStorageFile("GeneratedSourcedFeatureStorage") + val feature = fixture.sourcedStorageFile("sourcedGeneratedFeatureStorage") feature.shouldNotExist() } @@ -179,7 +179,7 @@ class GenerateSourcedStorageTaskSpec : StringSpec({ result.task(":generateSourcedFeatureStorage")!!.outcome shouldBe FAILED result.output shouldContain InvalidFeatureValues(NonEmptyList("!!!, ???"), "Feature").message - val feature = fixture.sourcedStorageFile("GeneratedSourcedFeatureStorage") + val feature = fixture.sourcedStorageFile("sourcedGeneratedFeatureStorage") feature.shouldNotExist() } @@ -191,7 +191,7 @@ class GenerateSourcedStorageTaskSpec : StringSpec({ result.task(":generateSourcedFeatureStorage")!!.outcome shouldBe FAILED result.output shouldContain InvalidFeatureName("!!!", "!!!").message - val feature = fixture.sourcedStorageFile("GeneratedSourcedFeatureStorage") + val feature = fixture.sourcedStorageFile("sourcedGeneratedFeatureStorage") feature.shouldNotExist() } @@ -203,7 +203,7 @@ class GenerateSourcedStorageTaskSpec : StringSpec({ result.task(":generateSourcedFeatureStorage")!!.outcome shouldBe FAILED result.output shouldContain InvalidPackageName("!!!.Feature").message - val feature = fixture.sourcedStorageFile("GeneratedSourcedFeatureStorage") + val feature = fixture.sourcedStorageFile("sourcedGeneratedFeatureStorage") feature.shouldNotExist() } @@ -215,7 +215,7 @@ class GenerateSourcedStorageTaskSpec : StringSpec({ result.task(":generateSourcedFeatureStorage")!!.outcome shouldBe FAILED result.output shouldContain FeaturesCollision("io.mehow.Feature".nel()).message - val feature = fixture.sourcedStorageFile("GeneratedSourcedFeatureStorage") + val feature = fixture.sourcedStorageFile("sourcedGeneratedFeatureStorage") feature.shouldNotExist() } @@ -226,11 +226,11 @@ class GenerateSourcedStorageTaskSpec : StringSpec({ result.task(":generateSourcedFeatureStorage")!!.outcome shouldBe SUCCESS - val factory = fixture.sourcedStorageFile("GeneratedSourcedFeatureStorage") + val factory = fixture.sourcedStorageFile("sourcedGeneratedFeatureStorage") factory.shouldExist() factory.readText() shouldContain """ - |fun FeatureStorage.Companion.generatedSourced( + |fun FeatureStorage.Companion.sourcedGenerated( | localSource: FeatureStorage, | remoteSource: FeatureStorage, | remoteASource: FeatureStorage, @@ -253,11 +253,11 @@ class GenerateSourcedStorageTaskSpec : StringSpec({ result.task(":generateSourcedFeatureStorage")!!.outcome shouldBe SUCCESS - val factory = fixture.sourcedStorageFile("GeneratedSourcedFeatureStorage") + val factory = fixture.sourcedStorageFile("sourcedGeneratedFeatureStorage") factory.shouldExist() factory.readText() shouldContain """ - |fun FeatureStorage.Companion.generatedSourced( + |fun FeatureStorage.Companion.sourcedGenerated( | localSource: FeatureStorage, | remoteSource: FeatureStorage, | remoteBSource: FeatureStorage @@ -279,7 +279,7 @@ class GenerateSourcedStorageTaskSpec : StringSpec({ result.task(":generateSourcedFeatureStorage")!!.outcome shouldBe FAILED result.output shouldContain FeaturesCollision("Feature".nel()).message - val feature = fixture.sourcedStorageFile("GeneratedSourcedFeatureStorage") + val feature = fixture.sourcedStorageFile("sourcedGeneratedFeatureStorage") feature.shouldNotExist() } @@ -290,11 +290,11 @@ class GenerateSourcedStorageTaskSpec : StringSpec({ result.task(":generateSourcedFeatureStorage")!!.outcome shouldBe SUCCESS - val factory = fixture.sourcedStorageFile("GeneratedSourcedFeatureStorage") + val factory = fixture.sourcedStorageFile("sourcedGeneratedFeatureStorage") factory.shouldExist() factory.readText() shouldContain """ - |fun FeatureStorage.Companion.generatedSourced(localSource: FeatureStorage): FeatureStorage + |fun FeatureStorage.Companion.sourcedGenerated(localSource: FeatureStorage): FeatureStorage | = sourced( | localSource, | emptyMap() @@ -309,11 +309,11 @@ class GenerateSourcedStorageTaskSpec : StringSpec({ result.task(":generateSourcedFeatureStorage")!!.outcome shouldBe SUCCESS - val factory = fixture.sourcedStorageFile("GeneratedSourcedFeatureStorage") + val factory = fixture.sourcedStorageFile("sourcedGeneratedFeatureStorage") factory.shouldExist() factory.readText() shouldContain """ - |fun FeatureStorage.Companion.generatedSourced(localSource: FeatureStorage): FeatureStorage + |fun FeatureStorage.Companion.sourcedGenerated(localSource: FeatureStorage): FeatureStorage | = sourced( | localSource, | emptyMap() diff --git a/sample/src/main/java/io/mehow/laboratory/sample/SampleApplication.kt b/sample/src/main/java/io/mehow/laboratory/sample/SampleApplication.kt index bc3a3d304..5d8a4c479 100644 --- a/sample/src/main/java/io/mehow/laboratory/sample/SampleApplication.kt +++ b/sample/src/main/java/io/mehow/laboratory/sample/SampleApplication.kt @@ -23,7 +23,7 @@ class SampleApplication : Application() { val awsStorage = SharedPreferencesFeatureStorage( getSharedPreferences("awsFeatures", MODE_PRIVATE) ) - val sourcedStorage = FeatureStorage.generatedSourced( + val sourcedStorage = FeatureStorage.sourcedGenerated( localSource = localStorage, firebaseSource = firebaseStorage, awsSource = awsStorage,