randomperson 0.0.12 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data.tar.gz.sig +0 -0
  2. data/lib/randomperson.rb +11 -11
  3. data/lib/randomperson/Generator.rb +2 -2
  4. data/lib/randomperson/Names/AmericanPrefix.rb +28 -0
  5. data/lib/randomperson/Names/AnyLast.rb +2 -0
  6. data/lib/randomperson/Names/BasqueFemaleFirst.rb +1 -0
  7. data/lib/randomperson/Names/BasqueMaleFirst.rb +1 -0
  8. data/lib/randomperson/Names/BritishPrefix.rb +6 -4
  9. data/lib/randomperson/Names/BritishSuffix.rb +9 -9
  10. data/lib/randomperson/Names/EnglishFemaleFirst.rb +2 -0
  11. data/lib/randomperson/Names/EnglishLast.rb +2 -0
  12. data/lib/randomperson/Names/EnglishMaleFirst.rb +2 -0
  13. data/lib/randomperson/Names/EnglishPrefix.rb +28 -0
  14. data/lib/randomperson/Names/FinnishFemaleFirst.rb +2 -0
  15. data/lib/randomperson/Names/FinnishLast.rb +2 -0
  16. data/lib/randomperson/Names/FinnishMaleFirst.rb +2 -0
  17. data/lib/randomperson/Names/FinnishPrefix.rb +30 -0
  18. data/lib/randomperson/Names/FrenchFemaleFirst.rb +2 -0
  19. data/lib/randomperson/Names/FrenchLast.rb +2 -0
  20. data/lib/randomperson/Names/FrenchMaleFirst.rb +2 -0
  21. data/lib/randomperson/Names/GermanFemaleFirst.rb +2 -0
  22. data/lib/randomperson/Names/GermanLast.rb +2 -0
  23. data/lib/randomperson/Names/GermanMaleFirst.rb +2 -0
  24. data/lib/randomperson/Names/ScottishFemaleFirst.rb +2 -0
  25. data/lib/randomperson/Names/ScottishLast.rb +2 -0
  26. data/lib/randomperson/Names/ScottishMaleFirst.rb +2 -0
  27. data/lib/randomperson/Names/ScottishPrefix.rb +30 -0
  28. data/lib/randomperson/Names/ThaiRomanisedFemaleFirst.rb +2 -0
  29. data/lib/randomperson/Names/ThaiRomanisedLast.rb +2 -0
  30. data/lib/randomperson/Names/ThaiRomanisedMaleFirst.rb +2 -0
  31. data/lib/randomperson/Names/WelshFemaleFirst.rb +2 -0
  32. data/lib/randomperson/Names/WelshLast.rb +2 -0
  33. data/lib/randomperson/Names/WelshMaleFirst.rb +2 -0
  34. data/lib/randomperson/Names/WelshPrefix.rb +30 -0
  35. data/randomperson.gemspec +1 -1
  36. metadata +8 -3
  37. metadata.gz.sig +3 -2
data.tar.gz.sig CHANGED
Binary file
data/lib/randomperson.rb CHANGED
@@ -3,15 +3,15 @@
3
3
  require 'set'
4
4
  require 'date'
5
5
 
6
- require 'randomperson/ext/Array.rb'
7
- require 'randomperson/ext/Date.rb'
8
- require 'randomperson/ext/Enumerable.rb'
9
- require 'randomperson/ext/Hash.rb'
10
- require 'randomperson/ext/Kernel.rb'
11
- require 'randomperson/ext/Set.rb'
6
+ require_relative 'randomperson/ext/Array.rb'
7
+ require_relative 'randomperson/ext/Date.rb'
8
+ require_relative 'randomperson/ext/Enumerable.rb'
9
+ require_relative 'randomperson/ext/Hash.rb'
10
+ require_relative 'randomperson/ext/Kernel.rb'
11
+ require_relative 'randomperson/ext/Set.rb'
12
12
 
13
- require 'randomperson/choice.rb'
14
- require 'randomperson/generator.rb'
15
- require 'randomperson/name.rb'
16
- require 'randomperson/person.rb'
17
- #require 'randomperson/ratio.rb'
13
+ require_relative 'randomperson/choice.rb'
14
+ require_relative 'randomperson/generator.rb'
15
+ require_relative 'randomperson/name.rb'
16
+ require_relative 'randomperson/person.rb'
17
+ #require_relative 'randomperson/ratio.rb'
@@ -28,8 +28,8 @@ module RandomPerson
28
28
  end
29
29
 
30
30
  person.last = choice.last.execute( person ) unless choice.last.nil?#lastname,
31
- person.prefix = choice.prefix.execute( person ) unless person.prefix.nil? #title
32
- person.suffix = choice.suffix.execute( person ) unless person.suffix.nil?#suffix
31
+ person.prefix = choice.prefix.execute( person ) unless choice.prefix.nil? #title
32
+ person.suffix = choice.suffix.execute( person ) unless choice.suffix.nil?#suffix
33
33
 
34
34
  person
35
35
  }
@@ -0,0 +1,28 @@
1
+ module RandomPerson
2
+ module Names
3
+
4
+ class AmericanPrefix < Name
5
+
6
+ def initialize
7
+
8
+ @formats_ratiod = [ 0..47, 48..50, 51..69, 70..87, 88..99]
9
+
10
+ @names = %w(Mr. Dr. Mrs. Ms. Miss )
11
+ end
12
+
13
+ def execute( person )
14
+
15
+ if person.age < 17
16
+ return 'Miss' if person.gender == 'f'
17
+ return 'Mr.'
18
+ end
19
+
20
+ r = rand(51) #0..50
21
+ r += 49 if person.gender == 'f' #give 50% chance of being a Dr
22
+
23
+ i = @formats_ratiod.index_in_range( r )
24
+ return @names[i]
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module RandomPerson
2
4
  module Names
3
5
 
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+
2
3
  module RandomPerson
3
4
  module Names
4
5
 
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+
2
3
  module RandomPerson
3
4
  module Names
4
5
 
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module RandomPerson
2
4
  module Names
3
5
 
@@ -5,16 +7,16 @@ module RandomPerson
5
7
 
6
8
  def initialize
7
9
 
8
- @formats_ratiod = [ 0..47, 48..50, 51..52, 53..81, 82..99]
10
+ @formats_ratiod = [ 0..47, 48..50, 51..70, 71..87, 88..99]
9
11
 
10
- @names = %w(Mr. Dr. Mrs. Ms. Miss )
12
+ @names = %w(Mr Dr Mrs Ms Miss)
11
13
  end
12
14
 
13
15
  def execute( person )
14
16
 
15
17
  if person.age < 17
16
- return 'Miss' if person.gender == 'f'
17
- return 'Mr.'
18
+ return @names[4] if person.gender == 'f'
19
+ return @names[0]
18
20
  end
19
21
 
20
22
  r = rand(51) #0..50
@@ -8,20 +8,20 @@ module RandomPerson
8
8
 
9
9
  }
10
10
 
11
- @formats_ratiod = [ 0, 1, 2, 3, 4, 5, 6..18, 98, 99]
11
+ @formats_ratiod = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9..59, 59..159]
12
12
 
13
- @names = %w( OBE, MBE, GBE, KBE, DBE, CBE, JP, GM, BSc, BA )
13
+ @names = %w( OBE, MBE, GBE, KBE, DBE, CBE, JP, GM, PhD BSc, BA )
14
14
  end
15
15
 
16
16
  def execute( person )
17
-
18
- r = rand(99)
19
- if person.age > 17
20
- r += 1 #Jr can't happen
21
- end
22
-
17
+ retval = nil
18
+ r = rand(999)
19
+ unless person.age < 17 #sorry kids, but you ain't gonna get these
23
20
  i = @formats_ratiod.index_in_range( r )
24
- return @names[i]
21
+ retval = @names[i] unless i.nil?
22
+ end
23
+
24
+ return retval
25
25
  end
26
26
  end
27
27
  end
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module RandomPerson
2
4
  module Names
3
5
 
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module RandomPerson
2
4
  module Names
3
5
 
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module RandomPerson
2
4
  module Names
3
5
 
@@ -0,0 +1,28 @@
1
+ module RandomPerson
2
+ module Names
3
+
4
+ class EnglishPrefix < Name
5
+
6
+ def initialize
7
+
8
+ @formats_ratiod = [ 0..47, 48..50, 51..70, 71..87, 88..99]
9
+
10
+ @names = %w(Mr Dr Mrs Ms Miss )
11
+ end
12
+
13
+ def execute( person )
14
+
15
+ if person.age < 17
16
+ return @names[4] if person.gender == 'f'
17
+ return @names[0]
18
+ end
19
+
20
+ r = rand(51) #0..50
21
+ r += 49 if person.gender == 'f' #give 50% chance of being a Dr
22
+
23
+ i = @formats_ratiod.index_in_range( r )
24
+ return @names[i]
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module RandomPerson
2
4
  module Names
3
5
 
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module RandomPerson
2
4
  module Names
3
5
 
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module RandomPerson
2
4
  module Names
3
5
 
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+
3
+ module RandomPerson
4
+ module Names
5
+
6
+ class FinnishPrefix < Name
7
+
8
+ def initialize
9
+
10
+ @formats_ratiod = [ 0..47, 48..50, 51..69, 70..99]
11
+
12
+ @names = %w(herra Dr rouva neiti)
13
+ end
14
+
15
+ def execute( person )
16
+
17
+ if person.age < 17
18
+ return @names[3] if person.gender == 'f'
19
+ return @names[0]
20
+ end
21
+
22
+ r = rand(51) #0..50
23
+ r += 49 if person.gender == 'f' #give 50% chance of being a Dr
24
+
25
+ i = @formats_ratiod.index_in_range( r )
26
+ return @names[i]
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module RandomPerson
2
4
  module Names
3
5
 
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module RandomPerson
2
4
  module Names
3
5
 
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module RandomPerson
2
4
  module Names
3
5
 
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module RandomPerson
2
4
  module Names
3
5
 
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module RandomPerson
2
4
  module Names
3
5
 
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module RandomPerson
2
4
  module Names
3
5
 
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module RandomPerson
2
4
  module Names
3
5
 
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module RandomPerson
2
4
  module Names
3
5
 
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module RandomPerson
2
4
  module Names
3
5
 
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+
3
+ module RandomPerson
4
+ module Names
5
+
6
+ class ScottishPrefix < Name
7
+
8
+ def initialize
9
+
10
+ @formats_ratiod = [ 0..47, 48..50, 51..70, 71..87, 88..99]
11
+
12
+ @names = %w(Mr Dr Mrs Ms Miss)
13
+ end
14
+
15
+ def execute( person )
16
+
17
+ if person.age < 17
18
+ return @names[4] if person.gender == 'f'
19
+ return @names[0]
20
+ end
21
+
22
+ r = rand(51) #0..50
23
+ r += 49 if person.gender == 'f' #give 50% chance of being a Dr
24
+
25
+ i = @formats_ratiod.index_in_range( r )
26
+ return @names[i]
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module RandomPerson
2
4
  module Names
3
5
 
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module RandomPerson
2
4
  module Names
3
5
 
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module RandomPerson
2
4
  module Names
3
5
 
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module RandomPerson
2
4
  module Names
3
5
 
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module RandomPerson
2
4
  module Names
3
5
 
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module RandomPerson
2
4
  module Names
3
5
 
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+
3
+ module RandomPerson
4
+ module Names
5
+
6
+ class WelshPrefix < Name
7
+
8
+ def initialize
9
+
10
+ @formats_ratiod = [ 0..47, 48..50, 51..70, 71..87, 88..99]
11
+
12
+ @names = %w(Mr Dr Mrs Ms Miss)
13
+ end
14
+
15
+ def execute( person )
16
+
17
+ if person.age < 17
18
+ return @names[4] if person.gender == 'f'
19
+ return @names[0]
20
+ end
21
+
22
+ r = rand(51) #0..50
23
+ r += 49 if person.gender == 'f' #give 50% chance of being a Dr
24
+
25
+ i = @formats_ratiod.index_in_range( r )
26
+ return @names[i]
27
+ end
28
+ end
29
+ end
30
+ end
data/randomperson.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.description = <<-EOF
10
10
  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.
11
11
  EOF
12
- s.version = "0.0.12"
12
+ s.version = "0.0.16"
13
13
  s.platform = Gem::Platform::RUBY
14
14
  s.require_paths << 'ext'
15
15
  s.required_ruby_version = ">= 1.9.1"
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 12
9
- version: 0.0.12
8
+ - 16
9
+ version: 0.0.16
10
10
  platform: ruby
11
11
  authors:
12
12
  - Iain Barnett
@@ -35,7 +35,7 @@ cert_chain:
35
35
  YK13fiGcldY=
36
36
  -----END CERTIFICATE-----
37
37
 
38
- date: 2010-10-25 00:00:00 +01:00
38
+ date: 2010-11-11 00:00:00 +00:00
39
39
  default_executable:
40
40
  dependencies: []
41
41
 
@@ -62,6 +62,7 @@ files:
62
62
  - lib/randomperson/Names/AmericanFemaleFirst.rb
63
63
  - lib/randomperson/Names/AmericanLast.rb
64
64
  - lib/randomperson/Names/AmericanMaleFirst.rb
65
+ - lib/randomperson/Names/AmericanPrefix.rb
65
66
  - lib/randomperson/Names/AmericanSuffix.rb
66
67
  - lib/randomperson/Names/AncientGreekFemaleFirst.rb
67
68
  - lib/randomperson/Names/AncientGreekLast.rb
@@ -75,9 +76,11 @@ files:
75
76
  - lib/randomperson/Names/EnglishFemaleFirst.rb
76
77
  - lib/randomperson/Names/EnglishLast.rb
77
78
  - lib/randomperson/Names/EnglishMaleFirst.rb
79
+ - lib/randomperson/Names/EnglishPrefix.rb
78
80
  - lib/randomperson/Names/FinnishFemaleFirst.rb
79
81
  - lib/randomperson/Names/FinnishLast.rb
80
82
  - lib/randomperson/Names/FinnishMaleFirst.rb
83
+ - lib/randomperson/Names/FinnishPrefix.rb
81
84
  - lib/randomperson/Names/FrenchFemaleFirst.rb
82
85
  - lib/randomperson/Names/FrenchLast.rb
83
86
  - lib/randomperson/Names/FrenchMaleFirst.rb
@@ -87,6 +90,7 @@ files:
87
90
  - lib/randomperson/Names/ScottishFemaleFirst.rb
88
91
  - lib/randomperson/Names/ScottishLast.rb
89
92
  - lib/randomperson/Names/ScottishMaleFirst.rb
93
+ - lib/randomperson/Names/ScottishPrefix.rb
90
94
  - lib/randomperson/Names/SpanishFemaleFirst.rb
91
95
  - lib/randomperson/Names/SpanishLast.rb
92
96
  - lib/randomperson/Names/SpanishMaleFirst.rb
@@ -103,6 +107,7 @@ files:
103
107
  - lib/randomperson/Names/WelshFemaleFirst.rb
104
108
  - lib/randomperson/Names/WelshLast.rb
105
109
  - lib/randomperson/Names/WelshMaleFirst.rb
110
+ - lib/randomperson/Names/WelshPrefix.rb
106
111
  - lib/randomperson/Person.rb
107
112
  - lib/randomperson/Ratio.rb
108
113
  - lib/randomperson.rb
metadata.gz.sig CHANGED
@@ -1,2 +1,3 @@
1
- ��d����K�B+�:<�,�� �����2��|�}@,�7�u���.^m�n�a��y���M���-�q�[Xv6�֍�ayE�q�kW��L1^03�CԱ"K썛i�ن߻
2
- ����|�)Z(���Gb��1ɔ'Cp��yX+��>��LT'`��2zdr@ �j� �h��ڋA��!� �����}o~Lϊ�>��O�7B���`OX���[!
1
+ �Ϸ3��) i
2
+ ���篖E�y��;s�⛝��Fm\/�t�(e$��^��̕��&���l�Qs�tͨ����Z�� �)TG�-����o�I������e����DC̔U)��/��kN�o&����T[^��*�&�~��w�m�S��k"6{U��sC���cyR̺=��cH����s��E�w<c�k��H`�@�]1�؞�M4�6x���/�j�{F��dL�h����
3
+ ���0���߻�a\}&�q���