faker 2.19.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +346 -7
  3. data/History.md +1 -1
  4. data/README.md +198 -104
  5. data/lib/faker/blockchain/aeternity.rb +1 -1
  6. data/lib/faker/blockchain/ethereum.rb +1 -1
  7. data/lib/faker/blockchain/tezos.rb +1 -1
  8. data/lib/faker/books/dune.rb +2 -10
  9. data/lib/faker/books/lovecraft.rb +7 -38
  10. data/lib/faker/books/the_kingkiller_chronicle.rb +61 -0
  11. data/lib/faker/default/address.rb +5 -25
  12. data/lib/faker/default/alphanumeric.rb +2 -8
  13. data/lib/faker/default/app.rb +1 -10
  14. data/lib/faker/default/avatar.rb +1 -12
  15. data/lib/faker/default/bank.rb +9 -17
  16. data/lib/faker/default/boolean.rb +1 -4
  17. data/lib/faker/default/chile_rut.rb +8 -14
  18. data/lib/faker/default/code.rb +11 -24
  19. data/lib/faker/default/color.rb +77 -6
  20. data/lib/faker/default/commerce.rb +3 -17
  21. data/lib/faker/default/company.rb +23 -20
  22. data/lib/faker/default/crypto_coin.rb +3 -15
  23. data/lib/faker/default/date.rb +5 -38
  24. data/lib/faker/default/demographic.rb +1 -5
  25. data/lib/faker/default/driving_licence.rb +1 -11
  26. data/lib/faker/default/drone.rb +1 -1
  27. data/lib/faker/default/file.rb +5 -24
  28. data/lib/faker/default/finance.rb +17 -7
  29. data/lib/faker/default/food.rb +14 -1
  30. data/lib/faker/default/hipster.rb +6 -45
  31. data/lib/faker/default/id_number.rb +108 -11
  32. data/lib/faker/default/internet.rb +168 -129
  33. data/lib/faker/default/invoice.rb +4 -17
  34. data/lib/faker/default/json.rb +2 -20
  35. data/lib/faker/default/lorem.rb +20 -76
  36. data/lib/faker/default/lorem_flickr.rb +4 -32
  37. data/lib/faker/default/markdown.rb +6 -11
  38. data/lib/faker/default/marketing.rb +1 -1
  39. data/lib/faker/default/measurement.rb +16 -48
  40. data/lib/faker/default/name.rb +1 -5
  41. data/lib/faker/default/nation.rb +0 -3
  42. data/lib/faker/default/nhs.rb +2 -6
  43. data/lib/faker/default/number.rb +10 -55
  44. data/lib/faker/default/omniauth.rb +51 -41
  45. data/lib/faker/default/phone_number.rb +2 -6
  46. data/lib/faker/default/placeholdit.rb +1 -12
  47. data/lib/faker/default/relationship.rb +1 -5
  48. data/lib/faker/default/religion.rb +6 -0
  49. data/lib/faker/default/source.rb +3 -16
  50. data/lib/faker/default/string.rb +1 -8
  51. data/lib/faker/default/stripe.rb +4 -20
  52. data/lib/faker/default/time.rb +4 -34
  53. data/lib/faker/default/twitter.rb +7 -23
  54. data/lib/faker/default/types.rb +5 -27
  55. data/lib/faker/default/vehicle.rb +29 -51
  56. data/lib/faker/default/vulnerability_identifier.rb +23 -0
  57. data/lib/faker/default/world_cup.rb +2 -11
  58. data/lib/faker/games/clash_of_clans.rb +1 -1
  59. data/lib/faker/games/dnd.rb +49 -7
  60. data/lib/faker/games/dota.rb +1 -5
  61. data/lib/faker/games/minecraft.rb +1 -1
  62. data/lib/faker/games/myst.rb +1 -1
  63. data/lib/faker/games/tarkov.rb +205 -0
  64. data/lib/faker/japanese_media/cowboy_bebop.rb +61 -0
  65. data/lib/faker/japanese_media/fullmetal_alchemist_brotherhood.rb +48 -0
  66. data/lib/faker/japanese_media/kamen_rider.rb +102 -0
  67. data/lib/faker/japanese_media/one_piece.rb +1 -1
  68. data/lib/faker/movies/avatar.rb +49 -0
  69. data/lib/faker/movies/hackers.rb +48 -0
  70. data/lib/faker/movies/star_wars.rb +1 -5
  71. data/lib/faker/movies/tron.rb +161 -0
  72. data/lib/faker/quotes/quote.rb +13 -0
  73. data/lib/faker/religion/bible.rb +50 -0
  74. data/lib/faker/sports/chess.rb +90 -0
  75. data/lib/faker/sports/mountaineering.rb +22 -0
  76. data/lib/faker/sports/sport.rb +116 -0
  77. data/lib/faker/travel/airport.rb +43 -0
  78. data/lib/faker/tv_shows/brooklyn_nine_nine.rb +38 -0
  79. data/lib/faker/tv_shows/michael_scott.rb +0 -3
  80. data/lib/faker/tv_shows/spongebob.rb +50 -0
  81. data/lib/faker/version.rb +1 -1
  82. data/lib/faker.rb +15 -64
  83. data/lib/helpers/base58.rb +1 -1
  84. data/lib/helpers/unique_generator.rb +13 -11
  85. data/lib/locales/ar.yml +6 -1
  86. data/lib/locales/bg.yml +1 -1
  87. data/lib/locales/da-DK.yml +1 -1
  88. data/lib/locales/de-AT.yml +3 -4
  89. data/lib/locales/de-CH.yml +1 -1
  90. data/lib/locales/de.yml +1 -1
  91. data/lib/locales/en/address.yml +2 -3
  92. data/lib/locales/en/airport.yml +381 -0
  93. data/lib/locales/en/australia.yml +3 -4
  94. data/lib/locales/en/avatar.yml +31 -0
  95. data/lib/locales/en/bible.yml +90 -0
  96. data/lib/locales/en/brooklyn_nine_nine.yml +35 -0
  97. data/lib/locales/en/cat.yml +1 -1
  98. data/lib/locales/en/chess.yml +103 -0
  99. data/lib/locales/en/coffee.yml +1 -1
  100. data/lib/locales/en/company.yml +1 -0
  101. data/lib/locales/en/computer.yml +23 -4
  102. data/lib/locales/en/cowboy_bebop.yml +163 -0
  103. data/lib/locales/en/dnd.yml +186 -1
  104. data/lib/locales/en/dota.yml +113 -0
  105. data/lib/locales/en/file.yml +9 -1
  106. data/lib/locales/en/finance.yml +3 -1
  107. data/lib/locales/en/fma_brotherhood.yml +78 -0
  108. data/lib/locales/en/food.yml +12 -0
  109. data/lib/locales/en/game.yml +11 -0
  110. data/lib/locales/en/hackers.yml +53 -0
  111. data/lib/locales/en/heroes.yml +2 -2
  112. data/lib/locales/en/internet.yml +140 -3
  113. data/lib/locales/en/kamen_rider.yml +452 -0
  114. data/lib/locales/en/mitch_hedberg.yml +46 -0
  115. data/lib/locales/en/mountain.yml +14 -1
  116. data/lib/locales/en/mountaineering.yml +14 -0
  117. data/lib/locales/en/movie.yml +2 -1
  118. data/lib/locales/en/naruto.yml +2 -3
  119. data/lib/locales/en/one_piece.yml +1 -1
  120. data/lib/locales/en/opera.yml +1 -1
  121. data/lib/locales/en/overwatch.yml +5 -7
  122. data/lib/locales/en/source.yml +5 -0
  123. data/lib/locales/en/spongebob.yml +489 -0
  124. data/lib/locales/en/sport.yml +130 -0
  125. data/lib/locales/en/star_wars.yml +1 -1
  126. data/lib/locales/en/stranger_thing.yml +1 -1
  127. data/lib/locales/en/super_smash_bros.yml +2 -0
  128. data/lib/locales/en/tarkov.yml +593 -0
  129. data/lib/locales/en/the_kingkiller_chronicle.yml +56 -0
  130. data/lib/locales/en/tron.yml +227 -0
  131. data/lib/locales/en/vehicle.yml +2809 -75
  132. data/lib/locales/en-AU.yml +2 -2
  133. data/lib/locales/en-CA.yml +2 -1
  134. data/lib/locales/en-GB.yml +2 -1
  135. data/lib/locales/en-MS.yml +1 -0
  136. data/lib/locales/en-NG.yml +1 -0
  137. data/lib/locales/en-NZ.yml +1 -0
  138. data/lib/locales/en-PAK.yml +1 -0
  139. data/lib/locales/en-SG.yml +1 -0
  140. data/lib/locales/en-UG.yml +1 -0
  141. data/lib/locales/en-US.yml +2 -2
  142. data/lib/locales/en-ZA.yml +1 -1
  143. data/lib/locales/en-au-ocker.yml +2 -0
  144. data/lib/locales/es-AR.yml +3 -2
  145. data/lib/locales/es-MX.yml +1 -1
  146. data/lib/locales/es.yml +2 -2
  147. data/lib/locales/fi-FI.yml +3 -1
  148. data/lib/locales/fr/address.yml +0 -1
  149. data/lib/locales/fr/adjective.yml +266 -0
  150. data/lib/locales/fr/ancient.yml +141 -0
  151. data/lib/locales/fr-CA.yml +1 -1
  152. data/lib/locales/fr-CH.yml +1 -1
  153. data/lib/locales/hy.yml +2 -1
  154. data/lib/locales/it.yml +1 -0
  155. data/lib/locales/ja/address.yml +258 -4169
  156. data/lib/locales/ja/adjective.yml +148 -0
  157. data/lib/locales/ja/dog.yml +1 -0
  158. data/lib/locales/ja/emotion.yml +51 -0
  159. data/lib/locales/ja/lorem.yml +2 -2
  160. data/lib/locales/ja/naruto.yml +230 -0
  161. data/lib/locales/ja/relationship.yml +10 -0
  162. data/lib/locales/ja/super_mario.yml +1 -1
  163. data/lib/locales/ja/super_smash_bros.yml +8 -0
  164. data/lib/locales/ko.yml +1 -0
  165. data/lib/locales/lt.yml +34 -0
  166. data/lib/locales/lv.yml +1 -1
  167. data/lib/locales/mi-NZ.yml +283 -0
  168. data/lib/locales/nb-NO.yml +1 -0
  169. data/lib/locales/nl.yml +1 -0
  170. data/lib/locales/pl.yml +2 -2
  171. data/lib/locales/pt-BR.yml +5 -0
  172. data/lib/locales/pt.yml +1 -1
  173. data/lib/locales/ru.yml +1 -0
  174. data/lib/locales/sk.yml +1 -0
  175. data/lib/locales/sv.yml +1 -0
  176. data/lib/locales/th.yml +76 -76
  177. data/lib/locales/tr.yml +1 -0
  178. data/lib/locales/uk.yml +1 -0
  179. data/lib/locales/vi.yml +1 -0
  180. data/lib/locales/zh-CN.yml +1 -0
  181. data/lib/locales/zh-TW.yml +1 -0
  182. metadata +96 -33
  183. data/lib/faker/default/fillmurray.rb +0 -45
  184. data/lib/faker/default/lorem_pixel.rb +0 -70
  185. /data/lib/faker/default/{faker_adjective.rb → adjective.rb} +0 -0
@@ -17,12 +17,7 @@ module Faker
17
17
  # Faker::Finance.amount_between(0, 10) #=> 4.33
18
18
  #
19
19
  # @faker.version 1.9.0
20
- def amount_between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 0, to: 0)
21
- warn_for_deprecated_arguments do |keywords|
22
- keywords << :from if legacy_from != NOT_GIVEN
23
- keywords << :to if legacy_to != NOT_GIVEN
24
- end
25
-
20
+ def amount_between(from: 0, to: 0)
26
21
  Faker::Base.rand_in_range(from, to).round(2)
27
22
  end
28
23
 
@@ -36,11 +31,7 @@ module Faker
36
31
  # Faker::Invoice.creditor_reference #=> "RF34118592570724925498"
37
32
  #
38
33
  # @faker.version 1.9.0
39
- def creditor_reference(legacy_ref = NOT_GIVEN, ref: '')
40
- warn_for_deprecated_arguments do |keywords|
41
- keywords << :ref if legacy_ref != NOT_GIVEN
42
- end
43
-
34
+ def creditor_reference(ref: '')
44
35
  ref = reference if ref.empty?
45
36
 
46
37
  "RF#{iban_checksum('RF', ref)}#{ref}"
@@ -56,11 +47,7 @@ module Faker
56
47
  # Faker::Invoice.reference #=> "45656646957845"
57
48
  #
58
49
  # @faker.version 1.9.0
59
- def reference(legacy_ref = NOT_GIVEN, ref: '')
60
- warn_for_deprecated_arguments do |keywords|
61
- keywords << :ref if legacy_ref != NOT_GIVEN
62
- end
63
-
50
+ def reference(ref: '')
64
51
  pattern = fetch('invoice.reference.pattern')
65
52
 
66
53
  ref = Base.regexify(/#{pattern}/) if ref.empty?
@@ -115,7 +102,7 @@ module Faker
115
102
  mod10_remainder(weighted_sum)
116
103
  end
117
104
 
118
- # Calculates weigthed sum
105
+ # Calculates weighted sum
119
106
  #
120
107
  # For example with 12345678, [1,2]
121
108
  # Ref.num. 1 2 3 4 5 6 7 8
@@ -20,12 +20,7 @@ module Faker
20
20
  # something to eat - it's all been wrong."}
21
21
  #
22
22
  # @faker.version 1.9.2
23
- def shallow_json(legacy_width = NOT_GIVEN, legacy_options = NOT_GIVEN, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' })
24
- warn_for_deprecated_arguments do |keywords|
25
- keywords << :width if legacy_width != NOT_GIVEN
26
- keywords << :options if legacy_options != NOT_GIVEN
27
- end
28
-
23
+ def shallow_json(width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' })
29
24
  options[:key] = "Faker::#{options[:key]}"
30
25
  options[:value] = "Faker::#{options[:value]}"
31
26
 
@@ -33,8 +28,6 @@ module Faker
33
28
  JSON.generate(hash)
34
29
  end
35
30
 
36
- # rubocop:disable Metrics/ParameterLists
37
-
38
31
  ##
39
32
  # Produces a random nested JSON formatted string that can take JSON as an additional argument.
40
33
  #
@@ -73,17 +66,7 @@ module Faker
73
66
  # {"Rick":"Wiza","Bonita":"Bayer","Gardner":"Auer","Felicity":"Abbott"}}}
74
67
  #
75
68
  # @faker.version 1.9.2
76
- def add_depth_to_json(legacy_json = NOT_GIVEN, legacy_width = NOT_GIVEN, legacy_options = NOT_GIVEN, json: shallow_json, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' })
77
- warn_for_deprecated_arguments do |keywords|
78
- keywords << :json if legacy_json != NOT_GIVEN
79
- end
80
- warn_for_deprecated_arguments do |keywords|
81
- keywords << :width if legacy_width != NOT_GIVEN
82
- end
83
- warn_for_deprecated_arguments do |keywords|
84
- keywords << :options if legacy_options != NOT_GIVEN
85
- end
86
-
69
+ def add_depth_to_json(json: shallow_json, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' })
87
70
  options[:key] = "Faker::#{options[:key]}"
88
71
  options[:value] = "Faker::#{options[:value]}"
89
72
 
@@ -93,7 +76,6 @@ module Faker
93
76
  end
94
77
  JSON.generate(hash)
95
78
  end
96
- # rubocop:enable Metrics/ParameterLists
97
79
 
98
80
  private
99
81
 
@@ -28,19 +28,19 @@ module Faker
28
28
  # Faker::Lorem.words #=> ["hic", "quia", "nihil"]
29
29
  # Faker::Lorem.words(number: 4) #=> ["est", "temporibus", "et", "quaerat"]
30
30
  # Faker::Lorem.words(number: 4, supplemental: true) #=> ["nisi", "sit", "allatus", "consequatur"]
31
+ # Faker::Lorem.words(number: 4, supplemental: true, exclude_words: 'sit') #=> ["nisi", "allatus", "consequatur", "aut"]
31
32
  #
32
33
  # @faker.version 2.1.3
33
- def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
34
- warn_for_deprecated_arguments do |keywords|
35
- keywords << :number if legacy_number != NOT_GIVEN
36
- keywords << :supplemental if legacy_supplemental != NOT_GIVEN
37
- end
38
-
34
+ def words(number: 3, supplemental: false, exclude_words: nil)
39
35
  resolved_num = resolve(number)
40
36
  word_list = (
41
37
  translate('faker.lorem.words') +
42
38
  (supplemental ? translate('faker.lorem.supplemental') : [])
43
39
  )
40
+ if exclude_words
41
+ exclude_words = exclude_words.split(', ') if exclude_words.instance_of?(::String)
42
+ word_list -= exclude_words
43
+ end
44
44
  word_list *= ((resolved_num / word_list.length) + 1)
45
45
  shuffle(word_list)[0, resolved_num]
46
46
  end
@@ -74,16 +74,10 @@ module Faker
74
74
  # Faker::Lorem.characters(number: 10, min_alpha: 4, min_numeric: 1) #=> "ang9cbhoa8"
75
75
  #
76
76
  # @faker.version 2.1.3
77
- def characters(legacy_number = NOT_GIVEN, number: 255, min_alpha: 0, min_numeric: 0)
78
- warn_for_deprecated_arguments do |keywords|
79
- keywords << :number if legacy_number != NOT_GIVEN
80
- end
81
-
77
+ def characters(number: 255, min_alpha: 0, min_numeric: 0)
82
78
  Alphanumeric.alphanumeric(number: number, min_alpha: min_alpha, min_numeric: min_numeric)
83
79
  end
84
80
 
85
- # rubocop:disable Style/AsciiComments
86
-
87
81
  ##
88
82
  # Generates the emoji
89
83
  #
@@ -97,9 +91,6 @@ module Faker
97
91
  def multibyte
98
92
  sample(translate('faker.lorem.multibyte')).pack('C*').force_encoding('utf-8')
99
93
  end
100
- # rubocop:enable Style/AsciiComments
101
-
102
- # rubocop:disable Metrics/ParameterLists
103
94
 
104
95
  ##
105
96
  # Generates sentence
@@ -117,16 +108,9 @@ module Faker
117
108
  # Faker::Lorem.sentence(word_count: 5, supplemental: true, random_words_to_add:2) #=> "Crinis quo cruentus velit animi vomer."
118
109
  #
119
110
  # @faker.version 2.1.3
120
- def sentence(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, supplemental: false, random_words_to_add: 0)
121
- warn_for_deprecated_arguments do |keywords|
122
- keywords << :word_count if legacy_word_count != NOT_GIVEN
123
- keywords << :supplemental if legacy_supplemental != NOT_GIVEN
124
- keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
125
- end
126
-
127
- words(number: word_count + rand(random_words_to_add.to_i), supplemental: supplemental).join(locale_space).capitalize + locale_period
111
+ def sentence(word_count: 4, supplemental: false, random_words_to_add: 0, exclude_words: nil)
112
+ words(number: word_count + rand(random_words_to_add.to_i), supplemental: supplemental, exclude_words: exclude_words).join(locale_space).capitalize + locale_period
128
113
  end
129
- # rubocop:enable Metrics/ParameterLists
130
114
 
131
115
  ##
132
116
  # Generates three sentences
@@ -142,17 +126,10 @@ module Faker
142
126
  # Faker::Lorem.sentences(number: 2, supplemental: true) #=> ["Cito cena ad.", "Solvo animus allatus."]
143
127
  #
144
128
  # @faker.version 2.1.3
145
- def sentences(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
146
- warn_for_deprecated_arguments do |keywords|
147
- keywords << :number if legacy_number != NOT_GIVEN
148
- keywords << :supplemental if legacy_supplemental != NOT_GIVEN
149
- end
150
-
151
- 1.upto(resolve(number)).collect { sentence(word_count: 3, supplemental: supplemental) }
129
+ def sentences(number: 3, supplemental: false, exclude_words: nil)
130
+ 1.upto(resolve(number)).collect { sentence(word_count: 3, supplemental: supplemental, exclude_words: exclude_words) }
152
131
  end
153
132
 
154
- # rubocop:disable Metrics/ParameterLists
155
-
156
133
  ##
157
134
  # Generates three sentence paragraph
158
135
  #
@@ -173,16 +150,9 @@ module Faker
173
150
  # #=> "Texo tantillus tamisium. Tribuo amissio tamisium. Facere aut canis."
174
151
  #
175
152
  # @faker.version 2.1.3
176
- def paragraph(legacy_sentence_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_sentences_to_add = NOT_GIVEN, sentence_count: 3, supplemental: false, random_sentences_to_add: 0)
177
- warn_for_deprecated_arguments do |keywords|
178
- keywords << :sentence_count if legacy_sentence_count != NOT_GIVEN
179
- keywords << :supplemental if legacy_supplemental != NOT_GIVEN
180
- keywords << :random_sentences_to_add if legacy_random_sentences_to_add != NOT_GIVEN
181
- end
182
-
183
- sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i), supplemental: supplemental).join(locale_space)
153
+ def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 0, exclude_words: nil)
154
+ sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i), supplemental: supplemental, exclude_words: exclude_words).join(locale_space)
184
155
  end
185
- # rubocop:enable Metrics/ParameterLists
186
156
 
187
157
  ##
188
158
  # Generates three paragraphs
@@ -198,15 +168,8 @@ module Faker
198
168
  # Faker::Lorem.paragraphs(number:2, supplemental: true)
199
169
  #
200
170
  # @faker.version 2.1.3
201
- def paragraphs(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
202
- warn_for_deprecated_arguments do |keywords|
203
- keywords << :number if legacy_number != NOT_GIVEN
204
- end
205
- warn_for_deprecated_arguments do |keywords|
206
- keywords << :supplemental if legacy_supplemental != NOT_GIVEN
207
- end
208
-
209
- 1.upto(resolve(number)).collect { paragraph(sentence_count: 3, supplemental: supplemental) }
171
+ def paragraphs(number: 3, supplemental: false, exclude_words: nil)
172
+ 1.upto(resolve(number)).collect { paragraph(sentence_count: 3, supplemental: supplemental, exclude_words: exclude_words) }
210
173
  end
211
174
 
212
175
  ##
@@ -223,12 +186,7 @@ module Faker
223
186
  # Faker::Lorem.paragraph_by_chars(number: 20, supplemental: true) #=> "Certus aveho admove."
224
187
  #
225
188
  # @faker.version 2.1.3
226
- def paragraph_by_chars(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 256, supplemental: false)
227
- warn_for_deprecated_arguments do |keywords|
228
- keywords << :number if legacy_number != NOT_GIVEN
229
- keywords << :supplemental if legacy_supplemental != NOT_GIVEN
230
- end
231
-
189
+ def paragraph_by_chars(number: 256, supplemental: false)
232
190
  paragraph = paragraph(sentence_count: 3, supplemental: supplemental)
233
191
 
234
192
  paragraph += " #{paragraph(sentence_count: 3, supplemental: supplemental)}" while paragraph.length < number
@@ -236,8 +194,6 @@ module Faker
236
194
  "#{paragraph[0...number - 1]}."
237
195
  end
238
196
 
239
- # rubocop:disable Metrics/ParameterLists
240
-
241
197
  ##
242
198
  # Returns the question with 4 words
243
199
  #
@@ -254,16 +210,9 @@ module Faker
254
210
  # Faker::Lorem.question(word_count: 2, supplemental: true, random_words_to_add: 2) #=> "Depulso uter ut?"
255
211
  #
256
212
  # @faker.version 2.1.3
257
- def question(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, supplemental: false, random_words_to_add: 0)
258
- warn_for_deprecated_arguments do |keywords|
259
- keywords << :word_count if legacy_word_count != NOT_GIVEN
260
- keywords << :supplemental if legacy_supplemental != NOT_GIVEN
261
- keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
262
- end
263
-
264
- words(number: word_count + rand(random_words_to_add), supplemental: supplemental).join(' ').capitalize + locale_question_mark
213
+ def question(word_count: 4, supplemental: false, random_words_to_add: 0, exclude_words: nil)
214
+ words(number: word_count + rand(random_words_to_add), supplemental: supplemental, exclude_words: exclude_words).join(' ').capitalize + locale_question_mark
265
215
  end
266
- # rubocop:enable Metrics/ParameterLists
267
216
 
268
217
  ##
269
218
  # Generates array of three questions
@@ -279,13 +228,8 @@ module Faker
279
228
  # Faker::Lorem.questions(number: 2, supplemental: true) #=> ["Acceptus subito cetera?", "Aro sulum cubicularis?"]
280
229
  #
281
230
  # @faker.version 2.1.3
282
- def questions(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
283
- warn_for_deprecated_arguments do |keywords|
284
- keywords << :number if legacy_number != NOT_GIVEN
285
- keywords << :supplemental if legacy_supplemental != NOT_GIVEN
286
- end
287
-
288
- 1.upto(resolve(number)).collect { question(word_count: 3, supplemental: supplemental) }
231
+ def questions(number: 3, supplemental: false, exclude_words: nil)
232
+ 1.upto(resolve(number)).collect { question(word_count: 3, supplemental: supplemental, exclude_words: exclude_words) }
289
233
  end
290
234
 
291
235
  private
@@ -5,8 +5,6 @@ module Faker
5
5
  class << self
6
6
  SUPPORTED_COLORIZATIONS = %w[red green blue].freeze
7
7
 
8
- # rubocop:disable Metrics/ParameterLists
9
-
10
8
  ##
11
9
  # Produces a random image URL from loremflickr.com.
12
10
  #
@@ -23,13 +21,7 @@ module Faker
23
21
  # Faker::LoremFlickr.image(size: "50x60", search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/50/60/sports,fitness/all"
24
22
  #
25
23
  # @faker.version 1.9.0
26
- def image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: [], match_all: false)
27
- warn_for_deprecated_arguments do |keywords|
28
- keywords << :size if legacy_size != NOT_GIVEN
29
- keywords << :search_terms if legacy_search_terms != NOT_GIVEN
30
- keywords << :match_all if legacy_match_all != NOT_GIVEN
31
- end
32
-
24
+ def image(size: '300x300', search_terms: [], match_all: false)
33
25
  build_url(size, nil, search_terms, match_all)
34
26
  end
35
27
 
@@ -49,13 +41,7 @@ module Faker
49
41
  # Faker::LoremFlickr.grayscale_image(size: "50x60", search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/g/50/60/sports,fitness/all"
50
42
  #
51
43
  # @faker.version 1.9.0
52
- def grayscale_image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: ['all'], match_all: false)
53
- warn_for_deprecated_arguments do |keywords|
54
- keywords << :size if legacy_size != NOT_GIVEN
55
- keywords << :search_terms if legacy_search_terms != NOT_GIVEN
56
- keywords << :match_all if legacy_match_all != NOT_GIVEN
57
- end
58
-
44
+ def grayscale_image(size: '300x300', search_terms: ['all'], match_all: false)
59
45
  raise ArgumentError, 'Search terms must be specified for grayscale images' unless search_terms.any?
60
46
 
61
47
  build_url(size, 'g', search_terms, match_all)
@@ -77,13 +63,7 @@ module Faker
77
63
  # Faker::LoremFlickr.pixelated_image(size: "50x60", search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/p/50/60/sports,fitness/all"
78
64
  #
79
65
  # @faker.version 1.9.0
80
- def pixelated_image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: ['all'], match_all: false)
81
- warn_for_deprecated_arguments do |keywords|
82
- keywords << :size if legacy_size != NOT_GIVEN
83
- keywords << :search_terms if legacy_search_terms != NOT_GIVEN
84
- keywords << :match_all if legacy_match_all != NOT_GIVEN
85
- end
86
-
66
+ def pixelated_image(size: '300x300', search_terms: ['all'], match_all: false)
87
67
  raise ArgumentError, 'Search terms must be specified for pixelated images' unless search_terms.any?
88
68
 
89
69
  build_url(size, 'p', search_terms, match_all)
@@ -106,20 +86,12 @@ module Faker
106
86
  # Faker::LoremFlickr.image(size: "50x60", color: 'blue', search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/blue/50/60/sports,fitness/all"
107
87
  #
108
88
  # @faker.version 1.9.0
109
- def colorized_image(legacy_size = NOT_GIVEN, legacy_color = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', color: 'red', search_terms: ['all'], match_all: false)
110
- warn_for_deprecated_arguments do |keywords|
111
- keywords << :size if legacy_size != NOT_GIVEN
112
- keywords << :color if legacy_color != NOT_GIVEN
113
- keywords << :search_terms if legacy_search_terms != NOT_GIVEN
114
- keywords << :match_all if legacy_match_all != NOT_GIVEN
115
- end
116
-
89
+ def colorized_image(size: '300x300', color: 'red', search_terms: ['all'], match_all: false)
117
90
  raise ArgumentError, 'Search terms must be specified for colorized images' unless search_terms.any?
118
91
  raise ArgumentError, "Supported colorizations are #{SUPPORTED_COLORIZATIONS.join(', ')}" unless SUPPORTED_COLORIZATIONS.include?(color)
119
92
 
120
93
  build_url(size, color, search_terms, match_all)
121
94
  end
122
- # rubocop:enable Metrics/ParameterLists
123
95
 
124
96
  private
125
97
 
@@ -27,7 +27,7 @@ module Faker
27
27
  # @faker.version 1.8.0
28
28
  def emphasis
29
29
  paragraph = Faker::Lorem.paragraph(sentence_count: 3)
30
- words = paragraph.split(' ')
30
+ words = paragraph.split
31
31
  position = rand(0..words.length - 1)
32
32
  formatting = fetch('markdown.emphasis')
33
33
  words[position] = "#{formatting}#{words[position]}#{formatting}"
@@ -50,7 +50,7 @@ module Faker
50
50
  number.times do |i|
51
51
  result << "#{i}. #{Faker::Lorem.sentence(word_count: 1)} \n"
52
52
  end
53
- result.join('')
53
+ result.join
54
54
  end
55
55
 
56
56
  ##
@@ -69,7 +69,7 @@ module Faker
69
69
  number.times do |_i|
70
70
  result << "* #{Faker::Lorem.sentence(word_count: 1)} \n"
71
71
  end
72
- result.join('')
72
+ result.join
73
73
  end
74
74
 
75
75
  ##
@@ -133,7 +133,7 @@ module Faker
133
133
  def random(*args)
134
134
  method_list = available_methods
135
135
  args&.each { |ex| method_list.delete_if { |meth| meth == ex.to_sym } }
136
- send(method_list[rand(0..method_list.length - 1)])
136
+ send(method_list[Faker::Config.random.rand(0..method_list.length - 1)])
137
137
  end
138
138
 
139
139
  ##
@@ -150,12 +150,7 @@ module Faker
150
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
151
  #
152
152
  # @faker.version 1.8.0
153
- def sandwich(legacy_sentences = NOT_GIVEN, legacy_repeat = NOT_GIVEN, sentences: 3, repeat: 1)
154
- warn_for_deprecated_arguments do |keywords|
155
- keywords << :sentences if legacy_sentences != NOT_GIVEN
156
- keywords << :repeat if legacy_repeat != NOT_GIVEN
157
- end
158
-
153
+ def sandwich(sentences: 3, repeat: 1)
159
154
  text_block = []
160
155
  text_block << headers
161
156
  repeat.times do
@@ -168,7 +163,7 @@ module Faker
168
163
  private
169
164
 
170
165
  def available_methods
171
- Markdown.public_methods(false) - Base.methods
166
+ (Markdown.public_methods(false) - Base.methods).sort
172
167
  end
173
168
  end
174
169
  end
@@ -6,7 +6,7 @@ module Faker
6
6
 
7
7
  class << self
8
8
  ##
9
- # Produces the name of a video game console or platform.
9
+ # Produces a few marketing buzzwords.
10
10
  #
11
11
  # @return [String]
12
12
  #
@@ -9,7 +9,7 @@ module Faker
9
9
  ##
10
10
  # Produces a random height measurement.
11
11
  #
12
- # @param amount [Integer] Speficies the random height value.
12
+ # @param amount [Integer] Specifies the random height value.
13
13
  # @return [String]
14
14
  #
15
15
  # @example
@@ -19,18 +19,14 @@ module Faker
19
19
  # Faker::Measurement.height(amount: "all") #=> "inches"
20
20
  #
21
21
  # @faker.version 1.7.3
22
- def height(legacy_amount = NOT_GIVEN, amount: rand(10))
23
- warn_for_deprecated_arguments do |keywords|
24
- keywords << :amount if legacy_amount != NOT_GIVEN
25
- end
26
-
22
+ def height(amount: rand(10))
27
23
  define_measurement_locale(amount, 'height')
28
24
  end
29
25
 
30
26
  ##
31
27
  # Produces a random length measurement.
32
28
  #
33
- # @param amount [Integer] Speficies the random length value.
29
+ # @param amount [Integer] Specifies the random length value.
34
30
  # @return [String]
35
31
  #
36
32
  # @example
@@ -38,18 +34,14 @@ module Faker
38
34
  # Faker::Measurement.length(amount: 1.4) #=> "1.4 yards"
39
35
  #
40
36
  # @faker.version 1.7.3
41
- def length(legacy_amount = NOT_GIVEN, amount: rand(10))
42
- warn_for_deprecated_arguments do |keywords|
43
- keywords << :amount if legacy_amount != NOT_GIVEN
44
- end
45
-
37
+ def length(amount: rand(10))
46
38
  define_measurement_locale(amount, 'length')
47
39
  end
48
40
 
49
41
  ##
50
42
  # Produces a random volume measurement.
51
43
  #
52
- # @param amount [Integer] Speficies the random volume value.
44
+ # @param amount [Integer] Specifies the random volume value.
53
45
  # @return [String]
54
46
  #
55
47
  # @example
@@ -57,18 +49,14 @@ module Faker
57
49
  # Faker::Measurement.volume(amount: 1.4) #=> "1.4 cups"
58
50
  #
59
51
  # @faker.version 1.7.3
60
- def volume(legacy_amount = NOT_GIVEN, amount: rand(10))
61
- warn_for_deprecated_arguments do |keywords|
62
- keywords << :amount if legacy_amount != NOT_GIVEN
63
- end
64
-
52
+ def volume(amount: rand(10))
65
53
  define_measurement_locale(amount, 'volume')
66
54
  end
67
55
 
68
56
  ##
69
57
  # Produces a random weight measurement.
70
58
  #
71
- # @param amount [Integer] Speficies the random weight value.
59
+ # @param amount [Integer] Specifies the random weight value.
72
60
  # @return [String]
73
61
  #
74
62
  # @example
@@ -76,18 +64,14 @@ module Faker
76
64
  # Faker::Measurement.weight(amount: 1.4) #=> "1.4 pounds"
77
65
  #
78
66
  # @faker.version 1.7.3
79
- def weight(legacy_amount = NOT_GIVEN, amount: rand(10))
80
- warn_for_deprecated_arguments do |keywords|
81
- keywords << :amount if legacy_amount != NOT_GIVEN
82
- end
83
-
67
+ def weight(amount: rand(10))
84
68
  define_measurement_locale(amount, 'weight')
85
69
  end
86
70
 
87
71
  ##
88
72
  # Produces a random metric height measurement.
89
73
  #
90
- # @param amount [Integer] Speficies the random height value.
74
+ # @param amount [Integer] Specifies the random height value.
91
75
  # @return [String]
92
76
  #
93
77
  # @example
@@ -95,18 +79,14 @@ module Faker
95
79
  # Faker::Measurement.metric_height(amount: 1.4) #=> "1.4 meters"
96
80
  #
97
81
  # @faker.version 1.7.3
98
- def metric_height(legacy_amount = NOT_GIVEN, amount: rand(10))
99
- warn_for_deprecated_arguments do |keywords|
100
- keywords << :amount if legacy_amount != NOT_GIVEN
101
- end
102
-
82
+ def metric_height(amount: rand(10))
103
83
  define_measurement_locale(amount, 'metric_height')
104
84
  end
105
85
 
106
86
  ##
107
87
  # Produces a random metric length measurement.
108
88
  #
109
- # @param amount [Integer] Speficies the random length value.
89
+ # @param amount [Integer] Specifies the random length value.
110
90
  # @return [String]
111
91
  #
112
92
  # @example
@@ -114,18 +94,14 @@ module Faker
114
94
  # Faker::Measurement.metric_length(amount: 1.4) #=> "1.4 decimeters"
115
95
  #
116
96
  # @faker.version 1.7.3
117
- def metric_length(legacy_amount = NOT_GIVEN, amount: rand(10))
118
- warn_for_deprecated_arguments do |keywords|
119
- keywords << :amount if legacy_amount != NOT_GIVEN
120
- end
121
-
97
+ def metric_length(amount: rand(10))
122
98
  define_measurement_locale(amount, 'metric_length')
123
99
  end
124
100
 
125
101
  ##
126
102
  # Produces a random metric volume measurement.
127
103
  #
128
- # @param amount [Integer] Speficies the random volume value.
104
+ # @param amount [Integer] Specifies the random volume value.
129
105
  # @return [String]
130
106
  #
131
107
  # @example
@@ -133,18 +109,14 @@ module Faker
133
109
  # Faker::Measurement.metric_volume(amount: 1.4) #=> "1.4 liters"
134
110
  #
135
111
  # @faker.version 1.7.3
136
- def metric_volume(legacy_amount = NOT_GIVEN, amount: rand(10))
137
- warn_for_deprecated_arguments do |keywords|
138
- keywords << :amount if legacy_amount != NOT_GIVEN
139
- end
140
-
112
+ def metric_volume(amount: rand(10))
141
113
  define_measurement_locale(amount, 'metric_volume')
142
114
  end
143
115
 
144
116
  ##
145
117
  # Produces a random metric weight measurement.
146
118
  #
147
- # @param amount [Integer] Speficies the random weight value.
119
+ # @param amount [Integer] Specifies the random weight value.
148
120
  # @return [String]
149
121
  #
150
122
  # @example
@@ -152,11 +124,7 @@ module Faker
152
124
  # Faker::Measurement.metric_weight(amount: 1.4) #=> "1.4 grams"
153
125
  #
154
126
  # @faker.version 1.7.3
155
- def metric_weight(legacy_amount = NOT_GIVEN, amount: rand(10))
156
- warn_for_deprecated_arguments do |keywords|
157
- keywords << :amount if legacy_amount != NOT_GIVEN
158
- end
159
-
127
+ def metric_weight(amount: rand(10))
160
128
  define_measurement_locale(amount, 'metric_weight')
161
129
  end
162
130
 
@@ -144,11 +144,7 @@ module Faker
144
144
  # Faker::Name.initials(number: 2) #=> "NM"
145
145
  #
146
146
  # @faker.version 1.8.5
147
- def initials(legacy_number = NOT_GIVEN, number: 3)
148
- warn_for_deprecated_arguments do |keywords|
149
- keywords << :number if legacy_number != NOT_GIVEN
150
- end
151
-
147
+ def initials(number: 3)
152
148
  (0...number).map { rand(65..90).chr }.join
153
149
  end
154
150
  end
@@ -17,8 +17,6 @@ module Faker
17
17
  fetch('nation.nationality')
18
18
  end
19
19
 
20
- # rubocop:disable Style/AsciiComments
21
-
22
20
  ##
23
21
  # Produces a random national flag emoji.
24
22
  #
@@ -31,7 +29,6 @@ module Faker
31
29
  def flag
32
30
  sample(translate('faker.nation.flag')).pack('C*').force_encoding('utf-8')
33
31
  end
34
- # rubocop:enable Style/AsciiComments
35
32
 
36
33
  ##
37
34
  # Produces a random national language.
@@ -21,7 +21,7 @@ module Faker
21
21
  .chars
22
22
  .insert(3, ' ')
23
23
  .insert(7, ' ')
24
- .join('')
24
+ .join
25
25
  end
26
26
 
27
27
  ##
@@ -34,11 +34,7 @@ module Faker
34
34
  # Faker::NationalHealthService.check_digit(number: 400_012_114) #=> 6
35
35
  #
36
36
  # @faker.version 1.9.2
37
- def check_digit(legacy_number = NOT_GIVEN, number: 0)
38
- warn_for_deprecated_arguments do |keywords|
39
- keywords << :number if legacy_number != NOT_GIVEN
40
- end
41
-
37
+ def check_digit(number: 0)
42
38
  sum = 0
43
39
  number.to_s.chars.each_with_index do |digit, idx|
44
40
  position = idx + 1