You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Extending faker with external generators experiment #3191
I finalized experimenting with extending Faker classes so users can create their own external generators and/or add new functionalities to faker-ruby generators. I created two example repositories of external generators exemplifying that:
Faker::Git - a new generator that produces random git branch name. Examples include setting a different locale as well.
Faker::Omniauth - adds new functionality to an existing faker-ruby generator by adding a new provider.
I tested them by building and installing the gem. Then I used the generators in an irb session:
This shows that we don't need to change anything in faker to have users creating their own external generators! Fun surprise. It turns out all that is needed is to inherit from Faker::Base to get access to faker's helpers.
Recommended next steps
test examples above in a real world application beyond an irb session ✅
think of edge cases to test
document best practices on how to name the gems (for ex. faker-$name), avoid overriding faker's functionalities, etc., list them in our docs so people can find them. Fore example, roda's list of external plugins.
ask users to use external generators (even create their own) and report any bugs
start extracting non-core generators to external gems. There are a few options to consider:
it might not be necessary after we stop requiring all generators by default.
we could follow faker JS SimpleFaker and have a core set of generators without locales and then another gem that has the remaining generators and locales. This would be nice because we could not load i18n as a required dependency.
It worked great and I think we can get started documenting how people can create their own plugins. I created an external generator under faker's organization so people can use it as as example (private repo for now until we decide on naming, etc.): https://github.com/faker-ruby/faker-database
Activity
stefannibrasil commentedon Jan 22, 2026
I finalized experimenting with extending Faker classes so users can create their own external generators and/or add new functionalities to faker-ruby generators. I created two example repositories of external generators exemplifying that:
I tested them by building and installing the gem. Then I used the generators in an
irbsession:This shows that we don't need to change anything in faker to have users creating their own external generators! Fun surprise. It turns out all that is needed is to inherit from
Faker::Baseto get access to faker's helpers.Recommended next steps
faker-$name), avoid overriding faker's functionalities, etc., list them in our docs so people can find them. Fore example, roda's list of external plugins.[-]Lazy load generators experiment[/-][+]Extending faker with external generators experiment[/+]stefannibrasil commentedon Jan 23, 2026
I tested the example generators shared above on CASA:
https://github.com/rubyforgood/casa/compare/main...hexdevs:casa:sb-use-faker-external-generators-example?expand=1
It worked great and I think we can get started documenting how people can create their own plugins. I created an external generator under faker's organization so people can use it as as example (private repo for now until we decide on naming, etc.):
https://github.com/faker-ruby/faker-database
stefannibrasil commentedon Jan 29, 2026
Will revisit this after the loading experiments are done.
stefannibrasil commentedon Feb 19, 2026
Closing in favour of #3162
After we push a beta release with the new loading mechanism, we will work on this.