Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Quickly and easily create seed data for your ruby application. Names, first and last, female and male. Randomly generate users with appropriate names and matching email addresses. It works by combining a couple of lists of names and providing a simple way to retrieve personas.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .rvmrc
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 LICENSE.txt
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 babynames.gemspec
README.md

BabyNames

Quickly and easily create seed data for your ruby application. Names, first and last, female and male. Randomly generate users with appropriate names and matching email addresses.

It works by combining a couple of lists of names and providing a simple way to retrieve personas.

Install

Using bundler just

gem "babynames"

Or otherwise

gem install babynames

Then you are good to go

Example

person = BabyNames.person
User.create(:first_name => person.first_name, :last_name => person.last_name, :email => person.email, :male => person.male?)

Ruby Versions

Tested with 1.8.7, 1.9.2, 1.9.3. Should work on most others too.

Making it repeatable with seeds

If you want to make sure that the seed data is always the same when run (still random, but the same random sequence when rerun) you can keep the seed number and use it again

BabyNames.seed
 3890
BabyNames.name
 "Thelma" 
BabyNames.name
 "Ronnie" 
BabyNames.name
 "Joanna" 
BabyNames.seed(3890)
 3890 
BabyNames.name
 "Thelma" 
BabyNames.name
 "Ronnie" 
BabyNames.name
 "Joanna" 

Demo

> require "rubygems"
=> true

> require "babynames"
=> true

> BabyNames.name
=> "Mickey"

> BabyNames.female_name
=> "Valarie"

> BabyNames.male_name
=> "Julius"

> BabyNames.persons_name
=> ["Darin", "Odonnell"]

> BabyNames.persons_name(:male)
=> ["Brad", "Downs"]

> BabyNames.persons_name(:female)
=> ["Karen", "House"]

> BabyNames.email
=> "agnes.rutledge@yah0o.com"

> BabyNames.email(:male)
=> "w.downs@yah0o.com"

> BabyNames.email(:female)
=> "k.anthony@yah0o.com"

> person = BabyNames.person
=> #<BabyNames::Person:0x100612668 @gender=:male, @middle_name="Carmine", @email="e.c.mcdonald@yah0o.com", @last_name="Mcdonald", @first_name="Edwin">

> person.first_name
=> "Edwin"

> person.last_name
=> "Mcdonald"

> person.email
=> "e.c.mcdonald@yah0o.com"

> person.middle_name
=> "Carmine"    

> person.male?
=> true

> person.female?
=> false

Contributing to babynames

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright

Copyright (c) 2011 Jordan Carter. See LICENSE.txt for further details.

Something went wrong with that request. Please try again.