faker 2.0.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +72 -1
  3. data/README.md +3 -3
  4. data/lib/faker.rb +22 -1
  5. data/lib/faker/books/dune.rb +12 -2
  6. data/lib/faker/books/lovecraft.rb +54 -7
  7. data/lib/faker/default/address.rb +30 -5
  8. data/lib/faker/default/alphanumeric.rb +45 -7
  9. data/lib/faker/default/app.rb +16 -1
  10. data/lib/faker/default/avatar.rb +24 -1
  11. data/lib/faker/default/bank.rb +12 -2
  12. data/lib/faker/default/boolean.rb +6 -1
  13. data/lib/faker/default/chile_rut.rb +20 -2
  14. data/lib/faker/default/code.rb +22 -3
  15. data/lib/faker/default/commerce.rb +26 -3
  16. data/lib/faker/default/company.rb +12 -2
  17. data/lib/faker/default/crypto_coin.rb +18 -3
  18. data/lib/faker/default/date.rb +48 -5
  19. data/lib/faker/default/demographic.rb +6 -1
  20. data/lib/faker/default/driving_licence.rb +20 -4
  21. data/lib/faker/default/file.rb +36 -2
  22. data/lib/faker/default/fillmurray.rb +16 -1
  23. data/lib/faker/default/finance.rb +6 -1
  24. data/lib/faker/default/hipster.rb +78 -6
  25. data/lib/faker/default/id_number.rb +50 -3
  26. data/lib/faker/default/internet.rb +124 -13
  27. data/lib/faker/default/invoice.rb +22 -3
  28. data/lib/faker/default/json.rb +26 -2
  29. data/lib/faker/default/lorem.rb +120 -10
  30. data/lib/faker/default/lorem_flickr.rb +69 -5
  31. data/lib/faker/default/lorem_pixel.rb +26 -1
  32. data/lib/faker/default/markdown.rb +10 -1
  33. data/lib/faker/default/measurement.rb +48 -8
  34. data/lib/faker/default/name.rb +6 -1
  35. data/lib/faker/default/nhs.rb +6 -1
  36. data/lib/faker/default/number.rb +81 -11
  37. data/lib/faker/default/omniauth.rb +84 -5
  38. data/lib/faker/default/phone_number.rb +6 -1
  39. data/lib/faker/default/placeholdit.rb +24 -1
  40. data/lib/faker/default/relationship.rb +6 -1
  41. data/lib/faker/default/source.rb +22 -3
  42. data/lib/faker/default/string.rb +6 -1
  43. data/lib/faker/default/stripe.rb +24 -4
  44. data/lib/faker/default/time.rb +68 -4
  45. data/lib/faker/default/twitter.rb +26 -3
  46. data/lib/faker/default/types.rb +38 -5
  47. data/lib/faker/default/vehicle.rb +22 -3
  48. data/lib/faker/default/world_cup.rb +16 -2
  49. data/lib/faker/games/dota.rb +6 -1
  50. data/lib/faker/movies/star_wars.rb +6 -1
  51. data/lib/faker/version.rb +1 -1
  52. data/lib/locales/en.yml +0 -47
  53. metadata +11 -11
@@ -46,7 +46,12 @@ module Faker
46
46
  fetch('name.suffix')
47
47
  end
48
48
 
49
- def initials(number: 3)
49
+ def initials(legacy_number = NOT_GIVEN, number: 3)
50
+ if legacy_number != NOT_GIVEN
51
+ warn_with_uplevel 'Passing `number` with the 1st argument of `Name.initials` is deprecated. Use keyword argument like `Name.initials(number: ...)` instead.', uplevel: 1
52
+ number = legacy_number
53
+ end
54
+
50
55
  (0...number).map { rand(65..90).chr }.join
51
56
  end
52
57
  end
@@ -15,7 +15,12 @@ module Faker
15
15
  .join('')
16
16
  end
17
17
 
18
- def check_digit(number: 0)
18
+ def check_digit(legacy_number = NOT_GIVEN, number: 0)
19
+ if legacy_number != NOT_GIVEN
20
+ warn_with_uplevel 'Passing `number` with the 1st argument of `NationalHealthService.check_digit` is deprecated. Use keyword argument like `NationalHealthService.check_digit(number: ...)` instead.', uplevel: 1
21
+ number = legacy_number
22
+ end
23
+
19
24
  sum = 0
20
25
  number.to_s.chars.each_with_index do |digit, idx|
21
26
  position = idx + 1
@@ -3,19 +3,34 @@
3
3
  module Faker
4
4
  class Number < Base
5
5
  class << self
6
- def number(digits: 10)
6
+ def number(legacy_digits = NOT_GIVEN, digits: 10)
7
+ if legacy_digits != NOT_GIVEN
8
+ warn_with_uplevel 'Passing `digits` with the 1st argument of `Number.number` is deprecated. Use keyword argument like `Number.number(digits: ...)` instead.', uplevel: 1
9
+ digits = legacy_digits
10
+ end
11
+
7
12
  return if digits < 1
8
- return 0 if digits == 1
13
+ return rand(0..9).round if digits == 1
9
14
 
10
15
  # Ensure the first digit is not zero
11
16
  ([non_zero_digit] + generate(digits - 1)).join.to_i
12
17
  end
13
18
 
14
- def leading_zero_number(digits: 10)
19
+ def leading_zero_number(legacy_digits = NOT_GIVEN, digits: 10)
20
+ if legacy_digits != NOT_GIVEN
21
+ warn_with_uplevel 'Passing `digits` with the 1st argument of `Number.leading_zero_number` is deprecated. Use keyword argument like `Number.leading_zero_number(digits: ...)` instead.', uplevel: 1
22
+ digits = legacy_digits
23
+ end
24
+
15
25
  '0' + (2..digits).collect { digit }.join
16
26
  end
17
27
 
18
- def decimal_part(digits: 10)
28
+ def decimal_part(legacy_digits = NOT_GIVEN, digits: 10)
29
+ if legacy_digits != NOT_GIVEN
30
+ warn_with_uplevel 'Passing `digits` with the 1st argument of `Number.decimal_part` is deprecated. Use keyword argument like `Number.decimal_part(digits: ...)` instead.', uplevel: 1
31
+ digits = legacy_digits
32
+ end
33
+
19
34
  num = ''
20
35
  if digits > 1
21
36
  num = non_zero_digit
@@ -24,7 +39,16 @@ module Faker
24
39
  leading_zero_number(digits: digits) + num.to_s
25
40
  end
26
41
 
27
- def decimal(l_digits: 5, r_digits: 2)
42
+ def decimal(legacy_l_digits = NOT_GIVEN, legacy_r_digits = NOT_GIVEN, l_digits: 5, r_digits: 2)
43
+ if legacy_l_digits != NOT_GIVEN
44
+ warn_with_uplevel 'Passing `l_digits` with the 1st argument of `Number.decimal` is deprecated. Use keyword argument like `Number.decimal(l_digits: ...)` instead.', uplevel: 1
45
+ l_digits = legacy_l_digits
46
+ end
47
+ if legacy_r_digits != NOT_GIVEN
48
+ warn_with_uplevel 'Passing `r_digits` with the 2nd argument of `Number.decimal` is deprecated. Use keyword argument like `Number.decimal(r_digits: ...)` instead.', uplevel: 1
49
+ r_digits = legacy_r_digits
50
+ end
51
+
28
52
  l_d = number(digits: l_digits)
29
53
  r_d = if r_digits == 1
30
54
  generate(r_digits)
@@ -44,34 +68,80 @@ module Faker
44
68
  rand(10)
45
69
  end
46
70
 
47
- def hexadecimal(digits: 6)
71
+ def hexadecimal(legacy_digits = NOT_GIVEN, digits: 6)
72
+ if legacy_digits != NOT_GIVEN
73
+ warn_with_uplevel 'Passing `digits` with the 1st argument of `Number.hexadecimal` is deprecated. Use keyword argument like `Number.hexadecimal(digits: ...)` instead.', uplevel: 1
74
+ digits = legacy_digits
75
+ end
76
+
48
77
  hex = ''
49
78
  digits.times { hex += rand(15).to_s(16) }
50
79
  hex
51
80
  end
52
81
 
53
- def normal(mean: 1, standard_deviation: 1)
82
+ def normal(legacy_mean = NOT_GIVEN, legacy_standard_deviation = NOT_GIVEN, mean: 1, standard_deviation: 1)
83
+ if legacy_mean != NOT_GIVEN
84
+ warn_with_uplevel 'Passing `mean` with the 1st argument of `Number.normal` is deprecated. Use keyword argument like `Number.normal(mean: ...)` instead.', uplevel: 1
85
+ mean = legacy_mean
86
+ end
87
+ if legacy_standard_deviation != NOT_GIVEN
88
+ warn_with_uplevel 'Passing `standard_deviation` with the 2nd argument of `Number.normal` is deprecated. Use keyword argument like `Number.normal(standard_deviation: ...)` instead.', uplevel: 1
89
+ standard_deviation = legacy_standard_deviation
90
+ end
91
+
54
92
  theta = 2 * Math::PI * rand
55
93
  rho = Math.sqrt(-2 * Math.log(1 - rand))
56
94
  scale = standard_deviation * rho
57
95
  mean + scale * Math.cos(theta)
58
96
  end
59
97
 
60
- def between(from: 1.00, to: 5000.00)
98
+ def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 1.00, to: 5000.00)
99
+ if legacy_from != NOT_GIVEN
100
+ warn_with_uplevel 'Passing `from` with the 1st argument of `Number.between` is deprecated. Use keyword argument like `Number.between(from: ...)` instead.', uplevel: 1
101
+ from = legacy_from
102
+ end
103
+ if legacy_to != NOT_GIVEN
104
+ warn_with_uplevel 'Passing `to` with the 2nd argument of `Number.between` is deprecated. Use keyword argument like `Number.between(to: ...)` instead.', uplevel: 1
105
+ to = legacy_to
106
+ end
107
+
61
108
  Faker::Base.rand_in_range(from, to)
62
109
  end
63
110
 
64
- def within(range: 1.00..5000.00)
111
+ def within(legacy_range = NOT_GIVEN, range: 1.00..5000.00)
112
+ if legacy_range != NOT_GIVEN
113
+ warn_with_uplevel 'Passing `range` with the 1st argument of `Number.within` is deprecated. Use keyword argument like `Number.within(range: ...)` instead.', uplevel: 1
114
+ range = legacy_range
115
+ end
116
+
65
117
  between(from: range.min, to: range.max)
66
118
  end
67
119
 
68
- def positive(from: 1.00, to: 5000.00)
120
+ def positive(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 1.00, to: 5000.00)
121
+ if legacy_from != NOT_GIVEN
122
+ warn_with_uplevel 'Passing `from` with the 1st argument of `Number.positive` is deprecated. Use keyword argument like `Number.positive(from: ...)` instead.', uplevel: 1
123
+ from = legacy_from
124
+ end
125
+ if legacy_to != NOT_GIVEN
126
+ warn_with_uplevel 'Passing `to` with the 2nd argument of `Number.positive` is deprecated. Use keyword argument like `Number.positive(to: ...)` instead.', uplevel: 1
127
+ to = legacy_to
128
+ end
129
+
69
130
  random_number = between(from: from, to: to)
70
131
 
71
132
  greater_than_zero(random_number)
72
133
  end
73
134
 
74
- def negative(from: -5000.00, to: -1.00)
135
+ def negative(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: -5000.00, to: -1.00)
136
+ if legacy_from != NOT_GIVEN
137
+ warn_with_uplevel 'Passing `from` with the 1st argument of `Number.negative` is deprecated. Use keyword argument like `Number.negative(from: ...)` instead.', uplevel: 1
138
+ from = legacy_from
139
+ end
140
+ if legacy_to != NOT_GIVEN
141
+ warn_with_uplevel 'Passing `to` with the 2nd argument of `Number.negative` is deprecated. Use keyword argument like `Number.negative(to: ...)` instead.', uplevel: 1
142
+ to = legacy_to
143
+ end
144
+
75
145
  random_number = between(from: from, to: to)
76
146
 
77
147
  less_than_zero(random_number)
@@ -15,7 +15,22 @@ module Faker
15
15
  end
16
16
 
17
17
  class << self
18
- def google(name: nil, email: nil, uid: Number.number(digits: 9).to_s)
18
+ # rubocop:disable Metrics/ParameterLists
19
+ 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)
20
+ # rubocop:enable Metrics/ParameterLists
21
+ if legacy_name != NOT_GIVEN
22
+ warn_with_uplevel 'Passing `name` with the 1st argument of `Omniauth.google` is deprecated. Use keyword argument like `Omniauth.google(name: ...)` instead.', uplevel: 1
23
+ name = legacy_name
24
+ end
25
+ if legacy_email != NOT_GIVEN
26
+ warn_with_uplevel 'Passing `email` with the 2nd argument of `Omniauth.google` is deprecated. Use keyword argument like `Omniauth.google(email: ...)` instead.', uplevel: 1
27
+ email = legacy_email
28
+ end
29
+ if legacy_uid != NOT_GIVEN
30
+ warn_with_uplevel 'Passing `uid` with the 3rd argument of `Omniauth.google` is deprecated. Use keyword argument like `Omniauth.google(uid: ...)` instead.', uplevel: 1
31
+ uid = legacy_uid
32
+ end
33
+
19
34
  auth = Omniauth.new(name: name, email: email)
20
35
  {
21
36
  provider: 'google_oauth2',
@@ -64,7 +79,26 @@ module Faker
64
79
  }
65
80
  end
66
81
 
67
- def facebook(name: nil, email: nil, username: nil, uid: Number.number(digits: 7).to_s)
82
+ # rubocop:disable Metrics/ParameterLists
83
+ 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)
84
+ # rubocop:enable Metrics/ParameterLists
85
+ if legacy_name != NOT_GIVEN
86
+ warn_with_uplevel 'Passing `name` with the 1st argument of `Omniauth.facebook` is deprecated. Use keyword argument like `Omniauth.facebook(name: ...)` instead.', uplevel: 1
87
+ name = legacy_name
88
+ end
89
+ if legacy_email != NOT_GIVEN
90
+ warn_with_uplevel 'Passing `email` with the 2nd argument of `Omniauth.facebook` is deprecated. Use keyword argument like `Omniauth.facebook(email: ...)` instead.', uplevel: 1
91
+ email = legacy_email
92
+ end
93
+ if legacy_username != NOT_GIVEN
94
+ warn_with_uplevel 'Passing `username` with the 3rd argument of `Omniauth.facebook` is deprecated. Use keyword argument like `Omniauth.facebook(username: ...)` instead.', uplevel: 1
95
+ username = legacy_username
96
+ end
97
+ if legacy_uid != NOT_GIVEN
98
+ warn_with_uplevel 'Passing `uid` with the 4th argument of `Omniauth.facebook` is deprecated. Use keyword argument like `Omniauth.facebook(uid: ...)` instead.', uplevel: 1
99
+ uid = legacy_uid
100
+ end
101
+
68
102
  auth = Omniauth.new(name: name, email: email)
69
103
  username ||= "#{auth.first_name.downcase[0]}#{auth.last_name.downcase}"
70
104
  {
@@ -106,7 +140,22 @@ module Faker
106
140
  }
107
141
  end
108
142
 
109
- def twitter(name: nil, nickname: nil, uid: Number.number(digits: 6).to_s)
143
+ # rubocop:disable Metrics/ParameterLists
144
+ 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)
145
+ # rubocop:enable Metrics/ParameterLists
146
+ if legacy_name != NOT_GIVEN
147
+ warn_with_uplevel 'Passing `name` with the 1st argument of `Omniauth.twitter` is deprecated. Use keyword argument like `Omniauth.twitter(name: ...)` instead.', uplevel: 1
148
+ name = legacy_name
149
+ end
150
+ if legacy_nickname != NOT_GIVEN
151
+ warn_with_uplevel 'Passing `nickname` with the 2nd argument of `Omniauth.twitter` is deprecated. Use keyword argument like `Omniauth.twitter(nickname: ...)` instead.', uplevel: 1
152
+ nickname = legacy_nickname
153
+ end
154
+ if legacy_uid != NOT_GIVEN
155
+ warn_with_uplevel 'Passing `uid` with the 3rd argument of `Omniauth.twitter` is deprecated. Use keyword argument like `Omniauth.twitter(uid: ...)` instead.', uplevel: 1
156
+ uid = legacy_uid
157
+ end
158
+
110
159
  auth = Omniauth.new(name: name)
111
160
  nickname ||= auth.name.downcase.delete(' ')
112
161
  location = city_state
@@ -179,7 +228,22 @@ module Faker
179
228
  }
180
229
  end
181
230
 
182
- def linkedin(name: nil, email: nil, uid: Number.number(digits: 6).to_s)
231
+ # rubocop:disable Metrics/ParameterLists
232
+ 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)
233
+ # rubocop:enable Metrics/ParameterLists
234
+ if legacy_name != NOT_GIVEN
235
+ warn_with_uplevel 'Passing `name` with the 1st argument of `Omniauth.linkedin` is deprecated. Use keyword argument like `Omniauth.linkedin(name: ...)` instead.', uplevel: 1
236
+ name = legacy_name
237
+ end
238
+ if legacy_email != NOT_GIVEN
239
+ warn_with_uplevel 'Passing `email` with the 2nd argument of `Omniauth.linkedin` is deprecated. Use keyword argument like `Omniauth.linkedin(email: ...)` instead.', uplevel: 1
240
+ email = legacy_email
241
+ end
242
+ if legacy_uid != NOT_GIVEN
243
+ warn_with_uplevel 'Passing `uid` with the 3rd argument of `Omniauth.linkedin` is deprecated. Use keyword argument like `Omniauth.linkedin(uid: ...)` instead.', uplevel: 1
244
+ uid = legacy_uid
245
+ end
246
+
183
247
  auth = Omniauth.new(name: name, email: email)
184
248
  first_name = auth.first_name.downcase
185
249
  last_name = auth.last_name.downcase
@@ -242,7 +306,22 @@ module Faker
242
306
  }
243
307
  end
244
308
 
245
- def github(name: nil, email: nil, uid: Number.number(digits: 8).to_s)
309
+ # rubocop:disable Metrics/ParameterLists
310
+ 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)
311
+ # rubocop:enable Metrics/ParameterLists
312
+ if legacy_name != NOT_GIVEN
313
+ warn_with_uplevel 'Passing `name` with the 1st argument of `Omniauth.github` is deprecated. Use keyword argument like `Omniauth.github(name: ...)` instead.', uplevel: 1
314
+ name = legacy_name
315
+ end
316
+ if legacy_email != NOT_GIVEN
317
+ warn_with_uplevel 'Passing `email` with the 2nd argument of `Omniauth.github` is deprecated. Use keyword argument like `Omniauth.github(email: ...)` instead.', uplevel: 1
318
+ email = legacy_email
319
+ end
320
+ if legacy_uid != NOT_GIVEN
321
+ warn_with_uplevel 'Passing `uid` with the 3rd argument of `Omniauth.github` is deprecated. Use keyword argument like `Omniauth.github(uid: ...)` instead.', uplevel: 1
322
+ uid = legacy_uid
323
+ end
324
+
246
325
  auth = Omniauth.new(name: name, email: email)
247
326
  login = auth.name.downcase.tr(' ', '-')
248
327
  html_url = "https://github.com/#{login}"
@@ -40,7 +40,12 @@ module Faker
40
40
  # US and Canada only
41
41
  # Can be used for both extensions and last four digits of phone number.
42
42
  # Since extensions can be of variable length, this method taks a length parameter
43
- def subscriber_number(length: 4)
43
+ def subscriber_number(legacy_length = NOT_GIVEN, length: 4)
44
+ if legacy_length != NOT_GIVEN
45
+ warn_with_uplevel 'Passing `length` with the 1st argument of `PhoneNumber.subscriber_number` is deprecated. Use keyword argument like `PhoneNumber.subscriber_number(length: ...)` instead.', uplevel: 1
46
+ length = legacy_length
47
+ end
48
+
44
49
  rand.to_s[2..(1 + length)]
45
50
  end
46
51
 
@@ -5,7 +5,30 @@ module Faker
5
5
  class << self
6
6
  SUPPORTED_FORMATS = %w[png jpg gif jpeg].freeze
7
7
 
8
- def image(size: '300x300', format: 'png', background_color: nil, text_color: nil, text: nil)
8
+ # rubocop:disable Metrics/ParameterLists
9
+ 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)
10
+ # rubocop:enable Metrics/ParameterLists
11
+ if legacy_size != NOT_GIVEN
12
+ warn_with_uplevel 'Passing `size` with the 1st argument of `Placeholdit.image` is deprecated. Use keyword argument like `Placeholdit.image(size: ...)` instead.', uplevel: 1
13
+ size = legacy_size
14
+ end
15
+ if legacy_format != NOT_GIVEN
16
+ warn_with_uplevel 'Passing `format` with the 2nd argument of `Placeholdit.image` is deprecated. Use keyword argument like `Placeholdit.image(format: ...)` instead.', uplevel: 1
17
+ format = legacy_format
18
+ end
19
+ if legacy_background_color != NOT_GIVEN
20
+ warn_with_uplevel 'Passing `background_color` with the 3rd argument of `Placeholdit.image` is deprecated. Use keyword argument like `Placeholdit.image(background_color: ...)` instead.', uplevel: 1
21
+ background_color = legacy_background_color
22
+ end
23
+ if legacy_text_color != NOT_GIVEN
24
+ warn_with_uplevel 'Passing `text_color` with the 4th argument of `Placeholdit.image` is deprecated. Use keyword argument like `Placeholdit.image(text_color: ...)` instead.', uplevel: 1
25
+ text_color = legacy_text_color
26
+ end
27
+ if legacy_text != NOT_GIVEN
28
+ warn_with_uplevel 'Passing `text` with the 5th argument of `Placeholdit.image` is deprecated. Use keyword argument like `Placeholdit.image(text: ...)` instead.', uplevel: 1
29
+ text = legacy_text
30
+ end
31
+
9
32
  background_color = generate_color if background_color == :random
10
33
  text_color = generate_color if text_color == :random
11
34
 
@@ -5,7 +5,12 @@ module Faker
5
5
  flexible :relationship
6
6
 
7
7
  class << self
8
- def familial(connection: nil)
8
+ def familial(legacy_connection = NOT_GIVEN, connection: nil)
9
+ if legacy_connection != NOT_GIVEN
10
+ warn_with_uplevel 'Passing `connection` with the 1st argument of `Relationship.familial` is deprecated. Use keyword argument like `Relationship.familial(connection: ...)` instead.', uplevel: 1
11
+ connection = legacy_connection
12
+ end
13
+
9
14
  familial_connections = translate('faker.relationship.familial').keys
10
15
 
11
16
  if connection.nil?
@@ -3,16 +3,35 @@
3
3
  module Faker
4
4
  class Source < Base
5
5
  class << self
6
- def hello_world(lang: :ruby)
6
+ def hello_world(legacy_lang = NOT_GIVEN, lang: :ruby)
7
+ if legacy_lang != NOT_GIVEN
8
+ warn_with_uplevel 'Passing `lang` with the 1st argument of `Source.hello_world` is deprecated. Use keyword argument like `Source.hello_world(lang: ...)` instead.', uplevel: 1
9
+ lang = legacy_lang
10
+ end
11
+
7
12
  fetch("source.hello_world.#{lang}")
8
13
  end
9
14
 
10
- def print(str: 'some string', lang: :ruby)
15
+ def print(legacy_str = NOT_GIVEN, legacy_lang = NOT_GIVEN, str: 'some string', lang: :ruby)
16
+ if legacy_str != NOT_GIVEN
17
+ warn_with_uplevel 'Passing `str` with the 1st argument of `Source.print` is deprecated. Use keyword argument like `Source.print(str: ...)` instead.', uplevel: 1
18
+ str = legacy_str
19
+ end
20
+ if legacy_lang != NOT_GIVEN
21
+ warn_with_uplevel 'Passing `lang` with the 2nd argument of `Source.print` is deprecated. Use keyword argument like `Source.print(lang: ...)` instead.', uplevel: 1
22
+ lang = legacy_lang
23
+ end
24
+
11
25
  code = fetch("source.print.#{lang}")
12
26
  code.gsub('faker_string_to_print', str)
13
27
  end
14
28
 
15
- def print_1_to_10(lang: :ruby)
29
+ def print_1_to_10(legacy_lang = NOT_GIVEN, lang: :ruby)
30
+ if legacy_lang != NOT_GIVEN
31
+ warn_with_uplevel 'Passing `lang` with the 1st argument of `Source.print_1_to_10` is deprecated. Use keyword argument like `Source.print_1_to_10(lang: ...)` instead.', uplevel: 1
32
+ lang = legacy_lang
33
+ end
34
+
16
35
  fetch("source.print_1_to_10.#{lang}")
17
36
  end
18
37
  end
@@ -3,7 +3,12 @@
3
3
  module Faker
4
4
  class String < Base
5
5
  class << self
6
- def random(length: 32)
6
+ def random(legacy_length = NOT_GIVEN, length: 32)
7
+ if legacy_length != NOT_GIVEN
8
+ warn_with_uplevel 'Passing `length` with the 1st argument of `String.random` is deprecated. Use keyword argument like `String.random(length: ...)` instead.', uplevel: 1
9
+ length = legacy_length
10
+ end
11
+
7
12
  utf8string select_a length
8
13
  end
9
14
 
@@ -3,7 +3,12 @@
3
3
  module Faker
4
4
  class Stripe < Base
5
5
  class << self
6
- def valid_card(card_type: nil)
6
+ def valid_card(legacy_card_type = NOT_GIVEN, card_type: nil)
7
+ if legacy_card_type != NOT_GIVEN
8
+ warn_with_uplevel 'Passing `card_type` with the 1st argument of `Stripe.valid_card` is deprecated. Use keyword argument like `Stripe.valid_card(card_type: ...)` instead.', uplevel: 1
9
+ card_type = legacy_card_type
10
+ end
11
+
7
12
  valid_cards = translate('faker.stripe.valid_cards').keys
8
13
 
9
14
  if card_type.nil?
@@ -18,7 +23,12 @@ module Faker
18
23
  fetch('stripe.valid_cards.' + card_type)
19
24
  end
20
25
 
21
- def valid_token(card_type: nil)
26
+ def valid_token(legacy_card_type = NOT_GIVEN, card_type: nil)
27
+ if legacy_card_type != NOT_GIVEN
28
+ warn_with_uplevel 'Passing `card_type` with the 1st argument of `Stripe.valid_token` is deprecated. Use keyword argument like `Stripe.valid_token(card_type: ...)` instead.', uplevel: 1
29
+ card_type = legacy_card_type
30
+ end
31
+
22
32
  valid_tokens = translate('faker.stripe.valid_tokens').keys
23
33
 
24
34
  if card_type.nil?
@@ -33,7 +43,12 @@ module Faker
33
43
  fetch('stripe.valid_tokens.' + card_type)
34
44
  end
35
45
 
36
- def invalid_card(card_error: nil)
46
+ def invalid_card(legacy_card_error = NOT_GIVEN, card_error: nil)
47
+ if legacy_card_error != NOT_GIVEN
48
+ warn_with_uplevel 'Passing `card_error` with the 1st argument of `Stripe.invalid_card` is deprecated. Use keyword argument like `Stripe.invalid_card(card_error: ...)` instead.', uplevel: 1
49
+ card_error = legacy_card_error
50
+ end
51
+
37
52
  invalid_cards = translate('faker.stripe.invalid_cards').keys
38
53
 
39
54
  if card_error.nil?
@@ -57,7 +72,12 @@ module Faker
57
72
  rand_in_range(start_year, start_year + 5).to_s
58
73
  end
59
74
 
60
- def ccv(card_type: nil)
75
+ def ccv(legacy_card_type = NOT_GIVEN, card_type: nil)
76
+ if legacy_card_type != NOT_GIVEN
77
+ warn_with_uplevel 'Passing `card_type` with the 1st argument of `Stripe.ccv` is deprecated. Use keyword argument like `Stripe.ccv(card_type: ...)` instead.', uplevel: 1
78
+ card_type = legacy_card_type
79
+ end
80
+
61
81
  (card_type.to_s == 'amex' ? rand_in_range(1000, 9999) : rand_in_range(100, 999)).to_s
62
82
  end
63
83
  end