randomperson 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.rspec +1 -1
- data/.travis.yml +1 -2
- data/CHANGELOG.md +16 -0
- data/Gemfile +13 -0
- data/LICENCE +19 -0
- data/README.markdown +4 -22
- data/Rakefile +1 -1
- data/lib/randomperson.rb +35 -14
- data/lib/randomperson/demographic.rb +38 -29
- data/lib/randomperson/generator.rb +10 -4
- data/lib/randomperson/loader.rb +24 -12
- data/lib/randomperson/name.rb +1 -1
- data/lib/randomperson/outputter.rb +36 -5
- data/lib/randomperson/ratio.rb +7 -2
- data/lib/randomperson/version.rb +4 -1
- data/randomperson.gemspec +2 -7
- data/spec/last_and_first_names_spec.rb +19 -8
- data/spec/randomperson_spec.rb +151 -178
- data/spec/spec_helper.rb +11 -2
- data/spec/support/shared_examples/names.rb +2 -2
- metadata +17 -122
- data/lib/randomperson/ext/date.rb +0 -16
- data/lib/randomperson/ext/hash.rb +0 -6
- data/lib/randomperson/ext/kernel.rb +0 -21
- data/lib/randomperson/ext/set.rb +0 -15
- data/lib/randomperson/ext/string.rb +0 -0
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
require "rspec"
|
4
|
+
require "rspec/its"
|
5
|
+
require "rspec-given"
|
6
|
+
|
4
7
|
Spec_dir = File.expand_path( File.dirname __FILE__ )
|
5
8
|
|
6
9
|
unless Kernel.respond_to?(:require_relative)
|
@@ -16,11 +19,17 @@ SimpleCov.start do
|
|
16
19
|
add_filter "/vendor/"
|
17
20
|
add_filter "/bin/"
|
18
21
|
add_filter "/spec/"
|
22
|
+
add_filter "/vendor.noindex/"
|
23
|
+
end
|
24
|
+
|
25
|
+
if ENV["DEBUG"]
|
26
|
+
require 'pry-byebug'
|
27
|
+
binding.pry
|
19
28
|
end
|
20
29
|
|
21
30
|
|
22
|
-
RSpec.configure do |
|
23
|
-
c.
|
31
|
+
RSpec.configure do |config|
|
32
|
+
config.expect_with(:rspec) { |c| c.syntax = [:should,:expect] }
|
24
33
|
end
|
25
34
|
|
26
35
|
Dir[ File.join( Spec_dir, "/support/**/*.rb")].each {|f| require f}
|
@@ -40,7 +40,7 @@ shared_examples "a Name class", :parent => "Name" do
|
|
40
40
|
it { should respond_to( :formats_ratiod ) }
|
41
41
|
it { should respond_to(:names)}
|
42
42
|
it { should respond_to(:possibles)}
|
43
|
-
specify { subject.
|
43
|
+
specify { subject.class.constants.should_not be_empty }
|
44
44
|
end
|
45
45
|
|
46
46
|
|
@@ -48,7 +48,7 @@ shared_examples "a Name class", :parent => "Name" do
|
|
48
48
|
subject { instance.formats_ratiod }
|
49
49
|
it { should be_a_kind_of Array }
|
50
50
|
it { should all_be_a_kind_of Range }
|
51
|
-
specify { (0..99).all?{|i| subject.index_in_range( i ).kind_of? Fixnum }.should
|
51
|
+
specify { (0..99).all?{|i| subject.index_in_range( i ).kind_of? Fixnum }.should be true } # this should make sure that format ratios are specified properly
|
52
52
|
end
|
53
53
|
|
54
54
|
describe :names do
|
metadata
CHANGED
@@ -1,128 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: randomperson
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.4.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Iain Barnett
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
14
|
-
|
15
|
-
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :development
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: rspec
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
38
|
-
type: :development
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: rake
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ! '>='
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: simplecov
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
70
|
-
type: :development
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: yard
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ! '>='
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '0'
|
86
|
-
type: :development
|
87
|
-
prerelease: false
|
88
|
-
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ! '>='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '0'
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: redcarpet
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
|
-
requirements:
|
99
|
-
- - ! '>='
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '0'
|
102
|
-
type: :development
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ! '>='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
110
|
-
description: ! ' RandomPerson is a port to Ruby of Perl''s Data::RandomPerson.
|
111
|
-
Use it to generate random persons given various parameters, such as country, age
|
112
|
-
and gender ratio.
|
113
|
-
|
114
|
-
'
|
11
|
+
date: 2017-01-27 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: |2
|
14
|
+
RandomPerson is a port to Ruby of Perl's Data::RandomPerson. Use it to generate random persons given various parameters, such as country, age and gender ratio.
|
115
15
|
email:
|
116
16
|
- iainspeed@gmail.com
|
117
17
|
executables: []
|
118
18
|
extensions: []
|
119
19
|
extra_rdoc_files: []
|
120
20
|
files:
|
121
|
-
- .gitignore
|
122
|
-
- .rspec
|
123
|
-
- .travis.yml
|
21
|
+
- ".gitignore"
|
22
|
+
- ".rspec"
|
23
|
+
- ".travis.yml"
|
124
24
|
- CHANGELOG.md
|
125
25
|
- Gemfile
|
26
|
+
- LICENCE
|
126
27
|
- Manifest
|
127
28
|
- README.markdown
|
128
29
|
- Rakefile
|
@@ -130,12 +31,7 @@ files:
|
|
130
31
|
- lib/randomperson.rb
|
131
32
|
- lib/randomperson/demographic.rb
|
132
33
|
- lib/randomperson/ext/array.rb
|
133
|
-
- lib/randomperson/ext/date.rb
|
134
34
|
- lib/randomperson/ext/enumerable.rb
|
135
|
-
- lib/randomperson/ext/hash.rb
|
136
|
-
- lib/randomperson/ext/kernel.rb
|
137
|
-
- lib/randomperson/ext/set.rb
|
138
|
-
- lib/randomperson/ext/string.rb
|
139
35
|
- lib/randomperson/generator.rb
|
140
36
|
- lib/randomperson/loader.rb
|
141
37
|
- lib/randomperson/name.rb
|
@@ -211,28 +107,28 @@ files:
|
|
211
107
|
- test/test_Choice.rb
|
212
108
|
- test/test_Generator.rb
|
213
109
|
homepage: http://github.com/yb66/RandomPerson
|
214
|
-
licenses:
|
110
|
+
licenses:
|
111
|
+
- MIT
|
112
|
+
metadata: {}
|
215
113
|
post_install_message:
|
216
114
|
rdoc_options: []
|
217
115
|
require_paths:
|
218
116
|
- lib
|
219
117
|
required_ruby_version: !ruby/object:Gem::Requirement
|
220
|
-
none: false
|
221
118
|
requirements:
|
222
|
-
- -
|
119
|
+
- - ">="
|
223
120
|
- !ruby/object:Gem::Version
|
224
|
-
version:
|
121
|
+
version: 2.0.0
|
225
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
226
|
-
none: false
|
227
123
|
requirements:
|
228
|
-
- -
|
124
|
+
- - ">="
|
229
125
|
- !ruby/object:Gem::Version
|
230
126
|
version: '0'
|
231
127
|
requirements: []
|
232
128
|
rubyforge_project:
|
233
|
-
rubygems_version:
|
129
|
+
rubygems_version: 2.4.5
|
234
130
|
signing_key:
|
235
|
-
specification_version:
|
131
|
+
specification_version: 4
|
236
132
|
summary: A gem for generating random persons :)
|
237
133
|
test_files:
|
238
134
|
- spec/any-last_spec.rb
|
@@ -251,4 +147,3 @@ test_files:
|
|
251
147
|
- test/benchmarks/my_assoc_or_select.rb
|
252
148
|
- test/test_Choice.rb
|
253
149
|
- test/test_Generator.rb
|
254
|
-
has_rdoc:
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'date'
|
2
|
-
|
3
|
-
|
4
|
-
module RandomPerson
|
5
|
-
class Date < ::Date
|
6
|
-
|
7
|
-
# Convenience function
|
8
|
-
# @param [Integer] year
|
9
|
-
# @param [Integer] month
|
10
|
-
# @return [Integer]
|
11
|
-
def self.days_in_month( year, month )
|
12
|
-
::Date.civil(year, month, -1).day
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Kernel
|
2
|
-
def qualified_const_get(str)
|
3
|
-
path = str.to_s.split('::')
|
4
|
-
from_root = path[0].empty?
|
5
|
-
if from_root
|
6
|
-
from_root = []
|
7
|
-
path = path[1..-1]
|
8
|
-
else
|
9
|
-
start_ns = ((Class === self)||(Module === self)) ? self : self.class
|
10
|
-
from_root = start_ns.to_s.split('::')
|
11
|
-
end
|
12
|
-
until from_root.empty?
|
13
|
-
begin
|
14
|
-
return (from_root+path).inject(Object) { |ns,name| ns.const_get(name) }
|
15
|
-
rescue NameError
|
16
|
-
from_root.delete_at(-1)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
path.inject(Object) { |ns,name| ns.const_get(name) }
|
20
|
-
end
|
21
|
-
end
|
data/lib/randomperson/ext/set.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'set'
|
2
|
-
|
3
|
-
module RandomPerson
|
4
|
-
|
5
|
-
# @todo Spec
|
6
|
-
class Set < ::Set
|
7
|
-
|
8
|
-
# @todo handle failure
|
9
|
-
# @return [Set] The set for which the pattern matches.
|
10
|
-
def classify_true( pattern )
|
11
|
-
self.classify{|s| true if s =~ %r{^.*/[^/]*#{pattern}[^/]*$}i }[true]
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
File without changes
|