faker 2.2.1 → 2.2.2

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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +28 -0
  3. data/lib/faker.rb +34 -0
  4. data/lib/faker/blockchain/tezos.rb +6 -6
  5. data/lib/faker/books/dune.rb +4 -6
  6. data/lib/faker/books/lovecraft.rb +17 -33
  7. data/lib/faker/default/address.rb +10 -15
  8. data/lib/faker/default/alphanumeric.rb +6 -12
  9. data/lib/faker/default/app.rb +4 -11
  10. data/lib/faker/default/avatar.rb +6 -19
  11. data/lib/faker/default/bank.rb +4 -6
  12. data/lib/faker/default/boolean.rb +2 -3
  13. data/lib/faker/default/chile_rut.rb +6 -14
  14. data/lib/faker/default/code.rb +7 -13
  15. data/lib/faker/default/commerce.rb +8 -17
  16. data/lib/faker/default/company.rb +4 -6
  17. data/lib/faker/default/crypto_coin.rb +6 -9
  18. data/lib/faker/default/date.rb +17 -28
  19. data/lib/faker/default/demographic.rb +2 -3
  20. data/lib/faker/default/driving_licence.rb +5 -15
  21. data/lib/faker/default/file.rb +9 -26
  22. data/lib/faker/default/fillmurray.rb +4 -11
  23. data/lib/faker/default/finance.rb +2 -3
  24. data/lib/faker/default/hipster.rb +21 -54
  25. data/lib/faker/default/id_number.rb +5 -7
  26. data/lib/faker/default/internet.rb +30 -65
  27. data/lib/faker/default/invoice.rb +7 -13
  28. data/lib/faker/default/json.rb +9 -16
  29. data/lib/faker/default/lorem.rb +30 -70
  30. data/lib/faker/default/lorem_flickr.rb +17 -48
  31. data/lib/faker/default/lorem_pixel.rb +7 -23
  32. data/lib/faker/default/markdown.rb +3 -7
  33. data/lib/faker/default/measurement.rb +16 -24
  34. data/lib/faker/default/name.rb +2 -3
  35. data/lib/faker/default/nhs.rb +2 -3
  36. data/lib/faker/default/number.rb +25 -50
  37. data/lib/faker/default/omniauth.rb +25 -63
  38. data/lib/faker/default/phone_number.rb +2 -3
  39. data/lib/faker/default/placeholdit.rb +6 -19
  40. data/lib/faker/default/relationship.rb +2 -3
  41. data/lib/faker/default/source.rb +8 -12
  42. data/lib/faker/default/string.rb +2 -3
  43. data/lib/faker/default/stripe.rb +8 -12
  44. data/lib/faker/default/time.rb +17 -48
  45. data/lib/faker/default/twitter.rb +23 -32
  46. data/lib/faker/default/types.rb +12 -23
  47. data/lib/faker/default/vehicle.rb +8 -14
  48. data/lib/faker/default/world_cup.rb +5 -10
  49. data/lib/faker/games/dota.rb +2 -3
  50. data/lib/faker/movies/star_wars.rb +3 -6
  51. data/lib/faker/version.rb +1 -1
  52. data/lib/locales/en/science.yml +1 -1
  53. metadata +13 -13
@@ -13,9 +13,8 @@ module Faker
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
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
16
+ warn_for_deprecated_arguments do |keywords|
17
+ keywords << :base if legacy_base != NOT_GIVEN
19
18
  end
20
19
 
21
20
  base == 13 ? generate_base13_isbn : generate_base10_isbn
@@ -24,9 +23,8 @@ module Faker
24
23
  # By default generates 13 sign ean code in format 1234567890123
25
24
  # You can pass 8 to generate ean8 code
26
25
  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
26
+ warn_for_deprecated_arguments do |keywords|
27
+ keywords << :base if legacy_base != NOT_GIVEN
30
28
  end
31
29
 
32
30
  base == 8 ? generate_base8_ean : generate_base13_ean
@@ -41,13 +39,9 @@ module Faker
41
39
  # By default generates a Singaporean NRIC ID for someone
42
40
  # who is born between the age of 18 and 65.
43
41
  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
42
+ warn_for_deprecated_arguments do |keywords|
43
+ keywords << :min_age if legacy_min_age != NOT_GIVEN
44
+ keywords << :max_age if legacy_max_age != NOT_GIVEN
51
45
  end
52
46
 
53
47
  birthyear = Date.birthday(min_age: min_age, max_age: max_age).year
@@ -8,9 +8,8 @@ module Faker
8
8
  end
9
9
 
10
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
11
+ warn_for_deprecated_arguments do |keywords|
12
+ keywords << :digits if legacy_digits != NOT_GIVEN
14
13
  end
15
14
 
16
15
  [
@@ -21,13 +20,9 @@ module Faker
21
20
  end
22
21
 
23
22
  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
23
+ warn_for_deprecated_arguments do |keywords|
24
+ keywords << :max if legacy_max != NOT_GIVEN
25
+ keywords << :fixed_amount if legacy_fixed_amount != NOT_GIVEN
31
26
  end
32
27
 
33
28
  num = max if fixed_amount
@@ -49,13 +44,9 @@ module Faker
49
44
  end
50
45
 
51
46
  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
47
+ warn_for_deprecated_arguments do |keywords|
48
+ keywords << :range if legacy_range != NOT_GIVEN
49
+ keywords << :as_string if legacy_as_string != NOT_GIVEN
59
50
  end
60
51
 
61
52
  price = (rand(range) * 100).floor / 100.0
@@ -127,9 +127,8 @@ module Faker
127
127
 
128
128
  # Get a random Polish register of national economy number. More info https://pl.wikipedia.org/wiki/REGON
129
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
130
+ warn_for_deprecated_arguments do |keywords|
131
+ keywords << :length if legacy_length != NOT_GIVEN
133
132
  end
134
133
 
135
134
  raise ArgumentError, 'Length should be 9 or 14' unless [9, 14].include? length
@@ -159,9 +158,8 @@ module Faker
159
158
  end
160
159
 
161
160
  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
161
+ warn_for_deprecated_arguments do |keywords|
162
+ keywords << :formatted if legacy_formatted != NOT_GIVEN
165
163
  end
166
164
 
167
165
  digits = Array.new(8) { Faker::Number.digit.to_i } + [0, 0, 0, Faker::Number.non_zero_digit.to_i]
@@ -8,27 +8,24 @@ module Faker
8
8
  URL_LOGO = 2
9
9
 
10
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
11
+ warn_for_deprecated_arguments do |keywords|
12
+ keywords << :coin if legacy_coin != NOT_GIVEN
14
13
  end
15
14
 
16
15
  coin[COIN_NAME]
17
16
  end
18
17
 
19
18
  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
19
+ warn_for_deprecated_arguments do |keywords|
20
+ keywords << :coin if legacy_coin != NOT_GIVEN
23
21
  end
24
22
 
25
23
  coin[ACRONYM]
26
24
  end
27
25
 
28
26
  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
27
+ warn_for_deprecated_arguments do |keywords|
28
+ keywords << :coin if legacy_coin != NOT_GIVEN
32
29
  end
33
30
 
34
31
  coin[URL_LOGO]
@@ -4,13 +4,9 @@ module Faker
4
4
  class Date < Base
5
5
  class << self
6
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
7
+ warn_for_deprecated_arguments do |keywords|
8
+ keywords << :from if legacy_from != NOT_GIVEN
9
+ keywords << :to if legacy_to != NOT_GIVEN
14
10
  end
15
11
 
16
12
  from = get_date_object(from)
@@ -22,17 +18,14 @@ module Faker
22
18
  # rubocop:disable Metrics/ParameterLists
23
19
  def between_except(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_excepted = NOT_GIVEN, from:, to:, excepted:)
24
20
  # 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
21
+ warn_for_deprecated_arguments do |keywords|
22
+ keywords << :from if legacy_from != NOT_GIVEN
28
23
  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
24
+ warn_for_deprecated_arguments do |keywords|
25
+ keywords << :to if legacy_to != NOT_GIVEN
32
26
  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
27
+ warn_for_deprecated_arguments do |keywords|
28
+ keywords << :excepted if legacy_excepted != NOT_GIVEN
36
29
  end
37
30
 
38
31
  raise ArgumentError, 'From date, to date and excepted date must not be the same' if from == to && to == excepted
@@ -46,9 +39,8 @@ module Faker
46
39
  end
47
40
 
48
41
  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
42
+ warn_for_deprecated_arguments do |keywords|
43
+ keywords << :days if legacy_days != NOT_GIVEN
52
44
  end
53
45
 
54
46
  from = ::Date.today + 1
@@ -58,9 +50,8 @@ module Faker
58
50
  end
59
51
 
60
52
  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
53
+ warn_for_deprecated_arguments do |keywords|
54
+ keywords << :days if legacy_days != NOT_GIVEN
64
55
  end
65
56
 
66
57
  from = ::Date.today - days
@@ -70,13 +61,11 @@ module Faker
70
61
  end
71
62
 
72
63
  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
64
+ warn_for_deprecated_arguments do |keywords|
65
+ keywords << :min_age if legacy_min_age != NOT_GIVEN
76
66
  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
67
+ warn_for_deprecated_arguments do |keywords|
68
+ keywords << :max_age if legacy_max_age != NOT_GIVEN
80
69
  end
81
70
 
82
71
  t = ::Date.today
@@ -24,9 +24,8 @@ module Faker
24
24
  end
25
25
 
26
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
27
+ warn_for_deprecated_arguments do |keywords|
28
+ keywords << :unit if legacy_unit != NOT_GIVEN
30
29
  end
31
30
 
32
31
  case unit
@@ -9,21 +9,11 @@ module Faker
9
9
  # rubocop:disable Metrics/ParameterLists
10
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
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
12
+ warn_for_deprecated_arguments do |keywords|
13
+ keywords << :last_name if legacy_last_name != NOT_GIVEN
14
+ keywords << :initials if legacy_initials != NOT_GIVEN
15
+ keywords << :gender if legacy_gender != NOT_GIVEN
16
+ keywords << :date_of_birth if legacy_date_of_birth != NOT_GIVEN
27
17
  end
28
18
 
29
19
  [
@@ -6,17 +6,10 @@ module Faker
6
6
  # rubocop:disable Metrics/ParameterLists
7
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
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
9
+ warn_for_deprecated_arguments do |keywords|
10
+ keywords << :segment_count if legacy_segment_count != NOT_GIVEN
11
+ keywords << :root if legacy_root != NOT_GIVEN
12
+ keywords << :directory_separator if legacy_directory_separator != NOT_GIVEN
20
13
  end
21
14
 
22
15
  Array
@@ -38,21 +31,11 @@ module Faker
38
31
  # rubocop:disable Metrics/ParameterLists
39
32
  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
33
  # 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
34
+ warn_for_deprecated_arguments do |keywords|
35
+ keywords << :dir if legacy_dir != NOT_GIVEN
36
+ keywords << :name if legacy_name != NOT_GIVEN
37
+ keywords << :ext if legacy_ext != NOT_GIVEN
38
+ keywords << :directory_separator if legacy_directory_separator != NOT_GIVEN
56
39
  end
57
40
 
58
41
  dir ||= dir(segment_count: 1)
@@ -6,17 +6,10 @@ module Faker
6
6
  # rubocop:disable Metrics/ParameterLists
7
7
  def image(legacy_grayscale = NOT_GIVEN, legacy_width = NOT_GIVEN, legacy_height = NOT_GIVEN, grayscale: false, width: 200, height: 200)
8
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
9
+ warn_for_deprecated_arguments do |keywords|
10
+ keywords << :grayscale if legacy_grayscale != NOT_GIVEN
11
+ keywords << :width if legacy_width != NOT_GIVEN
12
+ keywords << :height if legacy_height != NOT_GIVEN
20
13
  end
21
14
 
22
15
  raise ArgumentError, 'Width should be a number' unless width.to_s =~ /^\d+$/
@@ -27,9 +27,8 @@ module Faker
27
27
  end
28
28
 
29
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
30
+ warn_for_deprecated_arguments do |keywords|
31
+ keywords << :country if legacy_country != NOT_GIVEN
33
32
  end
34
33
 
35
34
  numerify(fetch("finance.vat_number.#{country}"))
@@ -11,17 +11,10 @@ module Faker
11
11
  # rubocop:disable Metrics/ParameterLists
12
12
  def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_spaces_allowed = NOT_GIVEN, number: 3, supplemental: false, spaces_allowed: false)
13
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
14
+ warn_for_deprecated_arguments do |keywords|
15
+ keywords << :number if legacy_number != NOT_GIVEN
16
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
17
+ keywords << :spaces_allowed if legacy_spaces_allowed != NOT_GIVEN
25
18
  end
26
19
 
27
20
  resolved_num = resolve(number)
@@ -40,30 +33,19 @@ module Faker
40
33
  # rubocop:disable Metrics/ParameterLists
41
34
  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
35
  # 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
36
+ warn_for_deprecated_arguments do |keywords|
37
+ keywords << :word_count if legacy_word_count != NOT_GIVEN
38
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
39
+ keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
54
40
  end
55
41
 
56
42
  words(number: word_count + rand(random_words_to_add.to_i).to_i, supplemental: supplemental, spaces_allowed: true).join(' ').capitalize + '.'
57
43
  end
58
44
 
59
45
  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
46
+ warn_for_deprecated_arguments do |keywords|
47
+ keywords << :number if legacy_number != NOT_GIVEN
48
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
67
49
  end
68
50
 
69
51
  [].tap do |sentences|
@@ -76,30 +58,19 @@ module Faker
76
58
  # rubocop:disable Metrics/ParameterLists
77
59
  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
60
  # 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
61
+ warn_for_deprecated_arguments do |keywords|
62
+ keywords << :sentence_count if legacy_sentence_count != NOT_GIVEN
63
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
64
+ keywords << :random_sentences_to_add if legacy_random_sentences_to_add != NOT_GIVEN
90
65
  end
91
66
 
92
67
  sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i, supplemental: supplemental).join(' ')
93
68
  end
94
69
 
95
70
  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
71
+ warn_for_deprecated_arguments do |keywords|
72
+ keywords << :number if legacy_number != NOT_GIVEN
73
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
103
74
  end
104
75
 
105
76
  [].tap do |paragraphs|
@@ -110,13 +81,9 @@ module Faker
110
81
  end
111
82
 
112
83
  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
84
+ warn_for_deprecated_arguments do |keywords|
85
+ keywords << :characters if legacy_characters != NOT_GIVEN
86
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
120
87
  end
121
88
 
122
89
  paragraph = paragraph(sentence_count: 3, supplemental: supplemental)