Home

Awesome

Forgery

Build Status Code Climate

A Problem: It's harder than absolutely easy to make meaningful, simple, data for testing and development.

A Solution: A fake data generator that provides not only a host of basics and a rememberable syntax, but a customizable library to boot.

Welcome to Forgery, an excellent solution to a problem so hard you didn't know it was there.

Using

You'll want to read individual Forgery categories for more information, but these are the basics:

Forgery(:basic).password
  #=> "b6qZTQEH"

Forgery(:internet).email_address
  #=> "krainboltgreene@crt.net"

Forgery(:monetary).money
  #=> "1.58"

Forgery(:lorem_ipsum).words(10)
  #=> "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam egestas."

Forgery(:monetary).formatted_money :min => 100, :max => 1000
  #=> "$923.36"

And many many more!

Alternatively you can write it like this:

Forgery::Basic.hex_color
Forgery::Name.full_name
Forgery::Personal.shirt_size

In addition, you can always write your own dictionaries and formats, overriding the ones in the gem. Fully explained here.

Installing

Like any gem, you can install Forgery two ways depending on it's use.

For normal Ruby development, you need simply use:

gem install forgery

This will add it to your gem library, just like any normal gem. You can then use it like any normal gem library. See examples for more.

Rails 3.x

If you're using Rails 3.x you need to do a few extra things (that are probably rote). First step is to add it to your Rails.root/Gemfile, we also suggest specifying the latest version (found on rubygems):

gem 'forgery', '0.6.0'

Then you'll need to run bundle install to install and lock in your new gem. Next you'll want to run the special Rails 3 generator:

bundle exec rails generate forgery

Rails 2.x

For Rails 2.x you'll need to do something a little different, by first editing your Rails.root/config/environment.rb and adding this to the configuration block:

config.gem 'forgery'

Then you'll need to run this in your command line:

script/generate forgery

Generators

This Rails generators will make these directories in your Rails.root directory:

You can then use these directories to write your own dictionaries, class extensions, forgeries, and formats.

Full List of Methods

AddressExample Output
Forgery('address').cityLoomis
Forgery('address').continentSouth America
Forgery('address').countryCameroon
Forgery('address').phone+1 (693) 901-4549
Forgery('address').provinceAlberta
Forgery('address').province_abbrevNT
Forgery('address').stateAlabama
Forgery('address').state_abbrevSC
Forgery('address').street_address21 Hayes Park
Forgery('address').street_nameOneill
Forgery('address').street_number222
Forgery('address').street_suffixDrive
Forgery('address').zip11281-5568
BasicExample Output
Forgery('basic').booleantrue (TrueClass)
Forgery('basic').colorRed
Forgery('basic').encryptfc0d835dd4e4df144a33a6a346298b0f23dcd14a
Forgery('basic').frequencyNever
Forgery('basic').hex_color#e1d82a
Forgery('basic').number4
Forgery('basic').passwordKcLBHCv6
Forgery('basic').short_hex_color#c1d
Forgery('basic').textG8gECFfvDs2
Credit CardExample Output
Forgery('credit_card').check_digit(number)5
Forgery('credit_card').number343682330855371
Forgery('credit_card').typeAmerican Express
Forgery('currency').codeXPF
Forgery('currency').descriptionAustria Schillings
DateExample Output
Forgery('date').dateFri, 20 Mar 2009 (Date)
Forgery('date').day15
Forgery('date').day_of_weekMonday
Forgery('date').delta(options)3
Forgery('date').monthJanuary
Forgery('date').year1994
EmailExample Output
Forgery('email').addressgsmith@kamba.org
Forgery('email').bodyLorem ipsum dolor sit amet, consectetuer ...
Forgery('email').subjectLorem Ipsum Dolor Sit Amet...
GeoExample Output
Forgery('geo').latitude-8.095096815540515 (Float)
Forgery('geo').latitude_degrees-49
Forgery('geo').latitude_directionN
Forgery('geo').latitude_minutes14
Forgery('geo').latitude_seconds45
Forgery('geo').longitude-22.56746406884514 (Float)
Forgery('geo').longitude_degrees100
Forgery('geo').longitude_directionW
Forgery('geo').longitude_minutes47
Forgery('geo').longitude_seconds41
InternetExample Output
Forgery('internet').cctldcf
Forgery('internet').domain_namebubbletube.net
Forgery('internet').email_addresscwalker@quire.name
Forgery('internet').email_subjectLorem Ipsum Dolor Sit Amet...
Forgery('internet').ip_v494.120.51.103
Forgery('internet').ip_v6c61e:5926:15e6:d225:8eef:fb39:7412:e9d5
Forgery('internet').top_level_domaincom
Forgery('internet').user_namesdixon
Lorem IpsumExample Output
Forgery('lorem_ipsum').characterl
Forgery('lorem_ipsum').characterslorem ipsu
Forgery('lorem_ipsum').lorem_ipsum_characterslorem ipsum dolor sit amet...
Forgery('lorem_ipsum').lorem_ipsum_words"lorem", "ipsum", "dolor", ...
Forgery('lorem_ipsum').paragraphLorem ipsum dolor sit amet...
Forgery('lorem_ipsum').paragraphsLorem ipsum dolor sit amet...
Forgery('lorem_ipsum').range_from_quantity(quantity)0..4 (Range)
Forgery('lorem_ipsum').sentenceLorem ipsum dolor sit amet...
Forgery('lorem_ipsum').sentencesLorem ipsum dolor sit amet...
Forgery('lorem_ipsum').textLorem ipsum dolor sit amet...
Forgery('lorem_ipsum').titleLorem Ipsum Dolor Sit Amet...
Forgery('lorem_ipsum').wordlorem
Forgery('lorem_ipsum').wordslorem ipsum dolor sit amet...
MonetaryExample Output
Forgery('monetary').formatted_money$5.49
Forgery('monetary').money9.20 (String)
NameExample Output
Forgery('name').company_nameBubbletube
Forgery('name').female_first_nameJudy
Forgery('name').first_nameAlbert
Forgery('name').full_nameEvelyn Wallace
Forgery('name').industryToy & Hobby Stores
Forgery('name').job_titleAnalyst Programmer
Forgery('name').job_title_suffixIII
Forgery('name').last_nameJackson
Forgery('name').locationTry-N-Save
Forgery('name').male_first_nameDonald
Forgery('name').suffixSr
Forgery('name').titleMr
PersonalExample Output
Forgery('personal').abbreviated_genderF
Forgery('personal').genderFemale
Forgery('personal').languageBislama
Forgery('personal').raceIndonesian
Forgery('personal').shirt_size2XL
Bank AccountExample Output
Forgery('bank_account').ibanBE68539007547034
Forgery('bank_account').bicVBRSDE33345
Russian TaxExample Output
Forgery('russian_tax').account_number56335652786612121479
Forgery('russian_tax').bik046533860
Forgery('russian_tax').inn7366543467
Forgery('russian_tax').legal_inn7822838630
Forgery('russian_tax').legal_ogrn3483465598635
Forgery('russian_tax').ogrn666325227817763
Forgery('russian_tax').person_inn451559765443
Forgery('russian_tax').person_ogrn195478617554621
TimeExample Output
Forgery('time').zoneAmsterdam (String)

Contributing

This is a work in progress and an open source project, so feel free to contribute.

We'll take pull requests via git or suggestions via the issues tab. Any work done on Forgery will get you into the credits list and in our hearts.