faker 2.10.2 → 2.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +323 -0
  3. data/README.md +27 -2
  4. data/lib/faker.rb +57 -25
  5. data/lib/faker/blockchain/aeternity.rb +4 -4
  6. data/lib/faker/books/dune.rb +15 -2
  7. data/lib/faker/books/lovecraft.rb +8 -4
  8. data/lib/faker/default/address.rb +35 -5
  9. data/lib/faker/default/bank.rb +80 -3
  10. data/lib/faker/default/barcode.rb +154 -0
  11. data/lib/faker/default/beer.rb +3 -3
  12. data/lib/faker/default/blood.rb +48 -0
  13. data/lib/faker/default/business.rb +1 -1
  14. data/lib/faker/default/camera.rb +46 -0
  15. data/lib/faker/default/cannabis.rb +80 -0
  16. data/lib/faker/default/chile_rut.rb +47 -3
  17. data/lib/faker/default/code.rb +98 -17
  18. data/lib/faker/default/commerce.rb +74 -11
  19. data/lib/faker/default/company.rb +78 -11
  20. data/lib/faker/default/compass.rb +135 -0
  21. data/lib/faker/default/computer.rb +63 -0
  22. data/lib/faker/default/construction.rb +54 -0
  23. data/lib/faker/default/cosmere.rb +90 -0
  24. data/lib/faker/default/crypto_coin.rb +45 -0
  25. data/lib/faker/default/date.rb +16 -12
  26. data/lib/faker/default/driving_licence.rb +65 -0
  27. data/lib/faker/default/drone.rb +332 -0
  28. data/lib/faker/default/faker_adjective.rb +35 -0
  29. data/lib/faker/default/file.rb +49 -0
  30. data/lib/faker/default/finance.rb +45 -0
  31. data/lib/faker/default/food.rb +1 -1
  32. data/lib/faker/default/funny_name.rb +45 -0
  33. data/lib/faker/default/gender.rb +1 -1
  34. data/lib/faker/default/hipster.rb +101 -4
  35. data/lib/faker/default/id_number.rb +88 -2
  36. data/lib/faker/default/internet.rb +68 -10
  37. data/lib/faker/default/internet_http.rb +48 -0
  38. data/lib/faker/default/invoice.rb +33 -6
  39. data/lib/faker/default/json.rb +59 -4
  40. data/lib/faker/default/lorem.rb +2 -2
  41. data/lib/faker/default/lorem_flickr.rb +65 -0
  42. data/lib/faker/default/lorem_pixel.rb +22 -0
  43. data/lib/faker/default/markdown.rb +89 -0
  44. data/lib/faker/default/measurement.rb +93 -2
  45. data/lib/faker/default/military.rb +26 -0
  46. data/lib/faker/default/mountain.rb +33 -0
  47. data/lib/faker/default/name.rb +98 -0
  48. data/lib/faker/default/nhs.rb +19 -0
  49. data/lib/faker/default/number.rb +6 -8
  50. data/lib/faker/default/omniauth.rb +107 -52
  51. data/lib/faker/default/phone_number.rb +88 -5
  52. data/lib/faker/default/placeholdit.rb +21 -0
  53. data/lib/faker/default/relationship.rb +1 -1
  54. data/lib/faker/default/slack_emoji.rb +81 -0
  55. data/lib/faker/default/south_africa.rb +90 -0
  56. data/lib/faker/default/space.rb +1 -1
  57. data/lib/faker/default/string.rb +19 -3
  58. data/lib/faker/default/stripe.rb +64 -3
  59. data/lib/faker/default/twitter.rb +35 -0
  60. data/lib/faker/default/types.rb +80 -0
  61. data/lib/faker/default/university.rb +45 -0
  62. data/lib/faker/default/vehicle.rb +184 -4
  63. data/lib/faker/default/verb.rb +45 -0
  64. data/lib/faker/default/world_cup.rb +4 -4
  65. data/lib/faker/fantasy/tolkien.rb +67 -0
  66. data/lib/faker/games/clash_of_clans.rb +48 -0
  67. data/lib/faker/games/control.rb +113 -0
  68. data/lib/faker/games/dnd.rb +136 -0
  69. data/lib/faker/games/elder_scrolls.rb +26 -0
  70. data/lib/faker/games/heroes.rb +13 -0
  71. data/lib/faker/games/heroes_of_the_storm.rb +16 -5
  72. data/lib/faker/games/minecraft.rb +113 -0
  73. data/lib/faker/games/street_fighter.rb +61 -0
  74. data/lib/faker/games/super_mario.rb +48 -0
  75. data/lib/faker/games/warhammer_fantasy.rb +74 -0
  76. data/lib/faker/games/world_of_warcraft.rb +26 -1
  77. data/lib/faker/japanese_media/conan.rb +48 -0
  78. data/lib/faker/japanese_media/doraemon.rb +48 -0
  79. data/lib/faker/japanese_media/dragon_ball.rb +26 -0
  80. data/lib/faker/japanese_media/naruto.rb +61 -0
  81. data/lib/faker/japanese_media/studio_ghibli.rb +48 -0
  82. data/lib/faker/movies/departed.rb +49 -0
  83. data/lib/faker/movies/hobbit.rb +4 -4
  84. data/lib/faker/movies/how_to_train_your_dragon.rb +48 -0
  85. data/lib/faker/movies/lord_of_the_rings.rb +3 -3
  86. data/lib/faker/movies/movie.rb +13 -0
  87. data/lib/faker/movies/room.rb +63 -0
  88. data/lib/faker/movies/star_wars.rb +2 -2
  89. data/lib/faker/music/hiphop.rb +48 -0
  90. data/lib/faker/music/opera.rb +237 -1
  91. data/lib/faker/music/pearl_jam.rb +50 -0
  92. data/lib/faker/music/phish.rb +27 -1
  93. data/lib/faker/music/prince.rb +64 -0
  94. data/lib/faker/music/rush.rb +37 -0
  95. data/lib/faker/music/show.rb +49 -0
  96. data/lib/faker/quotes/chiquito.rb +80 -0
  97. data/lib/faker/quotes/quote.rb +80 -1
  98. data/lib/faker/quotes/rajnikanth.rb +26 -0
  99. data/lib/faker/quotes/shakespeare.rb +36 -0
  100. data/lib/faker/sports/volleyball.rb +74 -0
  101. data/lib/faker/tv_shows/aqua_teen_hunger_force.rb +13 -0
  102. data/lib/faker/tv_shows/big_bang_theory.rb +37 -0
  103. data/lib/faker/tv_shows/buffy.rb +17 -4
  104. data/lib/faker/tv_shows/dr_who.rb +1 -1
  105. data/lib/faker/tv_shows/final_space.rb +51 -0
  106. data/lib/faker/tv_shows/futurama.rb +65 -0
  107. data/lib/faker/tv_shows/simpsons.rb +14 -0
  108. data/lib/faker/tv_shows/suits.rb +37 -0
  109. data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +17 -4
  110. data/lib/faker/version.rb +1 -1
  111. data/lib/helpers/base58.rb +1 -1
  112. data/lib/helpers/char.rb +22 -27
  113. data/lib/helpers/unique_generator.rb +3 -2
  114. data/lib/locales/de-AT.yml +4 -2
  115. data/lib/locales/de-CH.yml +1696 -1
  116. data/lib/locales/de.yml +4 -2
  117. data/lib/locales/en-AU.yml +50 -10
  118. data/lib/locales/en-CA.yml +2 -0
  119. data/lib/locales/en-GB.yml +1 -1
  120. data/lib/locales/en-IND.yml +2 -1
  121. data/lib/locales/en-MS.yml +2 -1
  122. data/lib/locales/en-NEP.yml +4 -1
  123. data/lib/locales/en-NZ.yml +3 -1
  124. data/lib/locales/en-PAK.yml +2 -1
  125. data/lib/locales/en-SG.yml +2 -1
  126. data/lib/locales/en-US.yml +36 -10
  127. data/lib/locales/en-au-ocker.yml +2 -1
  128. data/lib/locales/en.yml +0 -3
  129. data/lib/locales/en/address.yml +2 -0
  130. data/lib/locales/en/adjective.yml +179 -0
  131. data/lib/locales/en/animal.yml +1 -1
  132. data/lib/locales/en/aqua_teen_hunger_force.yml +33 -1
  133. data/lib/locales/en/bank.yml +1 -1
  134. data/lib/locales/en/barcode.yml +24 -0
  135. data/lib/locales/en/big_bang_theory.yml +38 -0
  136. data/lib/locales/en/blood.yml +13 -0
  137. data/lib/locales/en/buffy.yml +1 -1
  138. data/lib/locales/en/camera.yml +611 -0
  139. data/lib/locales/en/chiquito.yml +64 -0
  140. data/lib/locales/en/clash_of_clan.yml +101 -0
  141. data/lib/locales/en/company.yml +2 -2
  142. data/lib/locales/en/computer.yml +36 -0
  143. data/lib/locales/en/conan.yml +171 -0
  144. data/lib/locales/en/control.yml +247 -0
  145. data/lib/locales/en/demographic.yml +218 -5
  146. data/lib/locales/en/departed.yml +50 -0
  147. data/lib/locales/en/dnd.yml +451 -0
  148. data/lib/locales/en/doraemon.yml +286 -0
  149. data/lib/locales/en/dota.yml +531 -63
  150. data/lib/locales/en/dragon_ball.yml +243 -1
  151. data/lib/locales/en/driving_license.yml +181 -0
  152. data/lib/locales/en/drone.yml +95 -0
  153. data/lib/locales/en/dune.yml +401 -131
  154. data/lib/locales/en/elder_scrolls.yml +583 -9
  155. data/lib/locales/en/fallout.yml +311 -133
  156. data/lib/locales/en/final_space.yml +37 -0
  157. data/lib/locales/en/finance.yml +53 -0
  158. data/lib/locales/en/fresh_prince_of_bel_air.yml +1 -1
  159. data/lib/locales/en/futurama.yml +344 -0
  160. data/lib/locales/en/half_life.yml +84 -3
  161. data/lib/locales/en/heroes.yml +408 -3
  162. data/lib/locales/en/heroes_of_the_storm.yml +131 -4
  163. data/lib/locales/en/house.yml +1 -1
  164. data/lib/locales/en/how_to_train_your_dragon.yml +174 -0
  165. data/lib/locales/en/jack_handey.yml +54 -0
  166. data/lib/locales/en/league_of_legends.yml +285 -6
  167. data/lib/locales/en/military.yml +179 -5
  168. data/lib/locales/en/minecraft.yml +663 -0
  169. data/lib/locales/en/mountain.yml +158 -0
  170. data/lib/locales/en/movie.yml +192 -1
  171. data/lib/locales/en/music.yml +451 -29
  172. data/lib/locales/en/myst.yml +87 -31
  173. data/lib/locales/en/name.yml +6 -5
  174. data/lib/locales/en/naruto.yml +231 -0
  175. data/lib/locales/en/one_piece.yml +2 -2
  176. data/lib/locales/en/opera.yml +168 -0
  177. data/lib/locales/en/overwatch.yml +2650 -2622
  178. data/lib/locales/en/pearl_jam.yml +213 -0
  179. data/lib/locales/en/phish.yml +392 -1
  180. data/lib/locales/en/pokemon.yml +417 -4
  181. data/lib/locales/en/prince.yml +227 -0
  182. data/lib/locales/en/quote.yml +692 -163
  183. data/lib/locales/en/rajnikanth.yml +77 -0
  184. data/lib/locales/en/room.yml +68 -0
  185. data/lib/locales/en/rush.yml +32 -0
  186. data/lib/locales/en/show.yml +597 -0
  187. data/lib/locales/en/simpsons.yml +668 -0
  188. data/lib/locales/en/source.yml +30 -0
  189. data/lib/locales/en/star_trek.yml +1 -1
  190. data/lib/locales/en/star_wars.yml +568 -220
  191. data/lib/locales/en/street_fighter.yml +1524 -0
  192. data/lib/locales/en/studio_ghibli.yml +107 -0
  193. data/lib/locales/en/suits.yml +45 -0
  194. data/lib/locales/en/super_mario.yml +58 -0
  195. data/lib/locales/en/super_smash_bros.yml +16 -4
  196. data/lib/locales/en/tolkien.yml +2453 -0
  197. data/lib/locales/en/volleyball.yml +501 -0
  198. data/lib/locales/en/warhammer_fantasy.yml +582 -0
  199. data/lib/locales/en/witcher.yml +389 -7
  200. data/lib/locales/en/world_of_warcraft.yml +122 -4
  201. data/lib/locales/en/zelda.yml +962 -4
  202. data/lib/locales/es.yml +56 -0
  203. data/lib/locales/fi-FI.yml +1 -1
  204. data/lib/locales/fr-CA.yml +21 -5
  205. data/lib/locales/fr-CH.yml +2 -2
  206. data/lib/locales/fr.yml +8 -2
  207. data/lib/locales/id.yml +2 -1
  208. data/lib/locales/it.yml +2 -1
  209. data/lib/locales/ja.yml +5 -1
  210. data/lib/locales/ko.yml +94 -2
  211. data/lib/locales/nb-NO.yml +4 -2
  212. data/lib/locales/pt-BR.yml +2 -1
  213. data/lib/locales/pt.yml +3 -1
  214. data/lib/locales/ru.yml +3 -1
  215. data/lib/locales/sk.yml +4 -2
  216. data/lib/locales/uk.yml +2 -0
  217. metadata +89 -21
  218. data/lib/locales/en/hobbit.yml +0 -19
  219. data/lib/locales/en/lord_of_the_rings.yml +0 -6
@@ -6,6 +6,19 @@ module Faker
6
6
  ALL = 'all'
7
7
  NONE = 'none'
8
8
 
9
+ ##
10
+ # Produces a random height measurement.
11
+ #
12
+ # @param amount [Integer] Speficies the random height value.
13
+ # @return [String]
14
+ #
15
+ # @example
16
+ # Faker::Measurement.height #=> "6 inches"
17
+ # Faker::Measurement.height(amount: 1.4) #=> "1.4 inches"
18
+ # Faker::Measurement.height(amount: "none") #=> "inch"
19
+ # Faker::Measurement.height(amount: "all") #=> "inches"
20
+ #
21
+ # @faker.version 1.7.3
9
22
  def height(legacy_amount = NOT_GIVEN, amount: rand(10))
10
23
  warn_for_deprecated_arguments do |keywords|
11
24
  keywords << :amount if legacy_amount != NOT_GIVEN
@@ -14,6 +27,17 @@ module Faker
14
27
  define_measurement_locale(amount, 'height')
15
28
  end
16
29
 
30
+ ##
31
+ # Produces a random length measurement.
32
+ #
33
+ # @param amount [Integer] Speficies the random length value.
34
+ # @return [String]
35
+ #
36
+ # @example
37
+ # Faker::Measurement.length #=> "1 yard"
38
+ # Faker::Measurement.length(amount: 1.4) #=> "1.4 yards"
39
+ #
40
+ # @faker.version 1.7.3
17
41
  def length(legacy_amount = NOT_GIVEN, amount: rand(10))
18
42
  warn_for_deprecated_arguments do |keywords|
19
43
  keywords << :amount if legacy_amount != NOT_GIVEN
@@ -22,6 +46,17 @@ module Faker
22
46
  define_measurement_locale(amount, 'length')
23
47
  end
24
48
 
49
+ ##
50
+ # Produces a random volume measurement.
51
+ #
52
+ # @param amount [Integer] Speficies the random volume value.
53
+ # @return [String]
54
+ #
55
+ # @example
56
+ # Faker::Measurement.volume #=> "10 cups"
57
+ # Faker::Measurement.volume(amount: 1.4) #=> "1.4 cups"
58
+ #
59
+ # @faker.version 1.7.3
25
60
  def volume(legacy_amount = NOT_GIVEN, amount: rand(10))
26
61
  warn_for_deprecated_arguments do |keywords|
27
62
  keywords << :amount if legacy_amount != NOT_GIVEN
@@ -30,6 +65,17 @@ module Faker
30
65
  define_measurement_locale(amount, 'volume')
31
66
  end
32
67
 
68
+ ##
69
+ # Produces a random weight measurement.
70
+ #
71
+ # @param amount [Integer] Speficies the random weight value.
72
+ # @return [String]
73
+ #
74
+ # @example
75
+ # Faker::Measurement.weight #=> "3 pounds"
76
+ # Faker::Measurement.weight(amount: 1.4) #=> "1.4 pounds"
77
+ #
78
+ # @faker.version 1.7.3
33
79
  def weight(legacy_amount = NOT_GIVEN, amount: rand(10))
34
80
  warn_for_deprecated_arguments do |keywords|
35
81
  keywords << :amount if legacy_amount != NOT_GIVEN
@@ -38,6 +84,17 @@ module Faker
38
84
  define_measurement_locale(amount, 'weight')
39
85
  end
40
86
 
87
+ ##
88
+ # Produces a random metric height measurement.
89
+ #
90
+ # @param amount [Integer] Speficies the random height value.
91
+ # @return [String]
92
+ #
93
+ # @example
94
+ # Faker::Measurement.metric_height #=> "2 meters"
95
+ # Faker::Measurement.metric_height(amount: 1.4) #=> "1.4 meters"
96
+ #
97
+ # @faker.version 1.7.3
41
98
  def metric_height(legacy_amount = NOT_GIVEN, amount: rand(10))
42
99
  warn_for_deprecated_arguments do |keywords|
43
100
  keywords << :amount if legacy_amount != NOT_GIVEN
@@ -46,6 +103,17 @@ module Faker
46
103
  define_measurement_locale(amount, 'metric_height')
47
104
  end
48
105
 
106
+ ##
107
+ # Produces a random metric length measurement.
108
+ #
109
+ # @param amount [Integer] Speficies the random length value.
110
+ # @return [String]
111
+ #
112
+ # @example
113
+ # Faker::Measurement.metric_length #=> "0 decimeters"
114
+ # Faker::Measurement.metric_length(amount: 1.4) #=> "1.4 decimeters"
115
+ #
116
+ # @faker.version 1.7.3
49
117
  def metric_length(legacy_amount = NOT_GIVEN, amount: rand(10))
50
118
  warn_for_deprecated_arguments do |keywords|
51
119
  keywords << :amount if legacy_amount != NOT_GIVEN
@@ -54,6 +122,17 @@ module Faker
54
122
  define_measurement_locale(amount, 'metric_length')
55
123
  end
56
124
 
125
+ ##
126
+ # Produces a random metric volume measurement.
127
+ #
128
+ # @param amount [Integer] Speficies the random volume value.
129
+ # @return [String]
130
+ #
131
+ # @example
132
+ # Faker::Measurement.metric_volume #=> "1 liter"
133
+ # Faker::Measurement.metric_volume(amount: 1.4) #=> "1.4 liters"
134
+ #
135
+ # @faker.version 1.7.3
57
136
  def metric_volume(legacy_amount = NOT_GIVEN, amount: rand(10))
58
137
  warn_for_deprecated_arguments do |keywords|
59
138
  keywords << :amount if legacy_amount != NOT_GIVEN
@@ -62,6 +141,17 @@ module Faker
62
141
  define_measurement_locale(amount, 'metric_volume')
63
142
  end
64
143
 
144
+ ##
145
+ # Produces a random metric weight measurement.
146
+ #
147
+ # @param amount [Integer] Speficies the random weight value.
148
+ # @return [String]
149
+ #
150
+ # @example
151
+ # Faker::Measurement.metric_weight #=> "8 grams"
152
+ # Faker::Measurement.metric_weight(amount: 1.4) #=> "1.4 grams"
153
+ #
154
+ # @faker.version 1.7.3
65
155
  def metric_weight(legacy_amount = NOT_GIVEN, amount: rand(10))
66
156
  warn_for_deprecated_arguments do |keywords|
67
157
  keywords << :amount if legacy_amount != NOT_GIVEN
@@ -82,9 +172,10 @@ module Faker
82
172
 
83
173
  def define_measurement_locale(amount, locale)
84
174
  ensure_valid_amount(amount)
85
- if amount == ALL
175
+ case amount
176
+ when ALL
86
177
  make_plural(fetch("measurement.#{locale}"))
87
- elsif amount == NONE
178
+ when NONE
88
179
  fetch("measurement.#{locale}")
89
180
  else
90
181
  locale = check_for_plural(fetch("measurement.#{locale}"), amount)
@@ -55,6 +55,32 @@ module Faker
55
55
  fetch('military.air_force_rank')
56
56
  end
57
57
 
58
+ ##
59
+ # Produces a rank in the U.S. Space Force.
60
+ #
61
+ # @return [String]
62
+ #
63
+ # @example
64
+ # Faker::Military.space_force_rank #=> "Senior Enlisted Advisor of the Space Force"
65
+ #
66
+ # @faker.version next
67
+ def space_force_rank
68
+ fetch('military.space_force_rank')
69
+ end
70
+
71
+ ##
72
+ # Produces a rank in the U.S. Coast Guard
73
+ #
74
+ # @return [String]
75
+ #
76
+ # @example
77
+ # Faker::Military.coast_guard_rank #=> "Master Chief Petty Officer of the Coast Guard"
78
+ #
79
+ # @faker.version next
80
+ def coast_guard_rank
81
+ fetch('military.coast_guard_rank')
82
+ end
83
+
58
84
  ##
59
85
  # Produces a U.S. Department of Defense Paygrade.
60
86
  #
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Faker
4
+ class Mountain < Base
5
+ class << self
6
+ ##
7
+ # Produces a name of a mountain
8
+ #
9
+ # @return [String]
10
+ #
11
+ # @example
12
+ # Faker::Mountain.name #=> "Mount Everest"
13
+ #
14
+ # @faker.version next
15
+ def name
16
+ fetch('mountain.name')
17
+ end
18
+
19
+ ##
20
+ # Produces a name of a range
21
+ #
22
+ # @return [String]
23
+ #
24
+ # @example
25
+ # Faker::Mountain.range #=> "Dhaulagiri Himalaya"
26
+ #
27
+ # @faker.version next
28
+ def range
29
+ fetch('mountain.range')
30
+ end
31
+ end
32
+ end
33
+ end
@@ -5,14 +5,41 @@ module Faker
5
5
  flexible :name
6
6
 
7
7
  class << self
8
+ ##
9
+ # Produces a random name.
10
+ #
11
+ # @return [String]
12
+ #
13
+ # @example
14
+ # Faker::Name.name #=> "Tyshawn Johns Sr."
15
+ #
16
+ # @faker.version 0.9.0
8
17
  def name
9
18
  parse('name.name')
10
19
  end
11
20
 
21
+ ##
22
+ # Produces a random name with middle name.
23
+ #
24
+ # @return [String]
25
+ #
26
+ # @example
27
+ # Faker::Name.name_with_middle #=> "Aditya Elton Douglas"
28
+ #
29
+ # @faker.version 1.6.4
12
30
  def name_with_middle
13
31
  parse('name.name_with_middle')
14
32
  end
15
33
 
34
+ ##
35
+ # Produces a random first name.
36
+ #
37
+ # @return [String]
38
+ #
39
+ # @example
40
+ # Faker::Name.first_name #=> "Kaci"
41
+ #
42
+ # @faker.version 0.9.0
16
43
  def first_name
17
44
  if parse('name.first_name').empty?
18
45
  fetch('name.first_name')
@@ -21,31 +48,102 @@ module Faker
21
48
  end
22
49
  end
23
50
 
51
+ ##
52
+ # Produces a random male first name.
53
+ #
54
+ # @return [String]
55
+ #
56
+ # @example
57
+ # Faker::Name.male_first_name #=> "Edward"
58
+ #
59
+ # @faker.version 1.9.1
24
60
  def male_first_name
25
61
  fetch('name.male_first_name')
26
62
  end
27
63
  alias first_name_men male_first_name
28
64
  alias masculine_name male_first_name
29
65
 
66
+ ##
67
+ # Produces a random female first name.
68
+ #
69
+ # @return [String]
70
+ #
71
+ # @example
72
+ # Faker::Name.female_first_name #=> "Natasha"
73
+ #
74
+ # @faker.version 1.9.1
30
75
  def female_first_name
31
76
  fetch('name.female_first_name')
32
77
  end
33
78
  alias first_name_women female_first_name
34
79
  alias feminine_name female_first_name
35
80
 
81
+ ##
82
+ # Produces a random gender neutral first name.
83
+ #
84
+ # @return [String]
85
+ #
86
+ # @example
87
+ # Faker::Name.neutral_first_name #=> "Casey"
88
+ #
89
+ # @faker.version 2.13.0
90
+ def neutral_first_name
91
+ fetch('name.neutral_first_name')
92
+ end
93
+ alias first_name_neutral neutral_first_name
94
+ alias gender_neutral_first_name neutral_first_name
95
+
96
+ ##
97
+ # Produces a random last name.
98
+ #
99
+ # @return [String]
100
+ #
101
+ # @example
102
+ # Faker::Name.last_name #=> "Ernser"
103
+ #
104
+ # @faker.version 0.9.0
36
105
  def last_name
37
106
  parse('name.last_name')
38
107
  end
39
108
  alias middle_name last_name
40
109
 
110
+ ##
111
+ # Produces a random name prefix.
112
+ #
113
+ # @return [String]
114
+ #
115
+ # @example
116
+ # Faker::Name.prefix #=> "Mr."
117
+ #
118
+ # @faker.version 0.9.0
41
119
  def prefix
42
120
  fetch('name.prefix')
43
121
  end
44
122
 
123
+ ##
124
+ # Produces a random name suffix.
125
+ #
126
+ # @return [String]
127
+ #
128
+ # @example
129
+ # Faker::Name.suffix #=> "IV"
130
+ #
131
+ # @faker.version 0.9.0
45
132
  def suffix
46
133
  fetch('name.suffix')
47
134
  end
48
135
 
136
+ ##
137
+ # Produces random initials.
138
+ #
139
+ # @param number [Integer] Number of digits that the generated initials should have.
140
+ # @return [String]
141
+ #
142
+ # @example
143
+ # Faker::Name.initials #=> "NJM"
144
+ # Faker::Name.initials(number: 2) #=> "NM"
145
+ #
146
+ # @faker.version 1.8.5
49
147
  def initials(legacy_number = NOT_GIVEN, number: 3)
50
148
  warn_for_deprecated_arguments do |keywords|
51
149
  keywords << :number if legacy_number != NOT_GIVEN
@@ -3,6 +3,15 @@
3
3
  module Faker
4
4
  class NationalHealthService < Base
5
5
  class << self
6
+ ##
7
+ # Produces a random British NHS number.
8
+ #
9
+ # @return [String]
10
+ #
11
+ # @example
12
+ # Faker::NationalHealthService.british_number #=> "403 958 5577"
13
+ #
14
+ # @faker.version 1.9.2
6
15
  def british_number
7
16
  base_number = rand(400_000_001...499_999_999)
8
17
  # If the check digit is equivalent to 10, the number is invalid.
@@ -15,6 +24,16 @@ module Faker
15
24
  .join('')
16
25
  end
17
26
 
27
+ ##
28
+ # Produces a random British NHS number's check digit.
29
+ #
30
+ # @param number [Integer] Specifies the NHS number the check digit belongs to.
31
+ # @return [Integer]
32
+ #
33
+ # @example
34
+ # Faker::NationalHealthService.check_digit(number: 400_012_114) #=> 6
35
+ #
36
+ # @faker.version 1.9.2
18
37
  def check_digit(legacy_number = NOT_GIVEN, number: 0)
19
38
  warn_for_deprecated_arguments do |keywords|
20
39
  keywords << :number if legacy_number != NOT_GIVEN
@@ -40,7 +40,7 @@ module Faker
40
40
  keywords << :digits if legacy_digits != NOT_GIVEN
41
41
  end
42
42
 
43
- '0' + (2..digits).collect { digit }.join
43
+ "0#{(2..digits).collect { digit }.join}"
44
44
  end
45
45
 
46
46
  ##
@@ -85,13 +85,11 @@ module Faker
85
85
  end
86
86
 
87
87
  l_d = number(digits: l_digits)
88
- r_d = if r_digits == 1
89
- generate(r_digits)
90
- else
91
- # Ensure the last digit is not zero
92
- # so it does not get truncated on converting to float
93
- generate(r_digits - 1).join + non_zero_digit.to_s
94
- end
88
+
89
+ # Ensure the last digit is not zero
90
+ # so it does not get truncated on converting to float
91
+ r_d = generate(r_digits - 1).join + non_zero_digit.to_s
92
+
95
93
  "#{l_d}.#{r_d}".to_f
96
94
  end
97
95
 
@@ -9,12 +9,24 @@ module Faker
9
9
  :email
10
10
 
11
11
  def initialize(name: nil, email: nil)
12
+ super()
13
+
12
14
  @name = name || "#{Name.first_name} #{Name.last_name}"
13
15
  @email = email || Internet.safe_email(name: self.name)
14
16
  @first_name, @last_name = self.name.split
15
17
  end
16
18
 
17
19
  class << self
20
+ ##
21
+ # Generate a mock Omniauth response from Google.
22
+ #
23
+ # @param name [String] A specific name to return in the response.
24
+ # @param email [String] A specific email to return in the response.
25
+ # @param uid [String] A specific UID to return in the response.
26
+ #
27
+ # @return [Hash] An auth hash in the format provided by omniauth-google.
28
+ #
29
+ # @faker.version 1.8.0
18
30
  # rubocop:disable Metrics/ParameterLists
19
31
  def google(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, uid: Number.number(digits: 9).to_s)
20
32
  # rubocop:enable Metrics/ParameterLists
@@ -57,21 +69,32 @@ module Faker
57
69
  hd: "#{Company.name.downcase}.com"
58
70
  },
59
71
  id_info: {
60
- 'iss' => 'accounts.google.com',
61
- 'at_hash' => Crypto.md5,
62
- 'email_verified' => true,
63
- 'sub' => Number.number(digits: 28).to_s,
64
- 'azp' => 'APP_ID',
65
- 'email' => auth.email,
66
- 'aud' => 'APP_ID',
67
- 'iat' => Time.forward.to_i,
68
- 'exp' => Time.forward.to_i,
69
- 'openid_id' => "https://www.google.com/accounts/o8/id?id=#{uid}"
72
+ iss: 'accounts.google.com',
73
+ at_hash: Crypto.md5,
74
+ email_verified: true,
75
+ sub: Number.number(digits: 28).to_s,
76
+ azp: 'APP_ID',
77
+ email: auth.email,
78
+ aud: 'APP_ID',
79
+ iat: Time.forward.to_i,
80
+ exp: Time.forward.to_i,
81
+ openid_id: "https://www.google.com/accounts/o8/id?id=#{uid}"
70
82
  }
71
83
  }
72
84
  }
73
85
  end
74
86
 
87
+ ##
88
+ # Generate a mock Omniauth response from Facebook.
89
+ #
90
+ # @param name [String] A specific name to return in the response.
91
+ # @param email [String] A specific email to return in the response.
92
+ # @param username [String] A specific username to return in the response.
93
+ # @param uid [String] A specific UID to return in the response.
94
+ #
95
+ # @return [Hash] An auth hash in the format provided by omniauth-facebook.
96
+ #
97
+ # @faker.version 1.8.0
75
98
  # rubocop:disable Metrics/ParameterLists
76
99
  def facebook(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_username = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, username: nil, uid: Number.number(digits: 7).to_s)
77
100
  # rubocop:enable Metrics/ParameterLists
@@ -123,6 +146,16 @@ module Faker
123
146
  }
124
147
  end
125
148
 
149
+ ##
150
+ # Generate a mock Omniauth response from Twitter.
151
+ #
152
+ # @param name [String] A specific name to return in the response.
153
+ # @param nickname [String] A specific nickname to return in the response.
154
+ # @param uid [String] A specific UID to return in the response.
155
+ #
156
+ # @return [Hash] An auth hash in the format provided by omniauth-twitter.
157
+ #
158
+ # @faker.version 1.8.0
126
159
  # rubocop:disable Metrics/ParameterLists
127
160
  def twitter(legacy_name = NOT_GIVEN, legacy_nickname = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, nickname: nil, uid: Number.number(digits: 6).to_s)
128
161
  # rubocop:enable Metrics/ParameterLists
@@ -204,6 +237,16 @@ module Faker
204
237
  }
205
238
  end
206
239
 
240
+ ##
241
+ # Generate a mock Omniauth response from LinkedIn.
242
+ #
243
+ # @param name [String] A specific name to return in the response.
244
+ # @param email [String] A specific email to return in the response.
245
+ # @param uid [String] A specific UID to return in the response.
246
+ #
247
+ # @return [Hash] An auth hash in the format provided by omniauth-linkedin.
248
+ #
249
+ # @faker.version 1.8.0
207
250
  # rubocop:disable Metrics/ParameterLists
208
251
  def linkedin(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, uid: Number.number(digits: 6).to_s)
209
252
  # rubocop:enable Metrics/ParameterLists
@@ -223,58 +266,68 @@ module Faker
223
266
  industry = Commerce.department
224
267
  url = "http://www.linkedin.com/in/#{first_name}#{last_name}"
225
268
  {
226
- 'provider' => 'linkedin',
227
- 'uid' => uid,
228
- 'info' => {
229
- 'name' => auth.name,
230
- 'email' => auth.email,
231
- 'nickname' => auth.name,
232
- 'first_name' => auth.first_name,
233
- 'last_name' => auth.last_name,
234
- 'location' => location,
235
- 'description' => description,
236
- 'image' => image,
237
- 'phone' => PhoneNumber.phone_number,
238
- 'headline' => description,
239
- 'industry' => industry,
240
- 'urls' => {
241
- 'public_profile' => url
269
+ provider: 'linkedin',
270
+ uid: uid,
271
+ info: {
272
+ name: auth.name,
273
+ email: auth.email,
274
+ nickname: auth.name,
275
+ first_name: auth.first_name,
276
+ last_name: auth.last_name,
277
+ location: location,
278
+ description: description,
279
+ image: image,
280
+ phone: PhoneNumber.phone_number,
281
+ headline: description,
282
+ industry: industry,
283
+ urls: {
284
+ public_profile: url
242
285
  }
243
286
  },
244
- 'credentials' => {
245
- 'token' => token,
246
- 'secret' => secret
287
+ credentials: {
288
+ token: token,
289
+ secret: secret
247
290
  },
248
- 'extra' => {
249
- 'access_token' => {
250
- 'token' => token,
251
- 'secret' => secret,
252
- 'consumer' => nil,
253
- 'params' => {
291
+ extra: {
292
+ access_token: {
293
+ token: token,
294
+ secret: secret,
295
+ consumer: nil,
296
+ params: {
254
297
  oauth_token: token,
255
298
  oauth_token_secret: secret,
256
299
  oauth_expires_in: Time.forward.to_i,
257
300
  oauth_authorization_expires_in: Time.forward.to_i
258
301
  },
259
- 'response' => nil
302
+ response: nil
260
303
  },
261
- 'raw_info' => {
262
- 'firstName' => auth.first_name,
263
- 'headline' => description,
264
- 'id' => uid,
265
- 'industry' => industry,
266
- 'lastName' => auth.last_name,
267
- 'location' => {
268
- 'country' => { 'code' => Address.country_code.downcase },
269
- 'name' => city_state.split(', ').first
304
+ raw_info: {
305
+ firstName: auth.first_name,
306
+ headline: description,
307
+ id: uid,
308
+ industry: industry,
309
+ lastName: auth.last_name,
310
+ location: {
311
+ country: { code: Address.country_code.downcase },
312
+ name: city_state.split(', ').first
270
313
  },
271
- 'pictureUrl' => image,
272
- 'publicProfileUrl' => url
314
+ pictureUrl: image,
315
+ publicProfileUrl: url
273
316
  }
274
317
  }
275
318
  }
276
319
  end
277
320
 
321
+ ##
322
+ # Generate a mock Omniauth response from Github.
323
+ #
324
+ # @param name [String] A specific name to return in the response.
325
+ # @param email [String] A specific email to return in the response.
326
+ # @param uid [String] A specific UID to return in the response.
327
+ #
328
+ # @return [Hash] An auth hash in the format provided by omniauth-github.
329
+ #
330
+ # @faker.version 1.8.0
278
331
  # rubocop:disable Metrics/ParameterLists
279
332
  def github(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, uid: Number.number(digits: 8).to_s)
280
333
  # rubocop:enable Metrics/ParameterLists
@@ -342,13 +395,15 @@ module Faker
342
395
  end
343
396
 
344
397
  ##
345
- # Generate a mock Omniauth response from Apple
398
+ # Generate a mock Omniauth response from Apple.
399
+ #
400
+ # @param name [String] A specific name to return in the response.
401
+ # @param email [String] A specific email to return in the response.
402
+ # @param uid [String] A specific UID to return in the response.
346
403
  #
347
- # @param name [String] A specific name to return in the response
348
- # @param email [String] A specific email to return in the response
349
- # @param uid [String] A specific UID to return in the response
404
+ # @return [Hash] An auth hash in the format provided by omniauth-apple.
350
405
  #
351
- # @return [Hash] An auth hash in the format provided by omniauth-apple
406
+ # @faker.version 2.3.0
352
407
  def apple(name: nil, email: nil, uid: nil)
353
408
  uid ||= "#{Number.number(digits: 6)}.#{Number.hexadecimal(digits: 32)}.#{Number.number(digits: 4)}"
354
409
  auth = Omniauth.new(name: name, email: email)