faker 2.12.0 → 2.16.0

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.
Files changed (201) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +240 -0
  3. data/History.md +4 -4
  4. data/README.md +18 -1
  5. data/lib/faker.rb +14 -14
  6. data/lib/faker/blockchain/aeternity.rb +4 -4
  7. data/lib/faker/blockchain/tezos.rb +28 -0
  8. data/lib/faker/books/dune.rb +15 -2
  9. data/lib/faker/books/lovecraft.rb +8 -4
  10. data/lib/faker/default/address.rb +34 -4
  11. data/lib/faker/default/app.rb +1 -1
  12. data/lib/faker/default/avatar.rb +1 -1
  13. data/lib/faker/default/bank.rb +4 -6
  14. data/lib/faker/default/barcode.rb +165 -0
  15. data/lib/faker/default/beer.rb +3 -3
  16. data/lib/faker/default/blood.rb +3 -3
  17. data/lib/faker/default/camera.rb +46 -0
  18. data/lib/faker/default/cannabis.rb +10 -0
  19. data/lib/faker/default/chile_rut.rb +47 -3
  20. data/lib/faker/default/chuck_norris.rb +1 -0
  21. data/lib/faker/default/code.rb +98 -17
  22. data/lib/faker/default/commerce.rb +1 -1
  23. data/lib/faker/default/company.rb +57 -11
  24. data/lib/faker/default/computer.rb +4 -4
  25. data/lib/faker/default/date.rb +16 -12
  26. data/lib/faker/default/driving_licence.rb +26 -2
  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 +6 -4
  30. data/lib/faker/default/finance.rb +21 -0
  31. data/lib/faker/default/food.rb +1 -1
  32. data/lib/faker/default/gender.rb +1 -1
  33. data/lib/faker/default/hipster.rb +14 -11
  34. data/lib/faker/default/id_number.rb +88 -2
  35. data/lib/faker/default/internet.rb +266 -12
  36. data/lib/faker/default/internet_http.rb +48 -0
  37. data/lib/faker/default/invoice.rb +1 -1
  38. data/lib/faker/default/json.rb +7 -6
  39. data/lib/faker/default/lorem.rb +160 -5
  40. data/lib/faker/default/lorem_flickr.rb +67 -7
  41. data/lib/faker/default/lorem_pixel.rb +23 -0
  42. data/lib/faker/default/markdown.rb +91 -0
  43. data/lib/faker/default/measurement.rb +3 -2
  44. data/lib/faker/default/military.rb +26 -0
  45. data/lib/faker/default/mountain.rb +33 -0
  46. data/lib/faker/default/name.rb +15 -0
  47. data/lib/faker/default/nhs.rb +19 -0
  48. data/lib/faker/default/number.rb +6 -8
  49. data/lib/faker/default/omniauth.rb +62 -14
  50. data/lib/faker/default/placeholdit.rb +3 -2
  51. data/lib/faker/default/relationship.rb +1 -1
  52. data/lib/faker/default/space.rb +1 -1
  53. data/lib/faker/default/string.rb +3 -2
  54. data/lib/faker/default/stripe.rb +3 -3
  55. data/lib/faker/default/vehicle.rb +1 -1
  56. data/lib/faker/default/world_cup.rb +4 -4
  57. data/lib/faker/fantasy/tolkien.rb +67 -0
  58. data/lib/faker/games/clash_of_clans.rb +48 -0
  59. data/lib/faker/games/control.rb +9 -9
  60. data/lib/faker/games/dnd.rb +91 -16
  61. data/lib/faker/games/elder_scrolls.rb +26 -0
  62. data/lib/faker/games/heroes.rb +13 -0
  63. data/lib/faker/games/heroes_of_the_storm.rb +16 -5
  64. data/lib/faker/games/minecraft.rb +113 -0
  65. data/lib/faker/games/street_fighter.rb +61 -0
  66. data/lib/faker/games/super_mario.rb +48 -0
  67. data/lib/faker/games/touhou.rb +75 -0
  68. data/lib/faker/games/warhammer_fantasy.rb +5 -5
  69. data/lib/faker/games/world_of_warcraft.rb +26 -1
  70. data/lib/faker/japanese_media/conan.rb +48 -0
  71. data/lib/faker/japanese_media/doraemon.rb +48 -0
  72. data/lib/faker/japanese_media/dragon_ball.rb +26 -0
  73. data/lib/faker/japanese_media/naruto.rb +61 -0
  74. data/lib/faker/japanese_media/studio_ghibli.rb +48 -0
  75. data/lib/faker/movies/departed.rb +3 -3
  76. data/lib/faker/movies/hobbit.rb +4 -4
  77. data/lib/faker/movies/how_to_train_your_dragon.rb +48 -0
  78. data/lib/faker/movies/lord_of_the_rings.rb +3 -3
  79. data/lib/faker/movies/movie.rb +13 -0
  80. data/lib/faker/movies/room.rb +63 -0
  81. data/lib/faker/movies/star_wars.rb +74 -2
  82. data/lib/faker/music/hiphop.rb +48 -0
  83. data/lib/faker/music/opera.rb +237 -1
  84. data/lib/faker/music/pearl_jam.rb +3 -3
  85. data/lib/faker/music/phish.rb +2 -2
  86. data/lib/faker/music/prince.rb +64 -0
  87. data/lib/faker/music/rock_band.rb +12 -0
  88. data/lib/faker/music/rush.rb +37 -0
  89. data/lib/faker/music/show.rb +3 -3
  90. data/lib/faker/quotes/quote.rb +26 -0
  91. data/lib/faker/quotes/rajnikanth.rb +1 -0
  92. data/lib/faker/quotes/shakespeare.rb +34 -0
  93. data/lib/faker/sports/volleyball.rb +74 -0
  94. data/lib/faker/tv_shows/aqua_teen_hunger_force.rb +13 -0
  95. data/lib/faker/tv_shows/big_bang_theory.rb +37 -0
  96. data/lib/faker/tv_shows/buffy.rb +17 -4
  97. data/lib/faker/tv_shows/dr_who.rb +1 -1
  98. data/lib/faker/tv_shows/final_space.rb +51 -0
  99. data/lib/faker/tv_shows/futurama.rb +65 -0
  100. data/lib/faker/tv_shows/simpsons.rb +14 -0
  101. data/lib/faker/tv_shows/suits.rb +3 -3
  102. data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +17 -4
  103. data/lib/faker/version.rb +1 -1
  104. data/lib/helpers/base58.rb +1 -1
  105. data/lib/helpers/char.rb +20 -26
  106. data/lib/helpers/unique_generator.rb +3 -2
  107. data/lib/locales/de-AT.yml +4 -2
  108. data/lib/locales/de-CH.yml +3 -1
  109. data/lib/locales/de.yml +4 -2
  110. data/lib/locales/en-AU.yml +8 -2
  111. data/lib/locales/en-GB.yml +1 -1
  112. data/lib/locales/en-IND.yml +2 -1
  113. data/lib/locales/en-MS.yml +2 -1
  114. data/lib/locales/en-NEP.yml +4 -1
  115. data/lib/locales/en-NZ.yml +3 -1
  116. data/lib/locales/en-PAK.yml +2 -1
  117. data/lib/locales/en-SG.yml +2 -1
  118. data/lib/locales/en-US.yml +10 -10
  119. data/lib/locales/en-au-ocker.yml +2 -1
  120. data/lib/locales/en.yml +0 -3
  121. data/lib/locales/en/adjective.yml +179 -0
  122. data/lib/locales/en/animal.yml +1 -1
  123. data/lib/locales/en/aqua_teen_hunger_force.yml +33 -1
  124. data/lib/locales/en/bank.yml +1 -1
  125. data/lib/locales/en/barcode.yml +24 -0
  126. data/lib/locales/en/big_bang_theory.yml +38 -0
  127. data/lib/locales/en/buffy.yml +1 -1
  128. data/lib/locales/en/camera.yml +611 -0
  129. data/lib/locales/en/clash_of_clan.yml +101 -0
  130. data/lib/locales/en/company.yml +2 -2
  131. data/lib/locales/en/conan.yml +171 -0
  132. data/lib/locales/en/demographic.yml +218 -5
  133. data/lib/locales/en/dnd.yml +430 -33
  134. data/lib/locales/en/doraemon.yml +286 -0
  135. data/lib/locales/en/dota.yml +531 -63
  136. data/lib/locales/en/dragon_ball.yml +243 -1
  137. data/lib/locales/en/driving_license.yml +181 -0
  138. data/lib/locales/en/drone.yml +95 -0
  139. data/lib/locales/en/dune.yml +401 -131
  140. data/lib/locales/en/elder_scrolls.yml +583 -9
  141. data/lib/locales/en/fallout.yml +311 -133
  142. data/lib/locales/en/final_space.yml +37 -0
  143. data/lib/locales/en/finance.yml +53 -0
  144. data/lib/locales/en/football.yml +3 -3
  145. data/lib/locales/en/fresh_prince_of_bel_air.yml +1 -1
  146. data/lib/locales/en/futurama.yml +344 -0
  147. data/lib/locales/en/half_life.yml +84 -3
  148. data/lib/locales/en/heroes.yml +408 -3
  149. data/lib/locales/en/heroes_of_the_storm.yml +131 -4
  150. data/lib/locales/en/how_to_train_your_dragon.yml +174 -0
  151. data/lib/locales/en/jack_handey.yml +54 -0
  152. data/lib/locales/en/league_of_legends.yml +285 -6
  153. data/lib/locales/en/lebowski.yml +1 -1
  154. data/lib/locales/en/military.yml +179 -5
  155. data/lib/locales/en/minecraft.yml +663 -0
  156. data/lib/locales/en/mountain.yml +158 -0
  157. data/lib/locales/en/movie.yml +192 -1
  158. data/lib/locales/en/music.yml +451 -29
  159. data/lib/locales/en/myst.yml +87 -31
  160. data/lib/locales/en/name.yml +5 -4
  161. data/lib/locales/en/naruto.yml +231 -0
  162. data/lib/locales/en/opera.yml +168 -0
  163. data/lib/locales/en/overwatch.yml +2650 -2622
  164. data/lib/locales/en/pokemon.yml +417 -4
  165. data/lib/locales/en/prince.yml +227 -0
  166. data/lib/locales/en/quote.yml +692 -163
  167. data/lib/locales/en/rock_band.yml +1 -0
  168. data/lib/locales/en/room.yml +68 -0
  169. data/lib/locales/en/rush.yml +32 -0
  170. data/lib/locales/en/simpsons.yml +668 -0
  171. data/lib/locales/en/source.yml +30 -0
  172. data/lib/locales/en/star_trek.yml +1 -1
  173. data/lib/locales/en/star_wars.yml +1 -0
  174. data/lib/locales/en/street_fighter.yml +1524 -0
  175. data/lib/locales/en/studio_ghibli.yml +107 -0
  176. data/lib/locales/en/super_mario.yml +58 -0
  177. data/lib/locales/en/super_smash_bros.yml +18 -4
  178. data/lib/locales/en/tolkien.yml +2453 -0
  179. data/lib/locales/en/touhou.yml +839 -0
  180. data/lib/locales/en/volleyball.yml +501 -0
  181. data/lib/locales/en/witcher.yml +389 -7
  182. data/lib/locales/en/world_of_warcraft.yml +122 -4
  183. data/lib/locales/en/zelda.yml +962 -4
  184. data/lib/locales/es.yml +56 -0
  185. data/lib/locales/fi-FI.yml +1 -1
  186. data/lib/locales/fr-CA.yml +19 -5
  187. data/lib/locales/fr-CH.yml +2 -2
  188. data/lib/locales/fr.yml +12 -6
  189. data/lib/locales/id.yml +3 -1
  190. data/lib/locales/it.yml +2 -1
  191. data/lib/locales/ja.yml +10 -1
  192. data/lib/locales/ko.yml +34 -24
  193. data/lib/locales/nb-NO.yml +4 -2
  194. data/lib/locales/pt-BR.yml +1 -1
  195. data/lib/locales/pt.yml +3 -1
  196. data/lib/locales/ru.yml +3 -1
  197. data/lib/locales/sk.yml +4 -2
  198. data/lib/locales/uk.yml +2 -0
  199. metadata +66 -18
  200. data/lib/locales/en/hobbit.yml +0 -19
  201. data/lib/locales/en/lord_of_the_rings.yml +0 -6
@@ -18,6 +18,29 @@ module Faker
18
18
  transport].freeze
19
19
 
20
20
  # rubocop:disable Metrics/ParameterLists
21
+
22
+ ##
23
+ # Produces a random image URL from lorempixel.com.
24
+ #
25
+ # @param size [String] Specifies the size of image to generate.
26
+ # @param is_gray [Boolean] Determines if the image is gray.
27
+ # @param category [Symbol] Adds the category of the generated image to the URL.
28
+ # @param number [Integer] Adds a number as part of the URL.
29
+ # @param text [Integer] Adds dummy text as part of the URL.
30
+ # @param secure [Boolean] Changes the image URL between http and https.
31
+ # @return [String]
32
+ #
33
+ # @example
34
+ # Faker::LoremPixel.image #=> "https://lorempixel.com/300/300"
35
+ # Faker::LoremPixel.image(size: "50x60") #=> "https://lorempixel.com/50/60"
36
+ # Faker::LoremPixel.image(size: "50x60", is_gray: true) #=> "https://lorempixel.com/g/50/60"
37
+ # Faker::LoremPixel.image(size: "50x60", is_gray: false, category: 'sports') #=> "https://lorempixel.com/50/60/sports"
38
+ # Faker::LoremPixel.image(size: "50x60", is_gray: false, category: 'sports', number: 3) #=> "https://lorempixel.com/50/60/sports/3"
39
+ # Faker::LoremPixel.image(size: "50x60", is_gray: false, category: 'sports', number: 3, text: 'Dummy-text') #=> "https://lorempixel.com/50/60/sports/3/Dummy-text"
40
+ # Faker::LoremPixel.image(size: "50x60", is_gray: false, category: 'sports', number: nil, text: 'Dummy-text') #=> "https://lorempixel.com/50/60/sports/Dummy-text"
41
+ # Faker::LoremPixel.image(secure: false) #=> "http://lorempixel.com/300/300"
42
+ #
43
+ # @faker.version 1.7.0
21
44
  def image(legacy_size = NOT_GIVEN, legacy_is_gray = NOT_GIVEN, legacy_category = NOT_GIVEN, legacy_number = NOT_GIVEN, legacy_text = NOT_GIVEN, legacy_secure = NOT_GIVEN, size: '300x300', is_gray: false, category: nil, number: nil, text: nil, secure: true)
22
45
  warn_for_deprecated_arguments do |keywords|
23
46
  keywords << :size if legacy_size != NOT_GIVEN
@@ -3,10 +3,28 @@
3
3
  module Faker
4
4
  class Markdown < Base
5
5
  class << self
6
+ ##
7
+ # Produces a random header format.
8
+ #
9
+ # @return [String]
10
+ #
11
+ # @example
12
+ # Faker::Markdown.headers #=> "##### Autem"
13
+ #
14
+ # @faker.version 1.8.0
6
15
  def headers
7
16
  "#{fetch('markdown.headers')} #{Lorem.word.capitalize}"
8
17
  end
9
18
 
19
+ ##
20
+ # Produces a random emphasis formatting on a random word in two sentences.
21
+ #
22
+ # @return [String]
23
+ #
24
+ # @example
25
+ # Faker::Markdown.emphasis #=> "_Incidunt atque quis repellat id impedit. Quas numquam quod incidunt dicta non. Blanditiis delectus laudantium atque reiciendis qui._"
26
+ #
27
+ # @faker.version 1.8.0
10
28
  def emphasis
11
29
  paragraph = Faker::Lorem.paragraph(sentence_count: 3)
12
30
  words = paragraph.split(' ')
@@ -16,6 +34,15 @@ module Faker
16
34
  words.join(' ')
17
35
  end
18
36
 
37
+ ##
38
+ # Produces a random ordered list of items between 1 and 10 randomly.
39
+ #
40
+ # @return [String]
41
+ #
42
+ # @example
43
+ # Faker::Markdown.ordered_list #=> "1. Qui reiciendis non consequatur atque.\n2. Quo doloremque veritatis tempora aut.\n3. Aspernatur.\n4. Ea ab.\n5. Qui.\n6. Sit pariatur nemo eveniet.\n7. Molestiae aut.\n8. Nihil molestias iure placeat.\n9. Dolore autem quisquam."
44
+ #
45
+ # @faker.version 1.8.0
19
46
  def ordered_list
20
47
  number = rand(1..10)
21
48
 
@@ -26,6 +53,15 @@ module Faker
26
53
  result.join('')
27
54
  end
28
55
 
56
+ ##
57
+ # Produces a random unordered list of items between 1 and 10 randomly.
58
+ #
59
+ # @return [String]
60
+ #
61
+ # @example
62
+ # Faker::Markdown.unordered_list #=> "* Voluptatum aliquid tempora molestiae facilis non sed.\n* Nostrum omnis iste impedit voluptatum dolor.\n* Esse quidem et facere."
63
+ #
64
+ # @faker.version 1.8.0
29
65
  def unordered_list
30
66
  number = rand(1..10)
31
67
 
@@ -36,14 +72,41 @@ module Faker
36
72
  result.join('')
37
73
  end
38
74
 
75
+ ##
76
+ # Produces a random inline code snippet between two sentences.
77
+ #
78
+ # @return [String]
79
+ #
80
+ # @example
81
+ # Faker::Markdown.inline_code #=> "Aut eos quis suscipit. `Dignissimos voluptatem expedita qui.` Quo doloremque veritatis tempora aut."
82
+ #
83
+ # @faker.version 1.8.0
39
84
  def inline_code
40
85
  "`#{Faker::Lorem.sentence(word_count: 1)}`"
41
86
  end
42
87
 
88
+ ##
89
+ # Produces a random code block formatted in Ruby.
90
+ #
91
+ # @return [String]
92
+ #
93
+ # @example
94
+ # Faker::Markdown.block_code #=> "```ruby\nEos quasi qui.\n```"
95
+ #
96
+ # @faker.version 1.8.0
43
97
  def block_code
44
98
  "```ruby\n#{Lorem.sentence(word_count: 1)}\n```"
45
99
  end
46
100
 
101
+ ##
102
+ # Produces a random 3x4 table with a row of headings, a row of hyphens and two rows of data
103
+ #
104
+ # @return [String]
105
+ #
106
+ # @example
107
+ # Faker::Markdown.table #=> "ad | similique | voluptatem\n---- | ---- | ----\ncorrupti | est | rerum\nmolestiae | quidem | et"
108
+ #
109
+ # @faker.version 1.8.0
47
110
  def table
48
111
  table = []
49
112
  3.times do
@@ -53,12 +116,40 @@ module Faker
53
116
  table.join("\n")
54
117
  end
55
118
 
119
+ ##
120
+ # Produces a random method from the methods above, excluding the methods listed in the arguments.
121
+ #
122
+ # @overload random(methods)
123
+ # @param methods [Symbol] Specify which methods to exclude.
124
+ #
125
+ # @return [String, Array<String>]
126
+ #
127
+ # @example
128
+ # Faker::Markdown.random #=> returns output from a single method outlined above
129
+ # Faker::Markdown.random("table") #=> returns output from any single method outlined above except for "table"
130
+ # Faker::Markdown.random("ordered_list", "unordered_list") #=> returns output from any single method outlined above except for either ordered_list and unordered_list
131
+ #
132
+ # @faker.version 1.8.0
56
133
  def random(*args)
57
134
  method_list = available_methods
58
135
  args&.each { |ex| method_list.delete_if { |meth| meth == ex.to_sym } }
59
136
  send(method_list[rand(0..method_list.length - 1)])
60
137
  end
61
138
 
139
+ ##
140
+ # Produces a simulated blog-esque text-heavy block in markdown
141
+ #
142
+ # Keyword arguments: sentences, repeat
143
+ # @param sentences [Integer] Specifies how many sentences make a text block.
144
+ # @param repeat [Integer] Specifies how many times the text block repeats.
145
+ # @return [String]
146
+ #
147
+ # @example
148
+ # Faker::Markdown.sandwich #=> returns newline separated content of 1 header, 1 default lorem paragraph, and 1 random markdown element
149
+ # Faker::Markdown.sandwich(sentences: 5) #=> returns newline separated content of 1 header, 1 5-sentence lorem paragraph, and 1 random markdown element
150
+ # Faker::Markdown.sandwich(sentences: 6, repeat: 3) #=> returns newline separated content of 1 header, and then 3 sections consisting of, here, 1 6-sentence lorem paragraph and 1 random markdown element. The random markdown element is chosen at random in each iteration of the paragraph-markdown pairing.
151
+ #
152
+ # @faker.version 1.8.0
62
153
  def sandwich(legacy_sentences = NOT_GIVEN, legacy_repeat = NOT_GIVEN, sentences: 3, repeat: 1)
63
154
  warn_for_deprecated_arguments do |keywords|
64
155
  keywords << :sentences if legacy_sentences != NOT_GIVEN
@@ -172,9 +172,10 @@ module Faker
172
172
 
173
173
  def define_measurement_locale(amount, locale)
174
174
  ensure_valid_amount(amount)
175
- if amount == ALL
175
+ case amount
176
+ when ALL
176
177
  make_plural(fetch("measurement.#{locale}"))
177
- elsif amount == NONE
178
+ when NONE
178
179
  fetch("measurement.#{locale}")
179
180
  else
180
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
@@ -78,6 +78,21 @@ module Faker
78
78
  alias first_name_women female_first_name
79
79
  alias feminine_name female_first_name
80
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
+
81
96
  ##
82
97
  # Produces a random last name.
83
98
  #
@@ -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,6 +9,8 @@ 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
@@ -16,8 +18,18 @@ module Faker
16
18
 
17
19
  class << self
18
20
  # rubocop:disable Metrics/ParameterLists
21
+
22
+ ##
23
+ # Generate a mock Omniauth response from Google.
24
+ #
25
+ # @param name [String] A specific name to return in the response.
26
+ # @param email [String] A specific email to return in the response.
27
+ # @param uid [String] A specific UID to return in the response.
28
+ #
29
+ # @return [Hash] An auth hash in the format provided by omniauth-google.
30
+ #
31
+ # @faker.version 1.8.0
19
32
  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
- # rubocop:enable Metrics/ParameterLists
21
33
  warn_for_deprecated_arguments do |keywords|
22
34
  keywords << :name if legacy_name != NOT_GIVEN
23
35
  keywords << :email if legacy_email != NOT_GIVEN
@@ -72,9 +84,18 @@ module Faker
72
84
  }
73
85
  end
74
86
 
75
- # rubocop:disable Metrics/ParameterLists
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
76
98
  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
- # rubocop:enable Metrics/ParameterLists
78
99
  warn_for_deprecated_arguments do |keywords|
79
100
  keywords << :name if legacy_name != NOT_GIVEN
80
101
  keywords << :email if legacy_email != NOT_GIVEN
@@ -123,9 +144,17 @@ module Faker
123
144
  }
124
145
  end
125
146
 
126
- # rubocop:disable Metrics/ParameterLists
147
+ ##
148
+ # Generate a mock Omniauth response from Twitter.
149
+ #
150
+ # @param name [String] A specific name to return in the response.
151
+ # @param nickname [String] A specific nickname to return in the response.
152
+ # @param uid [String] A specific UID to return in the response.
153
+ #
154
+ # @return [Hash] An auth hash in the format provided by omniauth-twitter.
155
+ #
156
+ # @faker.version 1.8.0
127
157
  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
- # rubocop:enable Metrics/ParameterLists
129
158
  warn_for_deprecated_arguments do |keywords|
130
159
  keywords << :name if legacy_name != NOT_GIVEN
131
160
  keywords << :nickname if legacy_nickname != NOT_GIVEN
@@ -204,9 +233,17 @@ module Faker
204
233
  }
205
234
  end
206
235
 
207
- # rubocop:disable Metrics/ParameterLists
236
+ ##
237
+ # Generate a mock Omniauth response from LinkedIn.
238
+ #
239
+ # @param name [String] A specific name to return in the response.
240
+ # @param email [String] A specific email to return in the response.
241
+ # @param uid [String] A specific UID to return in the response.
242
+ #
243
+ # @return [Hash] An auth hash in the format provided by omniauth-linkedin.
244
+ #
245
+ # @faker.version 1.8.0
208
246
  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
- # rubocop:enable Metrics/ParameterLists
210
247
  warn_for_deprecated_arguments do |keywords|
211
248
  keywords << :name if legacy_name != NOT_GIVEN
212
249
  keywords << :email if legacy_email != NOT_GIVEN
@@ -275,9 +312,17 @@ module Faker
275
312
  }
276
313
  end
277
314
 
278
- # rubocop:disable Metrics/ParameterLists
315
+ ##
316
+ # Generate a mock Omniauth response from Github.
317
+ #
318
+ # @param name [String] A specific name to return in the response.
319
+ # @param email [String] A specific email to return in the response.
320
+ # @param uid [String] A specific UID to return in the response.
321
+ #
322
+ # @return [Hash] An auth hash in the format provided by omniauth-github.
323
+ #
324
+ # @faker.version 1.8.0
279
325
  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
- # rubocop:enable Metrics/ParameterLists
281
326
  warn_for_deprecated_arguments do |keywords|
282
327
  keywords << :name if legacy_name != NOT_GIVEN
283
328
  keywords << :email if legacy_email != NOT_GIVEN
@@ -340,15 +385,18 @@ module Faker
340
385
  }
341
386
  }
342
387
  end
388
+ # rubocop:enable Metrics/ParameterLists
343
389
 
344
390
  ##
345
- # Generate a mock Omniauth response from Apple
391
+ # Generate a mock Omniauth response from Apple.
392
+ #
393
+ # @param name [String] A specific name to return in the response.
394
+ # @param email [String] A specific email to return in the response.
395
+ # @param uid [String] A specific UID to return in the response.
346
396
  #
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
397
+ # @return [Hash] An auth hash in the format provided by omniauth-apple.
350
398
  #
351
- # @return [Hash] An auth hash in the format provided by omniauth-apple
399
+ # @faker.version 2.3.0
352
400
  def apple(name: nil, email: nil, uid: nil)
353
401
  uid ||= "#{Number.number(digits: 6)}.#{Number.hexadecimal(digits: 32)}.#{Number.number(digits: 4)}"
354
402
  auth = Omniauth.new(name: name, email: email)