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
@@ -5,7 +5,30 @@ module Faker
5
5
  class << self
6
6
  SUPPORTED_FORMATS = %w[png jpg bmp].freeze
7
7
 
8
- def image(slug: nil, size: '300x300', format: 'png', set: 'set1', bgset: nil)
8
+ # rubocop:disable Metrics/ParameterLists
9
+ def image(legacy_slug = NOT_GIVEN, legacy_size = NOT_GIVEN, legacy_format = NOT_GIVEN, legacy_set = NOT_GIVEN, legacy_bgset = NOT_GIVEN, slug: nil, size: '300x300', format: 'png', set: 'set1', bgset: nil)
10
+ # rubocop:enable Metrics/ParameterLists
11
+ if legacy_slug != NOT_GIVEN
12
+ warn_with_uplevel 'Passing `slug` with the 1st argument of `Avatar.image` is deprecated. Use keyword argument like `Avatar.image(slug: ...)` instead.', uplevel: 1
13
+ slug = legacy_slug
14
+ end
15
+ if legacy_size != NOT_GIVEN
16
+ warn_with_uplevel 'Passing `size` with the 2nd argument of `Avatar.image` is deprecated. Use keyword argument like `Avatar.image(size: ...)` instead.', uplevel: 1
17
+ size = legacy_size
18
+ end
19
+ if legacy_format != NOT_GIVEN
20
+ warn_with_uplevel 'Passing `format` with the 3rd argument of `Avatar.image` is deprecated. Use keyword argument like `Avatar.image(format: ...)` instead.', uplevel: 1
21
+ format = legacy_format
22
+ end
23
+ if legacy_set != NOT_GIVEN
24
+ warn_with_uplevel 'Passing `set` with the 4th argument of `Avatar.image` is deprecated. Use keyword argument like `Avatar.image(set: ...)` instead.', uplevel: 1
25
+ set = legacy_set
26
+ end
27
+ if legacy_bgset != NOT_GIVEN
28
+ warn_with_uplevel 'Passing `bgset` with the 5th argument of `Avatar.image` is deprecated. Use keyword argument like `Avatar.image(bgset: ...)` instead.', uplevel: 1
29
+ bgset = legacy_bgset
30
+ end
31
+
9
32
  raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /^[0-9]+x[0-9]+$/
10
33
  raise ArgumentError, "Supported formats are #{SUPPORTED_FORMATS.join(', ')}" unless SUPPORTED_FORMATS.include?(format)
11
34
 
@@ -5,7 +5,12 @@ module Faker
5
5
  flexible :bank
6
6
 
7
7
  class << self
8
- def account_number(digits: 10)
8
+ def account_number(legacy_digits = NOT_GIVEN, digits: 10)
9
+ if legacy_digits != NOT_GIVEN
10
+ warn_with_uplevel 'Passing `digits` with the 1st argument of `Bank.account_number` is deprecated. Use keyword argument like `Bank.account_number(digits: ...)` instead.', uplevel: 1
11
+ digits = legacy_digits
12
+ end
13
+
9
14
  output = ''
10
15
 
11
16
  output += rand.to_s[2..-1] while output.length < digits
@@ -13,10 +18,15 @@ module Faker
13
18
  output[0...digits]
14
19
  end
15
20
 
16
- def iban(country_code: 'GB')
21
+ def iban(legacy_country_code = NOT_GIVEN, country_code: 'GB')
17
22
  # Each country has it's own format for bank accounts
18
23
  # Many of them use letters in certain parts of the account
19
24
  # Using regex patterns we can create virtually any type of bank account
25
+ if legacy_country_code != NOT_GIVEN
26
+ warn_with_uplevel 'Passing `country_code` with the 1st argument of `Bank.iban` is deprecated. Use keyword argument like `Bank.iban(country_code: ...)` instead.', uplevel: 1
27
+ country_code = legacy_country_code
28
+ end
29
+
20
30
  begin
21
31
  pattern = fetch("bank.iban_details.#{country_code.downcase}.bban_pattern")
22
32
  rescue I18n::MissingTranslationData
@@ -3,7 +3,12 @@
3
3
  module Faker
4
4
  class Boolean < Base
5
5
  class << self
6
- def boolean(true_ratio: 0.5)
6
+ def boolean(legacy_true_ratio = NOT_GIVEN, true_ratio: 0.5)
7
+ if legacy_true_ratio != NOT_GIVEN
8
+ warn_with_uplevel 'Passing `true_ratio` with the 1st argument of `Boolean.boolean` is deprecated. Use keyword argument like `Boolean.boolean(true_ratio: ...)` instead.', uplevel: 1
9
+ true_ratio = legacy_true_ratio
10
+ end
11
+
7
12
  (rand < true_ratio)
8
13
  end
9
14
  end
@@ -6,7 +6,16 @@ module Faker
6
6
  @last_rut = nil
7
7
 
8
8
  # Fixed param added for testing a specific RUT and check digit combination.
9
- def rut(min_rut: 1, fixed: false)
9
+ def rut(legacy_min_rut = NOT_GIVEN, legacy_fixed = NOT_GIVEN, min_rut: 1, fixed: false)
10
+ if legacy_min_rut != NOT_GIVEN
11
+ warn_with_uplevel 'Passing `min_rut` with the 1st argument of `ChileRut.rut` is deprecated. Use keyword argument like `ChileRut.rut(min_rut: ...)` instead.', uplevel: 1
12
+ min_rut = legacy_min_rut
13
+ end
14
+ if legacy_fixed != NOT_GIVEN
15
+ warn_with_uplevel 'Passing `fixed` with the 2nd argument of `ChileRut.rut` is deprecated. Use keyword argument like `ChileRut.rut(fixed: ...)` instead.', uplevel: 1
16
+ fixed = legacy_fixed
17
+ end
18
+
10
19
  @last_rut = fixed ? min_rut : rand_in_range(min_rut, 99_999_999)
11
20
  end
12
21
 
@@ -34,7 +43,16 @@ module Faker
34
43
  dv
35
44
  end
36
45
 
37
- def full_rut(min_rut: 0, fixed: false)
46
+ def full_rut(legacy_min_rut = NOT_GIVEN, legacy_fixed = NOT_GIVEN, min_rut: 0, fixed: false)
47
+ if legacy_min_rut != NOT_GIVEN
48
+ warn_with_uplevel 'Passing `min_rut` with the 1st argument of `ChileRut.full_rut` is deprecated. Use keyword argument like `ChileRut.full_rut(min_rut: ...)` instead.', uplevel: 1
49
+ min_rut = legacy_min_rut
50
+ end
51
+ if legacy_fixed != NOT_GIVEN
52
+ warn_with_uplevel 'Passing `fixed` with the 2nd argument of `ChileRut.full_rut` is deprecated. Use keyword argument like `ChileRut.full_rut(fixed: ...)` instead.', uplevel: 1
53
+ fixed = legacy_fixed
54
+ end
55
+
38
56
  "#{rut(min_rut: min_rut, fixed: fixed)}-#{dv}"
39
57
  end
40
58
 
@@ -12,13 +12,23 @@ module Faker
12
12
 
13
13
  # By default generates 10 sign isbn code in format 123456789-X
14
14
  # You can pass 13 to generate new 13 sign code
15
- def isbn(base: 10)
15
+ def isbn(legacy_base = NOT_GIVEN, base: 10)
16
+ if legacy_base != NOT_GIVEN
17
+ warn_with_uplevel 'Passing `base` with the 1st argument of `Code.isbn` is deprecated. Use keyword argument like `Code.isbn(base: ...)` instead.', uplevel: 1
18
+ base = legacy_base
19
+ end
20
+
16
21
  base == 13 ? generate_base13_isbn : generate_base10_isbn
17
22
  end
18
23
 
19
24
  # By default generates 13 sign ean code in format 1234567890123
20
25
  # You can pass 8 to generate ean8 code
21
- def ean(base: 13)
26
+ def ean(legacy_base = NOT_GIVEN, base: 13)
27
+ if legacy_base != NOT_GIVEN
28
+ warn_with_uplevel 'Passing `base` with the 1st argument of `Code.ean` is deprecated. Use keyword argument like `Code.ean(base: ...)` instead.', uplevel: 1
29
+ base = legacy_base
30
+ end
31
+
22
32
  base == 8 ? generate_base8_ean : generate_base13_ean
23
33
  end
24
34
 
@@ -30,7 +40,16 @@ module Faker
30
40
 
31
41
  # By default generates a Singaporean NRIC ID for someone
32
42
  # who is born between the age of 18 and 65.
33
- def nric(min_age: 18, max_age: 65)
43
+ def nric(legacy_min_age = NOT_GIVEN, legacy_max_age = NOT_GIVEN, min_age: 18, max_age: 65)
44
+ if legacy_min_age != NOT_GIVEN
45
+ warn_with_uplevel 'Passing `min_age` with the 1st argument of `Code.nric` is deprecated. Use keyword argument like `Code.nric(min_age: ...)` instead.', uplevel: 1
46
+ min_age = legacy_min_age
47
+ end
48
+ if legacy_max_age != NOT_GIVEN
49
+ warn_with_uplevel 'Passing `max_age` with the 2nd argument of `Code.nric` is deprecated. Use keyword argument like `Code.nric(max_age: ...)` instead.', uplevel: 1
50
+ max_age = legacy_max_age
51
+ end
52
+
34
53
  birthyear = Date.birthday(min_age: min_age, max_age: max_age).year
35
54
  prefix = birthyear < 2000 ? 'S' : 'T'
36
55
  values = birthyear.to_s[-2..-1]
@@ -7,7 +7,12 @@ module Faker
7
7
  fetch('color.name')
8
8
  end
9
9
 
10
- def promotion_code(digits: 6)
10
+ def promotion_code(legacy_digits = NOT_GIVEN, digits: 6)
11
+ if legacy_digits != NOT_GIVEN
12
+ warn_with_uplevel 'Passing `digits` with the 1st argument of `Commerce.promotion_code` is deprecated. Use keyword argument like `Commerce.promotion_code(digits: ...)` instead.', uplevel: 1
13
+ digits = legacy_digits
14
+ end
15
+
11
16
  [
12
17
  fetch('commerce.promotion_code.adjective'),
13
18
  fetch('commerce.promotion_code.noun'),
@@ -15,7 +20,16 @@ module Faker
15
20
  ].join
16
21
  end
17
22
 
18
- def department(max: 3, fixed_amount: false)
23
+ def department(legacy_max = NOT_GIVEN, legacy_fixed_amount = NOT_GIVEN, max: 3, fixed_amount: false)
24
+ if legacy_max != NOT_GIVEN
25
+ warn_with_uplevel 'Passing `max` with the 1st argument of `Commerce.department` is deprecated. Use keyword argument like `Commerce.department(max: ...)` instead.', uplevel: 1
26
+ max = legacy_max
27
+ end
28
+ if legacy_fixed_amount != NOT_GIVEN
29
+ warn_with_uplevel 'Passing `fixed_amount` with the 2nd argument of `Commerce.department` is deprecated. Use keyword argument like `Commerce.department(fixed_amount: ...)` instead.', uplevel: 1
30
+ fixed_amount = legacy_fixed_amount
31
+ end
32
+
19
33
  num = max if fixed_amount
20
34
  num ||= 1 + rand(max)
21
35
 
@@ -34,7 +48,16 @@ module Faker
34
48
  fetch('commerce.product_name.material')
35
49
  end
36
50
 
37
- def price(range: 0..100.0, as_string: false)
51
+ def price(legacy_range = NOT_GIVEN, legacy_as_string = NOT_GIVEN, range: 0..100.0, as_string: false)
52
+ if legacy_range != NOT_GIVEN
53
+ warn_with_uplevel 'Passing `range` with the 1st argument of `Commerce.price` is deprecated. Use keyword argument like `Commerce.price(range: ...)` instead.', uplevel: 1
54
+ range = legacy_range
55
+ end
56
+ if legacy_as_string != NOT_GIVEN
57
+ warn_with_uplevel 'Passing `as_string` with the 2nd argument of `Commerce.price` is deprecated. Use keyword argument like `Commerce.price(as_string: ...)` instead.', uplevel: 1
58
+ as_string = legacy_as_string
59
+ end
60
+
38
61
  price = (rand(range) * 100).floor / 100.0
39
62
  if as_string
40
63
  price_parts = price.to_s.split('.')
@@ -126,7 +126,12 @@ module Faker
126
126
  end
127
127
 
128
128
  # Get a random Polish register of national economy number. More info https://pl.wikipedia.org/wiki/REGON
129
- def polish_register_of_national_economy(length: 9)
129
+ def polish_register_of_national_economy(legacy_length = NOT_GIVEN, length: 9)
130
+ if legacy_length != NOT_GIVEN
131
+ warn_with_uplevel 'Passing `length` with the 1st argument of `Company.polish_register_of_national_economy` is deprecated. Use keyword argument like `Company.polish_register_of_national_economy(length: ...)` instead.', uplevel: 1
132
+ length = legacy_length
133
+ end
134
+
130
135
  raise ArgumentError, 'Length should be 9 or 14' unless [9, 14].include? length
131
136
 
132
137
  random_digits = []
@@ -153,7 +158,12 @@ module Faker
153
158
  regexify(/IT\d{2,4}\/\d{2,10}/)
154
159
  end
155
160
 
156
- def brazilian_company_number(formatted: false)
161
+ def brazilian_company_number(legacy_formatted = NOT_GIVEN, formatted: false)
162
+ if legacy_formatted != NOT_GIVEN
163
+ warn_with_uplevel 'Passing `formatted` with the 1st argument of `Company.brazilian_company_number` is deprecated. Use keyword argument like `Company.brazilian_company_number(formatted: ...)` instead.', uplevel: 1
164
+ formatted = legacy_formatted
165
+ end
166
+
157
167
  digits = Array.new(8) { Faker::Number.digit.to_i } + [0, 0, 0, Faker::Number.non_zero_digit.to_i]
158
168
 
159
169
  factors = [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, 6].cycle
@@ -7,15 +7,30 @@ module Faker
7
7
  ACRONYM = 1
8
8
  URL_LOGO = 2
9
9
 
10
- def coin_name(coin: coin_array)
10
+ def coin_name(legacy_coin = NOT_GIVEN, coin: coin_array)
11
+ if legacy_coin != NOT_GIVEN
12
+ warn_with_uplevel 'Passing `coin` with the 1st argument of `CryptoCoin.coin_name` is deprecated. Use keyword argument like `CryptoCoin.coin_name(coin: ...)` instead.', uplevel: 1
13
+ coin = legacy_coin
14
+ end
15
+
11
16
  coin[COIN_NAME]
12
17
  end
13
18
 
14
- def acronym(coin: coin_array)
19
+ def acronym(legacy_coin = NOT_GIVEN, coin: coin_array)
20
+ if legacy_coin != NOT_GIVEN
21
+ warn_with_uplevel 'Passing `coin` with the 1st argument of `CryptoCoin.acronym` is deprecated. Use keyword argument like `CryptoCoin.acronym(coin: ...)` instead.', uplevel: 1
22
+ coin = legacy_coin
23
+ end
24
+
15
25
  coin[ACRONYM]
16
26
  end
17
27
 
18
- def url_logo(coin: coin_array)
28
+ def url_logo(legacy_coin = NOT_GIVEN, coin: coin_array)
29
+ if legacy_coin != NOT_GIVEN
30
+ warn_with_uplevel 'Passing `coin` with the 1st argument of `CryptoCoin.url_logo` is deprecated. Use keyword argument like `CryptoCoin.url_logo(coin: ...)` instead.', uplevel: 1
31
+ coin = legacy_coin
32
+ end
33
+
19
34
  coin[URL_LOGO]
20
35
  end
21
36
 
@@ -3,14 +3,38 @@
3
3
  module Faker
4
4
  class Date < Base
5
5
  class << self
6
- def between(from:, to:)
6
+ def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from:, to:)
7
+ if legacy_from != NOT_GIVEN
8
+ warn_with_uplevel 'Passing `from` with the 1st argument of `Date.between` is deprecated. Use keyword argument like `Date.between(from: ...)` instead.', uplevel: 1
9
+ from = legacy_from
10
+ end
11
+ if legacy_to != NOT_GIVEN
12
+ warn_with_uplevel 'Passing `to` with the 2nd argument of `Date.between` is deprecated. Use keyword argument like `Date.between(to: ...)` instead.', uplevel: 1
13
+ to = legacy_to
14
+ end
15
+
7
16
  from = get_date_object(from)
8
17
  to = get_date_object(to)
9
18
 
10
19
  Faker::Base.rand_in_range(from, to)
11
20
  end
12
21
 
13
- def between_except(from:, to:, excepted:)
22
+ # rubocop:disable Metrics/ParameterLists
23
+ def between_except(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_excepted = NOT_GIVEN, from:, to:, excepted:)
24
+ # rubocop:enable Metrics/ParameterLists
25
+ if legacy_from != NOT_GIVEN
26
+ warn_with_uplevel 'Passing `from` with the 1st argument of `Date.between_except` is deprecated. Use keyword argument like `Date.between_except(from: ...)` instead.', uplevel: 1
27
+ from = legacy_from
28
+ end
29
+ if legacy_to != NOT_GIVEN
30
+ warn_with_uplevel 'Passing `to` with the 2nd argument of `Date.between_except` is deprecated. Use keyword argument like `Date.between_except(to: ...)` instead.', uplevel: 1
31
+ to = legacy_to
32
+ end
33
+ if legacy_excepted != NOT_GIVEN
34
+ warn_with_uplevel 'Passing `excepted` with the 3rd argument of `Date.between_except` is deprecated. Use keyword argument like `Date.between_except(excepted: ...)` instead.', uplevel: 1
35
+ excepted = legacy_excepted
36
+ end
37
+
14
38
  raise ArgumentError, 'From date, to date and excepted date must not be the same' if from == to && to == excepted
15
39
 
16
40
  excepted = get_date_object(excepted)
@@ -21,21 +45,40 @@ module Faker
21
45
  end
22
46
  end
23
47
 
24
- def forward(days: 365)
48
+ def forward(legacy_days = NOT_GIVEN, days: 365)
49
+ if legacy_days != NOT_GIVEN
50
+ warn_with_uplevel 'Passing `days` with the 1st argument of `Date.forward` is deprecated. Use keyword argument like `Date.forward(days: ...)` instead.', uplevel: 1
51
+ days = legacy_days
52
+ end
53
+
25
54
  from = ::Date.today + 1
26
55
  to = ::Date.today + days
27
56
 
28
57
  between(from: from, to: to).to_date
29
58
  end
30
59
 
31
- def backward(days: 365)
60
+ def backward(legacy_days = NOT_GIVEN, days: 365)
61
+ if legacy_days != NOT_GIVEN
62
+ warn_with_uplevel 'Passing `days` with the 1st argument of `Date.backward` is deprecated. Use keyword argument like `Date.backward(days: ...)` instead.', uplevel: 1
63
+ days = legacy_days
64
+ end
65
+
32
66
  from = ::Date.today - days
33
67
  to = ::Date.today - 1
34
68
 
35
69
  between(from: from, to: to).to_date
36
70
  end
37
71
 
38
- def birthday(min_age: 18, max_age: 65)
72
+ def birthday(legacy_min_age = NOT_GIVEN, legacy_max_age = NOT_GIVEN, min_age: 18, max_age: 65)
73
+ if legacy_min_age != NOT_GIVEN
74
+ warn_with_uplevel 'Passing `min_age` with the 1st argument of `Date.birthday` is deprecated. Use keyword argument like `Date.birthday(min_age: ...)` instead.', uplevel: 1
75
+ min_age = legacy_min_age
76
+ end
77
+ if legacy_max_age != NOT_GIVEN
78
+ warn_with_uplevel 'Passing `max_age` with the 2nd argument of `Date.birthday` is deprecated. Use keyword argument like `Date.birthday(max_age: ...)` instead.', uplevel: 1
79
+ max_age = legacy_max_age
80
+ end
81
+
39
82
  t = ::Date.today
40
83
 
41
84
  from = birthday_date(t, max_age)
@@ -23,7 +23,12 @@ module Faker
23
23
  fetch('demographic.sex')
24
24
  end
25
25
 
26
- def height(unit: :metric)
26
+ def height(legacy_unit = NOT_GIVEN, unit: :metric)
27
+ if legacy_unit != NOT_GIVEN
28
+ warn_with_uplevel 'Passing `unit` with the 1st argument of `Demographic.height` is deprecated. Use keyword argument like `Demographic.height(unit: ...)` instead.', uplevel: 1
29
+ unit = legacy_unit
30
+ end
31
+
27
32
  case unit
28
33
  when :imperial
29
34
  inches = rand_in_range(57, 86)
@@ -6,10 +6,26 @@ module Faker
6
6
  NI_CHANCE = 0.03 # NI Pop is about 3% of total UK population
7
7
 
8
8
  class << self
9
- def british_driving_licence(last_name: Faker::Name.last_name,
10
- initials: Faker::Name.initials,
11
- gender: random_gender,
12
- date_of_birth: Faker::Date.birthday(min_age: 18, max_age: 65))
9
+ # rubocop:disable Metrics/ParameterLists
10
+ def british_driving_licence(legacy_last_name = NOT_GIVEN, legacy_initials = NOT_GIVEN, legacy_gender = NOT_GIVEN, legacy_date_of_birth = NOT_GIVEN, last_name: Faker::Name.last_name, initials: Faker::Name.initials, gender: random_gender, date_of_birth: Faker::Date.birthday(min_age: 18, max_age: 65))
11
+ # rubocop:enable Metrics/ParameterLists
12
+ if legacy_last_name != NOT_GIVEN
13
+ warn_with_uplevel 'Passing `last_name` with the 1st argument of `DrivingLicence.british_driving_licence` is deprecated. Use keyword argument like `DrivingLicence.british_driving_licence(last_name: ...)` instead.', uplevel: 1
14
+ last_name = legacy_last_name
15
+ end
16
+ if legacy_initials != NOT_GIVEN
17
+ warn_with_uplevel 'Passing `initials` with the 2nd argument of `DrivingLicence.british_driving_licence` is deprecated. Use keyword argument like `DrivingLicence.british_driving_licence(initials: ...)` instead.', uplevel: 1
18
+ initials = legacy_initials
19
+ end
20
+ if legacy_gender != NOT_GIVEN
21
+ warn_with_uplevel 'Passing `gender` with the 3rd argument of `DrivingLicence.british_driving_licence` is deprecated. Use keyword argument like `DrivingLicence.british_driving_licence(gender: ...)` instead.', uplevel: 1
22
+ gender = legacy_gender
23
+ end
24
+ if legacy_date_of_birth != NOT_GIVEN
25
+ warn_with_uplevel 'Passing `date_of_birth` with the 4th argument of `DrivingLicence.british_driving_licence` is deprecated. Use keyword argument like `DrivingLicence.british_driving_licence(date_of_birth: ...)` instead.', uplevel: 1
26
+ date_of_birth = legacy_date_of_birth
27
+ end
28
+
13
29
  [
14
30
  gb_licence_padding(last_name, 5),
15
31
  gb_licence_year(date_of_birth, gender),
@@ -3,7 +3,22 @@
3
3
  module Faker
4
4
  class File < Base
5
5
  class << self
6
- def dir(segment_count: 3, root: nil, directory_separator: '/')
6
+ # rubocop:disable Metrics/ParameterLists
7
+ def dir(legacy_segment_count = NOT_GIVEN, legacy_root = NOT_GIVEN, legacy_directory_separator = NOT_GIVEN, segment_count: 3, root: nil, directory_separator: '/')
8
+ # rubocop:enable Metrics/ParameterLists
9
+ if legacy_segment_count != NOT_GIVEN
10
+ warn_with_uplevel 'Passing `segment_count` with the 1st argument of `File.dir` is deprecated. Use keyword argument like `File.dir(segment_count: ...)` instead.', uplevel: 1
11
+ segment_count = legacy_segment_count
12
+ end
13
+ if legacy_root != NOT_GIVEN
14
+ warn_with_uplevel 'Passing `root` with the 2nd argument of `File.dir` is deprecated. Use keyword argument like `File.dir(root: ...)` instead.', uplevel: 1
15
+ root = legacy_root
16
+ end
17
+ if legacy_directory_separator != NOT_GIVEN
18
+ warn_with_uplevel 'Passing `directory_separator` with the 3rd argument of `File.dir` is deprecated. Use keyword argument like `File.dir(directory_separator: ...)` instead.', uplevel: 1
19
+ directory_separator = legacy_directory_separator
20
+ end
21
+
7
22
  Array
8
23
  .new(segment_count) { Faker::Internet.slug }
9
24
  .unshift(root)
@@ -20,7 +35,26 @@ module Faker
20
35
  fetch('file.mime_type')
21
36
  end
22
37
 
23
- def file_name(dir: nil, name: nil, ext: nil, directory_separator: '/')
38
+ # rubocop:disable Metrics/ParameterLists
39
+ def file_name(legacy_dir = NOT_GIVEN, legacy_name = NOT_GIVEN, legacy_ext = NOT_GIVEN, legacy_directory_separator = NOT_GIVEN, dir: nil, name: nil, ext: nil, directory_separator: '/')
40
+ # rubocop:enable Metrics/ParameterLists
41
+ if legacy_dir != NOT_GIVEN
42
+ warn_with_uplevel 'Passing `dir` with the 1st argument of `File.file_name` is deprecated. Use keyword argument like `File.file_name(dir: ...)` instead.', uplevel: 1
43
+ dir = legacy_dir
44
+ end
45
+ if legacy_name != NOT_GIVEN
46
+ warn_with_uplevel 'Passing `name` with the 2nd argument of `File.file_name` is deprecated. Use keyword argument like `File.file_name(name: ...)` instead.', uplevel: 1
47
+ name = legacy_name
48
+ end
49
+ if legacy_ext != NOT_GIVEN
50
+ warn_with_uplevel 'Passing `ext` with the 3rd argument of `File.file_name` is deprecated. Use keyword argument like `File.file_name(ext: ...)` instead.', uplevel: 1
51
+ ext = legacy_ext
52
+ end
53
+ if legacy_directory_separator != NOT_GIVEN
54
+ warn_with_uplevel 'Passing `directory_separator` with the 4th argument of `File.file_name` is deprecated. Use keyword argument like `File.file_name(directory_separator: ...)` instead.', uplevel: 1
55
+ directory_separator = legacy_directory_separator
56
+ end
57
+
24
58
  dir ||= dir(segment_count: 1)
25
59
  name ||= Faker::Lorem.word.downcase
26
60
  ext ||= extension