From 25142f6820f61a20f971d2ba7e4c205bd6845263 Mon Sep 17 00:00:00 2001 From: Ryan Bates Date: Fri, 3 Oct 2008 16:31:49 -0700 Subject: [PATCH] adding .rdoc extension to README so it is formatted on GitHub --- Manifest | 3 +- README | 91 -------------------------------------------------------- 2 files changed, 2 insertions(+), 92 deletions(-) delete mode 100644 README diff --git a/Manifest b/Manifest index 47fde95..03c73ac 100644 --- a/Manifest +++ b/Manifest @@ -1,5 +1,6 @@ CHANGELOG lib/populator/adapters/abstract.rb +lib/populator/adapters/oracle.rb lib/populator/adapters/sqlite.rb lib/populator/factory.rb lib/populator/model_additions.rb @@ -9,7 +10,7 @@ lib/populator.rb LICENSE Manifest Rakefile -README +README.rdoc spec/database.yml spec/example_database.yml spec/models/category.rb diff --git a/README b/README deleted file mode 100644 index ff81ded..0000000 --- a/README +++ /dev/null @@ -1,91 +0,0 @@ -= Populator - -Populate an Active Record database with mass insert. - -You can find the rdocs at http://populator.rubyforge.org. - -Special thanks to Zach Dennis for his ar-extensions gem which some of -this code is loosely based on. - - -== Install - -Install the gem: - - gem install populator - -And then load it in your project: - - require 'populator' - - -== Usage - -This gem adds a "populate" method to all Active Record models. Pass the -number of records you want to create along with a block. In the block -you can set the column values for each record. - - Person.populate(3000) do |person| - person.first_name = "John" - person.last_name = "Smith" - end - -This will do a mass insert into the database so it is very fast. -The person object contains the "id" so you can set up associations. - - Person.populate(3000) do |person| - person.first_name = "John" - person.last_name = "Smith" - Project.populate(30) do |project| - project.person_id = person.id - end - end - -That will create 30 projects for each person. - -Passing a range or array of values will randomly select one. - - Person.populate(1000..5000) do |person| - person.gender = ['male', 'female'] - person.annual_income = 10000..200000 - end - -This will create 1000 to 5000 men or women with the annual income -between 10,000 and 200,000. - -You can pass a :per_query option to limit how many records are saved -per query. This defaults to 1000. - - Person.populate(2000, :per_query => 100) - -If you need to generate fake data, there are a few methods to do this. - - Populator.words(3) # generates 3 random words separated by spaces - Populator.words(10..20) # generates between 10 and 20 random words - Populator.sentences(5) # generates 5 sentences - Populator.paragraphs(3) # generates 3 paragraphs - -For fancier data generation, try the Faker gem. - -http://faker.rubyforge.org - - -== Important - -For performance reasons, this gem does not use actual instances of the -model. This means validations and callbacks are bypassed. It is up to -you to ensure you're adding valid data. - - -== Development - -See spec/README for instructions on running specs. - -This project can be found on github at the following URL. - -http://github.com/ryanb/populator - -If you find a bug, please send me a message on GitHub. - -If you would like to contribute to this project, please fork the -repository and send me a pull request.