Thursday, September 20, 2007

random_data gem released

I just released my first Ruby gem. I have a library of functions that I use for generating realistic data so I can have more meaningful examples to work with during development. So I used the newgem generator and hoe to package it all into a gem called random_data.

It provides a Random singleton class with a series of methods for generating random test data including names, mailing addresses, dates, phone numbers, e-mail addresses, and text. This lets you quickly mock up realistic looking data for informal testing.

Instead of:
>> foo.name = "John Doe"
You get:

>>
foo.name = "#{Random.firstname} #{Random.initial} #{Random.lastname}"
>> foo.name
=> "Miriam R. Xichuan"


The gem also includes code for phone numbers, e-mail addresses, physical addresses, and (primitive) text generation.

You can install it via:

sudo gem install random_data
For more details and full documentation, visit the rubyforge site.

4 comments:

Conrad Taylor said...

How does one require your gem? I have tried

require 'random_data'

which produced the following error message:

irb(main):002:0> require 'random_data'
LoadError: no such file to load -- random_data
from (irb):2:in `require'
from (irb):2

Conrad Taylor said...

OK, I resolved the issue. I needed to do the following:

require 'rubygems'
require 'random_data'

Mike Subelsky said...

glad you were able to get it working! In Ruby 1.9 I believe rubygems is standard, so you won't have to require it separately.

abriening said...

Great plugin.

I posted a bug on rubyforge:
http://rubyforge.org/tracker/index.php?func=detail&aid=22299&group_id=4458&atid=17142

includes a patch.