Repository: serpro69/kotlin-faker
Pull request #115 (2021-12-03 11:09:13)

Add Crossfit® provider to Faker

serpro69: Hi @jgiovaresco ,
Thanks for this contribution! I'll go over your PR on the weekend.

Patch:
diff --git a/cli-bot/src/main/resources/META-INF/native-image/io.github.serpro69/cli-bot/reflect-config.json b/cli-bot/src/main/resources/META-INF/native-image/io.github.serpro69/cli-bot/reflect-config.json
index 8e00f612..d2e5b3fa 100644
--- a/cli-bot/src/main/resources/META-INF/native-image/io.github.serpro69/cli-bot/reflect-config.json
+++ b/cli-bot/src/main/resources/META-INF/native-image/io.github.serpro69/cli-bot/reflect-config.json
@@ -56,6 +56,7 @@
     {"name":"getConstruction","parameterTypes":[] },
     {"name":"getControl","parameterTypes":[] },
     {"name":"getCosmere","parameterTypes":[] },
+    {"name":"getCrossfit","parameterTypes":[] },
     {"name":"getCryptoCoin","parameterTypes":[] },
     {"name":"getCultureSeries","parameterTypes":[] },
     {"name":"getCurrency","parameterTypes":[] },
diff --git a/core/src/main/kotlin/io/github/serpro69/kfaker/Constants.kt b/core/src/main/kotlin/io/github/serpro69/kfaker/Constants.kt
index 5c29819e..96a79a0c 100644
--- a/core/src/main/kotlin/io/github/serpro69/kfaker/Constants.kt
+++ b/core/src/main/kotlin/io/github/serpro69/kfaker/Constants.kt
@@ -40,6 +40,7 @@ val defaultFileNames = listOf(
     "construction.yml",
     "control.yml",
     "cosmere.yml",
+    "crossfit.yml",
     "crypto_coin.yml",
     "culture_series.yml",
     "currency.yml",
diff --git a/core/src/main/kotlin/io/github/serpro69/kfaker/Faker.kt b/core/src/main/kotlin/io/github/serpro69/kfaker/Faker.kt
index 914cf6a7..ba9186ae 100644
--- a/core/src/main/kotlin/io/github/serpro69/kfaker/Faker.kt
+++ b/core/src/main/kotlin/io/github/serpro69/kfaker/Faker.kt
@@ -63,6 +63,7 @@ class Faker @JvmOverloads constructor(internal val config: FakerConfig = fakerCo
     val construction: Construction = Construction(fakerService)
     val control: Control = Control(fakerService)
     val cosmere: Cosmere = Cosmere(fakerService)
+    val crossfit: Crossfit = Crossfit(fakerService)
     val cryptoCoin: CryptoCoin = CryptoCoin(fakerService)
     val cultureSeries: CultureSeries = CultureSeries(fakerService)
     val currency: Currency = Currency(fakerService)
diff --git a/core/src/main/kotlin/io/github/serpro69/kfaker/dictionary/Dictionary.kt b/core/src/main/kotlin/io/github/serpro69/kfaker/dictionary/Dictionary.kt
index 88715f0b..c9d652fa 100644
--- a/core/src/main/kotlin/io/github/serpro69/kfaker/dictionary/Dictionary.kt
+++ b/core/src/main/kotlin/io/github/serpro69/kfaker/dictionary/Dictionary.kt
@@ -56,6 +56,7 @@ internal enum class CategoryName {
     COSMERE,
     COUNTRY_CODE,
     CREATURE,
+    CROSSFIT,
     CRYPTO_COIN,
     CULTURE_SERIES,
     CURRENCY,
diff --git a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Crossfit.kt b/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Crossfit.kt
new file mode 100644
index 00000000..02020471
--- /dev/null
+++ b/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Crossfit.kt
@@ -0,0 +1,22 @@
+package io.github.serpro69.kfaker.provider
+
+import io.github.serpro69.kfaker.FakerService
+import io.github.serpro69.kfaker.dictionary.CategoryName
+import io.github.serpro69.kfaker.provider.unique.LocalUniqueDataProvider
+import io.github.serpro69.kfaker.provider.unique.UniqueProviderDelegate
+
+/**
+ * [FakeDataProvider] implementation for [CategoryName.CROSSFIT] category.
+ */
+class Crossfit internal constructor(fakerService: FakerService): AbstractFakeDataProvider<Crossfit>(fakerService){
+    override val categoryName= CategoryName.CROSSFIT
+    override val localUniqueDataProvider= LocalUniqueDataProvider<Crossfit>()
+    override val unique by UniqueProviderDelegate(localUniqueDataProvider)
+
+    fun competitions() = resolve("competition")
+    fun maleAthletes() = resolve("athlete", "male")
+    fun femaleAthletes() = resolve("athlete", "female")
+    fun movements() = resolve("movement")
+    fun girlWorkouts() = resolve("workout", "girl")
+    fun heroWorkouts() = resolve("workout", "hero")
+}
\ No newline at end of file
diff --git a/core/src/main/resources/locales/en/crossfit.yml b/core/src/main/resources/locales/en/crossfit.yml
new file mode 100644
index 00000000..4d543568
--- /dev/null
+++ b/core/src/main/resources/locales/en/crossfit.yml
@@ -0,0 +1,112 @@
+# START crossfit_provider_dict
+en:
+  faker:
+    crossfit:
+      competition:
+        - CrossFit Fittest in Cape Town
+        - CrossFit® French Throwdown
+        - CrossFit West Coast Classic
+        - Dubai CrossFit® Championship
+        - Mid-Atlantic CrossFit Challenge
+        - NOBULL CrossFit Games
+        - The Granite Games
+        - Torian Pro
+        - Rogue Invitational
+        - Wodapalooza
+      athlete:
+        male:
+          - Adrian Mundwiler
+          - Alec Smith
+          - Ben Smith
+          - Björgvin Karl Guðmundsson
+          - Brent Fikowski
+          - Chandler Smith
+          - Cole Sager
+          - Dan Bailey
+          - Guilherme Malheiros
+          - Jonne Koski
+          - Justin Medeiros
+          - Luka Đukić
+          - Patrick Vellner
+          - Mat Fraser
+          - Noah Ohlsen
+          - Rich Froning Jr.
+          - Royce Dunne
+          - Saxon Panchik
+          - Scott Panchik
+          - Travis Mayer
+        female:
+          - Amanda Barnhart
+          - Annie Thorisdottir
+          - Bethany Shadburne
+          - Brooke Wells
+          - Camille Leblanc Bazinet
+          - Dani Speegle
+          - Danielle Brandon
+          - Emma Carry
+          - Emma McQuaid
+          - Gabriela Migała
+          - Haley Adams
+          - Jessica Griffith
+          - Kara Saunders
+          - Kari Pearce
+          - Katrin Tanja Davidsdottir
+          - Kristi Eramo O'Connell
+          - Kristin Holte
+          - Laura Horváth
+          - Mallory O'Brien
+          - Samantha Briggs
+          - Thuridur Erla Helgadottir
+          - Tia-Clair Toomey
+      movement:
+        - Air Squat
+        - Back Squat
+        - Bar Muscle-Up
+        - Burpee
+        - Chest-to-Bar
+        - Clean
+        - Deadlift
+        - Double-Under
+        - Front Squat
+        - Handstand Push-up
+        - Medicine-Ball Clean
+        - Overhead Squat
+        - Pistol
+        - Pull-up
+        - Push Press
+        - Push Jerk
+        - Ring Dips
+        - Ring Muscle-Up
+        - Rope Climb
+        - Snatch
+        - Shoulder Press
+        - Sumo Deadlift High Pull
+        - Thruster
+        - Toes-to-Bar
+        - Wall-Ball Shot
+      workout:
+        girl:
+          - Angie
+          - Annie
+          - Barbara
+          - Chelsea
+          - Cindy
+          - Diane
+          - Elizabeth
+          - Fran
+          - Grace
+          - Helen
+          - Isabel
+          - Jackie
+          - Karen
+          - Kelly
+          - Linda
+          - Mary
+          - Nancy
+          - Nicole
+        hero:
+          - DT
+          - Glen
+          - JT
+          - Murph
+# END crossfit_provider_dict
diff --git a/docs/src/orchid/resources/pages/data-provider/crossfit.adoc b/docs/src/orchid/resources/pages/data-provider/crossfit.adoc
new file mode 100644
index 00000000..e8b13659
--- /dev/null
+++ b/docs/src/orchid/resources/pages/data-provider/crossfit.adoc
@@ -0,0 +1,27 @@
+---
+---
+
+== `Faker().crossfit`
+
+.Dictionary file
+[%collapsible]
+====
+[source,yaml]
+----
+{% snippet 'crossfit_provider_dict' %}
+----
+====
+
+.Available Functions
+[%collapsible]
+====
+[source,kotlin]
+----
+Faker().crossfit.competitions() // => The Granite Games, Wodapalooza
+Faker().crossfit.maleAthletes() // => Chandler Smith, Mat Fraser
+Faker().crossfit.femaleAthletes() // => Brooke Wells, Tia-Clair Toomey
+Faker().crossfit.movements() // => Handstand Push-up, Rope Climb
+Faker().crossfit.girlWorkouts() // => Fran, Grace
+Faker().crossfit.heroWorkouts() // => DT, Murph
+----
+====


Test patch:
diff --git a/cli-bot/src/test/kotlin/io/github/serpro69/kfaker/app/cli/IntrospectorTest.kt b/cli-bot/src/test/kotlin/io/github/serpro69/kfaker/app/cli/IntrospectorTest.kt
index c659347f..64248c21 100644
--- a/cli-bot/src/test/kotlin/io/github/serpro69/kfaker/app/cli/IntrospectorTest.kt
+++ b/cli-bot/src/test/kotlin/io/github/serpro69/kfaker/app/cli/IntrospectorTest.kt
@@ -56,6 +56,7 @@ class IntrospectorTest : DescribeSpec() {
                         "Construction",
                         "Control",
                         "Cosmere",
+                        "Crossfit",
                         "CryptoCoin",
                         "CultureSeries",
                         "Currency",
@@ -234,6 +235,7 @@ class IntrospectorTest : DescribeSpec() {
                         "construction",
                         "control",
                         "cosmere",
+                        "crossfit",
                         "cryptoCoin",
                         "cultureSeries",
                         "currency",
diff --git a/core/src/test/kotlin/io/github/serpro69/kfaker/TestConstants.kt b/core/src/test/kotlin/io/github/serpro69/kfaker/TestConstants.kt
index c9490a63..c7068289 100644
--- a/core/src/test/kotlin/io/github/serpro69/kfaker/TestConstants.kt
+++ b/core/src/test/kotlin/io/github/serpro69/kfaker/TestConstants.kt
@@ -42,6 +42,7 @@ val dictionaryKeys = listOf(
     "computer",
     "construction",
     "cosmere",
+    "crossfit",
     "crypto_coin",
     "culture_series",
     "currency",
diff --git a/core/src/test/kotlin/io/github/serpro69/kfaker/provider/CrossfitTest.kt b/core/src/test/kotlin/io/github/serpro69/kfaker/provider/CrossfitTest.kt
new file mode 100644
index 00000000..8cc66390
--- /dev/null
+++ b/core/src/test/kotlin/io/github/serpro69/kfaker/provider/CrossfitTest.kt
@@ -0,0 +1,18 @@
+package io.github.serpro69.kfaker.provider
+
+import io.github.serpro69.kfaker.Faker
+import io.github.serpro69.kfaker.FakerService
+import io.kotest.core.spec.style.DescribeSpec
+import io.kotest.matchers.shouldNotBe
+
+class CrossfitTest : DescribeSpec({
+    describe("Crossfit provider") {
+        val crossfit = Crossfit( FakerService(faker = Faker()))
+
+        context("competition fun") {
+            it("should returns a Crossfit® competition name") {
+                crossfit.competitions() shouldNotBe null
+            }
+        }
+    }
+})