Skip to content

Commit

Permalink
Add new 'avatar' and 'chess' data providers
Browse files Browse the repository at this point in the history
  • Loading branch information
serpro69 committed Mar 12, 2023
1 parent 74dfa8b commit 3ff0ff9
Show file tree
Hide file tree
Showing 12 changed files with 302 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
[discrete]
=== Added

* https://github.com/serpro69/kotlin-faker/pull/176[#176] [core] Update dictionary files, including:
* https://github.com/serpro69/kotlin-faker/pull/176[#176], https://github.com/serpro69/kotlin-faker/pull/182[#182], https://github.com/serpro69/kotlin-faker/pull/183[#183], [core] Update dictionary files, including:
** Data and functions in existing data providers
*** `Faker().food.allergens()`
** Updates to existing localized dictionaries

* https://github.com/serpro69/kotlin-faker/pull/179[#179] [core] Add parameter info context to user defined generators
Expand All @@ -15,6 +16,8 @@
<p>
++++
* `airport`
* `avatar`
* `chess`
* `cowboy_bebop`
* `spongebob`
++++
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
"name": "getAustralia",
"parameterTypes": []
},
{
"name": "getAvatar",
"parameterTypes": []
},
{
"name": "getBackToTheFuture",
"parameterTypes": []
Expand Down Expand Up @@ -130,6 +134,10 @@
"name": "getCat",
"parameterTypes": []
},
{
"name": "getChess",
"parameterTypes": []
},
{
"name": "getChiquito",
"parameterTypes": []
Expand Down Expand Up @@ -1010,6 +1018,23 @@
}
]
},
{
"name": "io.github.serpro69.kfaker.provider.Avatar",
"methods": [
{
"name": "characters",
"parameterTypes": []
},
{
"name": "dates",
"parameterTypes": []
},
{
"name": "quotes",
"parameterTypes": []
}
]
},
{
"name": "io.github.serpro69.kfaker.provider.BackToTheFuture",
"methods": [
Expand Down Expand Up @@ -1402,6 +1427,27 @@
{
"name": "io.github.serpro69.kfaker.provider.CellPhone"
},
{
"name": "io.github.serpro69.kfaker.provider.Chess",
"methods": [
{
"name": "players",
"parameterTypes": []
},
{
"name": "tournaments",
"parameterTypes": []
},
{
"name": "openings",
"parameterTypes": []
},
{
"name": "titles",
"parameterTypes": []
}
]
},
{
"name": "io.github.serpro69.kfaker.provider.Chiquito",
"methods": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class IntrospectorTest : DescribeSpec() {
"AquaTeenHungerForce",
"Artist",
"Australia",
"Avatar",
"BackToTheFuture",
"Bank",
"Barcode",
Expand All @@ -51,6 +52,7 @@ class IntrospectorTest : DescribeSpec() {
"Camera",
"Cannabis",
"Cat",
"Chess",
"Chiquito",
"ChuckNorris",
"ClashOfClans",
Expand Down Expand Up @@ -248,6 +250,7 @@ class IntrospectorTest : DescribeSpec() {
"aquaTeenHungerForce",
"artist",
"australia",
"avatar",
"backToTheFuture",
"bank",
"barcode",
Expand All @@ -267,6 +270,7 @@ class IntrospectorTest : DescribeSpec() {
"camera",
"cannabis",
"cat",
"chess",
"chiquito",
"chuckNorris",
"clashOfClans",
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/kotlin/io/github/serpro69/kfaker/Faker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Faker @JvmOverloads constructor(internal val config: FakerConfig = fakerCo
val aquaTeenHungerForce: AquaTeenHungerForce by lazy { AquaTeenHungerForce(fakerService) }
val artist: Artist by lazy { Artist(fakerService) }
val australia: Australia by lazy { Australia(fakerService) }
val avatar: Avatar by lazy { Avatar(fakerService) }
val backToTheFuture: BackToTheFuture by lazy { BackToTheFuture(fakerService) }
val bank: Bank by lazy { Bank(fakerService) }
val barcode: Barcode by lazy { Barcode(fakerService) }
Expand All @@ -65,6 +66,7 @@ class Faker @JvmOverloads constructor(internal val config: FakerConfig = fakerCo
val cannabis: Cannabis by lazy { Cannabis(fakerService) }
val cat: Cat by lazy { Cat(fakerService) }
val chiquito: Chiquito by lazy { Chiquito(fakerService) }
val chess: Chess by lazy { Chess(fakerService) }
val chuckNorris: ChuckNorris by lazy { ChuckNorris(fakerService) }
val clashOfClans: ClashOfClans by lazy { ClashOfClans(fakerService) }
val code: Code by lazy { Code(fakerService) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ internal enum class YamlCategory : Category {
AQUA_TEEN_HUNGER_FORCE,
ARTIST,
AUSTRALIA,
AVATAR,
BACK_TO_THE_FUTURE,
BANK,
BARCODE,
Expand All @@ -40,6 +41,7 @@ internal enum class YamlCategory : Category {
CAMERA,
CANNABIS,
CELL_PHONE,
CHESS,
CHIQUITO,
CHUCK_NORRIS,
CODE,
Expand Down
26 changes: 26 additions & 0 deletions core/src/main/kotlin/io/github/serpro69/kfaker/provider/Avatar.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@file:Suppress("unused")

package io.github.serpro69.kfaker.provider

import io.github.serpro69.kfaker.*
import io.github.serpro69.kfaker.dictionary.*
import io.github.serpro69.kfaker.provider.unique.LocalUniqueDataProvider
import io.github.serpro69.kfaker.provider.unique.UniqueProviderDelegate

/**
* [FakeDataProvider] implementation for [YamlCategory.AVATAR]
*/
class Avatar internal constructor(fakerService: FakerService) : YamlFakeDataProvider<Avatar>(fakerService) {
override val yamlCategory = YamlCategory.AVATAR
override val localUniqueDataProvider = LocalUniqueDataProvider<Avatar>()
override val unique by UniqueProviderDelegate(localUniqueDataProvider)

init {
fakerService.load(yamlCategory)
}

fun characters() = resolve("characters")
fun dates() = resolve("dates")
fun quotes() = resolve("quotes")
}

25 changes: 25 additions & 0 deletions core/src/main/kotlin/io/github/serpro69/kfaker/provider/Chess.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.github.serpro69.kfaker.provider

import io.github.serpro69.kfaker.*
import io.github.serpro69.kfaker.dictionary.*
import io.github.serpro69.kfaker.provider.unique.LocalUniqueDataProvider
import io.github.serpro69.kfaker.provider.unique.UniqueProviderDelegate

/**
* [FakeDataProvider] implementation for [YamlCategory.CHESS] category.
*/
@Suppress("unused")
class Chess internal constructor(fakerService: FakerService) : YamlFakeDataProvider<Chess>(fakerService) {
override val yamlCategory = YamlCategory.CHESS
override val localUniqueDataProvider = LocalUniqueDataProvider<Chess>()
override val unique by UniqueProviderDelegate(localUniqueDataProvider)

init {
fakerService.load(yamlCategory)
}

fun players() = resolve("players")
fun tournaments() = resolve("tournaments")
fun openings() = resolve("openings")
fun titles() = resolve("titles")
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import io.github.serpro69.kfaker.provider.unique.LocalUniqueDataProvider
import io.github.serpro69.kfaker.provider.unique.UniqueProviderDelegate

/**
* [FakeDataProvider] implementation for [YamlCategory.ANCIENT] category.
* [FakeDataProvider] implementation for [YamlCategory.CHIQUITO] category.
*/
@Suppress("unused")
class Chiquito internal constructor(fakerService: FakerService) : YamlFakeDataProvider<Chiquito>(fakerService) {
Expand Down
33 changes: 33 additions & 0 deletions core/src/main/resources/locales/en/avatar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# START avatar_provider_dict
en:
faker:
avatar:
characters: ['Neytiri', 'Jake Sully, Tommy', 'Doctora Grace Augustine', 'Ronal', 'Trudy Chacon', 'Miles Quaritch', 'Dr. Karina Mogue', 'Parker Selfridge', 'Mo at', 'Eytukan', 'Dragon Gunship Pilot', 'Neteyam', 'Varang', 'Otamu', 'Bilano', 'Deyshana', 'Entok', 'Eywaftia', 'Frapohu', 'Ronal', 'Saeyla', 'Sevineyo', 'Ian Garvin', 'Hukato']
dates: ['December 18, 2009', 'December 15, 2022', 'December 20, 2024']
quotes: [
"I'm a warrior of the Jarhead clan.",
"I was a warrior who dreamed he could bring peace. Sooner or later though, you always have to wake up.",
"You want a fair deal, you're on the wrong planet. The strong prey on the weak.",
"Sometimes your whole life boils down to one insane move.",
"The Sky People have sent us a message: that they can take whatever they want. That no one can stop them. Well, we will send them a message: that they cannot take whatever they want! And that this...this is our land!",
"All I ever wanted was a single thing worth fighting for.",
"You don't choose your Avatar... your Avatar chooses you.",
"The Na'vi say, that every person is born twice. The second time, is when you earn your place among the people...forever.",
"Your spirit goes with Eywa. Your body stays behind to become part of The People.",
"If it ain't raining, we ain't training.",
"I became a Marine for the hardship. To be hammered on the anvil of life. I told myself I could pass any test a man can pass.",
"If Grace is there with you - look in her memories - she can show you the world we come from. There's no green there. They killed their mother, and they're gonna do the same here.",
"Sooner or later, though, you always have to wake up.",
"Everything is backwards now, like out there is the true world, and in here is the dream.",
"I'm with you now, Jake. We are mated for life.",
"To become 'taronyu' hunter, you must choose your own Ikran and he must choose you.",
"Toruk chose him, it has only happened five times since the time of first songs.",
"You have a strong heart. No fear. But stupid! Ignorant like a child!",
"Our great mother does not take sides, Jake; she protects the balance of life.",
"Hey Sully... how does it feel to betray your own race? You think you're one of them? Time to wake up!",
"Everyone on this base, every one of you, is fighting for survival, and that's a fact.",
"And when we destroy it, we will blast a crater in their racial memory so deep, that they won't come within 1,000 klicks of this place ever again. And that too, is a fact.",
"So you just figured you'd come here, to the most hostile environment known to men, with no training of any kind, and see how it went? What was going through your head?",
"It is hard to fill a cup that is already full."
]
# END avatar_provider_dict
105 changes: 105 additions & 0 deletions core/src/main/resources/locales/en/chess.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# START chess_provider_dict
en:
faker:
chess:
players:
- Alexander Alekhine
- Alexei Shirov
- Alexis Vargas
- Anatoly Karpov
- Bobby Fischer
- Emanuel Lasker
- Fabiano Caruana
- Garry Kasparov
- Hikaru Nakamura
- Jose Raul Capablanca
- Levon Aronian
- Magnus Carlsen
- Mikhail Botvinnik
- Radjabov Teimour
- Sergey Karjakin
- Tigran Petrosian
- Viswanathan Anand
- Vladimir Kramnik
- Wesley So
- Paul Morphy
tournaments:
- Wijk aan Zee
- Linares
- Astrakhan
- Dortmund
- Shanghai
- Bilbao
- Nanjing
- Moscow
- London
- Moscow
- Tromsø (Chess World Cup)
- Paris (Grand Prix 2012–2013)
- Bucharest
- Nizhny Novgorod (Russian Championship)
- Zurich
- Khanty-Mansisyk (Candidates Tournament)
- Tbilisi (Grand Prix 2014–2015)
- Khanty-Mansisyk (Grand Prix 2014–2015)
- Baku (Chess World Cup)
- London (Grand Chess Tour)
- Gibraltar
openings:
- Alekhine’s Defense
- Benko Gambit
- Benoni Defense
- Bird’s Opening
- Bogo-Indian Defense
- Budapest Gambit
- Catalan Opening
- Caro-Kann Defense
- Colle System
- Dutch Defense
- Giuoco Piano
- English Opening
- Evans Gambit
- Four Knights Game
- French Defense
- Grünfeld Defense
- Italian Game
- King’s Gambit
- King’s Indian Attack
- King’s Indian Defense
- King’s Pawn Game
- London System
- Modern Defense
- Nimzo-Indian Defense
- Nimzowitsch Defense
- Petrov’s Defense
- Philidor’s Defense
- Pirc Defense
- Queen’s Pawn Game
- Queen’s Gambit Accepted
- Queen’s Gambit Declined
- Queen’s Indian Defense
- Réti Opening
- Ruy Lopez
- Scandinavian Defense
- Scotch Game
- Sicilian Defense
- Slav Defense
- Torre Attack
- Two Knights Defense
- Vienna Game
- Wade Defense
titles:
- GM
- IM
- FM
- CM
- WGM
- WIM
- WFM
- WCM
- AGM
- AIM
- AFM
- ACM

# END chess_provider_dict
26 changes: 26 additions & 0 deletions docs/src/orchid/resources/pages/data-provider/avatar.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
---

== `Faker().avatar`

.Dictionary file
[%collapsible]
====
[source,yaml]
----
{% snippet 'avatar_provider_dict' %}
----
====

.Available Functions
[%collapsible]
====
[source,kotlin]
----
Faker().avatar.characters() // => Neytiri
Faker().avatar.dates() // => December 18, 2009
Faker().avatar.quotes() // => I'm a warrior of the Jarhead clan.
----
====
Loading

0 comments on commit 3ff0ff9

Please sign in to comment.