|Number of watchers on Github||6260|
|Number of open issues||193|
|Average time to close an issue||9 days|
|Average time to merge a PR||9 days|
|Open pull requests||243+|
|Closed pull requests||77+|
|Last commit||over 1 year ago|
|Repo Created||over 10 years ago|
|Repo Last Updated||over 1 year ago|
|Organization / Author||stympy|
|Do you use faker? Leave a review!|
|View open issues (193)|
|View faker activity|
|View on github|
|Fresh, new opensource launches 🚀🚀🚀|
Trendy new open source projects in your inbox! View examples
This gem is a port of Perl's Data::Faker library that generates fake data.
It comes in very handy for taking screenshots (taking screenshots for my project, Catch the Best was the original impetus for the creation of this gem), having real-looking test data, and having your database populated with more than one or two records while you're doing development.
masterbranch of Faker and may contain changes that are not yet released. Please refer the README of your version for the available methods. List of all versions is available here.
gem install faker
Note: if you are getting a
uninitialized constant Faker::[some_class] error, your version of the gem is behind the one documented here. To make sure that your gem is the one documented here, change the line in your gemfile to:
gem 'faker', :git => 'https://github.com/stympy/faker.git', :branch => 'master'
require 'faker' Faker::Name.name #=> "Christophe Bartell" Faker::Internet.email #=> "firstname.lastname@example.org"
Prefix your method call with
unique. For example:
Faker::Name.unique.name # This will return a unique name every time it is called
If too many unique values are requested from a generator that has a limited
number of potential values, a
exception may be raised. It is possible to clear the record of unique values
that have been returned, for example between tests.
Faker::Name.unique.clear # Clears used values for Faker::Name Faker::UniqueGenerator.clear # Clears used values for all generators
Faker supports seeding of its pseudo-random number generator (PRNG) to provide deterministic output of repeated method calls.
Faker::Config.random = Random.new(42) Faker::Company.bs #=> "seize collaborative mindshare" Faker::Company.bs #=> "engage strategic platforms" Faker::Config.random = Random.new(42) Faker::Company.bs #=> "seize collaborative mindshare" Faker::Company.bs #=> "engage strategic platforms" Faker::Config.random = nil # seeds the PRNG using default entropy sources Faker::Config.random.seed #=> 185180369676275068918401850258677722187 Faker::Company.bs #=> "cultivate viral synergies"
Since you may want to make addresses and other types of data look different depending on where in the world you are (US postal codes vs. UK postal codes, for example), Faker uses the I18n gem to store strings (like state names) and formats (US postal codes are NNNNN while UK postal codes are AAN NAA), allowing you to get different formats by switching locales. Just set Faker::Config.locale to the locale you want, and Faker will take care of the rest.
If your locale doesn't already exist, create it in the \lib\locales\ directory and you can then override or add elements to suit your needs. See more about how to use locales here
en-au-ocker: faker: name: # Existing faker field, new data first_name: [Charlotte, Ava, Chloe, Emily] # New faker fields ocker_first_name: [Bazza, Bluey, Davo, Johno, Shano, Shazza] region: [South East Queensland, Wide Bay Burnett, Margaret River, Port Pirie, Gippsland, Elizabeth, Barossa]
Comments and feedback are welcome. Send an email to Benjamin Curtis via the google group.
This code is free to use under the terms of the MIT license.