diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 18b338849..e72bdc8e1 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -15,6 +15,7 @@ dependencies { // integration dependencies for classes in docs package, e.g. Homepage.kt // NB! only add providers that are needed val integrationImplementation by configurations + integrationImplementation(project(":provider:commerce")) integrationImplementation(project(":provider:movies")) integrationImplementation(project(":provider:tvshows")) } diff --git a/core/src/integration/kotlin/io/github/serpro69/kfaker/UniqueDataProvierIT.kt b/core/src/integration/kotlin/io/github/serpro69/kfaker/UniqueDataProvierIT.kt index a6ef78416..281550a27 100644 --- a/core/src/integration/kotlin/io/github/serpro69/kfaker/UniqueDataProvierIT.kt +++ b/core/src/integration/kotlin/io/github/serpro69/kfaker/UniqueDataProvierIT.kt @@ -109,12 +109,8 @@ class UniqueDataProviderIT : DescribeSpec({ "Block", "Bode", "Boehm", "Bogan", "Bogisich", "Borer", "Bosco", "Botsford", "Boyer", "Boyle", "Bradtke", "Brakus", "Braun", "Breitenberg", "Brekke", "Brown", "Bruen", "Buckridge" ) - val excludedBicCodes = listOf( - "AACCGB21", "AACNGB21", "AAFMGB21", "AAHOGB21", "AAHVGB21", "AANLGB21", - "AANLGB2L", "AAOGGB21", "AAPEGB21", "AAPUGB21", "AAQIGB21", "ABBYGB2L", - "BCYPGB2LCBB", "BCYPGB2LHGB", "BCYPGB2LHHB", "BCYPGB2LPGB", "BCYPGB2LSSB", "BCYPGB2LMBB" - ) - val excludeAll = listOf(excludedCountries, excludedNames, excludedBicCodes).flatten() + val excludedDomains = listOf("com", "biz", "info") + val excludeAll = listOf(excludedCountries, excludedNames, excludedDomains).flatten() faker.unique.configuration { enable(faker::address) @@ -125,16 +121,16 @@ class UniqueDataProviderIT : DescribeSpec({ context("collection of unique values is generated run#$it") { val countries = (0..30).map { faker.address.country() } val names = (0..30).map { faker.name.lastName() } - // Unique generation not enabled for Bank - val bicCodes = (0..30).map { faker.bank.swiftBic() } + // Unique generation not enabled for Internet + val domainSuffixes = (0..30).map { faker.internet.domainSuffix() } it("should not contain excluded values") { assertSoftly { countries shouldNotContainAnyOf excludeAll names shouldNotContainAnyOf excludeAll - // Unique generation not enabled for Bank - bicCodes shouldNot beUnique() - bicCodes shouldContainAnyOf excludedBicCodes + // Unique generation not enabled for Internet + domainSuffixes shouldNot beUnique() + domainSuffixes shouldContainAnyOf excludedDomains } } } @@ -150,23 +146,23 @@ class UniqueDataProviderIT : DescribeSpec({ enable(faker::address) enable(faker::name) // Exclude all values starting with "A" - exclude { listOf(Regex("^A")) } + exclude { listOf(Regex("^[Cc]")) } } it("should not contain values matching pattern run#$it") { val countries = (0..30).map { faker.address.country() } val names = (0..30).map { faker.name.lastName() } // Unique generation not enabled for Bank - val bicCodes = (0..30).map { faker.bank.swiftBic() } + val domainSuffixes = (0..30).map { faker.internet.domainSuffix() } assertSoftly { - countries.none { s -> s.startsWith("A") } shouldBe true + countries.none { s -> s.startsWith("C") } shouldBe true countries should beUnique() - names.none { s -> s.startsWith("A") } shouldBe true + names.none { s -> s.startsWith("C") } shouldBe true names should beUnique() - // Unique generation not enabled for Bank - bicCodes.any { s -> s.startsWith("A") } shouldBe true - bicCodes shouldNot beUnique() + // Unique generation not enabled for Internet + domainSuffixes.any { s -> s.startsWith("c") } shouldBe true + domainSuffixes shouldNot beUnique() } } } diff --git a/core/src/integration/kotlin/io/github/serpro69/kfaker/docs/Homepage.kt b/core/src/integration/kotlin/io/github/serpro69/kfaker/docs/Homepage.kt index b5230197f..16bf81e85 100644 --- a/core/src/integration/kotlin/io/github/serpro69/kfaker/docs/Homepage.kt +++ b/core/src/integration/kotlin/io/github/serpro69/kfaker/docs/Homepage.kt @@ -3,6 +3,7 @@ package io.github.serpro69.kfaker.docs import io.github.serpro69.kfaker.Faker +import io.github.serpro69.kfaker.commerce.CommerceFaker import io.github.serpro69.kfaker.fakerConfig import io.github.serpro69.kfaker.movies.MoviesFaker import io.github.serpro69.kfaker.tv.TvShowsFaker @@ -44,7 +45,7 @@ class Homepage : DescribeSpec({ } it("should print a SWIFT BIC code") { // START data_provider_four - faker.bank.swiftBic() // => AACCGB21 + CommerceFaker().bank.swiftBic() // => AACCGB21 // END data_provider_four } it("should print a safe email address") { 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 40530af4b..c03dd27ed 100644 --- a/core/src/main/kotlin/io/github/serpro69/kfaker/Faker.kt +++ b/core/src/main/kotlin/io/github/serpro69/kfaker/Faker.kt @@ -9,25 +9,16 @@ import io.github.serpro69.kfaker.provider.Ancient import io.github.serpro69.kfaker.provider.Animal import io.github.serpro69.kfaker.provider.Artist import io.github.serpro69.kfaker.provider.Australia -import io.github.serpro69.kfaker.provider.Bank -import io.github.serpro69.kfaker.provider.Barcode -import io.github.serpro69.kfaker.provider.Beer import io.github.serpro69.kfaker.provider.Bible import io.github.serpro69.kfaker.provider.Bird import io.github.serpro69.kfaker.provider.Blood import io.github.serpro69.kfaker.provider.BossaNova -import io.github.serpro69.kfaker.provider.Business -import io.github.serpro69.kfaker.provider.Cannabis import io.github.serpro69.kfaker.provider.Cat import io.github.serpro69.kfaker.provider.Chiquito import io.github.serpro69.kfaker.provider.ChuckNorris import io.github.serpro69.kfaker.provider.Code -import io.github.serpro69.kfaker.provider.Coffee import io.github.serpro69.kfaker.provider.Coin import io.github.serpro69.kfaker.provider.Color -import io.github.serpro69.kfaker.provider.Commerce -import io.github.serpro69.kfaker.provider.Company -import io.github.serpro69.kfaker.provider.Construction import io.github.serpro69.kfaker.provider.Cosmere import io.github.serpro69.kfaker.provider.Currency import io.github.serpro69.kfaker.provider.CurrencySymbol @@ -39,8 +30,6 @@ import io.github.serpro69.kfaker.provider.DrivingLicense import io.github.serpro69.kfaker.provider.Educator import io.github.serpro69.kfaker.provider.Emotion import io.github.serpro69.kfaker.provider.File -import io.github.serpro69.kfaker.provider.Finance -import io.github.serpro69.kfaker.provider.Food import io.github.serpro69.kfaker.provider.FunnyName import io.github.serpro69.kfaker.provider.Gender import io.github.serpro69.kfaker.provider.GreekPhilosophers @@ -50,14 +39,12 @@ import io.github.serpro69.kfaker.provider.Hobby import io.github.serpro69.kfaker.provider.Horse import io.github.serpro69.kfaker.provider.House import io.github.serpro69.kfaker.provider.IdNumber -import io.github.serpro69.kfaker.provider.IndustrySegments import io.github.serpro69.kfaker.provider.Internet import io.github.serpro69.kfaker.provider.JackHandey import io.github.serpro69.kfaker.provider.Job import io.github.serpro69.kfaker.provider.KamenRider import io.github.serpro69.kfaker.provider.Lorem import io.github.serpro69.kfaker.provider.Markdown -import io.github.serpro69.kfaker.provider.Marketing import io.github.serpro69.kfaker.provider.Measurement import io.github.serpro69.kfaker.provider.Military import io.github.serpro69.kfaker.provider.MitchHedberg @@ -71,7 +58,6 @@ import io.github.serpro69.kfaker.provider.PhoneNumber import io.github.serpro69.kfaker.provider.Quote import io.github.serpro69.kfaker.provider.Rajnikanth import io.github.serpro69.kfaker.provider.Relationship -import io.github.serpro69.kfaker.provider.Restaurant import io.github.serpro69.kfaker.provider.Room import io.github.serpro69.kfaker.provider.Science import io.github.serpro69.kfaker.provider.Separator @@ -80,10 +66,8 @@ import io.github.serpro69.kfaker.provider.Show import io.github.serpro69.kfaker.provider.SlackEmoji import io.github.serpro69.kfaker.provider.Sport import io.github.serpro69.kfaker.provider.Stripe -import io.github.serpro69.kfaker.provider.Subscription import io.github.serpro69.kfaker.provider.Superhero import io.github.serpro69.kfaker.provider.Tarkov -import io.github.serpro69.kfaker.provider.Tea import io.github.serpro69.kfaker.provider.Team import io.github.serpro69.kfaker.provider.TheThickOfIt import io.github.serpro69.kfaker.provider.Tolkien @@ -128,27 +112,18 @@ class Faker @JvmOverloads constructor(config: FakerConfig = fakerConfig { }): Ab val animal: Animal by lazy { Animal(fakerService) } val artist: Artist by lazy { Artist(fakerService) } val australia: Australia by lazy { Australia(fakerService) } - val bank: Bank by lazy { Bank(fakerService) } - val barcode: Barcode by lazy { Barcode(fakerService) } - val beer: Beer by lazy { Beer(fakerService) } val bible: Bible by lazy { Bible(fakerService) } val bird: Bird by lazy { Bird(fakerService) } val blood: Blood by lazy { Blood(fakerService) } val bossaNova: BossaNova by lazy { BossaNova(fakerService) } - val business: Business by lazy { Business(fakerService) } - val cannabis: Cannabis by lazy { Cannabis(fakerService) } val cat: Cat by lazy { Cat(fakerService) } val chiquito: Chiquito by lazy { Chiquito(fakerService) } val chuckNorris: ChuckNorris by lazy { ChuckNorris(fakerService) } val code: Code by lazy { Code(fakerService) } - val coffee: Coffee by lazy { Coffee(fakerService) } val coin: Coin by lazy { Coin(fakerService) } val color: Color by lazy { Color(fakerService) } - val commerce: Commerce by lazy { Commerce(fakerService) } - val company: Company by lazy { Company(fakerService) } // val compass: Compass by lazy {Compass(fakerService) } - val construction: Construction by lazy { Construction(fakerService) } val cosmere: Cosmere by lazy { Cosmere(fakerService) } val currency: Currency by lazy { Currency(fakerService) } val dcComics: DcComics by lazy { DcComics(fakerService) } @@ -159,8 +134,6 @@ class Faker @JvmOverloads constructor(config: FakerConfig = fakerConfig { }): Ab val educator: Educator by lazy { Educator(fakerService) } val emotion: Emotion by lazy { Emotion(fakerService) } val file: File by lazy { File(fakerService) } - val finance: Finance by lazy { Finance(fakerService) } - val food: Food by lazy { Food(fakerService) } val funnyName: FunnyName by lazy { FunnyName(fakerService) } val gender: Gender by lazy { Gender(fakerService) } val greekPhilosophers: GreekPhilosophers by lazy { GreekPhilosophers(fakerService) } @@ -170,16 +143,12 @@ class Faker @JvmOverloads constructor(config: FakerConfig = fakerConfig { }): Ab val horse: Horse by lazy { Horse(fakerService) } val house: House by lazy { House(fakerService) } val idNumber: IdNumber by lazy { IdNumber(fakerService) } - val industrySegments: IndustrySegments by lazy { IndustrySegments(fakerService) } - val internet: Internet by lazy { Internet(fakerService, company, name) } - - // val invoice: Invoice by lazy {Invoice(fakerService } + val internet: Internet by lazy { Internet(fakerService, name) } val jackHandey: JackHandey by lazy { JackHandey(fakerService) } val job: Job by lazy { Job(fakerService) } val kamenRider: KamenRider by lazy { KamenRider(fakerService) } val lorem: Lorem by lazy { Lorem(fakerService) } val markdown: Markdown by lazy { Markdown(fakerService) } - val marketing: Marketing by lazy { Marketing(fakerService) } val measurement: Measurement by lazy { Measurement(fakerService) } val military: Military by lazy { Military(fakerService) } val mitchHedberg: MitchHedberg by lazy { MitchHedberg(fakerService) } @@ -193,7 +162,6 @@ class Faker @JvmOverloads constructor(config: FakerConfig = fakerConfig { }): Ab val quote: Quote by lazy { Quote(fakerService) } val rajnikanth: Rajnikanth by lazy { Rajnikanth(fakerService) } val relationship: Relationship by lazy { Relationship(fakerService) } - val restaurant: Restaurant by lazy { Restaurant(fakerService) } val room: Room by lazy { Room(fakerService) } val science: Science by lazy { Science(fakerService) } val shakespeare: Shakespeare by lazy { Shakespeare(fakerService) } @@ -203,10 +171,8 @@ class Faker @JvmOverloads constructor(config: FakerConfig = fakerConfig { }): Ab // val source: Source by lazy {Source(fakerService } val sport: Sport by lazy { Sport(fakerService) } val stripe: Stripe by lazy { Stripe(fakerService) } - val subscription: Subscription by lazy { Subscription(fakerService) } val superhero: Superhero by lazy { Superhero(fakerService) } val tarkov: Tarkov by lazy { Tarkov(fakerService) } - val tea: Tea by lazy { Tea(fakerService) } val team: Team by lazy { Team(fakerService) } val theThickOfIt: TheThickOfIt by lazy { TheThickOfIt(fakerService) } val tolkien: Tolkien by lazy { Tolkien(fakerService) } diff --git a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Internet.kt b/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Internet.kt index 787b4e001..1df0283f0 100644 --- a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Internet.kt +++ b/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Internet.kt @@ -2,6 +2,7 @@ package io.github.serpro69.kfaker.provider import io.github.serpro69.kfaker.FakerService import io.github.serpro69.kfaker.dictionary.YamlCategory +import io.github.serpro69.kfaker.faker import io.github.serpro69.kfaker.helper.isReservedNet import io.github.serpro69.kfaker.helper.prepare import io.github.serpro69.kfaker.provider.unique.LocalUniqueDataProvider @@ -14,7 +15,6 @@ import java.lang.String.format @Suppress("unused") class Internet internal constructor( fakerService: FakerService, - private val companyProvider: Company, private val nameProvider: Name, ) : YamlFakeDataProvider(fakerService) { override val yamlCategory = YamlCategory.INTERNET @@ -26,7 +26,7 @@ class Internet internal constructor( } fun domain(subdomain: Boolean = false, domain: String? = null): String { - val name: () -> String = { prepare(companyProvider.name().split(" ").first(), fakerService.faker.config) } + val name: () -> String = { prepare(nameProvider.lastName().split(" ").first(), fakerService.faker.config) } return domain?.let { domain.split(".") .map { domainPart -> prepare(domainPart, fakerService.faker.config) } @@ -135,3 +135,10 @@ private val privateIpv4Ranges = listOf( // 198.18.0.0/15 - Used for benchmark testing of inter-network communications between subnets listOf(198..198, 18..19, 0..255, 1..255) ) + +fun main() { + val f = faker { } + repeat(100) { + println(f.internet.domain()) + } +} diff --git a/core/src/test/kotlin/io/github/serpro69/kfaker/provider/InternetTest.kt b/core/src/test/kotlin/io/github/serpro69/kfaker/provider/InternetTest.kt index 9c683536f..e240821ff 100644 --- a/core/src/test/kotlin/io/github/serpro69/kfaker/provider/InternetTest.kt +++ b/core/src/test/kotlin/io/github/serpro69/kfaker/provider/InternetTest.kt @@ -12,7 +12,7 @@ import sun.net.util.IPAddressUtil class InternetTest: DescribeSpec({ describe("Internet provider") { val s = FakerService(Faker()) - val internet = Internet(s, Company(s), Name(s)) + val internet = Internet(s, Name(s)) context("IPv4 address generation") { repeat(100) { diff --git a/provider/commerce/build.gradle.kts b/provider/commerce/build.gradle.kts new file mode 100644 index 000000000..55f6540f8 --- /dev/null +++ b/provider/commerce/build.gradle.kts @@ -0,0 +1,4 @@ +plugins { + `faker-lib-conventions` + `faker-provider-conventions` +} diff --git a/core/src/integration/kotlin/io/github/serpro69/kfaker/provider/CompanyIT.kt b/provider/commerce/src/integration/kotlin/io/github/serpro69/kfaker/commerce/provider/CompanyIT.kt similarity index 76% rename from core/src/integration/kotlin/io/github/serpro69/kfaker/provider/CompanyIT.kt rename to provider/commerce/src/integration/kotlin/io/github/serpro69/kfaker/commerce/provider/CompanyIT.kt index c8bc03fa2..fc04d37d6 100644 --- a/core/src/integration/kotlin/io/github/serpro69/kfaker/provider/CompanyIT.kt +++ b/provider/commerce/src/integration/kotlin/io/github/serpro69/kfaker/commerce/provider/CompanyIT.kt @@ -1,11 +1,9 @@ -package io.github.serpro69.kfaker.provider +package io.github.serpro69.kfaker.commerce.provider -import io.github.serpro69.kfaker.faker +import io.github.serpro69.kfaker.commerce.faker import io.kotest.assertions.throwables.shouldNotThrow import io.kotest.core.spec.style.DescribeSpec -import io.kotest.matchers.shouldBe import io.kotest.matchers.shouldNotBe -import io.kotest.matchers.string.shouldMatch class CompanyIT : DescribeSpec({ describe("Company Provider") { diff --git a/core/src/integration/kotlin/io/github/serpro69/kfaker/provider/FinanceIT.kt b/provider/commerce/src/integration/kotlin/io/github/serpro69/kfaker/commerce/provider/FinanceIT.kt similarity index 82% rename from core/src/integration/kotlin/io/github/serpro69/kfaker/provider/FinanceIT.kt rename to provider/commerce/src/integration/kotlin/io/github/serpro69/kfaker/commerce/provider/FinanceIT.kt index d0a1f4461..844536f3b 100644 --- a/core/src/integration/kotlin/io/github/serpro69/kfaker/provider/FinanceIT.kt +++ b/provider/commerce/src/integration/kotlin/io/github/serpro69/kfaker/commerce/provider/FinanceIT.kt @@ -1,10 +1,8 @@ -package io.github.serpro69.kfaker.provider +package io.github.serpro69.kfaker.commerce.provider -import io.github.serpro69.kfaker.faker +import io.github.serpro69.kfaker.commerce.faker import io.kotest.assertions.assertSoftly -import io.kotest.assertions.throwables.shouldNotThrow import io.kotest.core.spec.style.DescribeSpec -import io.kotest.matchers.shouldNotHave import io.kotest.matchers.string.shouldNotContain class FinanceIT : DescribeSpec({ diff --git a/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/CommerceFaker.kt b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/CommerceFaker.kt new file mode 100644 index 000000000..723935858 --- /dev/null +++ b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/CommerceFaker.kt @@ -0,0 +1,76 @@ +package io.github.serpro69.kfaker.commerce + +import io.github.serpro69.kfaker.AbstractFaker +import io.github.serpro69.kfaker.FakerConfig +import io.github.serpro69.kfaker.FakerDsl +import io.github.serpro69.kfaker.commerce.provider.Bank +import io.github.serpro69.kfaker.commerce.provider.Barcode +import io.github.serpro69.kfaker.commerce.provider.Beer +import io.github.serpro69.kfaker.commerce.provider.Business +import io.github.serpro69.kfaker.commerce.provider.Cannabis +import io.github.serpro69.kfaker.commerce.provider.Coffee +import io.github.serpro69.kfaker.commerce.provider.Commerce +import io.github.serpro69.kfaker.commerce.provider.Company +import io.github.serpro69.kfaker.commerce.provider.Construction +import io.github.serpro69.kfaker.commerce.provider.Finance +import io.github.serpro69.kfaker.commerce.provider.Food +import io.github.serpro69.kfaker.commerce.provider.IndustrySegments +import io.github.serpro69.kfaker.commerce.provider.Marketing +import io.github.serpro69.kfaker.provider.Money +import io.github.serpro69.kfaker.commerce.provider.Restaurant +import io.github.serpro69.kfaker.commerce.provider.Subscription +import io.github.serpro69.kfaker.commerce.provider.Tea +import io.github.serpro69.kfaker.fakerConfig + +/** + * Typealias for the [CommerceFaker] + */ +typealias Faker = CommerceFaker + +/** + * Provides access to fake data generators withing the Books domain. + * + * Each category (generator) from this [CommerceFaker] is represented by a property that has the same name as the `.yml` file. + * + * @property unique global provider for generation of unique values. + */ +@Suppress("unused") +class CommerceFaker @JvmOverloads constructor(config: FakerConfig = fakerConfig { }) : AbstractFaker(config) { + + val bank: Bank by lazy { Bank(fakerService) } + val barcode: Barcode by lazy { Barcode(fakerService) } + val beer: Beer by lazy { Beer(fakerService) } + val business: Business by lazy { Business(fakerService) } + val cannabis: Cannabis by lazy { Cannabis(fakerService) } + val coffee: Coffee by lazy { Coffee(fakerService) } + val commerce: Commerce by lazy { Commerce(fakerService) } + val company: Company by lazy { Company(fakerService) } + val construction: Construction by lazy { Construction(fakerService) } + val finance: Finance by lazy { Finance(fakerService, randomService) } + val food: Food by lazy { Food(fakerService) } + val industrySegments: IndustrySegments by lazy { IndustrySegments(fakerService) } + // TODO not implemented + // val invoice: Invoice by lazy { Invoice(fakerService } + val marketing: Marketing by lazy { Marketing(fakerService) } + val restaurant: Restaurant by lazy { Restaurant(fakerService) } + val subscription: Subscription by lazy { Subscription(fakerService) } + val tea: Tea by lazy { Tea(fakerService) } + + @FakerDsl + /** + * DSL builder for creating instances of [Faker] + */ + class Builder internal constructor() : AbstractFaker.Builder() { + + /** + * Builds an instance of [Faker] with this [config]. + */ + override fun build(): Faker = Faker(config) + } +} + +/** + * Applies the [block] function to [CommerceFaker.Builder] + * and returns as an instance of [CommerceFaker] from that builder. + */ +fun faker(block: CommerceFaker.Builder.() -> Unit): CommerceFaker = CommerceFaker.Builder().apply(block).build() diff --git a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Bank.kt b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Bank.kt similarity index 86% rename from core/src/main/kotlin/io/github/serpro69/kfaker/provider/Bank.kt rename to provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Bank.kt index 84465fe0c..bcda41aa5 100644 --- a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Bank.kt +++ b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Bank.kt @@ -1,7 +1,9 @@ -package io.github.serpro69.kfaker.provider +package io.github.serpro69.kfaker.commerce.provider import io.github.serpro69.kfaker.FakerService import io.github.serpro69.kfaker.dictionary.YamlCategory +import io.github.serpro69.kfaker.provider.FakeDataProvider +import io.github.serpro69.kfaker.provider.YamlFakeDataProvider import io.github.serpro69.kfaker.provider.unique.LocalUniqueDataProvider import io.github.serpro69.kfaker.provider.unique.UniqueProviderDelegate diff --git a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Barcode.kt b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Barcode.kt similarity index 93% rename from core/src/main/kotlin/io/github/serpro69/kfaker/provider/Barcode.kt rename to provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Barcode.kt index 058f241f5..5321f39b0 100644 --- a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Barcode.kt +++ b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Barcode.kt @@ -1,7 +1,8 @@ -package io.github.serpro69.kfaker.provider +package io.github.serpro69.kfaker.commerce.provider import io.github.serpro69.kfaker.* import io.github.serpro69.kfaker.dictionary.* +import io.github.serpro69.kfaker.provider.* import io.github.serpro69.kfaker.provider.unique.LocalUniqueDataProvider import io.github.serpro69.kfaker.provider.unique.UniqueProviderDelegate diff --git a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Beer.kt b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Beer.kt similarity index 90% rename from core/src/main/kotlin/io/github/serpro69/kfaker/provider/Beer.kt rename to provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Beer.kt index ccfee090c..dd438511d 100644 --- a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Beer.kt +++ b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Beer.kt @@ -1,7 +1,8 @@ -package io.github.serpro69.kfaker.provider +package io.github.serpro69.kfaker.commerce.provider import io.github.serpro69.kfaker.* import io.github.serpro69.kfaker.dictionary.* +import io.github.serpro69.kfaker.provider.* import io.github.serpro69.kfaker.provider.unique.LocalUniqueDataProvider import io.github.serpro69.kfaker.provider.unique.UniqueProviderDelegate diff --git a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Business.kt b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Business.kt similarity index 89% rename from core/src/main/kotlin/io/github/serpro69/kfaker/provider/Business.kt rename to provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Business.kt index 95627912c..22fbfe294 100644 --- a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Business.kt +++ b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Business.kt @@ -1,7 +1,8 @@ -package io.github.serpro69.kfaker.provider +package io.github.serpro69.kfaker.commerce.provider import io.github.serpro69.kfaker.* import io.github.serpro69.kfaker.dictionary.* +import io.github.serpro69.kfaker.provider.* import io.github.serpro69.kfaker.provider.unique.LocalUniqueDataProvider import io.github.serpro69.kfaker.provider.unique.UniqueProviderDelegate diff --git a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Cannabis.kt b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Cannabis.kt similarity index 92% rename from core/src/main/kotlin/io/github/serpro69/kfaker/provider/Cannabis.kt rename to provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Cannabis.kt index 6dca4bf41..48fb08c26 100644 --- a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Cannabis.kt +++ b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Cannabis.kt @@ -1,7 +1,8 @@ -package io.github.serpro69.kfaker.provider +package io.github.serpro69.kfaker.commerce.provider import io.github.serpro69.kfaker.* import io.github.serpro69.kfaker.dictionary.* +import io.github.serpro69.kfaker.provider.* import io.github.serpro69.kfaker.provider.unique.LocalUniqueDataProvider import io.github.serpro69.kfaker.provider.unique.UniqueProviderDelegate diff --git a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Coffee.kt b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Coffee.kt similarity index 90% rename from core/src/main/kotlin/io/github/serpro69/kfaker/provider/Coffee.kt rename to provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Coffee.kt index 95f4d9f99..e6c56933b 100644 --- a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Coffee.kt +++ b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Coffee.kt @@ -1,7 +1,8 @@ -package io.github.serpro69.kfaker.provider +package io.github.serpro69.kfaker.commerce.provider import io.github.serpro69.kfaker.* import io.github.serpro69.kfaker.dictionary.* +import io.github.serpro69.kfaker.provider.* import io.github.serpro69.kfaker.provider.unique.LocalUniqueDataProvider import io.github.serpro69.kfaker.provider.unique.UniqueProviderDelegate diff --git a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Commerce.kt b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Commerce.kt similarity index 93% rename from core/src/main/kotlin/io/github/serpro69/kfaker/provider/Commerce.kt rename to provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Commerce.kt index 7cb9ad5ab..c2c8e9567 100644 --- a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Commerce.kt +++ b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Commerce.kt @@ -1,7 +1,8 @@ -package io.github.serpro69.kfaker.provider +package io.github.serpro69.kfaker.commerce.provider import io.github.serpro69.kfaker.* import io.github.serpro69.kfaker.dictionary.* +import io.github.serpro69.kfaker.provider.* import io.github.serpro69.kfaker.provider.unique.LocalUniqueDataProvider import io.github.serpro69.kfaker.provider.unique.UniqueProviderDelegate diff --git a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Company.kt b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Company.kt similarity index 91% rename from core/src/main/kotlin/io/github/serpro69/kfaker/provider/Company.kt rename to provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Company.kt index bce80a8c0..02517dc6c 100644 --- a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Company.kt +++ b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Company.kt @@ -1,7 +1,8 @@ -package io.github.serpro69.kfaker.provider +package io.github.serpro69.kfaker.commerce.provider import io.github.serpro69.kfaker.* import io.github.serpro69.kfaker.dictionary.* +import io.github.serpro69.kfaker.provider.* import io.github.serpro69.kfaker.provider.unique.LocalUniqueDataProvider import io.github.serpro69.kfaker.provider.unique.UniqueProviderDelegate diff --git a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Construction.kt b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Construction.kt similarity index 88% rename from core/src/main/kotlin/io/github/serpro69/kfaker/provider/Construction.kt rename to provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Construction.kt index 2436d921c..e4e473c97 100644 --- a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Construction.kt +++ b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Construction.kt @@ -1,7 +1,8 @@ -package io.github.serpro69.kfaker.provider +package io.github.serpro69.kfaker.commerce.provider import io.github.serpro69.kfaker.* import io.github.serpro69.kfaker.dictionary.* +import io.github.serpro69.kfaker.provider.* import io.github.serpro69.kfaker.provider.unique.LocalUniqueDataProvider import io.github.serpro69.kfaker.provider.unique.UniqueProviderDelegate diff --git a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Finance.kt b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Finance.kt similarity index 74% rename from core/src/main/kotlin/io/github/serpro69/kfaker/provider/Finance.kt rename to provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Finance.kt index 1e59bd6c5..99ef04641 100644 --- a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Finance.kt +++ b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Finance.kt @@ -1,7 +1,9 @@ -package io.github.serpro69.kfaker.provider +package io.github.serpro69.kfaker.commerce.provider import io.github.serpro69.kfaker.FakerService +import io.github.serpro69.kfaker.RandomService import io.github.serpro69.kfaker.dictionary.YamlCategory +import io.github.serpro69.kfaker.provider.* import io.github.serpro69.kfaker.provider.unique.LocalUniqueDataProvider import io.github.serpro69.kfaker.provider.unique.UniqueProviderDelegate @@ -9,7 +11,10 @@ import io.github.serpro69.kfaker.provider.unique.UniqueProviderDelegate * [FakeDataProvider] implementation for [YamlCategory.FINANCE] category. */ @Suppress("unused") -class Finance internal constructor(fakerService: FakerService) : YamlFakeDataProvider(fakerService) { +class Finance internal constructor( + fakerService: FakerService, + private val randomService: RandomService +) : YamlFakeDataProvider(fakerService) { override val yamlCategory = YamlCategory.FINANCE override val localUniqueDataProvider = LocalUniqueDataProvider() override val unique by UniqueProviderDelegate(localUniqueDataProvider) @@ -21,7 +26,7 @@ class Finance internal constructor(fakerService: FakerService) : YamlFakeDataPro fun creditCard(type: String): String = with(fakerService) { resolve("credit_card", type).numerify().generexify() } fun condominiumFiscalCode(): String = with(fakerService) { resolve("condominium_fiscal_code", "IT").numerify() } fun vatNumber(countryCode: String): String = with(fakerService) { resolve("vat_number", countryCode).numerify() } - fun ticker(stockExchange: StockExchange = fakerService.randomService.nextEnum()): String = + fun ticker(stockExchange: StockExchange = randomService.nextEnum()): String = resolve("ticker", stockExchange.name.lowercase()) fun stockMarket(): String = resolve("stock_market") diff --git a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Food.kt b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Food.kt similarity index 92% rename from core/src/main/kotlin/io/github/serpro69/kfaker/provider/Food.kt rename to provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Food.kt index 11257a428..82cd9d294 100644 --- a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Food.kt +++ b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Food.kt @@ -1,7 +1,8 @@ -package io.github.serpro69.kfaker.provider +package io.github.serpro69.kfaker.commerce.provider import io.github.serpro69.kfaker.* import io.github.serpro69.kfaker.dictionary.* +import io.github.serpro69.kfaker.provider.* import io.github.serpro69.kfaker.provider.unique.LocalUniqueDataProvider import io.github.serpro69.kfaker.provider.unique.UniqueProviderDelegate diff --git a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/IndustrySegments.kt b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/IndustrySegments.kt similarity index 90% rename from core/src/main/kotlin/io/github/serpro69/kfaker/provider/IndustrySegments.kt rename to provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/IndustrySegments.kt index 478bfc4eb..de0d7f00d 100644 --- a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/IndustrySegments.kt +++ b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/IndustrySegments.kt @@ -1,7 +1,8 @@ -package io.github.serpro69.kfaker.provider +package io.github.serpro69.kfaker.commerce.provider import io.github.serpro69.kfaker.* import io.github.serpro69.kfaker.dictionary.* +import io.github.serpro69.kfaker.provider.* import io.github.serpro69.kfaker.provider.unique.LocalUniqueDataProvider import io.github.serpro69.kfaker.provider.unique.UniqueProviderDelegate diff --git a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Invoice.kt b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Invoice.kt similarity index 91% rename from core/src/main/kotlin/io/github/serpro69/kfaker/provider/Invoice.kt rename to provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Invoice.kt index 2a8e8a741..6650a5de7 100644 --- a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Invoice.kt +++ b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Invoice.kt @@ -1,7 +1,8 @@ -package io.github.serpro69.kfaker.provider +package io.github.serpro69.kfaker.commerce.provider import io.github.serpro69.kfaker.* import io.github.serpro69.kfaker.dictionary.* +import io.github.serpro69.kfaker.provider.* import io.github.serpro69.kfaker.provider.unique.LocalUniqueDataProvider import io.github.serpro69.kfaker.provider.unique.UniqueProviderDelegate diff --git a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Marketing.kt b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Marketing.kt similarity index 88% rename from core/src/main/kotlin/io/github/serpro69/kfaker/provider/Marketing.kt rename to provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Marketing.kt index 837fd54dc..40e63b179 100644 --- a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Marketing.kt +++ b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Marketing.kt @@ -1,7 +1,8 @@ -package io.github.serpro69.kfaker.provider +package io.github.serpro69.kfaker.commerce.provider import io.github.serpro69.kfaker.* import io.github.serpro69.kfaker.dictionary.* +import io.github.serpro69.kfaker.provider.* import io.github.serpro69.kfaker.provider.unique.LocalUniqueDataProvider import io.github.serpro69.kfaker.provider.unique.UniqueProviderDelegate diff --git a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Restaurant.kt b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Restaurant.kt similarity index 90% rename from core/src/main/kotlin/io/github/serpro69/kfaker/provider/Restaurant.kt rename to provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Restaurant.kt index c142d0648..8e9ece270 100644 --- a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Restaurant.kt +++ b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Restaurant.kt @@ -1,7 +1,8 @@ -package io.github.serpro69.kfaker.provider +package io.github.serpro69.kfaker.commerce.provider import io.github.serpro69.kfaker.* import io.github.serpro69.kfaker.dictionary.* +import io.github.serpro69.kfaker.provider.* import io.github.serpro69.kfaker.provider.unique.LocalUniqueDataProvider import io.github.serpro69.kfaker.provider.unique.UniqueProviderDelegate diff --git a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Subscription.kt b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Subscription.kt similarity index 91% rename from core/src/main/kotlin/io/github/serpro69/kfaker/provider/Subscription.kt rename to provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Subscription.kt index 2d69941b6..10266e4e8 100644 --- a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Subscription.kt +++ b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Subscription.kt @@ -1,7 +1,8 @@ -package io.github.serpro69.kfaker.provider +package io.github.serpro69.kfaker.commerce.provider import io.github.serpro69.kfaker.* import io.github.serpro69.kfaker.dictionary.* +import io.github.serpro69.kfaker.provider.* import io.github.serpro69.kfaker.provider.unique.LocalUniqueDataProvider import io.github.serpro69.kfaker.provider.unique.UniqueProviderDelegate diff --git a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Tea.kt b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Tea.kt similarity index 93% rename from core/src/main/kotlin/io/github/serpro69/kfaker/provider/Tea.kt rename to provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Tea.kt index 59cca5218..72270638d 100644 --- a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/Tea.kt +++ b/provider/commerce/src/main/kotlin/io/github/serpro69/kfaker/commerce/provider/Tea.kt @@ -1,9 +1,10 @@ @file:Suppress("unused") -package io.github.serpro69.kfaker.provider +package io.github.serpro69.kfaker.commerce.provider import io.github.serpro69.kfaker.* import io.github.serpro69.kfaker.dictionary.* +import io.github.serpro69.kfaker.provider.* import io.github.serpro69.kfaker.provider.unique.LocalUniqueDataProvider import io.github.serpro69.kfaker.provider.unique.UniqueProviderDelegate diff --git a/settings.gradle.kts b/settings.gradle.kts index c4d561ce2..36e4f6ac8 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -19,6 +19,7 @@ include( val providers = listOf( "books", + "commerce", "games", "japmedia", "movies",