faker 2.23.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +83 -29
  3. data/History.md +1 -1
  4. data/README.md +10 -5
  5. data/lib/faker/books/dune.rb +2 -10
  6. data/lib/faker/books/lovecraft.rb +7 -38
  7. data/lib/faker/default/address.rb +5 -25
  8. data/lib/faker/default/alphanumeric.rb +2 -8
  9. data/lib/faker/default/app.rb +1 -10
  10. data/lib/faker/default/avatar.rb +1 -12
  11. data/lib/faker/default/bank.rb +5 -13
  12. data/lib/faker/default/boolean.rb +1 -4
  13. data/lib/faker/default/chile_rut.rb +2 -12
  14. data/lib/faker/default/code.rb +3 -16
  15. data/lib/faker/default/color.rb +77 -6
  16. data/lib/faker/default/commerce.rb +3 -17
  17. data/lib/faker/default/company.rb +2 -10
  18. data/lib/faker/default/crypto_coin.rb +3 -15
  19. data/lib/faker/default/date.rb +5 -38
  20. data/lib/faker/default/demographic.rb +1 -5
  21. data/lib/faker/default/driving_licence.rb +1 -11
  22. data/lib/faker/default/file.rb +2 -21
  23. data/lib/faker/default/fillmurray.rb +1 -10
  24. data/lib/faker/default/finance.rb +1 -5
  25. data/lib/faker/default/hipster.rb +6 -45
  26. data/lib/faker/default/id_number.rb +2 -10
  27. data/lib/faker/default/internet.rb +11 -69
  28. data/lib/faker/default/invoice.rb +3 -16
  29. data/lib/faker/default/json.rb +2 -20
  30. data/lib/faker/default/lorem.rb +9 -66
  31. data/lib/faker/default/lorem_flickr.rb +4 -32
  32. data/lib/faker/default/lorem_pixel.rb +4 -10
  33. data/lib/faker/default/markdown.rb +1 -6
  34. data/lib/faker/default/measurement.rb +8 -40
  35. data/lib/faker/default/name.rb +1 -5
  36. data/lib/faker/default/nhs.rb +1 -5
  37. data/lib/faker/default/number.rb +10 -55
  38. data/lib/faker/default/omniauth.rb +5 -39
  39. data/lib/faker/default/phone_number.rb +1 -5
  40. data/lib/faker/default/placeholdit.rb +1 -12
  41. data/lib/faker/default/relationship.rb +1 -5
  42. data/lib/faker/default/source.rb +3 -16
  43. data/lib/faker/default/string.rb +1 -5
  44. data/lib/faker/default/stripe.rb +4 -20
  45. data/lib/faker/default/time.rb +4 -32
  46. data/lib/faker/default/twitter.rb +3 -17
  47. data/lib/faker/default/types.rb +5 -27
  48. data/lib/faker/default/vehicle.rb +4 -17
  49. data/lib/faker/default/world_cup.rb +2 -11
  50. data/lib/faker/games/dota.rb +1 -5
  51. data/lib/faker/games/tarkov.rb +205 -0
  52. data/lib/faker/movies/hackers.rb +48 -0
  53. data/lib/faker/movies/star_wars.rb +1 -5
  54. data/lib/faker/version.rb +1 -1
  55. data/lib/faker.rb +0 -53
  56. data/lib/locales/en/hackers.yml +53 -0
  57. data/lib/locales/en/heroes.yml +2 -2
  58. data/lib/locales/en/opera.yml +1 -1
  59. data/lib/locales/en/overwatch.yml +5 -7
  60. data/lib/locales/en/source.yml +5 -0
  61. data/lib/locales/en/sport.yml +17 -8
  62. data/lib/locales/en/tarkov.yml +593 -0
  63. data/lib/locales/en-CA.yml +1 -0
  64. data/lib/locales/es-AR.yml +2 -2
  65. data/lib/locales/fi-FI.yml +2 -1
  66. data/lib/locales/fr/ancient.yml +141 -0
  67. data/lib/locales/hy.yml +1 -1
  68. data/lib/locales/th.yml +76 -76
  69. metadata +44 -16
@@ -29,12 +29,7 @@ module Faker
29
29
  # Faker::Internet.email(name: 'smith') #=> "smith@faker.com"
30
30
  # Faker::Internet.email(name: 'sam smith', separators: ['-']) #=> "sam-smith@faker.com"
31
31
  # Faker::Internet.email(name: 'sam smith', separators: ['-'], domain: 'gmail') #=> "sam-smith@gmail.com"
32
- def email(legacy_name = NOT_GIVEN, legacy_separators = NOT_GIVEN, name: nil, separators: nil, domain: nil)
33
- warn_for_deprecated_arguments do |keywords|
34
- keywords << :name if legacy_name != NOT_GIVEN
35
- keywords << :separators if legacy_separators != NOT_GIVEN
36
- end
37
-
32
+ def email(name: nil, separators: nil, domain: nil)
38
33
  local_part = if separators
39
34
  username(specifier: name, separators: separators)
40
35
  else
@@ -55,11 +50,7 @@ module Faker
55
50
  # @example
56
51
  # Faker::Internet.free_email #=> "samsmith@gmail.com"
57
52
  # Faker::Internet.free_email(name: 'smith') #=> "smith@yahoo.com"
58
- def free_email(legacy_name = NOT_GIVEN, name: nil)
59
- warn_for_deprecated_arguments do |keywords|
60
- keywords << :name if legacy_name != NOT_GIVEN
61
- end
62
-
53
+ def free_email(name: nil)
63
54
  construct_email(
64
55
  sanitize_email_local_part(username(specifier: name)),
65
56
  fetch('internet.free_email')
@@ -76,11 +67,7 @@ module Faker
76
67
  # @example
77
68
  # Faker::Internet.safe_email #=> "samsmith@example.com"
78
69
  # Faker::Internet.safe_email(name: 'smith') #=> "smith@example.net"
79
- def safe_email(legacy_name = NOT_GIVEN, name: nil)
80
- warn_for_deprecated_arguments do |keywords|
81
- keywords << :name if legacy_name != NOT_GIVEN
82
- end
83
-
70
+ def safe_email(name: nil)
84
71
  construct_email(
85
72
  sanitize_email_local_part(username(specifier: name)),
86
73
  "example.#{sample(%w[org com net])}"
@@ -100,12 +87,7 @@ module Faker
100
87
  # Faker::Internet.username(specifier: 5..10) #=> "morris"
101
88
  # Faker::Internet.username(specifier: 5..10) #=> "berryberry"
102
89
  # Faker::Internet.username(specifier: 20, separators: ['-']) #=> "nikki_sawaynnikki_saway"
103
- def username(legacy_specifier = NOT_GIVEN, legacy_separators = NOT_GIVEN, specifier: nil, separators: %w[. _])
104
- warn_for_deprecated_arguments do |keywords|
105
- keywords << :specifier if legacy_specifier != NOT_GIVEN
106
- keywords << :separators if legacy_separators != NOT_GIVEN
107
- end
108
-
90
+ def username(specifier: nil, separators: %w[. _])
109
91
  with_locale(:en) do
110
92
  return shuffle(specifier.scan(/[[:word:]]+/)).join(sample(separators)).downcase if specifier.respond_to?(:scan)
111
93
 
@@ -142,8 +124,6 @@ module Faker
142
124
  end
143
125
  end
144
126
 
145
- # rubocop:disable Metrics/ParameterLists
146
-
147
127
  ##
148
128
  # Produces a randomized string of characters suitable for passwords
149
129
  #
@@ -166,14 +146,7 @@ module Faker
166
146
  # Faker::Internet.password(min_length: 10, max_length: 20, mix_case: true, special_characters: true) #=> "*%NkOnJsH4"
167
147
  #
168
148
  # @faker.version 2.1.3
169
- def password(legacy_min_length = NOT_GIVEN, legacy_max_length = NOT_GIVEN, legacy_mix_case = NOT_GIVEN, legacy_special_characters = NOT_GIVEN, min_length: 8, max_length: 16, mix_case: true, special_characters: false)
170
- warn_for_deprecated_arguments do |keywords|
171
- keywords << :min_length if legacy_min_length != NOT_GIVEN
172
- keywords << :max_length if legacy_max_length != NOT_GIVEN
173
- keywords << :mix_case if legacy_mix_case != NOT_GIVEN
174
- keywords << :special_characters if legacy_special_characters != NOT_GIVEN
175
- end
176
-
149
+ def password(min_length: 8, max_length: 16, mix_case: true, special_characters: false)
177
150
  raise ArgumentError, 'Password of length 1 can not have both mixed case and special characters' if min_length <= 1 && mix_case && special_characters
178
151
 
179
152
  min_alpha = mix_case && min_length > 1 ? 2 : 0
@@ -206,7 +179,6 @@ module Faker
206
179
 
207
180
  temp
208
181
  end
209
- # rubocop:enable Metrics/ParameterLists
210
182
 
211
183
  ##
212
184
  # Returns the domain name
@@ -221,11 +193,7 @@ module Faker
221
193
  # Faker::Internet.domain_name(subdomain: true) #=> "test.faker.io"
222
194
  # Faker::Internet.domain_name(subdomain: true, domain: 'example') #=> "faker.example.com"
223
195
  # Faker::Internet.domain_name(domain: 'faker') #=> "faker.org"
224
- def domain_name(legacy_subdomain = NOT_GIVEN, subdomain: false, domain: nil)
225
- warn_for_deprecated_arguments do |keywords|
226
- keywords << :subdomain if legacy_subdomain != NOT_GIVEN
227
- end
228
-
196
+ def domain_name(subdomain: false, domain: nil)
229
197
  with_locale(:en) do
230
198
  if domain
231
199
  domain
@@ -254,11 +222,7 @@ module Faker
254
222
  # Faker::Internet.fix_umlauts #=> ""
255
223
  # Faker::Internet.fix_umlauts(string: 'faker') #=> "faker"
256
224
  # Faker::Internet.fix_umlauts(string: 'faküer') #=> "fakueer"
257
- def fix_umlauts(legacy_string = NOT_GIVEN, string: '')
258
- warn_for_deprecated_arguments do |keywords|
259
- keywords << :string if legacy_string != NOT_GIVEN
260
- end
261
-
225
+ def fix_umlauts(string: '')
262
226
  Char.fix_umlauts(string)
263
227
  end
264
228
 
@@ -294,11 +258,7 @@ module Faker
294
258
  # Faker::Internet.mac_address(prefix: 'a') #=> "0a:91:ce:24:89:3b"
295
259
  # Faker::Internet.mac_address(prefix: 'aa') #=> "aa:38:a0:3e:e8:41"
296
260
  # Faker::Internet.mac_address(prefix: 'aa:44') #=> "aa:44:30:88:6e:95"
297
- def mac_address(legacy_prefix = NOT_GIVEN, prefix: '')
298
- warn_for_deprecated_arguments do |keywords|
299
- keywords << :prefix if legacy_prefix != NOT_GIVEN
300
- end
301
-
261
+ def mac_address(prefix: '')
302
262
  prefix_digits = prefix.split(':').map { |d| d.to_i(16) }
303
263
  address_digits = Array.new((6 - prefix_digits.size)) { rand(256) }
304
264
  (prefix_digits + address_digits).map { |d| format('%02x', d) }.join(':')
@@ -440,8 +400,6 @@ module Faker
440
400
  "#{ip_v6_address}/#{rand(1..127)}"
441
401
  end
442
402
 
443
- # rubocop:disable Metrics/ParameterLists
444
-
445
403
  ##
446
404
  # Returns URL
447
405
  #
@@ -456,16 +414,9 @@ module Faker
456
414
  # Faker::Internet.url(host: 'faker') #=> "http://faker/shad"
457
415
  # Faker::Internet.url(host: 'faker', path: '/fake_test_path') #=> "http://faker/fake_test_path"
458
416
  # Faker::Internet.url(host: 'faker', path: '/fake_test_path', scheme: 'https') #=> "https://faker/fake_test_path"
459
- def url(legacy_host = NOT_GIVEN, legacy_path = NOT_GIVEN, legacy_scheme = NOT_GIVEN, host: domain_name, path: "/#{username}", scheme: 'http')
460
- warn_for_deprecated_arguments do |keywords|
461
- keywords << :host if legacy_host != NOT_GIVEN
462
- keywords << :path if legacy_path != NOT_GIVEN
463
- keywords << :scheme if legacy_scheme != NOT_GIVEN
464
- end
465
-
417
+ def url(host: domain_name, path: "/#{username}", scheme: 'http')
466
418
  "#{scheme}://#{host}#{path}"
467
419
  end
468
- # rubocop:enable Metrics/ParameterLists
469
420
 
470
421
  ##
471
422
  # Returns unique string in URL
@@ -480,12 +431,7 @@ module Faker
480
431
  # Faker::Internet.slug(words: 'test, faker') #=> "test-faker"
481
432
  # Faker::Internet.slug(words: 'test. faker') #=> "test-faker"
482
433
  # Faker::Internet.slug(words: 'test. faker', glue: '$') #=> "test$faker"
483
- def slug(legacy_words = NOT_GIVEN, legacy_glue = NOT_GIVEN, words: nil, glue: nil)
484
- warn_for_deprecated_arguments do |keywords|
485
- keywords << :words if legacy_words != NOT_GIVEN
486
- keywords << :glue if legacy_glue != NOT_GIVEN
487
- end
488
-
434
+ def slug(words: nil, glue: nil)
489
435
  glue ||= sample(%w[- _])
490
436
  return words.delete(',.').gsub(' ', glue).downcase unless words.nil?
491
437
 
@@ -515,11 +461,7 @@ module Faker
515
461
  # Faker::Internet.user_agent(vendor: 'chrome') #=> "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"
516
462
  # Faker::Internet.user_agent(vendor: 'safari') #=> "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A"
517
463
  # Faker::Internet.user_agent(vendor: 'faker') #=> "Mozilla/5.0 (Windows; U; Win 9x 4.90; SG; rv:1.9.2.4) Gecko/20101104 Netscape/9.1.0285"
518
- def user_agent(legacy_vendor = NOT_GIVEN, vendor: nil)
519
- warn_for_deprecated_arguments do |keywords|
520
- keywords << :vendor if legacy_vendor != NOT_GIVEN
521
- end
522
-
464
+ def user_agent(vendor: nil)
523
465
  agent_hash = translate('faker.internet.user_agent')
524
466
  agents = vendor.respond_to?(:to_sym) && agent_hash[vendor.to_sym] || agent_hash[sample(agent_hash.keys)]
525
467
  sample(agents)
@@ -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?
@@ -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
 
@@ -30,12 +30,7 @@ module Faker
30
30
  # Faker::Lorem.words(number: 4, supplemental: true) #=> ["nisi", "sit", "allatus", "consequatur"]
31
31
  #
32
32
  # @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
-
33
+ def words(number: 3, supplemental: false)
39
34
  resolved_num = resolve(number)
40
35
  word_list = (
41
36
  translate('faker.lorem.words') +
@@ -74,11 +69,7 @@ module Faker
74
69
  # Faker::Lorem.characters(number: 10, min_alpha: 4, min_numeric: 1) #=> "ang9cbhoa8"
75
70
  #
76
71
  # @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
-
72
+ def characters(number: 255, min_alpha: 0, min_numeric: 0)
82
73
  Alphanumeric.alphanumeric(number: number, min_alpha: min_alpha, min_numeric: min_numeric)
83
74
  end
84
75
 
@@ -95,7 +86,6 @@ module Faker
95
86
  def multibyte
96
87
  sample(translate('faker.lorem.multibyte')).pack('C*').force_encoding('utf-8')
97
88
  end
98
- # rubocop:disable Metrics/ParameterLists
99
89
 
100
90
  ##
101
91
  # Generates sentence
@@ -113,16 +103,9 @@ module Faker
113
103
  # Faker::Lorem.sentence(word_count: 5, supplemental: true, random_words_to_add:2) #=> "Crinis quo cruentus velit animi vomer."
114
104
  #
115
105
  # @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
-
106
+ def sentence(word_count: 4, supplemental: false, random_words_to_add: 0)
123
107
  words(number: word_count + rand(random_words_to_add.to_i), supplemental: supplemental).join(locale_space).capitalize + locale_period
124
108
  end
125
- # rubocop:enable Metrics/ParameterLists
126
109
 
127
110
  ##
128
111
  # Generates three sentences
@@ -138,17 +121,10 @@ module Faker
138
121
  # Faker::Lorem.sentences(number: 2, supplemental: true) #=> ["Cito cena ad.", "Solvo animus allatus."]
139
122
  #
140
123
  # @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
-
124
+ def sentences(number: 3, supplemental: false)
147
125
  1.upto(resolve(number)).collect { sentence(word_count: 3, supplemental: supplemental) }
148
126
  end
149
127
 
150
- # rubocop:disable Metrics/ParameterLists
151
-
152
128
  ##
153
129
  # Generates three sentence paragraph
154
130
  #
@@ -169,16 +145,9 @@ module Faker
169
145
  # #=> "Texo tantillus tamisium. Tribuo amissio tamisium. Facere aut canis."
170
146
  #
171
147
  # @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
-
148
+ def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 0)
179
149
  sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i), supplemental: supplemental).join(locale_space)
180
150
  end
181
- # rubocop:enable Metrics/ParameterLists
182
151
 
183
152
  ##
184
153
  # Generates three paragraphs
@@ -194,14 +163,7 @@ module Faker
194
163
  # Faker::Lorem.paragraphs(number:2, supplemental: true)
195
164
  #
196
165
  # @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
-
166
+ def paragraphs(number: 3, supplemental: false)
205
167
  1.upto(resolve(number)).collect { paragraph(sentence_count: 3, supplemental: supplemental) }
206
168
  end
207
169
 
@@ -219,12 +181,7 @@ module Faker
219
181
  # Faker::Lorem.paragraph_by_chars(number: 20, supplemental: true) #=> "Certus aveho admove."
220
182
  #
221
183
  # @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
-
184
+ def paragraph_by_chars(number: 256, supplemental: false)
228
185
  paragraph = paragraph(sentence_count: 3, supplemental: supplemental)
229
186
 
230
187
  paragraph += " #{paragraph(sentence_count: 3, supplemental: supplemental)}" while paragraph.length < number
@@ -232,8 +189,6 @@ module Faker
232
189
  "#{paragraph[0...number - 1]}."
233
190
  end
234
191
 
235
- # rubocop:disable Metrics/ParameterLists
236
-
237
192
  ##
238
193
  # Returns the question with 4 words
239
194
  #
@@ -250,16 +205,9 @@ module Faker
250
205
  # Faker::Lorem.question(word_count: 2, supplemental: true, random_words_to_add: 2) #=> "Depulso uter ut?"
251
206
  #
252
207
  # @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
-
208
+ def question(word_count: 4, supplemental: false, random_words_to_add: 0)
260
209
  words(number: word_count + rand(random_words_to_add), supplemental: supplemental).join(' ').capitalize + locale_question_mark
261
210
  end
262
- # rubocop:enable Metrics/ParameterLists
263
211
 
264
212
  ##
265
213
  # Generates array of three questions
@@ -275,12 +223,7 @@ module Faker
275
223
  # Faker::Lorem.questions(number: 2, supplemental: true) #=> ["Acceptus subito cetera?", "Aro sulum cubicularis?"]
276
224
  #
277
225
  # @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
-
226
+ def questions(number: 3, supplemental: false)
284
227
  1.upto(resolve(number)).collect { question(word_count: 3, supplemental: supplemental) }
285
228
  end
286
229
 
@@ -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
 
@@ -3,6 +3,8 @@
3
3
  module Faker
4
4
  class LoremPixel < Base
5
5
  class << self
6
+ extend Gem::Deprecate
7
+
6
8
  SUPPORTED_CATEGORIES = %w[abstract
7
9
  animals
8
10
  business
@@ -41,16 +43,7 @@ module Faker
41
43
  # Faker::LoremPixel.image(secure: false) #=> "http://lorempixel.com/300/300"
42
44
  #
43
45
  # @faker.version 1.7.0
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)
45
- warn_for_deprecated_arguments do |keywords|
46
- keywords << :size if legacy_size != NOT_GIVEN
47
- keywords << :is_gray if legacy_is_gray != NOT_GIVEN
48
- keywords << :category if legacy_category != NOT_GIVEN
49
- keywords << :number if legacy_number != NOT_GIVEN
50
- keywords << :text if legacy_text != NOT_GIVEN
51
- keywords << :secure if legacy_secure != NOT_GIVEN
52
- end
53
-
46
+ def image(size: '300x300', is_gray: false, category: nil, number: nil, text: nil, secure: true)
54
47
  raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /^[0-9]+x[0-9]+$/
55
48
  raise ArgumentError, "Supported categories are #{SUPPORTED_CATEGORIES.join(', ')}" unless category.nil? || SUPPORTED_CATEGORIES.include?(category)
56
49
  raise ArgumentError, 'Category required when number is passed' if !number.nil? && category.nil?
@@ -64,6 +57,7 @@ module Faker
64
57
  url_parts += [category, number, text].compact
65
58
  url_parts.join('/')
66
59
  end
60
+ deprecate :image, 'Faker::LoremFlickr.image', 2022, 12
67
61
  # rubocop:enable Metrics/ParameterLists
68
62
  end
69
63
  end
@@ -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
@@ -19,11 +19,7 @@ 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
 
@@ -38,11 +34,7 @@ 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
 
@@ -57,11 +49,7 @@ 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
 
@@ -76,11 +64,7 @@ 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
 
@@ -95,11 +79,7 @@ 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
 
@@ -114,11 +94,7 @@ 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
 
@@ -133,11 +109,7 @@ 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
 
@@ -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