faker 2.23.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 (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
@@ -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)
@@ -17,8 +17,6 @@ module Faker
17
17
  end
18
18
 
19
19
  class << self
20
- # rubocop:disable Metrics/ParameterLists
21
-
22
20
  ##
23
21
  # Generate a mock Omniauth response from Google.
24
22
  #
@@ -29,13 +27,7 @@ module Faker
29
27
  # @return [Hash] An auth hash in the format provided by omniauth-google.
30
28
  #
31
29
  # @faker.version 1.8.0
32
- def google(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, uid: Number.number(digits: 9).to_s)
33
- warn_for_deprecated_arguments do |keywords|
34
- keywords << :name if legacy_name != NOT_GIVEN
35
- keywords << :email if legacy_email != NOT_GIVEN
36
- keywords << :uid if legacy_uid != NOT_GIVEN
37
- end
38
-
30
+ def google(name: nil, email: nil, uid: Number.number(digits: 9).to_s)
39
31
  auth = Omniauth.new(name: name, email: email)
40
32
  {
41
33
  provider: 'google_oauth2',
@@ -95,14 +87,7 @@ module Faker
95
87
  # @return [Hash] An auth hash in the format provided by omniauth-facebook.
96
88
  #
97
89
  # @faker.version 1.8.0
98
- def facebook(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_username = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, username: nil, uid: Number.number(digits: 7).to_s)
99
- warn_for_deprecated_arguments do |keywords|
100
- keywords << :name if legacy_name != NOT_GIVEN
101
- keywords << :email if legacy_email != NOT_GIVEN
102
- keywords << :username if legacy_username != NOT_GIVEN
103
- keywords << :uid if legacy_uid != NOT_GIVEN
104
- end
105
-
90
+ def facebook(name: nil, email: nil, username: nil, uid: Number.number(digits: 7).to_s)
106
91
  auth = Omniauth.new(name: name, email: email)
107
92
  username ||= "#{auth.first_name.downcase[0]}#{auth.last_name.downcase}"
108
93
  {
@@ -154,13 +139,7 @@ module Faker
154
139
  # @return [Hash] An auth hash in the format provided by omniauth-twitter.
155
140
  #
156
141
  # @faker.version 1.8.0
157
- def twitter(legacy_name = NOT_GIVEN, legacy_nickname = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, nickname: nil, uid: Number.number(digits: 6).to_s)
158
- warn_for_deprecated_arguments do |keywords|
159
- keywords << :name if legacy_name != NOT_GIVEN
160
- keywords << :nickname if legacy_nickname != NOT_GIVEN
161
- keywords << :uid if legacy_uid != NOT_GIVEN
162
- end
163
-
142
+ def twitter(name: nil, nickname: nil, uid: Number.number(digits: 6).to_s)
164
143
  auth = Omniauth.new(name: name)
165
144
  nickname ||= auth.name.downcase.delete(' ')
166
145
  location = city_state
@@ -243,13 +222,7 @@ module Faker
243
222
  # @return [Hash] An auth hash in the format provided by omniauth-linkedin.
244
223
  #
245
224
  # @faker.version 1.8.0
246
- def linkedin(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, uid: Number.number(digits: 6).to_s)
247
- warn_for_deprecated_arguments do |keywords|
248
- keywords << :name if legacy_name != NOT_GIVEN
249
- keywords << :email if legacy_email != NOT_GIVEN
250
- keywords << :uid if legacy_uid != NOT_GIVEN
251
- end
252
-
225
+ def linkedin(name: nil, email: nil, uid: Number.number(digits: 6).to_s)
253
226
  auth = Omniauth.new(name: name, email: email)
254
227
  first_name = auth.first_name.downcase
255
228
  last_name = auth.last_name.downcase
@@ -322,13 +295,7 @@ module Faker
322
295
  # @return [Hash] An auth hash in the format provided by omniauth-github.
323
296
  #
324
297
  # @faker.version 1.8.0
325
- def github(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, uid: Number.number(digits: 8).to_s)
326
- warn_for_deprecated_arguments do |keywords|
327
- keywords << :name if legacy_name != NOT_GIVEN
328
- keywords << :email if legacy_email != NOT_GIVEN
329
- keywords << :uid if legacy_uid != NOT_GIVEN
330
- end
331
-
298
+ def github(name: nil, email: nil, uid: Number.number(digits: 8).to_s)
332
299
  auth = Omniauth.new(name: name, email: email)
333
300
  login = auth.name.downcase.tr(' ', '-')
334
301
  html_url = "https://github.com/#{login}"
@@ -385,7 +352,6 @@ module Faker
385
352
  }
386
353
  }
387
354
  end
388
- # rubocop:enable Metrics/ParameterLists
389
355
 
390
356
  ##
391
357
  # Generate a mock Omniauth response from Apple.
@@ -123,11 +123,7 @@ module Faker
123
123
  # Faker::PhoneNumber.extension #=> "3764"
124
124
  #
125
125
  # @faker.version 1.3.0
126
- def subscriber_number(legacy_length = NOT_GIVEN, length: 4)
127
- warn_for_deprecated_arguments do |keywords|
128
- keywords << :length if legacy_length != NOT_GIVEN
129
- end
130
-
126
+ def subscriber_number(length: 4)
131
127
  rand.to_s[2..(1 + length)]
132
128
  end
133
129
 
@@ -5,8 +5,6 @@ module Faker
5
5
  class << self
6
6
  SUPPORTED_FORMATS = %w[png jpg gif jpeg].freeze
7
7
 
8
- # rubocop:disable Metrics/ParameterLists
9
-
10
8
  ##
11
9
  # Produces a random placeholder image from https://via.placeholder.com.
12
10
  #
@@ -28,15 +26,7 @@ module Faker
28
26
  # Faker::Placeholdit.image(size: '50x50', format: 'jpg', background_color: 'ffffff', text_color: '000', text: 'Some Custom Text') #=> "https://via.placeholder.com/50x50.jpg/ffffff/000?text=Some Custom Text"
29
27
  #
30
28
  # @faker.version 1.6.0
31
- def image(legacy_size = NOT_GIVEN, legacy_format = NOT_GIVEN, legacy_background_color = NOT_GIVEN, legacy_text_color = NOT_GIVEN, legacy_text = NOT_GIVEN, size: '300x300', format: 'png', background_color: nil, text_color: nil, text: nil)
32
- warn_for_deprecated_arguments do |keywords|
33
- keywords << :size if legacy_size != NOT_GIVEN
34
- keywords << :format if legacy_format != NOT_GIVEN
35
- keywords << :background_color if legacy_background_color != NOT_GIVEN
36
- keywords << :text_color if legacy_text_color != NOT_GIVEN
37
- keywords << :text if legacy_text != NOT_GIVEN
38
- end
39
-
29
+ def image(size: '300x300', format: 'png', background_color: nil, text_color: nil, text: nil)
40
30
  background_color = generate_color if background_color == :random
41
31
  text_color = generate_color if text_color == :random
42
32
 
@@ -51,7 +41,6 @@ module Faker
51
41
  image_url += "?text=#{text}" if text
52
42
  image_url
53
43
  end
54
- # rubocop:enable Metrics/ParameterLists
55
44
 
56
45
  private
57
46
 
@@ -14,11 +14,7 @@ module Faker
14
14
  # Faker::Relationship.familial #=> "Grandfather"
15
15
  #
16
16
  # @faker.version 1.9.2
17
- def familial(legacy_connection = NOT_GIVEN, connection: nil)
18
- warn_for_deprecated_arguments do |keywords|
19
- keywords << :connection if legacy_connection != NOT_GIVEN
20
- end
21
-
17
+ def familial(connection: nil)
22
18
  familial_connections = translate('faker.relationship.familial').keys
23
19
 
24
20
  if connection.nil?
@@ -17,11 +17,7 @@ module Faker
17
17
  # #=> "alert('Hello World!');"
18
18
  #
19
19
  # @faker.version 1.9.0
20
- def hello_world(legacy_lang = NOT_GIVEN, lang: :ruby)
21
- warn_for_deprecated_arguments do |keywords|
22
- keywords << :lang if legacy_lang != NOT_GIVEN
23
- end
24
-
20
+ def hello_world(lang: :ruby)
25
21
  fetch("source.hello_world.#{lang}")
26
22
  end
27
23
 
@@ -39,13 +35,7 @@ module Faker
39
35
  # #=> "console.log('foo bar');"
40
36
  #
41
37
  # @faker.version 1.9.0
42
- def print(legacy_str = NOT_GIVEN, legacy_lang = NOT_GIVEN, str: 'some string', lang: :ruby)
43
- warn_for_deprecated_arguments do |keywords|
44
- keywords << :str if legacy_str != NOT_GIVEN
45
- end
46
- warn_for_deprecated_arguments do |keywords|
47
- keywords << :lang if legacy_lang != NOT_GIVEN
48
- end
38
+ def print(str: 'some string', lang: :ruby)
49
39
  code = fetch("source.print.#{lang}")
50
40
  code.gsub('faker_string_to_print', str)
51
41
  end
@@ -65,10 +55,7 @@ module Faker
65
55
  # # }"
66
56
  #
67
57
  # @faker.version 1.9.0
68
- def print_1_to_10(legacy_lang = NOT_GIVEN, lang: :ruby)
69
- warn_for_deprecated_arguments do |keywords|
70
- keywords << :lang if legacy_lang != NOT_GIVEN
71
- end
58
+ def print_1_to_10(lang: :ruby)
72
59
  fetch("source.print_1_to_10.#{lang}")
73
60
  end
74
61
  end
@@ -17,11 +17,7 @@ module Faker
17
17
  # Faker::String.random(length: [1, (2..5), [3, 6], nil]) #=> "葓L#ћ"
18
18
  #
19
19
  # @faker.version 1.9.0
20
- def random(legacy_length = NOT_GIVEN, length: 32)
21
- warn_for_deprecated_arguments do |keywords|
22
- keywords << :length if legacy_length != NOT_GIVEN
23
- end
24
-
20
+ def random(length: 32)
25
21
  utf8string select_a length
26
22
  end
27
23
 
@@ -14,11 +14,7 @@ module Faker
14
14
  # Faker::Stripe.valid_card(card_type: "visa_debit") #=> "4000056655665556"
15
15
  #
16
16
  # @faker.version 1.9.0
17
- def valid_card(legacy_card_type = NOT_GIVEN, card_type: nil)
18
- warn_for_deprecated_arguments do |keywords|
19
- keywords << :card_type if legacy_card_type != NOT_GIVEN
20
- end
21
-
17
+ def valid_card(card_type: nil)
22
18
  valid_cards = translate('faker.stripe.valid_cards').keys
23
19
 
24
20
  if card_type.nil?
@@ -44,11 +40,7 @@ module Faker
44
40
  # Faker::Stripe.valid_token(card_type: "mc_debit") #=> "tok_mastercard_debit"
45
41
  #
46
42
  # @faker.version 1.9.0
47
- def valid_token(legacy_card_type = NOT_GIVEN, card_type: nil)
48
- warn_for_deprecated_arguments do |keywords|
49
- keywords << :card_type if legacy_card_type != NOT_GIVEN
50
- end
51
-
43
+ def valid_token(card_type: nil)
52
44
  valid_tokens = translate('faker.stripe.valid_tokens').keys
53
45
 
54
46
  if card_type.nil?
@@ -73,11 +65,7 @@ module Faker
73
65
  # Faker::Stripe.invalid_card(card_error: "addressZipFail") #=> "4000000000000010"
74
66
  #
75
67
  # @faker.version 1.9.0
76
- def invalid_card(legacy_card_error = NOT_GIVEN, card_error: nil)
77
- warn_for_deprecated_arguments do |keywords|
78
- keywords << :card_error if legacy_card_error != NOT_GIVEN
79
- end
80
-
68
+ def invalid_card(card_error: nil)
81
69
  invalid_cards = translate('faker.stripe.invalid_cards').keys
82
70
 
83
71
  if card_error.nil?
@@ -130,11 +118,7 @@ module Faker
130
118
  # Faker::Stripe.ccv(card_type: "amex") #=> "1234"
131
119
  #
132
120
  # @faker.version 1.9.0
133
- def ccv(legacy_card_type = NOT_GIVEN, card_type: nil)
134
- warn_for_deprecated_arguments do |keywords|
135
- keywords << :card_type if legacy_card_type != NOT_GIVEN
136
- end
137
-
121
+ def ccv(card_type: nil)
138
122
  (card_type.to_s == 'amex' ? rand_in_range(1000, 9999) : rand_in_range(100, 999)).to_s
139
123
  end
140
124
  end
@@ -13,8 +13,6 @@ module Faker
13
13
  }.freeze
14
14
 
15
15
  class << self
16
- # rubocop:disable Metrics/ParameterLists
17
-
18
16
  ##
19
17
  # Produce a random time between two times.
20
18
  #
@@ -37,13 +35,7 @@ module Faker
37
35
  # Faker::Time.between(from: DateTime.now - 1, to: DateTime.now, format: :long) #=> "2018年10月16日(火) 10時48分27秒 -0500"
38
36
  #
39
37
  # @faker.version 1.5.0
40
- def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_format = NOT_GIVEN, from:, to:, format: nil)
41
- warn_for_deprecated_arguments do |keywords|
42
- keywords << :from if legacy_from != NOT_GIVEN
43
- keywords << :to if legacy_to != NOT_GIVEN
44
- keywords << :format if legacy_format != NOT_GIVEN
45
- end
46
-
38
+ def between(from:, to:, format: nil)
47
39
  from = get_time_object(from)
48
40
  to = get_time_object(to)
49
41
 
@@ -79,14 +71,7 @@ module Faker
79
71
  # #=> "Fri, 19 Oct 2018 15:17:46 -0500"
80
72
  #
81
73
  # @faker.version 1.0.0
82
- def between_dates(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_period = NOT_GIVEN, legacy_format = NOT_GIVEN, from:, to:, period: :all, format: nil)
83
- warn_for_deprecated_arguments do |keywords|
84
- keywords << :from if legacy_from != NOT_GIVEN
85
- keywords << :to if legacy_to != NOT_GIVEN
86
- keywords << :period if legacy_period != NOT_GIVEN
87
- keywords << :format if legacy_format != NOT_GIVEN
88
- end
89
-
74
+ def between_dates(from:, to:, period: :all, format: nil)
90
75
  date = Faker::Date.between(from: from, to: to)
91
76
  time = date_with_random_time(date, period)
92
77
  time_with_format(time, format)
@@ -107,13 +92,7 @@ module Faker
107
92
  # #=> "October 21, 2018 20:47"
108
93
  #
109
94
  # @faker.version 1.5.0
110
- def forward(legacy_days = NOT_GIVEN, legacy_period = NOT_GIVEN, legacy_format = NOT_GIVEN, days: 365, period: :all, format: nil)
111
- warn_for_deprecated_arguments do |keywords|
112
- keywords << :days if legacy_days != NOT_GIVEN
113
- keywords << :period if legacy_period != NOT_GIVEN
114
- keywords << :format if legacy_format != NOT_GIVEN
115
- end
116
-
95
+ def forward(days: 365, period: :all, format: nil)
117
96
  time_with_format(date_with_random_time(Faker::Date.forward(days: days), period), format)
118
97
  end
119
98
 
@@ -132,16 +111,9 @@ module Faker
132
111
  # #=> "14 Oct 07:44"
133
112
  #
134
113
  # @faker.version 1.5.0
135
- def backward(legacy_days = NOT_GIVEN, legacy_period = NOT_GIVEN, legacy_format = NOT_GIVEN, days: 365, period: :all, format: nil)
136
- warn_for_deprecated_arguments do |keywords|
137
- keywords << :days if legacy_days != NOT_GIVEN
138
- keywords << :period if legacy_period != NOT_GIVEN
139
- keywords << :format if legacy_format != NOT_GIVEN
140
- end
141
-
114
+ def backward(days: 365, period: :all, format: nil)
142
115
  time_with_format(date_with_random_time(Faker::Date.backward(days: days), period), format)
143
116
  end
144
- # rubocop:enable Metrics/ParameterLists
145
117
 
146
118
  private
147
119
 
@@ -16,12 +16,7 @@ module Faker
16
16
  # Faker::Twitter.user(include_email: true) # Simulate an authenticated user with the email permission
17
17
  #
18
18
  # @faker.version 1.7.3
19
- def user(legacy_include_status = NOT_GIVEN, legacy_include_email = NOT_GIVEN, include_status: true, include_email: false)
20
- warn_for_deprecated_arguments do |keywords|
21
- keywords << :include_status if legacy_include_status != NOT_GIVEN
22
- keywords << :include_email if legacy_include_email != NOT_GIVEN
23
- end
24
-
19
+ def user(include_status: true, include_email: false)
25
20
  user_id = id
26
21
  background_image_url = Faker::LoremPixel.image(size: '600x400') # TODO: Make the dimensions change
27
22
  profile_image_url = Faker::Avatar.image(slug: user_id, size: '48x48')
@@ -85,12 +80,7 @@ module Faker
85
80
  # Faker::Twitter.status(include_photo: true) # Includes entities for an attached image
86
81
  #
87
82
  # @faker.version 1.7.3
88
- def status(legacy_include_user = NOT_GIVEN, legacy_include_photo = NOT_GIVEN, include_user: true, include_photo: false)
89
- warn_for_deprecated_arguments do |keywords|
90
- keywords << :include_user if legacy_include_user != NOT_GIVEN
91
- keywords << :include_photo if legacy_include_photo != NOT_GIVEN
92
- end
93
-
83
+ def status(include_user: true, include_photo: false)
94
84
  status_id = id
95
85
  status = {
96
86
  id: status_id,
@@ -161,11 +151,7 @@ module Faker
161
151
  }
162
152
  end
163
153
 
164
- def status_entities(legacy_include_photo = NOT_GIVEN, include_photo: false)
165
- warn_for_deprecated_arguments do |keywords|
166
- keywords << :include_photo if legacy_include_photo != NOT_GIVEN
167
- end
168
-
154
+ def status_entities(include_photo: false)
169
155
  entities = {
170
156
  hashtags: [],
171
157
  symbols: [],
@@ -16,11 +16,7 @@ module Faker
16
16
  # Faker::Types.rb_string #=> "foobar"
17
17
  #
18
18
  # @faker.version 1.8.6
19
- def rb_string(legacy_words = NOT_GIVEN, words: 1)
20
- warn_for_deprecated_arguments do |keywords|
21
- keywords << :words if legacy_words != NOT_GIVEN
22
- end
23
-
19
+ def rb_string(words: 1)
24
20
  resolved_num = resolve(words)
25
21
  word_list =
26
22
  translate('faker.lorem.words')
@@ -51,12 +47,7 @@ module Faker
51
47
  # Faker::Types.rb_integer #=> 1
52
48
  #
53
49
  # @faker.version 1.8.6
54
- def rb_integer(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 0, to: 100)
55
- warn_for_deprecated_arguments do |keywords|
56
- keywords << :from if legacy_from != NOT_GIVEN
57
- keywords << :to if legacy_to != NOT_GIVEN
58
- end
59
-
50
+ def rb_integer(from: 0, to: 100)
60
51
  rand(from..to).to_i
61
52
  end
62
53
 
@@ -72,12 +63,7 @@ module Faker
72
63
  # Faker::Types.rb_hash(number: 2) #=> {name: "bob", last: "marley"}
73
64
  #
74
65
  # @faker.version 1.8.6
75
- def rb_hash(legacy_number = NOT_GIVEN, legacy_type = NOT_GIVEN, number: 1, type: -> { random_type })
76
- warn_for_deprecated_arguments do |keywords|
77
- keywords << :number if legacy_number != NOT_GIVEN
78
- keywords << :type if legacy_type != NOT_GIVEN
79
- end
80
-
66
+ def rb_hash(number: 1, type: -> { random_type })
81
67
  {}.tap do |hsh|
82
68
  Lorem.words(number: number * 2).uniq.first(number).each do |s|
83
69
  value = type.is_a?(Proc) ? type.call : type
@@ -98,11 +84,7 @@ module Faker
98
84
  # Faker::Types.complex_rb_hash(number: 2) #=> {user: {first: "bob", last: "marley"}, son: ["damien", "marley"]}
99
85
  #
100
86
  # @faker.version 1.8.6
101
- def complex_rb_hash(legacy_number = NOT_GIVEN, number: 1)
102
- warn_for_deprecated_arguments do |keywords|
103
- keywords << :number if legacy_number != NOT_GIVEN
104
- end
105
-
87
+ def complex_rb_hash(number: 1)
106
88
  rb_hash(number: number, type: -> { random_complex_type })
107
89
  end
108
90
 
@@ -117,11 +99,7 @@ module Faker
117
99
  # Faker::Types.rb_array(len: 4) #=> ["a", 1, 2, "bob"]
118
100
  #
119
101
  # @faker.version 1.8.6
120
- def rb_array(legacy_len = NOT_GIVEN, len: 1)
121
- warn_for_deprecated_arguments do |keywords|
122
- keywords << :len if legacy_len != NOT_GIVEN
123
- end
124
-
102
+ def rb_array(len: 1)
125
103
  [].tap do |ar|
126
104
  len.times do
127
105
  ar.push random_type
@@ -9,7 +9,7 @@ module Faker
9
9
  VIN_LETTERS = 'ABCDEFGHJKLMNPRSTUVWXYZ'
10
10
  VIN_MAP = '0123456789X'
11
11
  VIN_WEIGHTS = '8765432X098765432'
12
- VIN_REGEX = /^([A-HJ-NPR-Z0-9]){3}[A-HJ-NPR-Z0-9]{5}[A-HJ-NPR-Z0-9]{1}[A-HJ-NPR-Z0-9]{1}[A-HJ-NPR-Z0-]{1}[A-HJ-NPR-Z0-9]{1}\d{5}$/.freeze
12
+ VIN_REGEX = /^([A-HJ-NPR-Z0-9]){3}[A-HJ-NPR-Z0-9]{5}[A-HJ-NPR-Z0-9]{1}[A-HJ-NPR-Z0-9]{1}[A-HJ-NPR-Z0-9]{1}[A-HJ-NPR-Z0-9]{1}\d{5}$/.freeze
13
13
  SG_CHECKSUM_WEIGHTS = [3, 14, 2, 12, 2, 11, 1].freeze
14
14
  SG_CHECKSUM_CHARS = 'AYUSPLJGDBZXTRMKHEC'
15
15
 
@@ -62,11 +62,7 @@ module Faker
62
62
  # Faker::Vehicle.model(make_of_model: 'Toyota') #=> "Prius"
63
63
  #
64
64
  # @faker.version 1.6.4
65
- def model(legacy_make_of_model = NOT_GIVEN, make_of_model: '')
66
- warn_for_deprecated_arguments do |keywords|
67
- keywords << :make_of_model if legacy_make_of_model != NOT_GIVEN
68
- end
69
-
65
+ def model(make_of_model: '')
70
66
  return fetch("vehicle.models_by_make.#{make}") if make_of_model.empty?
71
67
 
72
68
  fetch("vehicle.models_by_make.#{make_of_model}")
@@ -249,12 +245,7 @@ module Faker
249
245
  # Faker::Vehicle.kilometrage #=> 35378
250
246
  #
251
247
  # @faker.version 1.6.4
252
- def mileage(legacy_min = NOT_GIVEN, legacy_max = NOT_GIVEN, min: MILEAGE_MIN, max: MILEAGE_MAX)
253
- warn_for_deprecated_arguments do |keywords|
254
- keywords << :min if legacy_min != NOT_GIVEN
255
- keywords << :max if legacy_max != NOT_GIVEN
256
- end
257
-
248
+ def mileage(min: MILEAGE_MIN, max: MILEAGE_MAX)
258
249
  rand_in_range(min, max)
259
250
  end
260
251
 
@@ -271,11 +262,7 @@ module Faker
271
262
  # Faker::Vehicle.license_plate(state_abbreviation: 'FL') #=> "977 UNU"
272
263
  #
273
264
  # @faker.version 1.6.4
274
- def license_plate(legacy_state_abreviation = NOT_GIVEN, state_abbreviation: '')
275
- warn_for_deprecated_arguments do |keywords|
276
- keywords << :state_abbreviation if legacy_state_abreviation != NOT_GIVEN
277
- end
278
-
265
+ def license_plate(state_abbreviation: '')
279
266
  return regexify(bothify(fetch('vehicle.license_plate'))) if state_abbreviation.empty?
280
267
 
281
268
  key = "vehicle.license_plate_by_state.#{state_abbreviation}"
@@ -53,11 +53,7 @@ module Faker
53
53
  # Faker::WorldCup.group #=> "Russia"
54
54
  #
55
55
  # @faker.version 2.13.0
56
- def group(legacy_group = NOT_GIVEN, group: 'group_A')
57
- warn_for_deprecated_arguments do |keywords|
58
- keywords << :group if legacy_group != NOT_GIVEN
59
- end
60
-
56
+ def group(group: 'group_A')
61
57
  fetch("world_cup.groups.#{group}")
62
58
  end
63
59
 
@@ -73,12 +69,7 @@ module Faker
73
69
  # Faker::WorldCup.roster(country: 'Spain', type: 'forwards') #=> "Diego Costa"
74
70
  #
75
71
  # @faker.version 2.13.0
76
- def roster(legacy_country = NOT_GIVEN, legacy_type = NOT_GIVEN, country: 'Egypt', type: 'coach')
77
- warn_for_deprecated_arguments do |keywords|
78
- keywords << :country if legacy_country != NOT_GIVEN
79
- keywords << :type if legacy_type != NOT_GIVEN
80
- end
81
-
72
+ def roster(country: 'Egypt', type: 'coach')
82
73
  fetch("world_cup.rosters.#{country}.#{type}")
83
74
  end
84
75
  end
@@ -80,11 +80,7 @@ module Faker
80
80
  # Faker::Games::Dota.quote(hero: 'alchemist') #=> "Better living through alchemy!"
81
81
  #
82
82
  # @faker.version 1.9.0
83
- def quote(legacy_hero = NOT_GIVEN, hero: 'abaddon')
84
- warn_for_deprecated_arguments do |keywords|
85
- keywords << :hero if legacy_hero != NOT_GIVEN
86
- end
87
-
83
+ def quote(hero: 'abaddon')
88
84
  fetch("games.dota.#{hero}.quote")
89
85
  end
90
86
  end