faker 2.22.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +88 -7
  3. data/History.md +1 -1
  4. data/README.md +11 -5
  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 +8 -14
  17. data/lib/faker/default/code.rb +10 -23
  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 +6 -14
  21. data/lib/faker/default/crypto_coin.rb +3 -15
  22. data/lib/faker/default/date.rb +5 -38
  23. data/lib/faker/default/demographic.rb +1 -5
  24. data/lib/faker/default/driving_licence.rb +1 -11
  25. data/lib/faker/default/file.rb +5 -24
  26. data/lib/faker/default/fillmurray.rb +1 -10
  27. data/lib/faker/default/finance.rb +17 -7
  28. data/lib/faker/default/hipster.rb +6 -45
  29. data/lib/faker/default/id_number.rb +108 -11
  30. data/lib/faker/default/internet.rb +17 -71
  31. data/lib/faker/default/invoice.rb +3 -16
  32. data/lib/faker/default/json.rb +2 -20
  33. data/lib/faker/default/lorem.rb +9 -66
  34. data/lib/faker/default/lorem_flickr.rb +4 -32
  35. data/lib/faker/default/lorem_pixel.rb +4 -10
  36. data/lib/faker/default/markdown.rb +4 -9
  37. data/lib/faker/default/measurement.rb +8 -40
  38. data/lib/faker/default/name.rb +1 -5
  39. data/lib/faker/default/nhs.rb +2 -6
  40. data/lib/faker/default/number.rb +10 -55
  41. data/lib/faker/default/omniauth.rb +5 -39
  42. data/lib/faker/default/phone_number.rb +1 -5
  43. data/lib/faker/default/placeholdit.rb +1 -12
  44. data/lib/faker/default/relationship.rb +1 -5
  45. data/lib/faker/default/source.rb +3 -16
  46. data/lib/faker/default/string.rb +1 -5
  47. data/lib/faker/default/stripe.rb +4 -20
  48. data/lib/faker/default/time.rb +4 -32
  49. data/lib/faker/default/twitter.rb +3 -17
  50. data/lib/faker/default/types.rb +5 -27
  51. data/lib/faker/default/vehicle.rb +21 -21
  52. data/lib/faker/default/vulnerability_identifier.rb +23 -0
  53. data/lib/faker/default/world_cup.rb +2 -11
  54. data/lib/faker/games/dota.rb +1 -5
  55. data/lib/faker/games/tarkov.rb +205 -0
  56. data/lib/faker/japanese_media/kamen_rider.rb +2 -2
  57. data/lib/faker/japanese_media/one_piece.rb +1 -1
  58. data/lib/faker/movies/hackers.rb +48 -0
  59. data/lib/faker/movies/star_wars.rb +1 -5
  60. data/lib/faker/sports/sport.rb +110 -0
  61. data/lib/faker/version.rb +1 -1
  62. data/lib/faker.rb +15 -63
  63. data/lib/helpers/base58.rb +1 -1
  64. data/lib/helpers/unique_generator.rb +13 -11
  65. data/lib/locales/en/computer.yml +23 -4
  66. data/lib/locales/en/file.yml +9 -1
  67. data/lib/locales/en/finance.yml +3 -1
  68. data/lib/locales/en/hackers.yml +53 -0
  69. data/lib/locales/en/heroes.yml +2 -2
  70. data/lib/locales/en/one_piece.yml +1 -1
  71. data/lib/locales/en/opera.yml +1 -1
  72. data/lib/locales/en/overwatch.yml +5 -7
  73. data/lib/locales/en/source.yml +5 -0
  74. data/lib/locales/en/sport.yml +130 -0
  75. data/lib/locales/en/tarkov.yml +593 -0
  76. data/lib/locales/en/vehicle.yml +2809 -75
  77. data/lib/locales/en-CA.yml +1 -0
  78. data/lib/locales/es-AR.yml +2 -2
  79. data/lib/locales/fi-FI.yml +2 -1
  80. data/lib/locales/fr/ancient.yml +141 -0
  81. data/lib/locales/hy.yml +1 -1
  82. data/lib/locales/th.yml +76 -76
  83. metadata +50 -19
@@ -17,8 +17,6 @@ module Faker
17
17
  random_word =~ /\s/ ? word : random_word
18
18
  end
19
19
 
20
- # rubocop:disable Metrics/ParameterLists
21
-
22
20
  ##
23
21
  # Produces a random hipster word.
24
22
  #
@@ -34,13 +32,7 @@ module Faker
34
32
  # Faker::Hipster.words(number: 4, supplemental: true, spaces_allowed: true) #=> ["qui", "magni", "craft beer", "est"]
35
33
  #
36
34
  # @faker.version 1.6.0
37
- def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_spaces_allowed = NOT_GIVEN, number: 3, supplemental: false, spaces_allowed: false)
38
- warn_for_deprecated_arguments do |keywords|
39
- keywords << :number if legacy_number != NOT_GIVEN
40
- keywords << :supplemental if legacy_supplemental != NOT_GIVEN
41
- keywords << :spaces_allowed if legacy_spaces_allowed != NOT_GIVEN
42
- end
43
-
35
+ def words(number: 3, supplemental: false, spaces_allowed: false)
44
36
  resolved_num = resolve(number)
45
37
  word_list = (
46
38
  translate('faker.hipster.words') +
@@ -73,16 +65,9 @@ module Faker
73
65
  # Faker::Hipster.sentence(word_count: 3, supplemental: true, random_words_to_add: 0, open_compounds_allowed: false) #=> "Dreamcatcher umami fixie."
74
66
  #
75
67
  # @faker.version 1.6.0
76
- 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: 6, open_compounds_allowed: true)
77
- warn_for_deprecated_arguments do |keywords|
78
- keywords << :word_count if legacy_word_count != NOT_GIVEN
79
- keywords << :supplemental if legacy_supplemental != NOT_GIVEN
80
- keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
81
- end
82
-
68
+ def sentence(word_count: 4, supplemental: false, random_words_to_add: 6, open_compounds_allowed: true)
83
69
  "#{words(number: word_count + rand(random_words_to_add.to_i).to_i, supplemental: supplemental, spaces_allowed: open_compounds_allowed).join(' ').capitalize}."
84
70
  end
85
- # rubocop:enable Metrics/ParameterLists
86
71
 
87
72
  ##
88
73
  # Produces random hipster sentences.
@@ -97,12 +82,7 @@ module Faker
97
82
  # Faker::Hipster.sentences(number: 1, supplemental: true) #=> ["Et sustainable optio aesthetic et."]
98
83
  #
99
84
  # @faker.version 1.6.0
100
- def sentences(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
101
- warn_for_deprecated_arguments do |keywords|
102
- keywords << :number if legacy_number != NOT_GIVEN
103
- keywords << :supplemental if legacy_supplemental != NOT_GIVEN
104
- end
105
-
85
+ def sentences(number: 3, supplemental: false)
106
86
  [].tap do |sentences|
107
87
  1.upto(resolve(number)) do
108
88
  sentences << sentence(word_count: 3, supplemental: supplemental)
@@ -110,8 +90,6 @@ module Faker
110
90
  end
111
91
  end
112
92
 
113
- # rubocop:disable Metrics/ParameterLists
114
-
115
93
  ##
116
94
  # Produces a random hipster paragraph.
117
95
  #
@@ -128,16 +106,9 @@ module Faker
128
106
  # Faker::Hipster.paragraph(sentence_count: 2, supplemental: true, random_sentences_to_add: 4) #=> "Deep v gluten-free unde waistcoat aperiam migas voluptas dolorum. Aut drinking illo sustainable sapiente. Direct trade fanny pack kale chips ennui semiotics."
129
107
  #
130
108
  # @faker.version 1.6.0
131
- 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: 3)
132
- warn_for_deprecated_arguments do |keywords|
133
- keywords << :sentence_count if legacy_sentence_count != NOT_GIVEN
134
- keywords << :supplemental if legacy_supplemental != NOT_GIVEN
135
- keywords << :random_sentences_to_add if legacy_random_sentences_to_add != NOT_GIVEN
136
- end
137
-
109
+ def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 3)
138
110
  sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i, supplemental: supplemental).join(' ')
139
111
  end
140
- # rubocop:enable Metrics/ParameterLists
141
112
 
142
113
  ##
143
114
  # Produces random hipster paragraphs.
@@ -152,12 +123,7 @@ module Faker
152
123
  # Faker::Hipster.paragraphs(number: 1, supplemental: true) #=> ["Quae direct trade pbr&b quo taxidermy autem loko. Umami quas ratione migas cardigan sriracha minima. Tenetur perspiciatis pickled sed eum doloribus truffaut. Excepturi dreamcatcher meditation."]
153
124
  #
154
125
  # @faker.version 1.6.0
155
- def paragraphs(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
156
- warn_for_deprecated_arguments do |keywords|
157
- keywords << :number if legacy_number != NOT_GIVEN
158
- keywords << :supplemental if legacy_supplemental != NOT_GIVEN
159
- end
160
-
126
+ def paragraphs(number: 3, supplemental: false)
161
127
  [].tap do |paragraphs|
162
128
  1.upto(resolve(number)) do
163
129
  paragraphs << paragraph(sentence_count: 3, supplemental: supplemental)
@@ -177,12 +143,7 @@ module Faker
177
143
  # Faker::Hipster.paragraph_by_chars(characters: 256, supplemental: false) #=> "Hella kogi blog narwhal sartorial selfies mustache schlitz. Bespoke normcore kitsch cred hella fixie. Park aesthetic fixie migas twee. Cliche mustache brunch tumblr fixie godard. Drinking pop-up synth hoodie dreamcatcher typewriter. Kitsch biodiesel green."
178
144
  #
179
145
  # @faker.version 1.6.0
180
- def paragraph_by_chars(legacy_characters = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, characters: 256, supplemental: false)
181
- warn_for_deprecated_arguments do |keywords|
182
- keywords << :characters if legacy_characters != NOT_GIVEN
183
- keywords << :supplemental if legacy_supplemental != NOT_GIVEN
184
- end
185
-
146
+ def paragraph_by_chars(characters: 256, supplemental: false)
186
147
  paragraph = paragraph(sentence_count: 3, supplemental: supplemental)
187
148
 
188
149
  paragraph += " #{paragraph(sentence_count: 3, supplemental: supplemental)}" while paragraph.length < characters
@@ -146,11 +146,7 @@ module Faker
146
146
  # Faker::IDNumber.brazilian_citizen_number(formatted: true) #=> "535.405.422-21"
147
147
  #
148
148
  # @faker.version 1.9.2
149
- def brazilian_citizen_number(legacy_formatted = NOT_GIVEN, formatted: false)
150
- warn_for_deprecated_arguments do |keywords|
151
- keywords << :formatted if legacy_formatted != NOT_GIVEN
152
- end
153
-
149
+ def brazilian_citizen_number(formatted: false)
154
150
  digits = Faker::Number.leading_zero_number(digits: 9) until digits&.match(/(\d)((?!\1)\d)+/)
155
151
  first_digit = brazilian_citizen_number_checksum_digit(digits)
156
152
  second_digit = brazilian_citizen_number_checksum_digit(digits + first_digit)
@@ -171,11 +167,7 @@ module Faker
171
167
  # Faker::IDNumber.brazilian_id(formatted: true) #=> "49.305.402-9"
172
168
  #
173
169
  # @faker.version 2.1.2
174
- def brazilian_id(legacy_formatted = NOT_GIVEN, formatted: false)
175
- warn_for_deprecated_arguments do |keywords|
176
- keywords << :formatted if legacy_formatted != NOT_GIVEN
177
- end
178
-
170
+ def brazilian_id(formatted: false)
179
171
  digits = Faker::Number.between(to: BRAZILIAN_ID_FROM, from: BRAZILIAN_ID_TO).to_s
180
172
  check_digit = brazilian_id_checksum_digit(digits)
181
173
  number = [digits, check_digit].join
@@ -219,6 +211,72 @@ module Faker
219
211
  "#{prefix}#{digits}#{checksum_digit}"
220
212
  end
221
213
 
214
+ ##
215
+ # Produces a random Danish ID Number (CPR number).
216
+ # CPR number is 10 digits. Digit 1-6 is the birthdate (format "DDMMYY").
217
+ # Digit 7-10 is a sequence number.
218
+ # Digit 7 digit is a control digit that determines the century of birth.
219
+ # Digit 10 reveals the gender: # even is female, odd is male.
220
+ #
221
+ # @param formatted [Boolean] Specifies if the number is formatted with dividers.
222
+ # @param birthday [Date] Specifies the birthday for the id number.
223
+ # @param gender [Symbol] Specifies the gender for the id number. Must be one :male or :female if present.
224
+ # @return [String]
225
+ #
226
+ # @example
227
+ # Faker::IDNumber.danish_id_number #=> "0503909980"
228
+ # Faker::IDNumber.danish_id_number(formatted: true) #=> "050390-9980"
229
+ # Faker::IDNumber.danish_id_number(birthday: Date.new(1990, 3, 5)) #=> "0503909980"
230
+ # Faker::IDNumber.danish_id_number(gender: :female) #=> "0503909980"
231
+ #
232
+ # @faker.version next
233
+ def danish_id_number(formatted: false, birthday: Faker::Date.birthday, gender: nil)
234
+ valid_control_digits = danish_control_digits(birthday)
235
+ control_digit = sample(valid_control_digits)
236
+ digits = (0..9).to_a
237
+ gender = gender.to_sym if gender.respond_to?(:to_sym)
238
+ gender_digit = case gender
239
+ when nil
240
+ sample(digits)
241
+ when :male
242
+ sample(digits.select(&:odd?))
243
+ when :female
244
+ sample(digits.select(&:even?))
245
+ else
246
+ raise ArgumentError, "Invalid gender #{gender}. Must be one of male, female, or be omitted."
247
+ end
248
+
249
+ [
250
+ birthday.strftime('%d%m%y'),
251
+ formatted ? '-' : '',
252
+ control_digit,
253
+ Faker::Number.number(digits: 2),
254
+ gender_digit
255
+ ].join
256
+ end
257
+
258
+ ##
259
+ # Produces a random French social security number (INSEE number).
260
+ #
261
+ # @return [String]
262
+ #
263
+ # @example
264
+ # Faker::IDNumber.french_insee_number #=> "53290236-H"
265
+ #
266
+ # @faker.version next
267
+ def french_insee_number
268
+ num = [
269
+ [1, 2].sample(random: Faker::Config.random), # gender
270
+ Faker::Number.between(from: 0, to: 99).to_s.rjust(2, '0'), # year of birth
271
+ Faker::Number.between(from: 1, to: 12).to_s.rjust(2, '0'), # month of birth
272
+ Faker::Number.number(digits: 5), # place of birth
273
+ Faker::Number.number(digits: 3) # order number
274
+ ].join
275
+ mod = num.to_i % 97
276
+ check = (97 - mod).to_s.rjust(2, '0')
277
+ "#{num}#{check}"
278
+ end
279
+
222
280
  private
223
281
 
224
282
  def croatian_id_checksum_digit(digits)
@@ -266,7 +324,7 @@ module Faker
266
324
  .with_index { |_, i| (i + 1).odd? }
267
325
 
268
326
  sum_of_odd_digits = odd_digits_without_last_character.map(&:to_i).reduce(:+)
269
- even_digits_times_two = (even_digits.join('').to_i * 2).to_s
327
+ even_digits_times_two = (even_digits.join.to_i * 2).to_s
270
328
  sum_of_even_digits = even_digits_times_two.chars.map(&:to_i).reduce(:+)
271
329
 
272
330
  total_sum = sum_of_odd_digits + sum_of_even_digits
@@ -305,6 +363,45 @@ module Faker
305
363
  digits.include?(subtraction) ? digits[subtraction] : subtraction.to_s
306
364
  end
307
365
 
366
+ def danish_control_digits(birthday)
367
+ year = birthday.year
368
+ century = year.to_s.slice(0, 2).to_i
369
+ year_digits = year.to_s.slice(2, 2).to_i
370
+ error_message = "Invalid birthday: #{birthday}. Danish CPR numbers are only distributed to persons born between 1858 and 2057."
371
+
372
+ case century
373
+ when 18
374
+ # If 5, 6, 7 or 8 and the year numbers are greater than or equal to 58, you were born in 18XX.
375
+ case year_digits
376
+ when 58..99
377
+ [5, 6, 7, 8]
378
+ else
379
+ raise ArgumentError, error_message
380
+ end
381
+ when 19
382
+ # If 0, 1, 2 or 3, you are always born in 19XX.
383
+ # If 4 or 9, you are born in 19XX if the year digits are greater than 36.
384
+
385
+ case year_digits
386
+ when 0..36
387
+ [0, 1, 2, 3]
388
+ else # 37..99
389
+ [0, 1, 2, 3, 4, 9]
390
+ end
391
+ else
392
+ # If 4, 5, 6, 7, 8 or 9 and the year digits are less than or equal to 36, you were born in 20XX.
393
+ # 5, 6, 7 and 8 are not distributed to persons, with year digits from and including 37 to and including 57.
394
+ case year_digits
395
+ when 0..36
396
+ [4, 5, 6, 7, 8, 9]
397
+ when 37..57
398
+ [5, 6, 7, 8]
399
+ else
400
+ raise ArgumentError, error_message
401
+ end
402
+ end
403
+ end
404
+
308
405
  def _translate(key)
309
406
  parse("id_number.#{key}")
310
407
  end
@@ -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,13 +146,8 @@ 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
149
+ def password(min_length: 8, max_length: 16, mix_case: true, special_characters: false)
150
+ raise ArgumentError, 'Password of length 1 can not have both mixed case and special characters' if min_length <= 1 && mix_case && special_characters
176
151
 
177
152
  min_alpha = mix_case && min_length > 1 ? 2 : 0
178
153
  temp = Lorem.characters(number: min_length, min_alpha: min_alpha)
@@ -200,9 +175,10 @@ module Faker
200
175
  end
201
176
  end
202
177
 
178
+ temp[rand(temp.size - 1)] = Lorem.characters(number: 1, min_alpha: 1).upcase if mix_case && special_characters && !temp.match(/[A-z]+/)
179
+
203
180
  temp
204
181
  end
205
- # rubocop:enable Metrics/ParameterLists
206
182
 
207
183
  ##
208
184
  # Returns the domain name
@@ -217,11 +193,7 @@ module Faker
217
193
  # Faker::Internet.domain_name(subdomain: true) #=> "test.faker.io"
218
194
  # Faker::Internet.domain_name(subdomain: true, domain: 'example') #=> "faker.example.com"
219
195
  # Faker::Internet.domain_name(domain: 'faker') #=> "faker.org"
220
- def domain_name(legacy_subdomain = NOT_GIVEN, subdomain: false, domain: nil)
221
- warn_for_deprecated_arguments do |keywords|
222
- keywords << :subdomain if legacy_subdomain != NOT_GIVEN
223
- end
224
-
196
+ def domain_name(subdomain: false, domain: nil)
225
197
  with_locale(:en) do
226
198
  if domain
227
199
  domain
@@ -250,11 +222,7 @@ module Faker
250
222
  # Faker::Internet.fix_umlauts #=> ""
251
223
  # Faker::Internet.fix_umlauts(string: 'faker') #=> "faker"
252
224
  # Faker::Internet.fix_umlauts(string: 'faküer') #=> "fakueer"
253
- def fix_umlauts(legacy_string = NOT_GIVEN, string: '')
254
- warn_for_deprecated_arguments do |keywords|
255
- keywords << :string if legacy_string != NOT_GIVEN
256
- end
257
-
225
+ def fix_umlauts(string: '')
258
226
  Char.fix_umlauts(string)
259
227
  end
260
228
 
@@ -266,7 +234,7 @@ module Faker
266
234
  # @example
267
235
  # Faker::Internet.domain_word #=> "senger"
268
236
  def domain_word
269
- with_locale(:en) { Char.prepare(Company.name.split(' ').first) }
237
+ with_locale(:en) { Char.prepare(Company.name.split.first) }
270
238
  end
271
239
 
272
240
  ## Returns the domain suffix e.g. com, org, co, biz, info etc.
@@ -290,11 +258,7 @@ module Faker
290
258
  # Faker::Internet.mac_address(prefix: 'a') #=> "0a:91:ce:24:89:3b"
291
259
  # Faker::Internet.mac_address(prefix: 'aa') #=> "aa:38:a0:3e:e8:41"
292
260
  # Faker::Internet.mac_address(prefix: 'aa:44') #=> "aa:44:30:88:6e:95"
293
- def mac_address(legacy_prefix = NOT_GIVEN, prefix: '')
294
- warn_for_deprecated_arguments do |keywords|
295
- keywords << :prefix if legacy_prefix != NOT_GIVEN
296
- end
297
-
261
+ def mac_address(prefix: '')
298
262
  prefix_digits = prefix.split(':').map { |d| d.to_i(16) }
299
263
  address_digits = Array.new((6 - prefix_digits.size)) { rand(256) }
300
264
  (prefix_digits + address_digits).map { |d| format('%02x', d) }.join(':')
@@ -436,8 +400,6 @@ module Faker
436
400
  "#{ip_v6_address}/#{rand(1..127)}"
437
401
  end
438
402
 
439
- # rubocop:disable Metrics/ParameterLists
440
-
441
403
  ##
442
404
  # Returns URL
443
405
  #
@@ -452,16 +414,9 @@ module Faker
452
414
  # Faker::Internet.url(host: 'faker') #=> "http://faker/shad"
453
415
  # Faker::Internet.url(host: 'faker', path: '/fake_test_path') #=> "http://faker/fake_test_path"
454
416
  # Faker::Internet.url(host: 'faker', path: '/fake_test_path', scheme: 'https') #=> "https://faker/fake_test_path"
455
- def url(legacy_host = NOT_GIVEN, legacy_path = NOT_GIVEN, legacy_scheme = NOT_GIVEN, host: domain_name, path: "/#{username}", scheme: 'http')
456
- warn_for_deprecated_arguments do |keywords|
457
- keywords << :host if legacy_host != NOT_GIVEN
458
- keywords << :path if legacy_path != NOT_GIVEN
459
- keywords << :scheme if legacy_scheme != NOT_GIVEN
460
- end
461
-
417
+ def url(host: domain_name, path: "/#{username}", scheme: 'http')
462
418
  "#{scheme}://#{host}#{path}"
463
419
  end
464
- # rubocop:enable Metrics/ParameterLists
465
420
 
466
421
  ##
467
422
  # Returns unique string in URL
@@ -476,12 +431,7 @@ module Faker
476
431
  # Faker::Internet.slug(words: 'test, faker') #=> "test-faker"
477
432
  # Faker::Internet.slug(words: 'test. faker') #=> "test-faker"
478
433
  # Faker::Internet.slug(words: 'test. faker', glue: '$') #=> "test$faker"
479
- def slug(legacy_words = NOT_GIVEN, legacy_glue = NOT_GIVEN, words: nil, glue: nil)
480
- warn_for_deprecated_arguments do |keywords|
481
- keywords << :words if legacy_words != NOT_GIVEN
482
- keywords << :glue if legacy_glue != NOT_GIVEN
483
- end
484
-
434
+ def slug(words: nil, glue: nil)
485
435
  glue ||= sample(%w[- _])
486
436
  return words.delete(',.').gsub(' ', glue).downcase unless words.nil?
487
437
 
@@ -511,11 +461,7 @@ module Faker
511
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"
512
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"
513
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"
514
- def user_agent(legacy_vendor = NOT_GIVEN, vendor: nil)
515
- warn_for_deprecated_arguments do |keywords|
516
- keywords << :vendor if legacy_vendor != NOT_GIVEN
517
- end
518
-
464
+ def user_agent(vendor: nil)
519
465
  agent_hash = translate('faker.internet.user_agent')
520
466
  agents = vendor.respond_to?(:to_sym) && agent_hash[vendor.to_sym] || agent_hash[sample(agent_hash.keys)]
521
467
  sample(agents)
@@ -609,10 +555,10 @@ module Faker
609
555
  Array('0'..'9'),
610
556
  Array('A'..'Z'),
611
557
  Array('a'..'z'),
612
- "!#$%&'*+-/=?^_`{|}~.".split(//)
558
+ "!#$%&'*+-/=?^_`{|}~.".chars
613
559
  ].flatten
614
560
 
615
- local_part.split(//).map do |char|
561
+ local_part.chars.map do |char|
616
562
  char_range.include?(char) ? char : '#'
617
563
  end.join
618
564
  end
@@ -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