faker 2.1.2 → 2.2.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 (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
@@ -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
@@ -3,7 +3,22 @@
3
3
  module Faker
4
4
  class Fillmurray < Base
5
5
  class << self
6
- def image(grayscale: false, width: 200, height: 200)
6
+ # rubocop:disable Metrics/ParameterLists
7
+ def image(legacy_grayscale = NOT_GIVEN, legacy_width = NOT_GIVEN, legacy_height = NOT_GIVEN, grayscale: false, width: 200, height: 200)
8
+ # rubocop:enable Metrics/ParameterLists
9
+ if legacy_grayscale != NOT_GIVEN
10
+ warn_with_uplevel 'Passing `grayscale` with the 1st argument of `Fillmurray.image` is deprecated. Use keyword argument like `Fillmurray.image(grayscale: ...)` instead.', uplevel: 1
11
+ grayscale = legacy_grayscale
12
+ end
13
+ if legacy_width != NOT_GIVEN
14
+ warn_with_uplevel 'Passing `width` with the 2nd argument of `Fillmurray.image` is deprecated. Use keyword argument like `Fillmurray.image(width: ...)` instead.', uplevel: 1
15
+ width = legacy_width
16
+ end
17
+ if legacy_height != NOT_GIVEN
18
+ warn_with_uplevel 'Passing `height` with the 3rd argument of `Fillmurray.image` is deprecated. Use keyword argument like `Fillmurray.image(height: ...)` instead.', uplevel: 1
19
+ height = legacy_height
20
+ end
21
+
7
22
  raise ArgumentError, 'Width should be a number' unless width.to_s =~ /^\d+$/
8
23
  raise ArgumentError, 'Height should be a number' unless height.to_s =~ /^\d+$/
9
24
  raise ArgumentError, 'Grayscale should be a boolean' unless [true, false].include?(grayscale)
@@ -26,7 +26,12 @@ module Faker
26
26
  template.gsub('L', luhn_digit.to_s)
27
27
  end
28
28
 
29
- def vat_number(country: 'BR')
29
+ def vat_number(legacy_country = NOT_GIVEN, country: 'BR')
30
+ if legacy_country != NOT_GIVEN
31
+ warn_with_uplevel 'Passing `country` with the 1st argument of `Finance.vat_number` is deprecated. Use keyword argument like `Finance.vat_number(country: ...)` instead.', uplevel: 1
32
+ country = legacy_country
33
+ end
34
+
30
35
  numerify(fetch("finance.vat_number.#{country}"))
31
36
  rescue I18n::MissingTranslationData
32
37
  raise ArgumentError, "Could not find vat number for #{country}"
@@ -8,7 +8,22 @@ module Faker
8
8
  random_word =~ /\s/ ? word : random_word
9
9
  end
10
10
 
11
- def words(number: 3, supplemental: false, spaces_allowed: false)
11
+ # rubocop:disable Metrics/ParameterLists
12
+ def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_spaces_allowed = NOT_GIVEN, number: 3, supplemental: false, spaces_allowed: false)
13
+ # rubocop:enable Metrics/ParameterLists
14
+ if legacy_number != NOT_GIVEN
15
+ warn_with_uplevel 'Passing `number` with the 1st argument of `Hipster.words` is deprecated. Use keyword argument like `Hipster.words(number: ...)` instead.', uplevel: 1
16
+ number = legacy_number
17
+ end
18
+ if legacy_supplemental != NOT_GIVEN
19
+ warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Hipster.words` is deprecated. Use keyword argument like `Hipster.words(supplemental: ...)` instead.', uplevel: 1
20
+ supplemental = legacy_supplemental
21
+ end
22
+ if legacy_spaces_allowed != NOT_GIVEN
23
+ warn_with_uplevel 'Passing `spaces_allowed` with the 3rd argument of `Hipster.words` is deprecated. Use keyword argument like `Hipster.words(spaces_allowed: ...)` instead.', uplevel: 1
24
+ spaces_allowed = legacy_spaces_allowed
25
+ end
26
+
12
27
  resolved_num = resolve(number)
13
28
  word_list = (
14
29
  translate('faker.hipster.words') +
@@ -22,11 +37,35 @@ module Faker
22
37
  words.each_with_index { |w, i| words[i] = word if w =~ /\s/ }
23
38
  end
24
39
 
25
- def sentence(word_count: 4, supplemental: false, random_words_to_add: 6)
40
+ # rubocop:disable Metrics/ParameterLists
41
+ def sentence(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, supplemental: false, random_words_to_add: 6)
42
+ # rubocop:enable Metrics/ParameterLists
43
+ if legacy_word_count != NOT_GIVEN
44
+ warn_with_uplevel 'Passing `word_count` with the 1st argument of `Hipster.sentence` is deprecated. Use keyword argument like `Hipster.sentence(word_count: ...)` instead.', uplevel: 1
45
+ word_count = legacy_word_count
46
+ end
47
+ if legacy_supplemental != NOT_GIVEN
48
+ warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Hipster.sentence` is deprecated. Use keyword argument like `Hipster.sentence(supplemental: ...)` instead.', uplevel: 1
49
+ supplemental = legacy_supplemental
50
+ end
51
+ if legacy_random_words_to_add != NOT_GIVEN
52
+ warn_with_uplevel 'Passing `random_words_to_add` with the 3rd argument of `Hipster.sentence` is deprecated. Use keyword argument like `Hipster.sentence(random_words_to_add: ...)` instead.', uplevel: 1
53
+ random_words_to_add = legacy_random_words_to_add
54
+ end
55
+
26
56
  words(number: word_count + rand(random_words_to_add.to_i).to_i, supplemental: supplemental, spaces_allowed: true).join(' ').capitalize + '.'
27
57
  end
28
58
 
29
- def sentences(number: 3, supplemental: false)
59
+ def sentences(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
60
+ if legacy_number != NOT_GIVEN
61
+ warn_with_uplevel 'Passing `number` with the 1st argument of `Hipster.sentences` is deprecated. Use keyword argument like `Hipster.sentences(number: ...)` instead.', uplevel: 1
62
+ number = legacy_number
63
+ end
64
+ if legacy_supplemental != NOT_GIVEN
65
+ warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Hipster.sentences` is deprecated. Use keyword argument like `Hipster.sentences(supplemental: ...)` instead.', uplevel: 1
66
+ supplemental = legacy_supplemental
67
+ end
68
+
30
69
  [].tap do |sentences|
31
70
  1.upto(resolve(number)) do
32
71
  sentences << sentence(word_count: 3, supplemental: supplemental)
@@ -34,11 +73,35 @@ module Faker
34
73
  end
35
74
  end
36
75
 
37
- def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 3)
76
+ # rubocop:disable Metrics/ParameterLists
77
+ def paragraph(legacy_sentence_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_sentences_to_add = NOT_GIVEN, sentence_count: 3, supplemental: false, random_sentences_to_add: 3)
78
+ # rubocop:enable Metrics/ParameterLists
79
+ if legacy_sentence_count != NOT_GIVEN
80
+ warn_with_uplevel 'Passing `sentence_count` with the 1st argument of `Hipster.paragraph` is deprecated. Use keyword argument like `Hipster.paragraph(sentence_count: ...)` instead.', uplevel: 1
81
+ sentence_count = legacy_sentence_count
82
+ end
83
+ if legacy_supplemental != NOT_GIVEN
84
+ warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Hipster.paragraph` is deprecated. Use keyword argument like `Hipster.paragraph(supplemental: ...)` instead.', uplevel: 1
85
+ supplemental = legacy_supplemental
86
+ end
87
+ if legacy_random_sentences_to_add != NOT_GIVEN
88
+ warn_with_uplevel 'Passing `random_sentences_to_add` with the 3rd argument of `Hipster.paragraph` is deprecated. Use keyword argument like `Hipster.paragraph(random_sentences_to_add: ...)` instead.', uplevel: 1
89
+ random_sentences_to_add = legacy_random_sentences_to_add
90
+ end
91
+
38
92
  sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i, supplemental: supplemental).join(' ')
39
93
  end
40
94
 
41
- def paragraphs(number: 3, supplemental: false)
95
+ def paragraphs(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
96
+ if legacy_number != NOT_GIVEN
97
+ warn_with_uplevel 'Passing `number` with the 1st argument of `Hipster.paragraphs` is deprecated. Use keyword argument like `Hipster.paragraphs(number: ...)` instead.', uplevel: 1
98
+ number = legacy_number
99
+ end
100
+ if legacy_supplemental != NOT_GIVEN
101
+ warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Hipster.paragraphs` is deprecated. Use keyword argument like `Hipster.paragraphs(supplemental: ...)` instead.', uplevel: 1
102
+ supplemental = legacy_supplemental
103
+ end
104
+
42
105
  [].tap do |paragraphs|
43
106
  1.upto(resolve(number)) do
44
107
  paragraphs << paragraph(sentence_count: 3, supplemental: supplemental)
@@ -46,7 +109,16 @@ module Faker
46
109
  end
47
110
  end
48
111
 
49
- def paragraph_by_chars(characters: 256, supplemental: false)
112
+ def paragraph_by_chars(legacy_characters = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, characters: 256, supplemental: false)
113
+ if legacy_characters != NOT_GIVEN
114
+ warn_with_uplevel 'Passing `characters` with the 1st argument of `Hipster.paragraph_by_chars` is deprecated. Use keyword argument like `Hipster.paragraph_by_chars(characters: ...)` instead.', uplevel: 1
115
+ characters = legacy_characters
116
+ end
117
+ if legacy_supplemental != NOT_GIVEN
118
+ warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Hipster.paragraph_by_chars` is deprecated. Use keyword argument like `Hipster.paragraph_by_chars(supplemental: ...)` instead.', uplevel: 1
119
+ supplemental = legacy_supplemental
120
+ end
121
+
50
122
  paragraph = paragraph(sentence_count: 3, supplemental: supplemental)
51
123
 
52
124
  paragraph += ' ' + paragraph(sentence_count: 3, supplemental: supplemental) while paragraph.length < characters