-
-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract faker's providers into several sub-modules of their own #219
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BookFaker could try to resolve "#{Name.name}" in one of its functions, which would try to lookup the `Name` provider that isn't available in the BooksFaker. In such cases we try to find the `Name` provider in the core `Faker` implementation, and failing that thrown an exception to make the error clearer. We do not try to support CustomFaker -> AnotherCustomFaker calls, e.g. BooksFaker -> MusicFaker. Only CustomFaker -> Faker is supported, i.e. BooksFaker -> Faker.
Also make safer some provider implementations that utilize secondaryCategory by allowing `YmlFakeDataProvider#resolve` to take Category as parameter instead of String
Use this to move all files with GAMES category: grep -lRF 'override val yamlCategory = YamlCategory.GAMES' \ core/src/main/kotlin/io/github/serpro69/kfaker/provider/ | \ xargs -I {} mv {} provider/games/src/main/kotlin/io/github/serpro69/kfaker/games/provider/ Then move a couple more, which have their own primary category, manually.
This included moving test files also, so had to add a testImplementation dependency on 'core' to the faker-provider-conventions plugin. Integration tests were also failing, particularly those that are used in docs, so needed to add some integrationImplementation dependencies on a new module also.
Apparently they've started using Anchors and Aliases in yml files upstream (see e.g. uk.yml -> male_first_name -> first_name). Seems like jackson can't handle Anchors properly (see FasterXML/jackson-dataformats-text#98) As a workaround, we use snakeyaml to read .yml files to Map objects, and then we use jackson to write them to .json files, since snakeyaml seems to support anchors just fine without needing to jump through hoops.
Room and TheRoom have the same data/functions
This leaves the core Faker with only its own data generators.
serpro69
added
enhancement 🚀
New feature or request
core 🧬
Issue related to :core module
labels
Feb 17, 2024
… faker:*:shadowJar
Update the build workflow to run native image several times for testing purposes
Keep plurality consistent across fakers' names
serpro69
added a commit
that referenced
this pull request
Feb 18, 2024
Relates to changes introduced in #219, particularly fakerService became publicly visible, which is not ideal. To hide it we had to introduce another property in UniqueProviderDelegate, since that was the only place where compilation was failing. So instead of using fakerService from thisRef, we make it constructor property and use it from there. This of course also touched almost all data providers. Not sure if this needs more testing though.
This also adds support for #63 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
core 🧬
Issue related to :core module
enhancement 🚀
New feature or request
faker 💯
Issue related to :faker modules
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Close #217
And as an added bonus, closes #218 as well.
SlackEmoji
toLoremFaker
?