Path: README.rdoc
Last Update: Sun Nov 09 15:46:26 -0500 2008


This gem 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. Instead of: = "John Doe"

You get: = "#{Random.firstname} #{Random.initial} #{Random.lastname}"


sudo gem install random_data

or get the gem manually from


Contact Methods, Random.international_phone,

Time/Date Methods, Random.date_between

Location Methods

Random.address_line_1, Random.address_line_2, Random.zipcode, Random.uk_post_code, Random.state, Random.state_full,,

Name Methods

Random.firstname, Random.firstname_male, Random.firstname_female, Random.initial, Random.lastname

Text Methods

Random.alphanumeric, Random.paragraphs

Grammatical Methods


Number Methods

Random.number, Random.bit, Random.bits

Boolean Methods


Markov Generator Methods Random.MarkovGenerator.insert Random.MarkovGenerator.generate

Array Extension

Array.rand Array.roulette

Choose From File Methods

Random implements a method_missing helper that will choose a line at random from a file in your load path. See Random::method_missing for details.

Note that some methods take parameters to bound or limit the amount of data returned. See RDocs for details.

Examples of Some Methods

        => "cfbutm3vYfhZXil0"

        >> Random.alphanumeric(5)
        => "XYVyn"

        >> Random.paragraphs
        => "Ulysses, fighting evil and tyranny with all his power and with all of his might. Ulysses, fighting evil and tyranny with all his power and with all
        of his might. \n\nHe's got style, a groovy style, and a car that just won't stop. \n\n"

        >> Random.paragraphs(3)
        => "Excepteur sint occaecat cupidatat non proident  sunt in culpa qui officia deserunt mollit anim id est laborum. Down the road that's where I'll always be.
        He's got style, a groovy style, and a car that just won't stop. I've gotten burned over Cheryl Tiegs and blown up for Raquel Welch, but when I end up in the
        hay it's only hay  hey hey. Hey there where ya goin, not exactly knowin'. \n\nLorem ipsum dolor sit amet  consectetur adipisicing elit sed do eiusmod tempor
        incididunt ut labore et dolore magna aliqua. I might jump an open drawbridge or Tarzan from a vine, beause I'm the unknown stuntman that makes Eastwood look so
        fine. He just keeps on movin' and ladies keep improvin'. Rolling  down to Dallas - who is providin my palace?. Every stop I make I make a new friend; Can't
        stay for long just turn around and I'm gone again. \n\nAlways fighting all the evil forces bringing peace and justice to all. \n\n"

        >> Random.firstname
        => "Thomas"

        >> Random.initial
        => "E"

        >> Random.lastname
        => "Robinson"

        => Sun, 09 Sep 2007

        (Returns an actual date object, shown here in its to_s form)

        => Sun, 26 Nov 2006

        => ""

        => "564-103-8353"

        >> Random.international_phone
        => "011-24-37-9704"

        >> Random.address_line_1
        => "38367 Adams Rd"

        >> Random.address_line_2
        => "Lot 247"

        >> Random.zipcode
        => 22904

        (Note that the zipcodes are totally random and may not be real zipcodes)

        >> Random.state
        => "MD"

        >> Random.state_full
        => "New Mexico"

        => "Philippines"


Let me know if you have patches, comments, or suggestions:

Special Thanks

Major thanks to Hugh Sasse and Paul Barry for their contributions.


Copyright (c) 2008 Mike Subelsky, Baltimore, Maryland, released under the MIT license.