public
Rubygem
Description: Easy and customizable generation of forged data.
Homepage: http://sevenwire.com
Clone URL: git://github.com/sevenwire/forgery.git
maxim (author)
Mon Apr 20 10:55:30 -0700 2009
commit  ad9a115ce2deea22e433648d17fc09b0e87fc232
tree    823f21a48868bad11ba9a1636936c273f136ce97
parent  f9ce4df5e688068b42c116d0c3d1dc5f6ac5d975
name age message
file .gitignore Fri Oct 31 22:58:39 -0700 2008 Adding rdoc task and adding the doc directory t... [nate]
file MIT-LICENSE Wed Feb 06 14:36:51 -0800 2008 The plugin. [brandonarbini]
file README.markdown Mon Apr 20 10:55:30 -0700 2009 Fix README formatting. [maxim]
file Rakefile Sat Nov 15 06:28:42 -0800 2008 Updated the gemspec to include the file list. [brandonarbini]
file VERSION.yml Sat Feb 07 05:52:48 -0800 2009 Version bump to 0.2.2 [brandonarbini]
file forgery.gemspec Sat Feb 07 05:52:55 -0800 2009 Regenerated gemspec for version 0.2.2 [brandonarbini]
directory generators/ Thu Apr 03 18:19:30 -0700 2008 Adding rails support. [nate]
file init.rb Thu Nov 27 20:54:00 -0800 2008 Moving rails requires to inside forgery so it w... [nate]
directory lib/ Fri Feb 06 15:43:47 -0800 2009 Added Canadian provinces to address forgery. [rtlechow]
directory spec/ Fri Feb 06 15:43:47 -0800 2009 Added Canadian provinces to address forgery. [rtlechow]

Forgery

The Problem: Making meaningful development data for your application.

The Solution: A fake data generator that does more than just lorem ipsum and random text (well, it does those too, but also does much more).

Forgery generates fake data from dictionaries, formats, and recipes. The plugin includes a generator providing directories to make your own forgeries.

Install

config.gem "sevenwire-forgery", :lib => "forgery", :source => "http://gems.github.com"

Generator

./script/generate forgery

In a rails project this generator creates:

  • RAILS_ROOT/lib/forgery
  • RAILS_ROOT/lib/forgery/dictionaries
  • RAILS_ROOT/lib/forgery/extensions
  • RAILS_ROOT/lib/forgery/forgeries
  • RAILS_ROOT/lib/forgery/formats

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

Forgery will look first here for dictionaries and formats, so you can override the ones used in the plugin.

See the forgeries in the plugin for examples of how to write your own.

See which dictionaries each forgery uses to override them with your own.

Examples

Here I'll supply a few examples of how it works, in general. See each forgery for individual examples.

# Traditional syntax
BasicForgery.password # => "wYMYvq"
BasicForgery.password :allow_special => true # => ";Qo^N[T"
BasicForgery.hex_color # => "#f4d841"

MonetaryForgery.money # => "8.21"
MonetaryForgery.formatted_money # => "$3.25"
MonetaryForgery.money :min => 100, :max => 1000 # => "848.97"

# Alternate syntax
Forgery(:basic).password # => "b6qZTQEH"
Forgery(:basic).password :allow_special => true # => "XlrhV%An"
Forgery(:basic).hex_color # => "#46b73f"

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

TODO

  • Add instanced forgeries for more relative information generation.

Thanks

Thanks to the authors and contributors:

  • Nate Sutton (nate aka fowlduck)
  • Brandon Arbini (brandonarbini)
  • Josh Nichols (technicalpickles)
  • Jeremy Stephens (viking aka crookshanks)

Notes

This is a work in progress. If you find bugs or have forgeries to contribute, we'll gladly take them and give credit.

Enjoy.

Nate Sutton (nate@sevenwire.com)