faker 2.1.2 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -0
  3. data/README.md +2 -2
  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 +12 -2
  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 +80 -10
  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. metadata +4 -4
@@ -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
@@ -13,7 +13,22 @@ module Faker
13
13
  }.freeze
14
14
 
15
15
  class << self
16
- def between(from:, to:, format: nil)
16
+ # rubocop:disable Metrics/ParameterLists
17
+ def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_format = NOT_GIVEN, from:, to:, format: nil)
18
+ # rubocop:enable Metrics/ParameterLists
19
+ if legacy_from != NOT_GIVEN
20
+ warn_with_uplevel 'Passing `from` with the 1st argument of `Time.between` is deprecated. Use keyword argument like `Time.between(from: ...)` instead.', uplevel: 1
21
+ from = legacy_from
22
+ end
23
+ if legacy_to != NOT_GIVEN
24
+ warn_with_uplevel 'Passing `to` with the 2nd argument of `Time.between` is deprecated. Use keyword argument like `Time.between(to: ...)` instead.', uplevel: 1
25
+ to = legacy_to
26
+ end
27
+ if legacy_format != NOT_GIVEN
28
+ warn_with_uplevel 'Passing `format` with the 3rd argument of `Time.between` is deprecated. Use keyword argument like `Time.between(format: ...)` instead.', uplevel: 1
29
+ format = legacy_format
30
+ end
31
+
17
32
  from = get_time_object(from)
18
33
  to = get_time_object(to)
19
34
 
@@ -21,17 +36,66 @@ module Faker
21
36
  time_with_format(time, format)
22
37
  end
23
38
 
24
- def between_dates(from:, to:, period: :all, format: nil)
39
+ # rubocop:disable Metrics/ParameterLists
40
+ 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)
41
+ # rubocop:enable Metrics/ParameterLists
42
+ if legacy_from != NOT_GIVEN
43
+ warn_with_uplevel 'Passing `from` with the 1st argument of `Time.between_dates` is deprecated. Use keyword argument like `Time.between_dates(from: ...)` instead.', uplevel: 1
44
+ from = legacy_from
45
+ end
46
+ if legacy_to != NOT_GIVEN
47
+ warn_with_uplevel 'Passing `to` with the 2nd argument of `Time.between_dates` is deprecated. Use keyword argument like `Time.between_dates(to: ...)` instead.', uplevel: 1
48
+ to = legacy_to
49
+ end
50
+ if legacy_period != NOT_GIVEN
51
+ warn_with_uplevel 'Passing `period` with the 3rd argument of `Time.between_dates` is deprecated. Use keyword argument like `Time.between_dates(period: ...)` instead.', uplevel: 1
52
+ period = legacy_period
53
+ end
54
+ if legacy_format != NOT_GIVEN
55
+ warn_with_uplevel 'Passing `format` with the 4th argument of `Time.between_dates` is deprecated. Use keyword argument like `Time.between_dates(format: ...)` instead.', uplevel: 1
56
+ format = legacy_format
57
+ end
58
+
25
59
  date = Faker::Date.between(from: from, to: to)
26
60
  time = date_with_random_time(date, period)
27
61
  time_with_format(time, format)
28
62
  end
29
63
 
30
- def forward(days: 365, period: :all, format: nil)
64
+ # rubocop:disable Metrics/ParameterLists
65
+ def forward(legacy_days = NOT_GIVEN, legacy_period = NOT_GIVEN, legacy_format = NOT_GIVEN, days: 365, period: :all, format: nil)
66
+ # rubocop:enable Metrics/ParameterLists
67
+ if legacy_days != NOT_GIVEN
68
+ warn_with_uplevel 'Passing `days` with the 1st argument of `Time.forward` is deprecated. Use keyword argument like `Time.forward(days: ...)` instead.', uplevel: 1
69
+ days = legacy_days
70
+ end
71
+ if legacy_period != NOT_GIVEN
72
+ warn_with_uplevel 'Passing `period` with the 2nd argument of `Time.forward` is deprecated. Use keyword argument like `Time.forward(period: ...)` instead.', uplevel: 1
73
+ period = legacy_period
74
+ end
75
+ if legacy_format != NOT_GIVEN
76
+ warn_with_uplevel 'Passing `format` with the 3rd argument of `Time.forward` is deprecated. Use keyword argument like `Time.forward(format: ...)` instead.', uplevel: 1
77
+ format = legacy_format
78
+ end
79
+
31
80
  time_with_format(date_with_random_time(Faker::Date.forward(days: days), period), format)
32
81
  end
33
82
 
34
- def backward(days: 365, period: :all, format: nil)
83
+ # rubocop:disable Metrics/ParameterLists
84
+ def backward(legacy_days = NOT_GIVEN, legacy_period = NOT_GIVEN, legacy_format = NOT_GIVEN, days: 365, period: :all, format: nil)
85
+ # rubocop:enable Metrics/ParameterLists
86
+ if legacy_days != NOT_GIVEN
87
+ warn_with_uplevel 'Passing `days` with the 1st argument of `Time.backward` is deprecated. Use keyword argument like `Time.backward(days: ...)` instead.', uplevel: 1
88
+ days = legacy_days
89
+ end
90
+ if legacy_period != NOT_GIVEN
91
+ warn_with_uplevel 'Passing `period` with the 2nd argument of `Time.backward` is deprecated. Use keyword argument like `Time.backward(period: ...)` instead.', uplevel: 1
92
+ period = legacy_period
93
+ end
94
+ if legacy_format != NOT_GIVEN
95
+ warn_with_uplevel 'Passing `format` with the 3rd argument of `Time.backward` is deprecated. Use keyword argument like `Time.backward(format: ...)` instead.', uplevel: 1
96
+ format = legacy_format
97
+ end
98
+
35
99
  time_with_format(date_with_random_time(Faker::Date.backward(days: days), period), format)
36
100
  end
37
101
 
@@ -3,7 +3,16 @@
3
3
  module Faker
4
4
  class Twitter < Base
5
5
  class << self
6
- def user(include_status: true, include_email: false)
6
+ def user(legacy_include_status = NOT_GIVEN, legacy_include_email = NOT_GIVEN, include_status: true, include_email: false)
7
+ if legacy_include_status != NOT_GIVEN
8
+ warn_with_uplevel 'Passing `include_status` with the 1st argument of `Twitter.user` is deprecated. Use keyword argument like `Twitter.user(include_status: ...)` instead.', uplevel: 1
9
+ include_status = legacy_include_status
10
+ end
11
+ if legacy_include_email != NOT_GIVEN
12
+ warn_with_uplevel 'Passing `include_email` with the 2nd argument of `Twitter.user` is deprecated. Use keyword argument like `Twitter.user(include_email: ...)` instead.', uplevel: 1
13
+ include_email = legacy_include_email
14
+ end
15
+
7
16
  user_id = id
8
17
  background_image_url = Faker::LoremPixel.image(size: '600x400') # TODO: Make the dimensions change
9
18
  profile_image_url = Faker::Avatar.image(slug: user_id, size: '48x48')
@@ -54,7 +63,16 @@ module Faker
54
63
  user
55
64
  end
56
65
 
57
- def status(include_user: true, include_photo: false)
66
+ def status(legacy_include_user = NOT_GIVEN, legacy_include_photo = NOT_GIVEN, include_user: true, include_photo: false)
67
+ if legacy_include_user != NOT_GIVEN
68
+ warn_with_uplevel 'Passing `include_user` with the 1st argument of `Twitter.status` is deprecated. Use keyword argument like `Twitter.status(include_user: ...)` instead.', uplevel: 1
69
+ include_user = legacy_include_user
70
+ end
71
+ if legacy_include_photo != NOT_GIVEN
72
+ warn_with_uplevel 'Passing `include_photo` with the 2nd argument of `Twitter.status` is deprecated. Use keyword argument like `Twitter.status(include_photo: ...)` instead.', uplevel: 1
73
+ include_photo = legacy_include_photo
74
+ end
75
+
58
76
  status_id = id
59
77
  status = {
60
78
  id: status_id,
@@ -116,7 +134,12 @@ module Faker
116
134
  }
117
135
  end
118
136
 
119
- def status_entities(include_photo: false)
137
+ def status_entities(legacy_include_photo = NOT_GIVEN, include_photo: false)
138
+ if legacy_include_photo != NOT_GIVEN
139
+ warn_with_uplevel 'Passing `include_photo` with the 1st argument of `Twitter.status_entities` is deprecated. Use keyword argument like `Twitter.status_entities(include_photo: ...)` instead.', uplevel: 1
140
+ include_photo = legacy_include_photo
141
+ end
142
+
120
143
  entities = {
121
144
  hashtags: [],
122
145
  symbols: [],
@@ -7,7 +7,12 @@ module Faker
7
7
  COMPLEX_TYPES = %i[hash array].freeze
8
8
 
9
9
  class << self
10
- def rb_string(words: 1)
10
+ def rb_string(legacy_words = NOT_GIVEN, words: 1)
11
+ if legacy_words != NOT_GIVEN
12
+ warn_with_uplevel 'Passing `words` with the 1st argument of `Types.rb_string` is deprecated. Use keyword argument like `Types.rb_string(words: ...)` instead.', uplevel: 1
13
+ words = legacy_words
14
+ end
15
+
11
16
  resolved_num = resolve(words)
12
17
  word_list =
13
18
  translate('faker.lorem.words')
@@ -20,11 +25,29 @@ module Faker
20
25
  sample(CHARACTERS)
21
26
  end
22
27
 
23
- def rb_integer(from: 0, to: 100)
28
+ def rb_integer(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 0, to: 100)
29
+ if legacy_from != NOT_GIVEN
30
+ warn_with_uplevel 'Passing `from` with the 1st argument of `Types.rb_integer` is deprecated. Use keyword argument like `Types.rb_integer(from: ...)` instead.', uplevel: 1
31
+ from = legacy_from
32
+ end
33
+ if legacy_to != NOT_GIVEN
34
+ warn_with_uplevel 'Passing `to` with the 2nd argument of `Types.rb_integer` is deprecated. Use keyword argument like `Types.rb_integer(to: ...)` instead.', uplevel: 1
35
+ to = legacy_to
36
+ end
37
+
24
38
  rand(from..to).to_i
25
39
  end
26
40
 
27
- def rb_hash(number: 1, type: random_type)
41
+ def rb_hash(legacy_number = NOT_GIVEN, legacy_type = NOT_GIVEN, number: 1, type: random_type)
42
+ if legacy_number != NOT_GIVEN
43
+ warn_with_uplevel 'Passing `number` with the 1st argument of `Types.rb_hash` is deprecated. Use keyword argument like `Types.rb_hash(number: ...)` instead.', uplevel: 1
44
+ number = legacy_number
45
+ end
46
+ if legacy_type != NOT_GIVEN
47
+ warn_with_uplevel 'Passing `type` with the 2nd argument of `Types.rb_hash` is deprecated. Use keyword argument like `Types.rb_hash(type: ...)` instead.', uplevel: 1
48
+ type = legacy_type
49
+ end
50
+
28
51
  {}.tap do |hsh|
29
52
  Lorem.words(number: number * 2).uniq.first(number).each do |s|
30
53
  hsh.merge!(s.to_sym => type)
@@ -32,11 +55,21 @@ module Faker
32
55
  end
33
56
  end
34
57
 
35
- def complex_rb_hash(number: 1)
58
+ def complex_rb_hash(legacy_number = NOT_GIVEN, number: 1)
59
+ if legacy_number != NOT_GIVEN
60
+ warn_with_uplevel 'Passing `number` with the 1st argument of `Types.complex_rb_hash` is deprecated. Use keyword argument like `Types.complex_rb_hash(number: ...)` instead.', uplevel: 1
61
+ number = legacy_number
62
+ end
63
+
36
64
  rb_hash(number: number, type: random_complex_type)
37
65
  end
38
66
 
39
- def rb_array(len: 1)
67
+ def rb_array(legacy_len = NOT_GIVEN, len: 1)
68
+ if legacy_len != NOT_GIVEN
69
+ warn_with_uplevel 'Passing `len` with the 1st argument of `Types.rb_array` is deprecated. Use keyword argument like `Types.rb_array(len: ...)` instead.', uplevel: 1
70
+ len = legacy_len
71
+ end
72
+
40
73
  [].tap do |ar|
41
74
  len.times do
42
75
  ar.push random_type
@@ -26,7 +26,12 @@ module Faker
26
26
  fetch('vehicle.makes')
27
27
  end
28
28
 
29
- def model(make_of_model: '')
29
+ def model(legacy_make_of_model = NOT_GIVEN, make_of_model: '')
30
+ if legacy_make_of_model != NOT_GIVEN
31
+ warn_with_uplevel 'Passing `make_of_model` with the 1st argument of `Vehicle.model` is deprecated. Use keyword argument like `Vehicle.model(make_of_model: ...)` instead.', uplevel: 1
32
+ make_of_model = legacy_make_of_model
33
+ end
34
+
30
35
  return fetch("vehicle.models_by_make.#{make}") if make_of_model.empty?
31
36
 
32
37
  fetch("vehicle.models_by_make.#{make_of_model}")
@@ -85,13 +90,27 @@ module Faker
85
90
  Faker::Time.backward(days: rand_in_range(365, 5475), period: :all, format: '%Y').to_i
86
91
  end
87
92
 
88
- def mileage(min: MILEAGE_MIN, max: MILEAGE_MAX)
93
+ def mileage(legacy_min = NOT_GIVEN, legacy_max = NOT_GIVEN, min: MILEAGE_MIN, max: MILEAGE_MAX)
94
+ if legacy_min != NOT_GIVEN
95
+ warn_with_uplevel 'Passing `min` with the 1st argument of `Vehicle.mileage` is deprecated. Use keyword argument like `Vehicle.mileage(min: ...)` instead.', uplevel: 1
96
+ min = legacy_min
97
+ end
98
+ if legacy_max != NOT_GIVEN
99
+ warn_with_uplevel 'Passing `max` with the 2nd argument of `Vehicle.mileage` is deprecated. Use keyword argument like `Vehicle.mileage(max: ...)` instead.', uplevel: 1
100
+ max = legacy_max
101
+ end
102
+
89
103
  rand_in_range(min, max)
90
104
  end
91
105
 
92
106
  alias kilometrage mileage
93
107
 
94
- def license_plate(state_abreviation: '')
108
+ def license_plate(legacy_state_abreviation = NOT_GIVEN, state_abreviation: '')
109
+ if legacy_state_abreviation != NOT_GIVEN
110
+ warn_with_uplevel 'Passing `state_abreviation` with the 1st argument of `Vehicle.license_plate` is deprecated. Use keyword argument like `Vehicle.license_plate(state_abreviation: ...)` instead.', uplevel: 1
111
+ state_abreviation = legacy_state_abreviation
112
+ end
113
+
95
114
  return regexify(bothify(fetch('vehicle.license_plate'))) if state_abreviation.empty?
96
115
 
97
116
  key = 'vehicle.license_plate_by_state.' + state_abreviation
@@ -15,11 +15,25 @@ module Faker
15
15
  fetch('world_cup.stadiums')
16
16
  end
17
17
 
18
- def group(group: 'group_A')
18
+ def group(legacy_group = NOT_GIVEN, group: 'group_A')
19
+ if legacy_group != NOT_GIVEN
20
+ warn_with_uplevel 'Passing `group` with the 1st argument of `WorldCup.group` is deprecated. Use keyword argument like `WorldCup.group(group: ...)` instead.', uplevel: 1
21
+ group = legacy_group
22
+ end
23
+
19
24
  fetch("world_cup.groups.#{group}")
20
25
  end
21
26
 
22
- def roster(country: 'Egypt', type: 'coach')
27
+ def roster(legacy_country = NOT_GIVEN, legacy_type = NOT_GIVEN, country: 'Egypt', type: 'coach')
28
+ if legacy_country != NOT_GIVEN
29
+ warn_with_uplevel 'Passing `country` with the 1st argument of `WorldCup.roster` is deprecated. Use keyword argument like `WorldCup.roster(country: ...)` instead.', uplevel: 1
30
+ country = legacy_country
31
+ end
32
+ if legacy_type != NOT_GIVEN
33
+ warn_with_uplevel 'Passing `type` with the 2nd argument of `WorldCup.roster` is deprecated. Use keyword argument like `WorldCup.roster(type: ...)` instead.', uplevel: 1
34
+ type = legacy_type
35
+ end
36
+
23
37
  fetch("world_cup.rosters.#{country}.#{type}")
24
38
  end
25
39
  end