faker 2.20.0 → 3.2.1

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 (178) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +346 -7
  3. data/History.md +1 -1
  4. data/README.md +193 -107
  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/default/address.rb +5 -25
  11. data/lib/faker/default/alphanumeric.rb +2 -8
  12. data/lib/faker/default/app.rb +1 -10
  13. data/lib/faker/default/avatar.rb +1 -12
  14. data/lib/faker/default/bank.rb +9 -17
  15. data/lib/faker/default/boolean.rb +1 -4
  16. data/lib/faker/default/chile_rut.rb +25 -25
  17. data/lib/faker/default/code.rb +68 -39
  18. data/lib/faker/default/color.rb +77 -6
  19. data/lib/faker/default/commerce.rb +3 -17
  20. data/lib/faker/default/company.rb +50 -19
  21. data/lib/faker/default/crypto_coin.rb +3 -15
  22. data/lib/faker/default/date.rb +65 -42
  23. data/lib/faker/default/demographic.rb +1 -5
  24. data/lib/faker/default/driving_licence.rb +20 -19
  25. data/lib/faker/default/drone.rb +1 -1
  26. data/lib/faker/default/file.rb +5 -24
  27. data/lib/faker/default/finance.rb +17 -7
  28. data/lib/faker/default/food.rb +14 -1
  29. data/lib/faker/default/hipster.rb +6 -45
  30. data/lib/faker/default/html.rb +230 -0
  31. data/lib/faker/default/id_number.rb +125 -14
  32. data/lib/faker/default/internet.rb +116 -111
  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 +25 -74
  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/nhs.rb +2 -6
  42. data/lib/faker/default/number.rb +10 -55
  43. data/lib/faker/default/omniauth.rb +6 -40
  44. data/lib/faker/default/phone_number.rb +2 -6
  45. data/lib/faker/default/placeholdit.rb +1 -12
  46. data/lib/faker/default/relationship.rb +1 -5
  47. data/lib/faker/default/release notes.md +59 -0
  48. data/lib/faker/default/source.rb +3 -16
  49. data/lib/faker/default/string.rb +1 -5
  50. data/lib/faker/default/stripe.rb +4 -20
  51. data/lib/faker/default/time.rb +4 -32
  52. data/lib/faker/default/twitter.rb +7 -23
  53. data/lib/faker/default/types.rb +7 -28
  54. data/lib/faker/default/vehicle.rb +40 -51
  55. data/lib/faker/default/vulnerability_identifier.rb +23 -0
  56. data/lib/faker/default/world_cup.rb +2 -11
  57. data/lib/faker/games/clash_of_clans.rb +1 -1
  58. data/lib/faker/games/dnd.rb +49 -7
  59. data/lib/faker/games/dota.rb +1 -5
  60. data/lib/faker/games/final_fantasy_xiv.rb +73 -0
  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/kamen_rider.rb +2 -2
  66. data/lib/faker/japanese_media/one_piece.rb +1 -1
  67. data/lib/faker/movies/avatar.rb +49 -0
  68. data/lib/faker/movies/hackers.rb +48 -0
  69. data/lib/faker/movies/star_wars.rb +1 -5
  70. data/lib/faker/movies/tron.rb +161 -0
  71. data/lib/faker/quotes/quote.rb +13 -0
  72. data/lib/faker/sports/chess.rb +90 -0
  73. data/lib/faker/sports/mountaineering.rb +22 -0
  74. data/lib/faker/sports/sport.rb +116 -0
  75. data/lib/faker/travel/airport.rb +43 -0
  76. data/lib/faker/travel/train_station.rb +54 -0
  77. data/lib/faker/tv_shows/archer.rb +51 -0
  78. data/lib/faker/tv_shows/south_park.rb +15 -0
  79. data/lib/faker/tv_shows/spongebob.rb +50 -0
  80. data/lib/faker/version.rb +1 -1
  81. data/lib/faker.rb +26 -67
  82. data/lib/helpers/base58.rb +1 -1
  83. data/lib/helpers/positional_generator.rb +480 -0
  84. data/lib/helpers/unique_generator.rb +13 -11
  85. data/lib/locales/README.md +18 -2
  86. data/lib/locales/ar.yml +1 -0
  87. data/lib/locales/bg.yml +1 -1
  88. data/lib/locales/da-DK.yml +1 -1
  89. data/lib/locales/de-AT.yml +1 -2
  90. data/lib/locales/de-CH.yml +4336 -12
  91. data/lib/locales/de.yml +1 -1
  92. data/lib/locales/en/airport.yml +381 -0
  93. data/lib/locales/en/archer.yml +75 -0
  94. data/lib/locales/en/australia.yml +3 -4
  95. data/lib/locales/en/avatar.yml +31 -0
  96. data/lib/locales/en/chess.yml +103 -0
  97. data/lib/locales/en/company.yml +1 -0
  98. data/lib/locales/en/computer.yml +23 -4
  99. data/lib/locales/en/cowboy_bebop.yml +163 -0
  100. data/lib/locales/en/dnd.yml +186 -1
  101. data/lib/locales/en/dota.yml +113 -0
  102. data/lib/locales/en/file.yml +9 -1
  103. data/lib/locales/en/final_fantasy_xiv.yml +754 -0
  104. data/lib/locales/en/finance.yml +3 -1
  105. data/lib/locales/en/food.yml +12 -0
  106. data/lib/locales/en/game.yml +0 -1
  107. data/lib/locales/en/hackers.yml +53 -0
  108. data/lib/locales/en/heroes.yml +2 -2
  109. data/lib/locales/en/internet.yml +32 -0
  110. data/lib/locales/en/minecraft.yml +4 -4
  111. data/lib/locales/en/mitch_hedberg.yml +46 -0
  112. data/lib/locales/en/mountaineering.yml +14 -0
  113. data/lib/locales/en/movie.yml +2 -1
  114. data/lib/locales/en/naruto.yml +2 -3
  115. data/lib/locales/en/one_piece.yml +1 -1
  116. data/lib/locales/en/opera.yml +2 -2
  117. data/lib/locales/en/overwatch.yml +5 -7
  118. data/lib/locales/en/source.yml +5 -0
  119. data/lib/locales/en/south_park.yml +360 -2
  120. data/lib/locales/en/spongebob.yml +489 -0
  121. data/lib/locales/en/sport.yml +130 -0
  122. data/lib/locales/en/star_wars.yml +1 -1
  123. data/lib/locales/en/tarkov.yml +593 -0
  124. data/lib/locales/en/train_station.yml +280 -0
  125. data/lib/locales/en/tron.yml +227 -0
  126. data/lib/locales/en/vehicle.yml +2809 -75
  127. data/lib/locales/en-AU.yml +2 -2
  128. data/lib/locales/en-CA.yml +2 -1
  129. data/lib/locales/en-GB.yml +2 -1
  130. data/lib/locales/en-MS.yml +1 -0
  131. data/lib/locales/en-NG.yml +1 -0
  132. data/lib/locales/en-NZ.yml +1 -0
  133. data/lib/locales/en-PAK.yml +1 -0
  134. data/lib/locales/en-SG.yml +1 -0
  135. data/lib/locales/en-UG.yml +1 -0
  136. data/lib/locales/en-US.yml +1 -1
  137. data/lib/locales/en-ZA.yml +1 -1
  138. data/lib/locales/en-au-ocker.yml +2 -0
  139. data/lib/locales/es-AR.yml +3 -2
  140. data/lib/locales/es-MX.yml +1 -1
  141. data/lib/locales/es.yml +2 -2
  142. data/lib/locales/fi-FI.yml +3 -1
  143. data/lib/locales/fr/address.yml +0 -1
  144. data/lib/locales/fr/adjective.yml +266 -0
  145. data/lib/locales/fr/ancient.yml +141 -0
  146. data/lib/locales/fr/name.yml +2 -1
  147. data/lib/locales/fr-CA.yml +1 -1
  148. data/lib/locales/fr-CH.yml +1 -1
  149. data/lib/locales/hy.yml +2 -1
  150. data/lib/locales/it.yml +1 -0
  151. data/lib/locales/ja/adjective.yml +148 -0
  152. data/lib/locales/ja/dog.yml +1 -0
  153. data/lib/locales/ja/emotion.yml +51 -0
  154. data/lib/locales/ja/naruto.yml +230 -0
  155. data/lib/locales/ja/relationship.yml +10 -0
  156. data/lib/locales/ja/sport.yml +130 -0
  157. data/lib/locales/ja/super_mario.yml +1 -1
  158. data/lib/locales/ko.yml +1 -0
  159. data/lib/locales/lt.yml +0 -1
  160. data/lib/locales/mi-NZ.yml +2 -0
  161. data/lib/locales/nb-NO.yml +1 -0
  162. data/lib/locales/nl.yml +1 -0
  163. data/lib/locales/pl.yml +2 -2
  164. data/lib/locales/pt-BR.yml +1 -0
  165. data/lib/locales/pt.yml +1 -1
  166. data/lib/locales/ru.yml +1 -0
  167. data/lib/locales/sk.yml +1 -0
  168. data/lib/locales/sv.yml +1 -0
  169. data/lib/locales/th.yml +76 -76
  170. data/lib/locales/tr.yml +1 -0
  171. data/lib/locales/uk.yml +3 -0
  172. data/lib/locales/vi.yml +1 -0
  173. data/lib/locales/zh-CN.yml +1 -0
  174. data/lib/locales/zh-TW.yml +1 -0
  175. metadata +46 -127
  176. data/lib/faker/default/fillmurray.rb +0 -45
  177. data/lib/faker/default/lorem_pixel.rb +0 -70
  178. /data/lib/faker/default/{faker_adjective.rb → adjective.rb} +0 -0
@@ -10,10 +10,13 @@ module Faker
10
10
  #
11
11
  # @example
12
12
  # Faker::Lorem.word #=> "soluto"
13
+ # Faker::Lorem.word(exclude_words: 'error') #=> "nisi"
14
+ # Faker::Lorem.word(exclude_words: 'id, error') #=> "et"
15
+ # Faker::Lorem.word(exclude_words: ['id', 'error']) #=> "consequatur"
13
16
  #
14
17
  # @faker.version 2.1.3
15
- def word
16
- sample(translate('faker.lorem.words'))
18
+ def word(exclude_words: nil)
19
+ words(number: 1, exclude_words: exclude_words).first
17
20
  end
18
21
 
19
22
  ##
@@ -28,19 +31,19 @@ module Faker
28
31
  # Faker::Lorem.words #=> ["hic", "quia", "nihil"]
29
32
  # Faker::Lorem.words(number: 4) #=> ["est", "temporibus", "et", "quaerat"]
30
33
  # Faker::Lorem.words(number: 4, supplemental: true) #=> ["nisi", "sit", "allatus", "consequatur"]
34
+ # Faker::Lorem.words(number: 4, supplemental: true, exclude_words: 'sit') #=> ["nisi", "allatus", "consequatur", "aut"]
31
35
  #
32
36
  # @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
-
37
+ def words(number: 3, supplemental: false, exclude_words: nil)
39
38
  resolved_num = resolve(number)
40
39
  word_list = (
41
40
  translate('faker.lorem.words') +
42
41
  (supplemental ? translate('faker.lorem.supplemental') : [])
43
42
  )
43
+ if exclude_words
44
+ exclude_words = exclude_words.split(', ') if exclude_words.instance_of?(::String)
45
+ word_list -= exclude_words
46
+ end
44
47
  word_list *= ((resolved_num / word_list.length) + 1)
45
48
  shuffle(word_list)[0, resolved_num]
46
49
  end
@@ -74,11 +77,7 @@ module Faker
74
77
  # Faker::Lorem.characters(number: 10, min_alpha: 4, min_numeric: 1) #=> "ang9cbhoa8"
75
78
  #
76
79
  # @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
-
80
+ def characters(number: 255, min_alpha: 0, min_numeric: 0)
82
81
  Alphanumeric.alphanumeric(number: number, min_alpha: min_alpha, min_numeric: min_numeric)
83
82
  end
84
83
 
@@ -95,7 +94,6 @@ module Faker
95
94
  def multibyte
96
95
  sample(translate('faker.lorem.multibyte')).pack('C*').force_encoding('utf-8')
97
96
  end
98
- # rubocop:disable Metrics/ParameterLists
99
97
 
100
98
  ##
101
99
  # Generates sentence
@@ -113,16 +111,9 @@ module Faker
113
111
  # Faker::Lorem.sentence(word_count: 5, supplemental: true, random_words_to_add:2) #=> "Crinis quo cruentus velit animi vomer."
114
112
  #
115
113
  # @faker.version 2.1.3
116
- 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)
117
- warn_for_deprecated_arguments do |keywords|
118
- keywords << :word_count if legacy_word_count != NOT_GIVEN
119
- keywords << :supplemental if legacy_supplemental != NOT_GIVEN
120
- keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
121
- end
122
-
123
- words(number: word_count + rand(random_words_to_add.to_i), supplemental: supplemental).join(locale_space).capitalize + locale_period
114
+ def sentence(word_count: 4, supplemental: false, random_words_to_add: 0, exclude_words: nil)
115
+ words(number: word_count + rand(random_words_to_add.to_i), supplemental: supplemental, exclude_words: exclude_words).join(locale_space).capitalize + locale_period
124
116
  end
125
- # rubocop:enable Metrics/ParameterLists
126
117
 
127
118
  ##
128
119
  # Generates three sentences
@@ -138,17 +129,10 @@ module Faker
138
129
  # Faker::Lorem.sentences(number: 2, supplemental: true) #=> ["Cito cena ad.", "Solvo animus allatus."]
139
130
  #
140
131
  # @faker.version 2.1.3
141
- def sentences(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
142
- warn_for_deprecated_arguments do |keywords|
143
- keywords << :number if legacy_number != NOT_GIVEN
144
- keywords << :supplemental if legacy_supplemental != NOT_GIVEN
145
- end
146
-
147
- 1.upto(resolve(number)).collect { sentence(word_count: 3, supplemental: supplemental) }
132
+ def sentences(number: 3, supplemental: false, exclude_words: nil)
133
+ 1.upto(resolve(number)).collect { sentence(word_count: 3, supplemental: supplemental, exclude_words: exclude_words) }
148
134
  end
149
135
 
150
- # rubocop:disable Metrics/ParameterLists
151
-
152
136
  ##
153
137
  # Generates three sentence paragraph
154
138
  #
@@ -169,16 +153,9 @@ module Faker
169
153
  # #=> "Texo tantillus tamisium. Tribuo amissio tamisium. Facere aut canis."
170
154
  #
171
155
  # @faker.version 2.1.3
172
- 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)
173
- warn_for_deprecated_arguments do |keywords|
174
- keywords << :sentence_count if legacy_sentence_count != NOT_GIVEN
175
- keywords << :supplemental if legacy_supplemental != NOT_GIVEN
176
- keywords << :random_sentences_to_add if legacy_random_sentences_to_add != NOT_GIVEN
177
- end
178
-
179
- sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i), supplemental: supplemental).join(locale_space)
156
+ def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 0, exclude_words: nil)
157
+ sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i), supplemental: supplemental, exclude_words: exclude_words).join(locale_space)
180
158
  end
181
- # rubocop:enable Metrics/ParameterLists
182
159
 
183
160
  ##
184
161
  # Generates three paragraphs
@@ -194,15 +171,8 @@ module Faker
194
171
  # Faker::Lorem.paragraphs(number:2, supplemental: true)
195
172
  #
196
173
  # @faker.version 2.1.3
197
- def paragraphs(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
198
- warn_for_deprecated_arguments do |keywords|
199
- keywords << :number if legacy_number != NOT_GIVEN
200
- end
201
- warn_for_deprecated_arguments do |keywords|
202
- keywords << :supplemental if legacy_supplemental != NOT_GIVEN
203
- end
204
-
205
- 1.upto(resolve(number)).collect { paragraph(sentence_count: 3, supplemental: supplemental) }
174
+ def paragraphs(number: 3, supplemental: false, exclude_words: nil)
175
+ 1.upto(resolve(number)).collect { paragraph(sentence_count: 3, supplemental: supplemental, exclude_words: exclude_words) }
206
176
  end
207
177
 
208
178
  ##
@@ -219,12 +189,7 @@ module Faker
219
189
  # Faker::Lorem.paragraph_by_chars(number: 20, supplemental: true) #=> "Certus aveho admove."
220
190
  #
221
191
  # @faker.version 2.1.3
222
- def paragraph_by_chars(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 256, supplemental: false)
223
- warn_for_deprecated_arguments do |keywords|
224
- keywords << :number if legacy_number != NOT_GIVEN
225
- keywords << :supplemental if legacy_supplemental != NOT_GIVEN
226
- end
227
-
192
+ def paragraph_by_chars(number: 256, supplemental: false)
228
193
  paragraph = paragraph(sentence_count: 3, supplemental: supplemental)
229
194
 
230
195
  paragraph += " #{paragraph(sentence_count: 3, supplemental: supplemental)}" while paragraph.length < number
@@ -232,8 +197,6 @@ module Faker
232
197
  "#{paragraph[0...number - 1]}."
233
198
  end
234
199
 
235
- # rubocop:disable Metrics/ParameterLists
236
-
237
200
  ##
238
201
  # Returns the question with 4 words
239
202
  #
@@ -250,16 +213,9 @@ module Faker
250
213
  # Faker::Lorem.question(word_count: 2, supplemental: true, random_words_to_add: 2) #=> "Depulso uter ut?"
251
214
  #
252
215
  # @faker.version 2.1.3
253
- 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)
254
- warn_for_deprecated_arguments do |keywords|
255
- keywords << :word_count if legacy_word_count != NOT_GIVEN
256
- keywords << :supplemental if legacy_supplemental != NOT_GIVEN
257
- keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
258
- end
259
-
260
- words(number: word_count + rand(random_words_to_add), supplemental: supplemental).join(' ').capitalize + locale_question_mark
216
+ def question(word_count: 4, supplemental: false, random_words_to_add: 0, exclude_words: nil)
217
+ words(number: word_count + rand(random_words_to_add), supplemental: supplemental, exclude_words: exclude_words).join(' ').capitalize + locale_question_mark
261
218
  end
262
- # rubocop:enable Metrics/ParameterLists
263
219
 
264
220
  ##
265
221
  # Generates array of three questions
@@ -275,13 +231,8 @@ module Faker
275
231
  # Faker::Lorem.questions(number: 2, supplemental: true) #=> ["Acceptus subito cetera?", "Aro sulum cubicularis?"]
276
232
  #
277
233
  # @faker.version 2.1.3
278
- def questions(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
279
- warn_for_deprecated_arguments do |keywords|
280
- keywords << :number if legacy_number != NOT_GIVEN
281
- keywords << :supplemental if legacy_supplemental != NOT_GIVEN
282
- end
283
-
284
- 1.upto(resolve(number)).collect { question(word_count: 3, supplemental: supplemental) }
234
+ def questions(number: 3, supplemental: false, exclude_words: nil)
235
+ 1.upto(resolve(number)).collect { question(word_count: 3, supplemental: supplemental, exclude_words: exclude_words) }
285
236
  end
286
237
 
287
238
  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
@@ -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
@@ -13,11 +13,7 @@ module Faker
13
13
  # Faker::Number.number(digits: 10) #=> 1968353479
14
14
  #
15
15
  # @faker.version 1.0.0
16
- def number(legacy_digits = NOT_GIVEN, digits: 10)
17
- warn_for_deprecated_arguments do |keywords|
18
- keywords << :digits if legacy_digits != NOT_GIVEN
19
- end
20
-
16
+ def number(digits: 10)
21
17
  return if digits < 1
22
18
  return rand(0..9).round if digits == 1
23
19
 
@@ -35,11 +31,7 @@ module Faker
35
31
  # Faker::Number.leading_zero_number(digits: 10) #=> "0669336915"
36
32
  #
37
33
  # @faker.version 1.0.0
38
- def leading_zero_number(legacy_digits = NOT_GIVEN, digits: 10)
39
- warn_for_deprecated_arguments do |keywords|
40
- keywords << :digits if legacy_digits != NOT_GIVEN
41
- end
42
-
34
+ def leading_zero_number(digits: 10)
43
35
  "0#{(2..digits).collect { digit }.join}"
44
36
  end
45
37
 
@@ -53,11 +45,7 @@ module Faker
53
45
  # Faker::Number.decimal_part(digits: 2) #=> "09"
54
46
  #
55
47
  # @faker.version 1.0.0
56
- def decimal_part(legacy_digits = NOT_GIVEN, digits: 10)
57
- warn_for_deprecated_arguments do |keywords|
58
- keywords << :digits if legacy_digits != NOT_GIVEN
59
- end
60
-
48
+ def decimal_part(digits: 10)
61
49
  num = ''
62
50
  if digits > 1
63
51
  num = non_zero_digit
@@ -78,12 +66,7 @@ module Faker
78
66
  # Faker::Number.decimal(l_digits: 3, r_digits: 3) #=> 181.843
79
67
  #
80
68
  # @faker.version 1.0.0
81
- def decimal(legacy_l_digits = NOT_GIVEN, legacy_r_digits = NOT_GIVEN, l_digits: 5, r_digits: 2)
82
- warn_for_deprecated_arguments do |keywords|
83
- keywords << :l_digits if legacy_l_digits != NOT_GIVEN
84
- keywords << :r_digits if legacy_r_digits != NOT_GIVEN
85
- end
86
-
69
+ def decimal(l_digits: 5, r_digits: 2)
87
70
  l_d = number(digits: l_digits)
88
71
 
89
72
  # Ensure the last digit is not zero
@@ -129,11 +112,7 @@ module Faker
129
112
  # Faker::Number.hexadecimal(digits: 3) #=> "e74"
130
113
  #
131
114
  # @faker.version 1.0.0
132
- def hexadecimal(legacy_digits = NOT_GIVEN, digits: 6)
133
- warn_for_deprecated_arguments do |keywords|
134
- keywords << :digits if legacy_digits != NOT_GIVEN
135
- end
136
-
115
+ def hexadecimal(digits: 6)
137
116
  hex = ''
138
117
  digits.times { hex += rand(15).to_s(16) }
139
118
  hex
@@ -165,12 +144,7 @@ module Faker
165
144
  # Faker::Number.normal(mean: 50, standard_deviation: 3.5) #=> 47.14669604069156
166
145
  #
167
146
  # @faker.version 1.0.0
168
- def normal(legacy_mean = NOT_GIVEN, legacy_standard_deviation = NOT_GIVEN, mean: 1, standard_deviation: 1)
169
- warn_for_deprecated_arguments do |keywords|
170
- keywords << :mean if legacy_mean != NOT_GIVEN
171
- keywords << :standard_deviation if legacy_standard_deviation != NOT_GIVEN
172
- end
173
-
147
+ def normal(mean: 1, standard_deviation: 1)
174
148
  theta = 2 * Math::PI * rand
175
149
  rho = Math.sqrt(-2 * Math.log(1 - rand))
176
150
  scale = standard_deviation * rho
@@ -189,12 +163,7 @@ module Faker
189
163
  # Faker::Number.between(from: 0.0, to: 1.0) #=> 0.7844640543957383
190
164
  #
191
165
  # @faker.version 1.0.0
192
- def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 1.00, to: 5000.00)
193
- warn_for_deprecated_arguments do |keywords|
194
- keywords << :from if legacy_from != NOT_GIVEN
195
- keywords << :to if legacy_to != NOT_GIVEN
196
- end
197
-
166
+ def between(from: 1.00, to: 5000.00)
198
167
  Faker::Base.rand_in_range(from, to)
199
168
  end
200
169
 
@@ -209,11 +178,7 @@ module Faker
209
178
  # Faker::Number.within(range: 0.0..1.0) #=> 0.7844640543957383
210
179
  #
211
180
  # @faker.version 1.0.0
212
- def within(legacy_range = NOT_GIVEN, range: 1.00..5000.00)
213
- warn_for_deprecated_arguments do |keywords|
214
- keywords << :range if legacy_range != NOT_GIVEN
215
- end
216
-
181
+ def within(range: 1.00..5000.00)
217
182
  between(from: range.min, to: range.max)
218
183
  end
219
184
 
@@ -228,12 +193,7 @@ module Faker
228
193
  # Faker::Number.positive #=> 235.59238499107653
229
194
  #
230
195
  # @faker.version 1.0.0
231
- def positive(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 1.00, to: 5000.00)
232
- warn_for_deprecated_arguments do |keywords|
233
- keywords << :from if legacy_from != NOT_GIVEN
234
- keywords << :to if legacy_to != NOT_GIVEN
235
- end
236
-
196
+ def positive(from: 1.00, to: 5000.00)
237
197
  random_number = between(from: from, to: to)
238
198
 
239
199
  greater_than_zero(random_number)
@@ -250,12 +210,7 @@ module Faker
250
210
  # Faker::Number.negative #=> -4480.042585669558
251
211
  #
252
212
  # @faker.version 1.0.0
253
- def negative(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: -5000.00, to: -1.00)
254
- warn_for_deprecated_arguments do |keywords|
255
- keywords << :from if legacy_from != NOT_GIVEN
256
- keywords << :to if legacy_to != NOT_GIVEN
257
- end
258
-
213
+ def negative(from: -5000.00, to: -1.00)
259
214
  random_number = between(from: from, to: to)
260
215
 
261
216
  less_than_zero(random_number)