Couple of New Methods

74 views
Skip to first unread message

Karl

unread,
Jan 26, 2008, 4:43:22 PM1/26/08
to Ruby Faker
I need these methods in Faker, so I though I would share:

Address::zip_code_five_only - only random 5 digit zip codes

Address::zip_code_plus_four - only random zip+4 zip codes
Note: Address::zip_code returns 5 digit and zip+4 zip codes which
was really messing up my day

Address::us_city - a random city name (from a list of real US
cities)

Name::middle_initial - a random, capital letter
Note: also changed 'Formats' so that it would occasionally
return a name with a middle initial

I didn't check the city names to see if there are any 'inappropriate'
names in there, but it came from a list of all the zip codes in the
US. About 150 random names selected from nearly 19,000.

Enjoy.

Benjamin Curtis

unread,
Jan 30, 2008, 3:48:33 PM1/30/08
to ruby-...@googlegroups.com
Thanks! I'll take a look at including these changes.

----
Benjamin Curtis
http://catchthebest.com/ - Track, share, and rate incoming resumes
http://www.bencurtis.com/ - Personal blog

Karl

unread,
Jan 30, 2008, 6:40:24 PM1/30/08
to Ruby Faker
I also wrote some modules for generating random dates and times. Any
interest in including this in Faker?

Benjamin Curtis

unread,
Jan 30, 2008, 6:58:00 PM1/30/08
to ruby-...@googlegroups.com
You bet! The more the merrier. :)

----
Benjamin Curtis
http://catchthebest.com/ - Track, share, and rate incoming resumes
http://www.bencurtis.com/ - Personal blog

Karl

unread,
Feb 2, 2008, 12:02:08 PM2/2/08
to Ruby Faker
Benjamin,
I just attached "time.rb" to the files upload. Should be pretty self
explanatory.

I'm sure there is quite a bit more that could be done with random
dates and times, but this is what I needed to create some fake visitor
data.

Enjoy.
Karl

iNemo

unread,
Feb 8, 2008, 5:56:09 AM2/8/08
to ruby-...@googlegroups.com
Address::us_city - a random city name (from a list of real US
cities)

Attached is a patch that adds the `uk_city` to return one of the 66 cities in the United Kingdom.

Caius
uk_cities.patch
Reply all
Reply to author
Forward
0 new messages