randomperson 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +8 -19
- data/lib/randomperson/Choice.rb +3 -2
- data/lib/randomperson/Generator.rb +1 -1
- data/lib/randomperson/ext/Array.rb +0 -2
- data/lib/randomperson/ext/Date.rb +0 -4
- data/lib/randomperson/ext/Enumerable.rb +0 -2
- data/lib/randomperson/ext/Hash.rb +0 -3
- data/lib/randomperson/ext/Kernel.rb +0 -2
- data/lib/randomperson/ext/Set.rb +0 -4
- data/lib/randomperson.rb +3 -2
- data/randomperson.gemspec +17 -29
- data.tar.gz.sig +0 -0
- metadata +17 -78
- metadata.gz.sig +0 -0
- data/CHANGELOG +0 -15
- data/Manifest +0 -56
- data/README +0 -264
- data/gem-public_cert.pem +0 -20
- data/t/Generator.t +0 -82
data/Rakefile
CHANGED
@@ -1,27 +1,16 @@
|
|
1
1
|
require 'rake'
|
2
|
-
require '
|
3
|
-
# require 'rake/testtask'
|
2
|
+
require 'rake/testtask'
|
4
3
|
|
5
4
|
lib_dir = File.expand_path('lib')
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
p.description = "A gem for generating random persons"
|
10
|
-
p.url = "http://github.com/yb66/RandomPerson"
|
11
|
-
p.author = "Iain Barnett"
|
12
|
-
p.email = "iainspeed @nospam@ gmail.com"
|
13
|
-
p.ignore_pattern = ["tmp/*", "script/*"]
|
14
|
-
p.development_dependencies = []
|
15
|
-
p.runtime_dependencies = []
|
16
|
-
p.ruby_version = ">= 1.9.1"
|
17
|
-
p.require_signed = true
|
18
|
-
end
|
5
|
+
app_dir = File.expand_path('lib/randomperson')
|
6
|
+
test_dir = File.expand_path('test')
|
7
|
+
ext_dir = File.expand_path('lib/randomperson/ext')
|
19
8
|
|
20
9
|
|
21
10
|
# desc "Run basic tests"
|
22
|
-
Rake::TestTask.new("test")
|
23
|
-
t.libs = [lib_dir, test_dir]
|
24
|
-
t.pattern = '
|
11
|
+
Rake::TestTask.new("test") do |t|
|
12
|
+
t.libs = [lib_dir, test_dir, app_dir]
|
13
|
+
t.pattern = 'test/test_*.rb'
|
25
14
|
t.verbose = true
|
26
15
|
t.warning = true
|
27
|
-
|
16
|
+
end
|
data/lib/randomperson/Choice.rb
CHANGED
@@ -2,12 +2,13 @@ module RandomPerson
|
|
2
2
|
|
3
3
|
class Choice
|
4
4
|
|
5
|
-
attr_accessor :malefirst, :femalefirst, :last, :gender_ratio, :age_lower, :age_upper, :
|
5
|
+
attr_accessor :malefirst, :femalefirst, :last, :gender_ratio, :age_lower, :age_upper, :prefix, :suffix #,:age_ratio
|
6
6
|
|
7
7
|
def available_classes
|
8
8
|
@@available_classes
|
9
9
|
end
|
10
10
|
|
11
|
+
|
11
12
|
@@available_classes = Set.new
|
12
13
|
|
13
14
|
def initialize( h={} )
|
@@ -16,6 +17,7 @@ module RandomPerson
|
|
16
17
|
@age_upper = h[:age_upper] || 100
|
17
18
|
|
18
19
|
load_names
|
20
|
+
|
19
21
|
end
|
20
22
|
|
21
23
|
def load_names( patterns=['*.rb'] )
|
@@ -84,7 +86,6 @@ module RandomPerson
|
|
84
86
|
|
85
87
|
#set the age and gender parameters for this instance to nil
|
86
88
|
def reset_parameters
|
87
|
-
@dob = nil
|
88
89
|
@age_upper = nil
|
89
90
|
@age_lower = nil
|
90
91
|
@gender_ratio = nil
|
data/lib/randomperson/ext/Set.rb
CHANGED
data/lib/randomperson.rb
CHANGED
data/randomperson.gemspec
CHANGED
@@ -1,33 +1,21 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib/', __FILE__)
|
3
|
+
$:.unshift lib unless $:.include?(lib)
|
2
4
|
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = %q{randomperson}
|
5
|
-
s.version = "0.0.9"
|
6
|
-
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["Iain Barnett"]
|
9
|
-
s.cert_chain = ["/Users/iainuser/.ssh/gem-public_cert.pem"]
|
10
|
-
s.date = %q{2010-08-26}
|
11
|
-
s.description = %q{A gem for generating random persons}
|
12
|
-
s.email = %q{iainspeed @nospam@ gmail.com}
|
13
|
-
s.extra_rdoc_files = ["CHANGELOG", "README", "lib/randomperson.rb", "lib/randomperson/Choice.rb", "lib/randomperson/Generator.rb", "lib/randomperson/Name.rb", "lib/randomperson/Names/AmericanFemaleFirst.rb", "lib/randomperson/Names/AmericanLast.rb", "lib/randomperson/Names/AmericanMaleFirst.rb", "lib/randomperson/Names/AmericanSuffix.rb", "lib/randomperson/Names/AncientGreekFemaleFirst.rb", "lib/randomperson/Names/AncientGreekLast.rb", "lib/randomperson/Names/AncientGreekMaleFirst.rb", "lib/randomperson/Names/AnyLast.rb", "lib/randomperson/Names/BasqueFemaleFirst.rb", "lib/randomperson/Names/BasqueLast.rb", "lib/randomperson/Names/BasqueMaleFirst.rb", "lib/randomperson/Names/BritishPrefix.rb", "lib/randomperson/Names/BritishSuffix.rb", "lib/randomperson/Names/EnglishFemaleFirst.rb", "lib/randomperson/Names/EnglishLast.rb", "lib/randomperson/Names/EnglishMaleFirst.rb", "lib/randomperson/Names/FrenchFemaleFirst.rb", "lib/randomperson/Names/FrenchLast.rb", "lib/randomperson/Names/FrenchMaleFirst.rb", "lib/randomperson/Names/ScottishFemaleFirst.rb", "lib/randomperson/Names/ScottishLast.rb", "lib/randomperson/Names/ScottishMaleFirst.rb", "lib/randomperson/Names/SpanishFemaleFirst.rb", "lib/randomperson/Names/SpanishLast.rb", "lib/randomperson/Names/SpanishMaleFirst.rb", "lib/randomperson/Names/SwedishFemaleFirst.rb", "lib/randomperson/Names/SwedishLast.rb", "lib/randomperson/Names/SwedishMaleFirst.rb", "lib/randomperson/Names/ThaiFemaleFirst.rb", "lib/randomperson/Names/ThaiFirst.rb", "lib/randomperson/Names/ThaiLast.rb", "lib/randomperson/Names/ThaiMaleFirst.rb", "lib/randomperson/Names/ThaiRomanisedFemaleFirst.rb", "lib/randomperson/Names/ThaiRomanisedLast.rb", "lib/randomperson/Names/ThaiRomanisedMaleFirst.rb", "lib/randomperson/Names/WelshFemaleFirst.rb", "lib/randomperson/Names/WelshLast.rb", "lib/randomperson/Names/WelshMaleFirst.rb", "lib/randomperson/Person.rb", "lib/randomperson/Ratio.rb", "lib/randomperson/ext/Array.rb", "lib/randomperson/ext/Date.rb", "lib/randomperson/ext/Enumerable.rb", "lib/randomperson/ext/Hash.rb", "lib/randomperson/ext/Kernel.rb", "lib/randomperson/ext/Set.rb"]
|
14
|
-
s.files = ["CHANGELOG", "Manifest", "README", "Rakefile", "gem-public_cert.pem", "lib/randomperson.rb", "lib/randomperson/Choice.rb", "lib/randomperson/Generator.rb", "lib/randomperson/Name.rb", "lib/randomperson/Names/AmericanFemaleFirst.rb", "lib/randomperson/Names/AmericanLast.rb", "lib/randomperson/Names/AmericanMaleFirst.rb", "lib/randomperson/Names/AmericanSuffix.rb", "lib/randomperson/Names/AncientGreekFemaleFirst.rb", "lib/randomperson/Names/AncientGreekLast.rb", "lib/randomperson/Names/AncientGreekMaleFirst.rb", "lib/randomperson/Names/AnyLast.rb", "lib/randomperson/Names/BasqueFemaleFirst.rb", "lib/randomperson/Names/BasqueLast.rb", "lib/randomperson/Names/BasqueMaleFirst.rb", "lib/randomperson/Names/BritishPrefix.rb", "lib/randomperson/Names/BritishSuffix.rb", "lib/randomperson/Names/EnglishFemaleFirst.rb", "lib/randomperson/Names/EnglishLast.rb", "lib/randomperson/Names/EnglishMaleFirst.rb", "lib/randomperson/Names/FrenchFemaleFirst.rb", "lib/randomperson/Names/FrenchLast.rb", "lib/randomperson/Names/FrenchMaleFirst.rb", "lib/randomperson/Names/ScottishFemaleFirst.rb", "lib/randomperson/Names/ScottishLast.rb", "lib/randomperson/Names/ScottishMaleFirst.rb", "lib/randomperson/Names/SpanishFemaleFirst.rb", "lib/randomperson/Names/SpanishLast.rb", "lib/randomperson/Names/SpanishMaleFirst.rb", "lib/randomperson/Names/SwedishFemaleFirst.rb", "lib/randomperson/Names/SwedishLast.rb", "lib/randomperson/Names/SwedishMaleFirst.rb", "lib/randomperson/Names/ThaiFemaleFirst.rb", "lib/randomperson/Names/ThaiFirst.rb", "lib/randomperson/Names/ThaiLast.rb", "lib/randomperson/Names/ThaiMaleFirst.rb", "lib/randomperson/Names/ThaiRomanisedFemaleFirst.rb", "lib/randomperson/Names/ThaiRomanisedLast.rb", "lib/randomperson/Names/ThaiRomanisedMaleFirst.rb", "lib/randomperson/Names/WelshFemaleFirst.rb", "lib/randomperson/Names/WelshLast.rb", "lib/randomperson/Names/WelshMaleFirst.rb", "lib/randomperson/Person.rb", "lib/randomperson/Ratio.rb", "lib/randomperson/ext/Array.rb", "lib/randomperson/ext/Date.rb", "lib/randomperson/ext/Enumerable.rb", "lib/randomperson/ext/Hash.rb", "lib/randomperson/ext/Kernel.rb", "lib/randomperson/ext/Set.rb", "t/Generator.t", "randomperson.gemspec"]
|
15
|
-
s.homepage = %q{http://github.com/yb66/RandomPerson}
|
16
|
-
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Randomperson", "--main", "README"]
|
17
|
-
s.require_paths = ["lib"]
|
18
|
-
s.required_ruby_version = Gem::Requirement.new(">= 1.9.1")
|
19
|
-
s.rubyforge_project = %q{randomperson}
|
20
|
-
s.rubygems_version = %q{1.3.7}
|
21
|
-
s.signing_key = %q{/Users/iainuser/.ssh/gem-private_key.pem}
|
22
|
-
s.summary = %q{A gem for generating random persons}
|
23
5
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "randomperson"
|
8
|
+
s.summary = "A gem for generating random persons :)"
|
9
|
+
s.version = "0.0.10"
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.require_paths << 'ext'
|
12
|
+
s.required_ruby_version = ">= 1.9.1"
|
13
|
+
s.author = "Iain Barnett"
|
14
|
+
s.files = ['Rakefile', 'randomperson.gemspec']
|
15
|
+
s.files += Dir['lib/**/*.rb']
|
16
|
+
s.homepage = "http://github.com/yb66/RandomPerson"
|
17
|
+
s.email = "iainspeed @nospam@ gmail.com"
|
18
|
+
s.test_files = Dir.glob('test/*.t')
|
19
|
+
s.signing_key = ENV['HOME'] + '/.ssh/gem-private_key.pem'
|
20
|
+
s.cert_chain = [ENV['HOME'] + '/.ssh/gem-public_cert.pem']
|
33
21
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 10
|
9
|
+
version: 0.0.10
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Iain Barnett
|
@@ -35,77 +35,28 @@ cert_chain:
|
|
35
35
|
YK13fiGcldY=
|
36
36
|
-----END CERTIFICATE-----
|
37
37
|
|
38
|
-
date: 2010-
|
38
|
+
date: 2010-09-28 00:00:00 +01:00
|
39
39
|
default_executable:
|
40
40
|
dependencies: []
|
41
41
|
|
42
|
-
description:
|
42
|
+
description:
|
43
43
|
email: iainspeed @nospam@ gmail.com
|
44
44
|
executables: []
|
45
45
|
|
46
46
|
extensions: []
|
47
47
|
|
48
|
-
extra_rdoc_files:
|
49
|
-
|
50
|
-
|
51
|
-
-
|
48
|
+
extra_rdoc_files: []
|
49
|
+
|
50
|
+
files:
|
51
|
+
- Rakefile
|
52
|
+
- randomperson.gemspec
|
52
53
|
- lib/randomperson/Choice.rb
|
53
|
-
- lib/randomperson/Generator.rb
|
54
|
-
- lib/randomperson/Name.rb
|
55
|
-
- lib/randomperson/Names/AmericanFemaleFirst.rb
|
56
|
-
- lib/randomperson/Names/AmericanLast.rb
|
57
|
-
- lib/randomperson/Names/AmericanMaleFirst.rb
|
58
|
-
- lib/randomperson/Names/AmericanSuffix.rb
|
59
|
-
- lib/randomperson/Names/AncientGreekFemaleFirst.rb
|
60
|
-
- lib/randomperson/Names/AncientGreekLast.rb
|
61
|
-
- lib/randomperson/Names/AncientGreekMaleFirst.rb
|
62
|
-
- lib/randomperson/Names/AnyLast.rb
|
63
|
-
- lib/randomperson/Names/BasqueFemaleFirst.rb
|
64
|
-
- lib/randomperson/Names/BasqueLast.rb
|
65
|
-
- lib/randomperson/Names/BasqueMaleFirst.rb
|
66
|
-
- lib/randomperson/Names/BritishPrefix.rb
|
67
|
-
- lib/randomperson/Names/BritishSuffix.rb
|
68
|
-
- lib/randomperson/Names/EnglishFemaleFirst.rb
|
69
|
-
- lib/randomperson/Names/EnglishLast.rb
|
70
|
-
- lib/randomperson/Names/EnglishMaleFirst.rb
|
71
|
-
- lib/randomperson/Names/FrenchFemaleFirst.rb
|
72
|
-
- lib/randomperson/Names/FrenchLast.rb
|
73
|
-
- lib/randomperson/Names/FrenchMaleFirst.rb
|
74
|
-
- lib/randomperson/Names/ScottishFemaleFirst.rb
|
75
|
-
- lib/randomperson/Names/ScottishLast.rb
|
76
|
-
- lib/randomperson/Names/ScottishMaleFirst.rb
|
77
|
-
- lib/randomperson/Names/SpanishFemaleFirst.rb
|
78
|
-
- lib/randomperson/Names/SpanishLast.rb
|
79
|
-
- lib/randomperson/Names/SpanishMaleFirst.rb
|
80
|
-
- lib/randomperson/Names/SwedishFemaleFirst.rb
|
81
|
-
- lib/randomperson/Names/SwedishLast.rb
|
82
|
-
- lib/randomperson/Names/SwedishMaleFirst.rb
|
83
|
-
- lib/randomperson/Names/ThaiFemaleFirst.rb
|
84
|
-
- lib/randomperson/Names/ThaiFirst.rb
|
85
|
-
- lib/randomperson/Names/ThaiLast.rb
|
86
|
-
- lib/randomperson/Names/ThaiMaleFirst.rb
|
87
|
-
- lib/randomperson/Names/ThaiRomanisedFemaleFirst.rb
|
88
|
-
- lib/randomperson/Names/ThaiRomanisedLast.rb
|
89
|
-
- lib/randomperson/Names/ThaiRomanisedMaleFirst.rb
|
90
|
-
- lib/randomperson/Names/WelshFemaleFirst.rb
|
91
|
-
- lib/randomperson/Names/WelshLast.rb
|
92
|
-
- lib/randomperson/Names/WelshMaleFirst.rb
|
93
|
-
- lib/randomperson/Person.rb
|
94
|
-
- lib/randomperson/Ratio.rb
|
95
54
|
- lib/randomperson/ext/Array.rb
|
96
55
|
- lib/randomperson/ext/Date.rb
|
97
56
|
- lib/randomperson/ext/Enumerable.rb
|
98
57
|
- lib/randomperson/ext/Hash.rb
|
99
58
|
- lib/randomperson/ext/Kernel.rb
|
100
59
|
- lib/randomperson/ext/Set.rb
|
101
|
-
files:
|
102
|
-
- CHANGELOG
|
103
|
-
- Manifest
|
104
|
-
- README
|
105
|
-
- Rakefile
|
106
|
-
- gem-public_cert.pem
|
107
|
-
- lib/randomperson.rb
|
108
|
-
- lib/randomperson/Choice.rb
|
109
60
|
- lib/randomperson/Generator.rb
|
110
61
|
- lib/randomperson/Name.rb
|
111
62
|
- lib/randomperson/Names/AmericanFemaleFirst.rb
|
@@ -148,28 +99,17 @@ files:
|
|
148
99
|
- lib/randomperson/Names/WelshMaleFirst.rb
|
149
100
|
- lib/randomperson/Person.rb
|
150
101
|
- lib/randomperson/Ratio.rb
|
151
|
-
- lib/randomperson
|
152
|
-
- lib/randomperson/ext/Date.rb
|
153
|
-
- lib/randomperson/ext/Enumerable.rb
|
154
|
-
- lib/randomperson/ext/Hash.rb
|
155
|
-
- lib/randomperson/ext/Kernel.rb
|
156
|
-
- lib/randomperson/ext/Set.rb
|
157
|
-
- t/Generator.t
|
158
|
-
- randomperson.gemspec
|
102
|
+
- lib/randomperson.rb
|
159
103
|
has_rdoc: true
|
160
104
|
homepage: http://github.com/yb66/RandomPerson
|
161
105
|
licenses: []
|
162
106
|
|
163
107
|
post_install_message:
|
164
|
-
rdoc_options:
|
165
|
-
|
166
|
-
- --inline-source
|
167
|
-
- --title
|
168
|
-
- Randomperson
|
169
|
-
- --main
|
170
|
-
- README
|
108
|
+
rdoc_options: []
|
109
|
+
|
171
110
|
require_paths:
|
172
111
|
- lib
|
112
|
+
- ext
|
173
113
|
required_ruby_version: !ruby/object:Gem::Requirement
|
174
114
|
none: false
|
175
115
|
requirements:
|
@@ -186,15 +126,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
126
|
- - ">="
|
187
127
|
- !ruby/object:Gem::Version
|
188
128
|
segments:
|
189
|
-
-
|
190
|
-
|
191
|
-
version: "1.2"
|
129
|
+
- 0
|
130
|
+
version: "0"
|
192
131
|
requirements: []
|
193
132
|
|
194
|
-
rubyforge_project:
|
133
|
+
rubyforge_project:
|
195
134
|
rubygems_version: 1.3.7
|
196
135
|
signing_key:
|
197
136
|
specification_version: 3
|
198
|
-
summary: A gem for generating random persons
|
137
|
+
summary: A gem for generating random persons :)
|
199
138
|
test_files: []
|
200
139
|
|
metadata.gz.sig
CHANGED
Binary file
|
data/CHANGELOG
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
v0.0.9 Added particle formats for French last names.
|
2
|
-
|
3
|
-
v0.0.8 Added French names. Added Thai script names, unfortunately the last names are places as couldn't get a proper list. Added a negation for the add_ method, see README
|
4
|
-
|
5
|
-
v0.0.7 All Basque names added.
|
6
|
-
|
7
|
-
v0.0.6 Added ancient Greek names. Improved default method call for formats.
|
8
|
-
|
9
|
-
v0.0.5 Moved into new dir structure to avoid filename collisions in LOAD_PATH. Greatly improved American names.
|
10
|
-
|
11
|
-
v0.0.4 Removed shebangs and requires that were causing warnings. Added reset methods to Choice.
|
12
|
-
|
13
|
-
v0.0.3. Fixed some silly bugs within NameFiles
|
14
|
-
|
15
|
-
v0.0.2. Added support for Welsh, Scottish and Swedish names
|
data/Manifest
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
CHANGELOG
|
2
|
-
Manifest
|
3
|
-
README
|
4
|
-
Rakefile
|
5
|
-
gem-public_cert.pem
|
6
|
-
lib/randomperson.rb
|
7
|
-
lib/randomperson/Choice.rb
|
8
|
-
lib/randomperson/Generator.rb
|
9
|
-
lib/randomperson/Name.rb
|
10
|
-
lib/randomperson/Names/AmericanFemaleFirst.rb
|
11
|
-
lib/randomperson/Names/AmericanLast.rb
|
12
|
-
lib/randomperson/Names/AmericanMaleFirst.rb
|
13
|
-
lib/randomperson/Names/AmericanSuffix.rb
|
14
|
-
lib/randomperson/Names/AncientGreekFemaleFirst.rb
|
15
|
-
lib/randomperson/Names/AncientGreekLast.rb
|
16
|
-
lib/randomperson/Names/AncientGreekMaleFirst.rb
|
17
|
-
lib/randomperson/Names/AnyLast.rb
|
18
|
-
lib/randomperson/Names/BasqueFemaleFirst.rb
|
19
|
-
lib/randomperson/Names/BasqueLast.rb
|
20
|
-
lib/randomperson/Names/BasqueMaleFirst.rb
|
21
|
-
lib/randomperson/Names/BritishPrefix.rb
|
22
|
-
lib/randomperson/Names/BritishSuffix.rb
|
23
|
-
lib/randomperson/Names/EnglishFemaleFirst.rb
|
24
|
-
lib/randomperson/Names/EnglishLast.rb
|
25
|
-
lib/randomperson/Names/EnglishMaleFirst.rb
|
26
|
-
lib/randomperson/Names/FrenchFemaleFirst.rb
|
27
|
-
lib/randomperson/Names/FrenchLast.rb
|
28
|
-
lib/randomperson/Names/FrenchMaleFirst.rb
|
29
|
-
lib/randomperson/Names/ScottishFemaleFirst.rb
|
30
|
-
lib/randomperson/Names/ScottishLast.rb
|
31
|
-
lib/randomperson/Names/ScottishMaleFirst.rb
|
32
|
-
lib/randomperson/Names/SpanishFemaleFirst.rb
|
33
|
-
lib/randomperson/Names/SpanishLast.rb
|
34
|
-
lib/randomperson/Names/SpanishMaleFirst.rb
|
35
|
-
lib/randomperson/Names/SwedishFemaleFirst.rb
|
36
|
-
lib/randomperson/Names/SwedishLast.rb
|
37
|
-
lib/randomperson/Names/SwedishMaleFirst.rb
|
38
|
-
lib/randomperson/Names/ThaiFemaleFirst.rb
|
39
|
-
lib/randomperson/Names/ThaiFirst.rb
|
40
|
-
lib/randomperson/Names/ThaiLast.rb
|
41
|
-
lib/randomperson/Names/ThaiMaleFirst.rb
|
42
|
-
lib/randomperson/Names/ThaiRomanisedFemaleFirst.rb
|
43
|
-
lib/randomperson/Names/ThaiRomanisedLast.rb
|
44
|
-
lib/randomperson/Names/ThaiRomanisedMaleFirst.rb
|
45
|
-
lib/randomperson/Names/WelshFemaleFirst.rb
|
46
|
-
lib/randomperson/Names/WelshLast.rb
|
47
|
-
lib/randomperson/Names/WelshMaleFirst.rb
|
48
|
-
lib/randomperson/Person.rb
|
49
|
-
lib/randomperson/Ratio.rb
|
50
|
-
lib/randomperson/ext/Array.rb
|
51
|
-
lib/randomperson/ext/Date.rb
|
52
|
-
lib/randomperson/ext/Enumerable.rb
|
53
|
-
lib/randomperson/ext/Hash.rb
|
54
|
-
lib/randomperson/ext/Kernel.rb
|
55
|
-
lib/randomperson/ext/Set.rb
|
56
|
-
t/Generator.t
|
data/README
DELETED
@@ -1,264 +0,0 @@
|
|
1
|
-
=RandomPerson
|
2
|
-
|
3
|
-
A port to Ruby of Perl's Data::RandomPerson.
|
4
|
-
|
5
|
-
http://search.cpan.org/~peterhi/Data-RandomPerson-0.4/
|
6
|
-
|
7
|
-
Initially just the Names portion. In fact, probably just that. I'm not a masochist. Well, just a bit.
|
8
|
-
|
9
|
-
==Why did I write this?
|
10
|
-
|
11
|
-
Because the Faker library and a few of the other random ones are very good, but they don't have the precision I needed. I wanted believable male names between a certain age range for a football game I was writing. Producing names like Mrs Albert Wiggins wasn't really going to cut it.
|
12
|
-
|
13
|
-
And I'm a masochist.
|
14
|
-
|
15
|
-
It also has unicode characters, so it'll give your database a real test.
|
16
|
-
|
17
|
-
|
18
|
-
==Installation:
|
19
|
-
|
20
|
-
You'll need at least Ruby v1.9.1
|
21
|
-
|
22
|
-
Get the public key from http://github.com/yb66/RandomPerson/blob/master/gem-public_cert.pem and do:
|
23
|
-
|
24
|
-
gem cert --add /path/to/public_cert.pem
|
25
|
-
|
26
|
-
then install it:
|
27
|
-
|
28
|
-
gem install randomperson -P HighSecurity
|
29
|
-
|
30
|
-
|
31
|
-
==USAGE (STOP SHOUTING!):
|
32
|
-
|
33
|
-
So, to generate 1000 random people with Spanish names, between the ages of 16 and 35 with a ratio of 3 males to every 5 females:
|
34
|
-
|
35
|
-
require 'randomperson'
|
36
|
-
|
37
|
-
choice = RandomPerson::Choice.new( {gender_ratio: [3,5] , age_lower:16, age_upper:35 } )
|
38
|
-
|
39
|
-
choice.add_Spanish
|
40
|
-
|
41
|
-
g = RandomPerson::Generator.new
|
42
|
-
|
43
|
-
g.make_generator choice
|
44
|
-
|
45
|
-
people = [ ]
|
46
|
-
|
47
|
-
1000.times { people << g.generators[0].call }
|
48
|
-
|
49
|
-
10.times { |i| puts "#{people[i].first} #{people[i].last} age: #{people[i].age} born: #{people[i].dob.strftime("%d-%b-%Y")}" }
|
50
|
-
|
51
|
-
Bartolomé Andrés de Elixaeberna age: 20 born: 28-Apr-1990
|
52
|
-
Fabiana Cordero Balmaceda age: 21 born: 14-Jun-1989
|
53
|
-
Jorge Alas Albarracin age: 29 born: 16-Apr-1981
|
54
|
-
Eufemia Berlanga de Sergi age: 33 born: 25-Jan-1977
|
55
|
-
David Puig Villaroel age: 19 born: 17-Apr-1991
|
56
|
-
Alba Henchoz de Hurtado age: 30 born: 14-Feb-1980
|
57
|
-
Natalia Jara de Guevara age: 33 born: 28-Jul-1977
|
58
|
-
Tito Cresaco Campo age: 20 born: 14-Feb-1990
|
59
|
-
Susana Pitillas de Vaime age: 32 born: 12-Aug-1978
|
60
|
-
Gustavo Hierro Carbajal y Plazas age: 31 born: 08-Feb-1979
|
61
|
-
|
62
|
-
Here's an example using the Thai Romanised data:
|
63
|
-
|
64
|
-
choice = RandomPerson::Choice.new
|
65
|
-
choice.add_Thai_Romanised
|
66
|
-
g = RandomPerson::Generator.new
|
67
|
-
g.make_generator choice
|
68
|
-
people = [ ]
|
69
|
-
10.times { people << g.generators[0].call }
|
70
|
-
10.times { |i| puts "#{people[i].first} #{people[i].last} age: #{people[i].age} born: #{people[i].dob.strftime("%d-%b-%Y")}" }
|
71
|
-
|
72
|
-
Yongchaiyuth Sripituksakul Puntasrima age: 39 born: 29-Mar-1971
|
73
|
-
Sri-Patana Wattanasin age: 77 born: 04-Feb-1933
|
74
|
-
Wattana Rojjanasukchai age: 7 born: 27-Jun-2003
|
75
|
-
Ban Sukbunsung age: 85 born: 07-Sep-1925
|
76
|
-
Daeng Prasongsanti age: 65 born: 27-Mar-1945
|
77
|
-
Proi Paowsong Sriwarunyu age: 60 born: 06-May-1950
|
78
|
-
Ban Yongjaiyut age: 4 born: 06-Nov-2006
|
79
|
-
Siam Narkhirunkanok age: 15 born: 12-Aug-1995
|
80
|
-
Tong Punyawong Kadesadayurat age: 64 born: 01-Sep-1946
|
81
|
-
Sarai Wattanapanit Maneerattana age: 44 born: 21-Dec-1966
|
82
|
-
|
83
|
-
==CHOICE
|
84
|
-
|
85
|
-
The choice class sets the parameters that will be used to generate people.
|
86
|
-
|
87
|
-
choice = RandomPerson::Choice.new
|
88
|
-
|
89
|
-
is the same as
|
90
|
-
|
91
|
-
choice = RandomPerson::Choice.new( gender_ratio:[1,1] , age_lower: 0, age_upper: 100 )
|
92
|
-
|
93
|
-
So you'd end up with a population of roughly 50:50 male/female with ages from 0 to 100 years.
|
94
|
-
|
95
|
-
==LOADING NAMEFILES
|
96
|
-
|
97
|
-
choice.add_Spanish_Female would just load the SpanishFemaleFirst into choice.female
|
98
|
-
|
99
|
-
choice.add_Spanish would load:
|
100
|
-
SpanishFemaleFirst into choice.female
|
101
|
-
SpanishMaleFirst into choice.male
|
102
|
-
SpanishLast into choice.last
|
103
|
-
etc etc
|
104
|
-
|
105
|
-
or you can do things the old fashioned way
|
106
|
-
|
107
|
-
require 'namefiles/spanishfemalefirst' #obviously you need to use the path from where you are or where the script will run from
|
108
|
-
|
109
|
-
choice.female = RandomPerson::SpanishFemaleFirst.new
|
110
|
-
|
111
|
-
The rule is, put_underscores_between_the_important_words
|
112
|
-
|
113
|
-
_and_
|
114
|
-
|
115
|
-
always begin with *add_*
|
116
|
-
|
117
|
-
_and_
|
118
|
-
|
119
|
-
make sure each word is capitalised, add_male will actually pick up Fe_male_ whereas Female and Male will get what you want.
|
120
|
-
|
121
|
-
If you want EnglishLast names loaded:
|
122
|
-
|
123
|
-
choice.add_English_Last
|
124
|
-
|
125
|
-
All English files:
|
126
|
-
|
127
|
-
choice.add_English
|
128
|
-
|
129
|
-
English males:
|
130
|
-
|
131
|
-
choice.add_English_Male
|
132
|
-
|
133
|
-
|
134
|
-
Do you see how this is working? If you need to check what's loaded, have a look in the instance variables of choice (or whatever you named your Choice instance):
|
135
|
-
|
136
|
-
choice.male
|
137
|
-
choice.female
|
138
|
-
choice.last
|
139
|
-
choice.prefix
|
140
|
-
choice.suffix
|
141
|
-
|
142
|
-
==NEGATIONS
|
143
|
-
|
144
|
-
Sometimes you'll want to load something but not another, you can do this by prepending _not_ to the things you don't want. For example, to get the Thai names that are in Thai script and not romanised:
|
145
|
-
|
146
|
-
choice = RandomPerson::Choice.new
|
147
|
-
choice.add_Thai_notRomanised
|
148
|
-
|
149
|
-
or
|
150
|
-
|
151
|
-
choice.add_Thai_notRomanised_notFemale
|
152
|
-
|
153
|
-
to also get rid of the female names.
|
154
|
-
|
155
|
-
This is an experimental thing. Seems to work, but may change. You cannot do this (at the moment)
|
156
|
-
|
157
|
-
choice.notRomanised_add_Thai
|
158
|
-
|
159
|
-
*Always begin with add_*
|
160
|
-
|
161
|
-
==RATIOS VS ODDS
|
162
|
-
|
163
|
-
The default gender ratio is 1:1. The male part is the left side (or Array#first), the female is the right side (or Array#last). All ratios are given as an array i.e. [1,1] or [3,2]
|
164
|
-
|
165
|
-
A ratio of 1:1 will not necessarily give you a population with exactly half male, half female. The ratio is the odds of getting that. So a ratio of [1,3] will give a 25% chance of producing a male and a 75% chance of being a female.
|
166
|
-
|
167
|
-
If you wish to have an exact ratio within the population then create two choices each with a 0% chance of producing the other. For example:
|
168
|
-
|
169
|
-
men = RandomPerson::Choice.new( gender_ratio:[1,0] )
|
170
|
-
women = RandomPerson::Choice.new( gender_ratio:[0,1] )
|
171
|
-
...more code here...
|
172
|
-
g.make_generator men # pushes the generator onto @generators in 0 position
|
173
|
-
g.make_generator women # pushes the generator onto @generators in 1 position
|
174
|
-
25.times { people << g.generators[0].call }
|
175
|
-
75.times { people << g.generators[1].call }
|
176
|
-
|
177
|
-
This would give you a population of 25 males and 75 females. Which sounds great unless you really think about it.
|
178
|
-
|
179
|
-
==FORMATTING
|
180
|
-
|
181
|
-
Each culture has it's own conventions around names. This makes sticking some monolithic algorithm in the centre of the code to sort out how names should be displayed impossible, so each data file describes how it thinks the names should be formatted.
|
182
|
-
|
183
|
-
For example, in the EnglishLast.rb file:
|
184
|
-
|
185
|
-
@formats = {
|
186
|
-
:single => ->(n) { n.rand },
|
187
|
-
:double_barrelled_hyphenated=> ->(n) { n.rand + '-' + n.rand },
|
188
|
-
}
|
189
|
-
|
190
|
-
This tells us that there are two ways of formatting last names defined in the file. All formats are described as lambda functions in a hash, the key being a description of what it's trying to achieve.
|
191
|
-
|
192
|
-
==BIT MORE ON RATIOS
|
193
|
-
|
194
|
-
Behind the scenes, ratios like this [1,3] are converted to an array of ranges like this [0..24, 25..99], called ratiod. Just so you know for this next bit.
|
195
|
-
|
196
|
-
In the EnglishLast.rb file:
|
197
|
-
@formats_ratiod = [ (0..96), (97..99) ]
|
198
|
-
|
199
|
-
This says that the chances of a name being single barrelled is 97%, and double barrelled is 3%. I made up those figures from my own experience, but if you disagree with either the ratios or the formatting then you can change it. Either directly in the file or while running the code. It's your choice. Just make sure the numbers are right, length of arrays should be the same ( e.g. four formatting options should have a ratio with four parts like [a,b,c,d]) or it will break.
|
200
|
-
|
201
|
-
==PREFIXES AND SUFFIXES
|
202
|
-
|
203
|
-
Each generator starts by producing a person with a gender, an age and a date of birth. These are then passed on to the subsequent name portions so that a male always gets a male name and a male prefix (if you've specified a prefix file).
|
204
|
-
|
205
|
-
Suffix files will also (I hope) do a bit of checking at what's already been set, so you won't get Dr. Bobby Horliton PhD, as it should be either Dr. or PhD (apparently). Stuff like that should get caught.
|
206
|
-
|
207
|
-
==ADDING YOUR OWN NAMEFILES
|
208
|
-
|
209
|
-
My suggestion is to find the type of name that is closest (if you're looking for Spanishy names then look at the Spanish files as they'll have similar formatting rules there for free...) and copy and paste it in to a new one. It's easier that way.
|
210
|
-
|
211
|
-
==ACCURACY OF NAMES AND RATIOS
|
212
|
-
|
213
|
-
I've taken bits and pieces from wherever I could get them, so if you see something is wrong then either let me know or produce a patch. I've no idea what the process is for that on GitHub but I'm sure there's a tutorial if you look for it. I'll also add you name to this readme, and worldly fame will be yours.
|
214
|
-
|
215
|
-
==TODO:
|
216
|
-
|
217
|
-
There's lots to do. Lot of repetition and ugly bits here and there, but it works so I'll get round to it when I can.
|
218
|
-
|
219
|
-
==THANKS GO TO
|
220
|
-
|
221
|
-
Peter Hickman for writing the original library in Perl that inspired this on in Ruby.
|
222
|
-
|
223
|
-
My good friend Johan Bergsten for helping me out with the Swedish names.
|
224
|
-
|
225
|
-
==THE END UNLESS YOU WANT TO READ THE LICENCE
|
226
|
-
|
227
|
-
*Iain Barnett*
|
228
|
-
|
229
|
-
==LICENCE:
|
230
|
-
|
231
|
-
It's an MIT Licence, I didn't take any code from the Perl one just names and a slight idea on how to structure things, so this ain't gonna be under the GPL. MIT is better anyway ;)
|
232
|
-
|
233
|
-
Copyright (c) 2010 Iain Barnett
|
234
|
-
|
235
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
236
|
-
of this software and associated documentation files (the "Software"), to deal
|
237
|
-
in the Software without restriction, including without limitation the rights
|
238
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
239
|
-
copies of the Software, and to permit persons to whom the Software is
|
240
|
-
furnished to do so, subject to the following conditions:
|
241
|
-
|
242
|
-
The above copyright notice and this permission notice shall be included in
|
243
|
-
all copies or substantial portions of the Software.
|
244
|
-
|
245
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
246
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
247
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
248
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
249
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
250
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
251
|
-
THE SOFTWARE.
|
252
|
-
|
253
|
-
In other words, be good.
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
data/gem-public_cert.pem
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
-----BEGIN CERTIFICATE-----
|
2
|
-
MIIDNDCCAhygAwIBAgIBADANBgkqhkiG9w0BAQUFADBAMRIwEAYDVQQDDAlpYWlu
|
3
|
-
c3BlZWQxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
|
4
|
-
bTAeFw0xMDA4MTkyMTQwMDlaFw0xMTA4MTkyMTQwMDlaMEAxEjAQBgNVBAMMCWlh
|
5
|
-
aW5zcGVlZDEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYD
|
6
|
-
Y29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApraebFPxvJVrayuZ
|
7
|
-
xJkFZLAId7j0G3QG4oyJcRaJVhaJ36zcCUeg6/6f9LC78nZSmL2zA2ZG9H3Lzda0
|
8
|
-
0j+McpynbK/eSq0XpruQbuuhcOBow1KgDfjdhz3qXylHJ/iIzBosQzoEIk5eVY84
|
9
|
-
R0qD+vNHwZQoDE+k4PB8LWIfbJPi+dmnL16C0qireO3nZASwTSGm1JdUtgESP0Hn
|
10
|
-
f1KAe/ox00S8cSQNGUZ/fAsrnhAOApL9V38TwxiL0eMVcY+TbUspI26MB8oNwsgV
|
11
|
-
zkBNt2lI45/SguV5wWMOWbWZ2v//w3PrBCUenkk+vwZmpOQUlk/8Ebrk+UeoAN1F
|
12
|
-
NqE2DQIDAQABozkwNzAJBgNVHRMEAjAAMB0GA1UdDgQWBBTMWVuCrozPKTpMRYkm
|
13
|
-
RUAqQFsGdDALBgNVHQ8EBAMCBLAwDQYJKoZIhvcNAQEFBQADggEBAFqZW23axU5A
|
14
|
-
Hf/p5iBfRlJLIZqFmVbGb1A+mxaPFUkhERH7FfY4ay4p2Ci1DNhSYQLy5dsB1ik0
|
15
|
-
J0tlNaXxkJ0uq6up65yoj4/XBJArm9oiO7PcwrzC52bmiEv4Ir67/AGRyfmgIU0A
|
16
|
-
5jv3cSFcnbrwCvClZOoVhNkvaxer3/DgLecpjgXfSwY++JHU0L/5HplidHzjE3PZ
|
17
|
-
1YGYQYJGIy5Hap8Lpn1x9/Q2C8pMX33JRItrIVie6UIsrGXVtGS5lZS/pri9Budd
|
18
|
-
+ikjZ+dLa/HjsXQ5HcI6WdySxyKElXr2Ecs8ipmnxCk6+KH9/2OnXrpBzeIXJoMS
|
19
|
-
YK13fiGcldY=
|
20
|
-
-----END CERTIFICATE-----
|
data/t/Generator.t
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby -wKU
|
2
|
-
|
3
|
-
# require
|
4
|
-
# require 'choice'
|
5
|
-
require 'test/unit'
|
6
|
-
require 'generator'
|
7
|
-
# require 'choice'
|
8
|
-
|
9
|
-
class TestTask < Test::Unit::TestCase
|
10
|
-
|
11
|
-
# def setup
|
12
|
-
# g = RandomPerson::Generator.new
|
13
|
-
# end
|
14
|
-
|
15
|
-
# def teardown
|
16
|
-
# end
|
17
|
-
|
18
|
-
# def test_load_names
|
19
|
-
# # assert_equal(@task1.from, 'iain')
|
20
|
-
# # assert_kind_of(@task1.added, Time)
|
21
|
-
# assert_equal
|
22
|
-
# end
|
23
|
-
|
24
|
-
# def test_ratiod
|
25
|
-
# assert_kind_of( RandomPerson::Generator.ratiod( [1,1] ), Array )
|
26
|
-
# assert_kind_of( RandomPerson::Generator.ratiod([1,1]).first, Range )
|
27
|
-
# assert_equal( RandomPerson::Generator.ratiod([1,3]).first.end, 25 )
|
28
|
-
# end
|
29
|
-
|
30
|
-
def test_pick_gender
|
31
|
-
assert_not_nil RandomPerson::Generator.pick_gender()
|
32
|
-
assert_equal( RandomPerson::Generator.pick_gender([1,0]), 'm' )
|
33
|
-
assert_equal( RandomPerson::Generator.pick_gender([0,1]), 'f' )
|
34
|
-
|
35
|
-
assert_equal( RandomPerson::Generator.pick_gender([10,0]), 'm' )
|
36
|
-
assert_equal( RandomPerson::Generator.pick_gender([0,10]), 'f' )
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_reset
|
40
|
-
# choice = RandomPerson::Choice.new
|
41
|
-
# choice2 = RandomPerson::Choice.new
|
42
|
-
g = RandomPerson::Generator.new
|
43
|
-
# g.make_generator choice
|
44
|
-
# g.make_generator choice2
|
45
|
-
# assert_equal( 2, g.generators.length )
|
46
|
-
# g.reset
|
47
|
-
# assert_equal( 2, g.generators.length )
|
48
|
-
# assert( g.generators.empty? )
|
49
|
-
end
|
50
|
-
|
51
|
-
# def test_pick_age
|
52
|
-
# n = 1000
|
53
|
-
# while n > 0
|
54
|
-
# r1 = rand(100)
|
55
|
-
# r2 = rand(100) + r1
|
56
|
-
# age = RandomPerson::Generator.pick_age(r1, r2)
|
57
|
-
# assert_not_nil( age )
|
58
|
-
# assert( r1..r2, age )
|
59
|
-
# n = n - 1
|
60
|
-
# end
|
61
|
-
# end
|
62
|
-
|
63
|
-
def test_pick_dob
|
64
|
-
assert(true)
|
65
|
-
end
|
66
|
-
# n = 1000
|
67
|
-
# while n > 0
|
68
|
-
# r1 = rand(100)
|
69
|
-
# dob = RandomPerson::Generator.pick_dob(r1)
|
70
|
-
# # assert_kind_of(dob, Time)
|
71
|
-
# # assert_not_nil( dob )
|
72
|
-
# # assert_equal( dob.year, Time.now.year - r1 )
|
73
|
-
# n = n - 1
|
74
|
-
# end
|
75
|
-
# end
|
76
|
-
|
77
|
-
# def test_read_initialvalues_failure
|
78
|
-
# # assert_not_equal(@task1.from , "jane")
|
79
|
-
# # assert_not_nil(@task2.unique_id)
|
80
|
-
# end
|
81
|
-
|
82
|
-
end
|