populator 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +6 -0
- data/Manifest +0 -1
- data/README +6 -1
- data/Rakefile +2 -1
- data/TODO +0 -6
- data/lib/populator/random.rb +8 -0
- data/populator.gemspec +6 -15
- data/spec/database.yml +2 -7
- data/spec/populator/random_spec.rb +4 -0
- metadata +5 -14
data/CHANGELOG
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
0.2.4 (September 9th, 2008)
|
2
|
+
|
3
|
+
* removing echoe from gem development dependencies, which didn't seem to work in the first place.
|
4
|
+
|
5
|
+
* adding Populator.paragraphs to generate paragraphs of text
|
6
|
+
|
1
7
|
0.2.3 (September 2nd, 2008)
|
2
8
|
|
3
9
|
* support single table inhertance by setting inheritance_column to class name
|
data/Manifest
CHANGED
data/README
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
Populate an Active Record database with mass insert.
|
4
4
|
|
5
|
+
You can find the rdocs at http://populator.rubyforge.org.
|
6
|
+
|
5
7
|
Special thanks to Zach Dennis for his ar-extensions gem which some of
|
6
8
|
this code is loosely based on.
|
7
9
|
|
@@ -41,7 +43,7 @@ The person object contains the "id" so you can set up associations.
|
|
41
43
|
|
42
44
|
That will create 30 projects for each person.
|
43
45
|
|
44
|
-
Passing
|
46
|
+
Passing a range or array of values will randomly select one.
|
45
47
|
|
46
48
|
Person.populate(1000..5000) do |person|
|
47
49
|
person.gender = ['male', 'female']
|
@@ -61,6 +63,7 @@ If you need to generate fake data, there are a few methods to do this.
|
|
61
63
|
Populator.words(3) # generates 3 random words separated by spaces
|
62
64
|
Populator.words(10..20) # generates between 10 and 20 random words
|
63
65
|
Populator.sentences(5) # generates 5 sentences
|
66
|
+
Populator.paragraphs(3) # generates 3 paragraphs
|
64
67
|
|
65
68
|
For fancier data generation, try the Faker gem.
|
66
69
|
|
@@ -82,5 +85,7 @@ This project can be found on github at the following URL.
|
|
82
85
|
|
83
86
|
http://github.com/ryanb/populator
|
84
87
|
|
88
|
+
If you find a bug, please send me a message on GitHub.
|
89
|
+
|
85
90
|
If you would like to contribute to this project, please fork the
|
86
91
|
repository and send me a pull request.
|
data/Rakefile
CHANGED
@@ -2,13 +2,14 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('populator', '0.2.
|
5
|
+
Echoe.new('populator', '0.2.4') do |p|
|
6
6
|
p.summary = "Mass populate an Active Record database."
|
7
7
|
p.description = "Mass populate an Active Record database."
|
8
8
|
p.url = "http://github.com/ryanb/populator"
|
9
9
|
p.author = 'Ryan Bates'
|
10
10
|
p.email = "ryan (at) railscasts (dot) com"
|
11
11
|
p.ignore_pattern = ["script/*", "**/*.sqlite3", "tmp/*"]
|
12
|
+
p.development_dependencies = []
|
12
13
|
end
|
13
14
|
|
14
15
|
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
data/TODO
CHANGED
@@ -1,17 +1,11 @@
|
|
1
|
-
Features
|
2
|
-
|
3
1
|
Possible
|
4
2
|
- randomly fill every column if no block is passed to populate
|
5
3
|
- add random_foo method to record for randomly generating content
|
6
4
|
|
7
|
-
Performance
|
8
|
-
- ensure instantiating the model is really that much of a performance hit.
|
9
|
-
|
10
5
|
Support Environments
|
11
6
|
- sqlite 2
|
12
7
|
- old rails
|
13
8
|
- edge rails
|
14
9
|
|
15
10
|
Tests
|
16
|
-
- automatically detect schema changes and rebuild database
|
17
11
|
- add db:reset, db:drop and db:create rake tasks
|
data/lib/populator/random.rb
CHANGED
@@ -28,6 +28,14 @@ module Populator
|
|
28
28
|
end.join('. ')
|
29
29
|
end
|
30
30
|
|
31
|
+
# Generate a given number of paragraphs. If a range is passed, it will generate
|
32
|
+
# a random number of paragraphs within that range.
|
33
|
+
def paragraphs(total)
|
34
|
+
(1..interpret_value(total)).map do
|
35
|
+
sentences(3..8).capitalize
|
36
|
+
end.join("\n\n")
|
37
|
+
end
|
38
|
+
|
31
39
|
# If an array or range is passed, a random value will be selected to match.
|
32
40
|
# All other values are simply returned.
|
33
41
|
def interpret_value(value)
|
data/populator.gemspec
CHANGED
@@ -1,30 +1,21 @@
|
|
1
1
|
|
2
|
-
# Gem::Specification for Populator-0.2.
|
2
|
+
# Gem::Specification for Populator-0.2.4
|
3
3
|
# Originally generated by Echoe
|
4
4
|
|
5
5
|
--- !ruby/object:Gem::Specification
|
6
6
|
name: populator
|
7
7
|
version: !ruby/object:Gem::Version
|
8
|
-
version: 0.2.
|
8
|
+
version: 0.2.4
|
9
9
|
platform: ruby
|
10
10
|
authors:
|
11
11
|
- Ryan Bates
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
|
15
|
-
date: 2008-09-
|
15
|
+
date: 2008-09-09 00:00:00 -07:00
|
16
16
|
default_executable:
|
17
|
-
dependencies:
|
18
|
-
|
19
|
-
name: echoe
|
20
|
-
type: :development
|
21
|
-
version_requirement:
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: "0"
|
27
|
-
version:
|
17
|
+
dependencies: []
|
18
|
+
|
28
19
|
description: Mass populate an Active Record database.
|
29
20
|
email: ryan (at) railscasts (dot) com
|
30
21
|
executables: []
|
@@ -56,7 +47,6 @@ files:
|
|
56
47
|
- lib/populator.rb
|
57
48
|
- LICENSE
|
58
49
|
- Manifest
|
59
|
-
- populator.gemspec
|
60
50
|
- Rakefile
|
61
51
|
- README
|
62
52
|
- spec/database.yml
|
@@ -73,6 +63,7 @@ files:
|
|
73
63
|
- tasks/deployment.rake
|
74
64
|
- tasks/spec.rake
|
75
65
|
- TODO
|
66
|
+
- populator.gemspec
|
76
67
|
has_rdoc: true
|
77
68
|
homepage: http://github.com/ryanb/populator
|
78
69
|
post_install_message:
|
data/spec/database.yml
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# you can add and remove entries to support different databases in tests.
|
2
|
+
|
1
3
|
sqlite3:
|
2
4
|
adapter: sqlite3
|
3
5
|
database: spec/test.sqlite3
|
@@ -9,10 +11,3 @@ mysql:
|
|
9
11
|
username: populator
|
10
12
|
password:
|
11
13
|
host: localhost
|
12
|
-
|
13
|
-
postgresql:
|
14
|
-
adapter: postgresql
|
15
|
-
database: populator_test
|
16
|
-
username: populator
|
17
|
-
password: populator
|
18
|
-
host: localhost
|
@@ -42,4 +42,8 @@ describe Populator::Random do
|
|
42
42
|
it "should generate 3 random sentences" do
|
43
43
|
Populator.sentences(3).split(/\. [A-Z]/).should have(3).records
|
44
44
|
end
|
45
|
+
|
46
|
+
it "should generate 3 random paragraphs" do
|
47
|
+
Populator.paragraphs(3).split(/\n\n/).should have(3).records
|
48
|
+
end
|
45
49
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: populator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Bates
|
@@ -9,19 +9,10 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-09-
|
12
|
+
date: 2008-09-09 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
name: echoe
|
17
|
-
type: :development
|
18
|
-
version_requirement:
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: "0"
|
24
|
-
version:
|
14
|
+
dependencies: []
|
15
|
+
|
25
16
|
description: Mass populate an Active Record database.
|
26
17
|
email: ryan (at) railscasts (dot) com
|
27
18
|
executables: []
|
@@ -53,7 +44,6 @@ files:
|
|
53
44
|
- lib/populator.rb
|
54
45
|
- LICENSE
|
55
46
|
- Manifest
|
56
|
-
- populator.gemspec
|
57
47
|
- Rakefile
|
58
48
|
- README
|
59
49
|
- spec/database.yml
|
@@ -70,6 +60,7 @@ files:
|
|
70
60
|
- tasks/deployment.rake
|
71
61
|
- tasks/spec.rake
|
72
62
|
- TODO
|
63
|
+
- populator.gemspec
|
73
64
|
has_rdoc: true
|
74
65
|
homepage: http://github.com/ryanb/populator
|
75
66
|
post_install_message:
|