faker 2.2.1 → 2.2.2

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 +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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5587b3da998c6565466a5886c285dc46218d0c6be32bbc9d1578b2493ccca0a
4
- data.tar.gz: da07c93a781ccaf2f57b79a220f05905913b11261d6c324ab54e63f7c4f757d3
3
+ metadata.gz: c140b70507d530616f9c4ab8253cde32bab8bd7489eec025ebc3e0d81027e0be
4
+ data.tar.gz: b752dafd7f9a6816b811e7b886b0097389fb12f2bb4ff714babcab5215c1528b
5
5
  SHA512:
6
- metadata.gz: e5e2770457c5eabde0476cbb1a6cd320c633ceb0dbb734636569dbd84471df2d85f47f1664f597a65ccfedda1af67340904b2cf64e3798edfa83481d11015a39
7
- data.tar.gz: 16721c3cd11278e59c6df91b5a99f507c938e705d1eb9e20bd2fb26811819b5c781abf639d7ac8ab79b11ee3d7fea56c7d7ef876054c177e597116a967c41375
6
+ metadata.gz: 01f9d799d52e5b502b21ba569a046f078c45d59e8f0c82e09fa5f79b13bcbf0633a2150d2017623c6ad50256536e94273fc30b59c1835fca639ca4772cf85839
7
+ data.tar.gz: 4f0fc396d99449791e7edf1ff9013842617e6ecd4c8d153574a773b81041801750c02fb3974c6e05cdfc4429c26bc54528e00a509fa0b8dfd3d788fc5ff0e335
@@ -1,5 +1,29 @@
1
1
  # Change Log
2
2
 
3
+ ## [v2.2.2](https://github.com/faker-ruby/faker/tree/v2.2.2) (2019-05-09)
4
+
5
+ ## Bug/Fixes
6
+
7
+ - [PR #1717](https://github.com/faker-ruby/faker/pull/1717) Fix ambiguity in element_symbol field [@psibi](https://github.com/psibi)
8
+
9
+ ## Chores
10
+
11
+ - [PR #1724](https://github.com/faker-ruby/faker/pull/1724) Include rubocop-faker autocorrect in deprecation [@koic](https://github.com/koic)
12
+
13
+ ## Documentation
14
+
15
+ - [PR #1726](https://github.com/faker-ruby/faker/pull/1726) Include 2.x breaking return value change in changelog [@zorab47](https://github.com/zorab47)
16
+ - [PR #1722](https://github.com/faker-ruby/faker/pull/1722) Fix examples in the Dota docs [@bzf](https://github.com/bzf)
17
+
18
+ ## Update local dependencies
19
+
20
+ The following development dependencies were updated:
21
+ - rake requirement from = 12.3.1 to = 12.3.3 (#1719)
22
+ - rubocop requirement from = 0.59.1 to = 0.74.0 (#1721)
23
+ - simplecov requirement from = 0.16.1 to = 0.17.0 (#1718)
24
+
25
+ ------------------------------------------------------------------------------
26
+
3
27
  ## [v2.2.1](https://github.com/faker-ruby/faker/tree/v2.2.1) (2019-30-08)
4
28
 
5
29
  ## Bug/Fixes
@@ -202,6 +226,10 @@ Version 2 has several `breaking changes`. We replaced positional arguments with
202
226
  - `Faker::WorldCup.roster(country = nil, type = nil)` becomes `Faker::WorldCup.roster(country: nil, type: nil)`
203
227
  - `Faker::Movies::StarWars.quote(character = nil)` becomes `Faker::Movies::StarWars.quote(character: nil)`
204
228
 
229
+ Additionally the following methods changed return values:
230
+
231
+ - `Faker::Number.number` now returns `Numeric` instead of `String` (see [PR #510](https://github.com/faker-ruby/faker/pull/510))
232
+
205
233
  ### Bug/Fixes
206
234
 
207
235
  - [PR #1660](https://github.com/stympy/faker/pull/1660) Update FillMurray Links To Include www [@RaymondFallon](https://github.com/RaymondFallon)
@@ -251,6 +251,40 @@ module Faker
251
251
 
252
252
  private
253
253
 
254
+ def warn_for_deprecated_arguments
255
+ keywords = []
256
+ yield(keywords)
257
+
258
+ return if keywords.empty?
259
+
260
+ method_name = caller.first.match(/`(?<method_name>.*)'/)[:method_name]
261
+
262
+ keywords.each.with_index(1) do |keyword, index|
263
+ i = case index
264
+ when 1 then '1st'
265
+ when 2 then '2nd'
266
+ when 3 then '3rd'
267
+ else "#{index}th"
268
+ end
269
+
270
+ warn_with_uplevel(<<~MSG, uplevel: 5)
271
+ Passing `#{keyword}` with the #{i} argument of `#{method_name}` is deprecated. Use keyword argument like `#{method_name}(#{keyword}: ...)` instead.
272
+ MSG
273
+ end
274
+
275
+ warn(<<~MSG)
276
+
277
+ To automatically update from positional arguments to keyword arguments,
278
+ install rubocop-faker and run:
279
+
280
+ rubocop \\
281
+ --require rubocop-faker \\
282
+ --only Faker/DeprecatedArguments \\
283
+ --auto-correct
284
+
285
+ MSG
286
+ end
287
+
254
288
  # Workaround for emulating `warn '...', uplevel: 1` in Ruby 2.4 or lower.
255
289
  def warn_with_uplevel(message, uplevel: 1)
256
290
  at = parse_caller(caller[uplevel]).join(':')
@@ -8,13 +8,13 @@ module Faker
8
8
  class Tezos < Base
9
9
  class << self
10
10
  PREFIXES = {
11
- tz1: [6, 161, 159],
12
- KT1: [2, 90, 121],
13
- edpk: [13, 15, 37, 217],
14
- edsk: [13, 15, 58, 7],
11
+ tz1: [6, 161, 159],
12
+ KT1: [2, 90, 121],
13
+ edpk: [13, 15, 37, 217],
14
+ edsk: [13, 15, 58, 7],
15
15
  edsig: [9, 245, 205, 134, 18],
16
- B: [1, 52],
17
- o: [5, 116]
16
+ B: [1, 52],
17
+ o: [5, 116]
18
18
  }.freeze
19
19
 
20
20
  def account
@@ -20,9 +20,8 @@ module Faker
20
20
  end
21
21
 
22
22
  def quote(legacy_character = NOT_GIVEN, character: nil)
23
- if legacy_character != NOT_GIVEN
24
- warn_with_uplevel 'Passing `character` with the 1st argument of `Dune.quote` is deprecated. Use keyword argument like `Dune.quote(character: ...)` instead.', uplevel: 1
25
- character = legacy_character
23
+ warn_for_deprecated_arguments do |keywords|
24
+ keywords << :character if legacy_character != NOT_GIVEN
26
25
  end
27
26
 
28
27
  quoted_characters = translate('faker.dune.quotes').keys
@@ -42,9 +41,8 @@ module Faker
42
41
  end
43
42
 
44
43
  def saying(legacy_source = NOT_GIVEN, source: nil)
45
- if legacy_source != NOT_GIVEN
46
- warn_with_uplevel 'Passing `source` with the 1st argument of `Dune.saying` is deprecated. Use keyword argument like `Dune.saying(source: ...)` instead.', uplevel: 1
47
- source = legacy_source
44
+ warn_for_deprecated_arguments do |keywords|
45
+ keywords << :source if legacy_source != NOT_GIVEN
48
46
  end
49
47
 
50
48
  sourced_sayings = translate('faker.dune.sayings').keys
@@ -9,9 +9,8 @@ module Faker
9
9
  end
10
10
 
11
11
  def fhtagn(legacy_number = NOT_GIVEN, number: 1)
12
- if legacy_number != NOT_GIVEN
13
- warn_with_uplevel 'Passing `number` with the 1st argument of `Lovecraft.fhtagn` is deprecated. Use keyword argument like `Lovecraft.fhtagn(number: ...)` instead.', uplevel: 1
14
- number = legacy_number
12
+ warn_for_deprecated_arguments do |keywords|
13
+ keywords << :number if legacy_number != NOT_GIVEN
15
14
  end
16
15
 
17
16
  Array.new(number) { fetch('lovecraft.fhtagn') }.join('. ')
@@ -26,13 +25,9 @@ module Faker
26
25
  end
27
26
 
28
27
  def sentence(legacy_word_count = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, random_words_to_add: 6)
29
- if legacy_word_count != NOT_GIVEN
30
- warn_with_uplevel 'Passing `word_count` with the 1st argument of `Lovecraft.sentence` is deprecated. Use keyword argument like `Lovecraft.sentence(word_count: ...)` instead.', uplevel: 1
31
- word_count = legacy_word_count
32
- end
33
- if legacy_random_words_to_add != NOT_GIVEN
34
- warn_with_uplevel 'Passing `random_words_to_add` with the 2nd argument of `Lovecraft.sentence` is deprecated. Use keyword argument like `Lovecraft.sentence(random_words_to_add: ...)` instead.', uplevel: 1
35
- random_words_to_add = legacy_random_words_to_add
28
+ warn_for_deprecated_arguments do |keywords|
29
+ keywords << :word_count if legacy_word_count != NOT_GIVEN
30
+ keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
36
31
  end
37
32
 
38
33
  words(number: word_count + rand(random_words_to_add.to_i).to_i, spaces_allowed: true).join(' ').capitalize + '.'
@@ -44,13 +39,9 @@ module Faker
44
39
  end
45
40
 
46
41
  def words(legacy_number = NOT_GIVEN, legacy_spaces_allowed = NOT_GIVEN, number: 3, spaces_allowed: false)
47
- if legacy_number != NOT_GIVEN
48
- warn_with_uplevel 'Passing `number` with the 1st argument of `Lovecraft.words` is deprecated. Use keyword argument like `Lovecraft.words(number: ...)` instead.', uplevel: 1
49
- number = legacy_number
50
- end
51
- if legacy_spaces_allowed != NOT_GIVEN
52
- warn_with_uplevel 'Passing `spaces_allowed` with the 2nd argument of `Lovecraft.words` is deprecated. Use keyword argument like `Lovecraft.words(spaces_allowed: ...)` instead.', uplevel: 1
53
- spaces_allowed = legacy_spaces_allowed
42
+ warn_for_deprecated_arguments do |keywords|
43
+ keywords << :number if legacy_number != NOT_GIVEN
44
+ keywords << :spaces_allowed if legacy_spaces_allowed != NOT_GIVEN
54
45
  end
55
46
 
56
47
  resolved_num = resolve(number)
@@ -64,9 +55,8 @@ module Faker
64
55
  end
65
56
 
66
57
  def sentences(legacy_number = NOT_GIVEN, number: 3)
67
- if legacy_number != NOT_GIVEN
68
- warn_with_uplevel 'Passing `number` with the 1st argument of `Lovecraft.sentences` is deprecated. Use keyword argument like `Lovecraft.sentences(number: ...)` instead.', uplevel: 1
69
- number = legacy_number
58
+ warn_for_deprecated_arguments do |keywords|
59
+ keywords << :number if legacy_number != NOT_GIVEN
70
60
  end
71
61
 
72
62
  [].tap do |sentences|
@@ -77,22 +67,17 @@ module Faker
77
67
  end
78
68
 
79
69
  def paragraph(legacy_sentence_count = NOT_GIVEN, legacy_random_sentences_to_add = NOT_GIVEN, sentence_count: 3, random_sentences_to_add: 3)
80
- if legacy_sentence_count != NOT_GIVEN
81
- warn_with_uplevel 'Passing `sentence_count` with the 1st argument of `Lovecraft.paragraph` is deprecated. Use keyword argument like `Lovecraft.paragraph(sentence_count: ...)` instead.', uplevel: 1
82
- sentence_count = legacy_sentence_count
83
- end
84
- if legacy_random_sentences_to_add != NOT_GIVEN
85
- warn_with_uplevel 'Passing `random_sentences_to_add` with the 2nd argument of `Lovecraft.paragraph` is deprecated. Use keyword argument like `Lovecraft.paragraph(random_sentences_to_add: ...)` instead.', uplevel: 1
86
- random_sentences_to_add = legacy_random_sentences_to_add
70
+ warn_for_deprecated_arguments do |keywords|
71
+ keywords << :sentence_count if legacy_sentence_count != NOT_GIVEN
72
+ keywords << :random_sentences_to_add if legacy_random_sentences_to_add != NOT_GIVEN
87
73
  end
88
74
 
89
75
  sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i).join(' ')
90
76
  end
91
77
 
92
78
  def paragraphs(legacy_number = NOT_GIVEN, number: 3)
93
- if legacy_number != NOT_GIVEN
94
- warn_with_uplevel 'Passing `number` with the 1st argument of `Lovecraft.paragraphs` is deprecated. Use keyword argument like `Lovecraft.paragraphs(number: ...)` instead.', uplevel: 1
95
- number = legacy_number
79
+ warn_for_deprecated_arguments do |keywords|
80
+ keywords << :number if legacy_number != NOT_GIVEN
96
81
  end
97
82
 
98
83
  [].tap do |paragraphs|
@@ -103,9 +88,8 @@ module Faker
103
88
  end
104
89
 
105
90
  def paragraph_by_chars(legacy_characters = NOT_GIVEN, characters: 256)
106
- if legacy_characters != NOT_GIVEN
107
- warn_with_uplevel 'Passing `characters` with the 1st argument of `Lovecraft.paragraph_by_chars` is deprecated. Use keyword argument like `Lovecraft.paragraph_by_chars(characters: ...)` instead.', uplevel: 1
108
- characters = legacy_characters
91
+ warn_for_deprecated_arguments do |keywords|
92
+ keywords << :characters if legacy_characters != NOT_GIVEN
109
93
  end
110
94
 
111
95
  paragraph = paragraph(sentence_count: 3)
@@ -6,9 +6,8 @@ module Faker
6
6
 
7
7
  class << self
8
8
  def city(legacy_options = NOT_GIVEN, options: {})
9
- if legacy_options != NOT_GIVEN
10
- warn_with_uplevel 'Passing `options` with the 1st argument of `Address.city` is deprecated. Use keyword argument like `Address.city(options: ...)` instead.', uplevel: 1
11
- options = legacy_options
9
+ warn_for_deprecated_arguments do |keywords|
10
+ keywords << :options if legacy_options != NOT_GIVEN
12
11
  end
13
12
 
14
13
  parse(options[:with_state] ? 'address.city_with_state' : 'address.city')
@@ -19,9 +18,8 @@ module Faker
19
18
  end
20
19
 
21
20
  def street_address(legacy_include_secondary = NOT_GIVEN, include_secondary: false)
22
- if legacy_include_secondary != NOT_GIVEN
23
- warn_with_uplevel 'Passing `include_secondary` with the 1st argument of `Address.street_address` is deprecated. Use keyword argument like `Address.street_address(include_secondary: ...)` instead.', uplevel: 1
24
- include_secondary = legacy_include_secondary
21
+ warn_for_deprecated_arguments do |keywords|
22
+ keywords << :include_secondary if legacy_include_secondary != NOT_GIVEN
25
23
  end
26
24
 
27
25
  numerify(parse('address.street_address') + (include_secondary ? ' ' + secondary_address : ''))
@@ -40,9 +38,8 @@ module Faker
40
38
  end
41
39
 
42
40
  def zip_code(legacy_state_abbreviation = NOT_GIVEN, state_abbreviation: '')
43
- if legacy_state_abbreviation != NOT_GIVEN
44
- warn_with_uplevel 'Passing `state_abbreviation` with the 1st argument of `Address.zip_code` is deprecated. Use keyword argument like `Address.zip_code(state_abbreviation: ...)` instead.', uplevel: 1
45
- state_abbreviation = legacy_state_abbreviation
41
+ warn_for_deprecated_arguments do |keywords|
42
+ keywords << :state_abbreviation if legacy_state_abbreviation != NOT_GIVEN
46
43
  end
47
44
 
48
45
  if state_abbreviation.empty?
@@ -87,18 +84,16 @@ module Faker
87
84
  end
88
85
 
89
86
  def country_by_code(legacy_code = NOT_GIVEN, code: 'US')
90
- if legacy_code != NOT_GIVEN
91
- warn_with_uplevel 'Passing `code` with the 1st argument of `Address.country_by_code` is deprecated. Use keyword argument like `Address.country_by_code(code: ...)` instead.', uplevel: 1
92
- code = legacy_code
87
+ warn_for_deprecated_arguments do |keywords|
88
+ keywords << :code if legacy_code != NOT_GIVEN
93
89
  end
94
90
 
95
91
  fetch('address.country_by_code.' + code)
96
92
  end
97
93
 
98
94
  def country_name_to_code(legacy_name = NOT_GIVEN, name: 'united_states')
99
- if legacy_name != NOT_GIVEN
100
- warn_with_uplevel 'Passing `name` with the 1st argument of `Address.country_name_to_code` is deprecated. Use keyword argument like `Address.country_name_to_code(name: ...)` instead.', uplevel: 1
101
- name = legacy_name
95
+ warn_for_deprecated_arguments do |keywords|
96
+ keywords << :name if legacy_name != NOT_GIVEN
102
97
  end
103
98
 
104
99
  fetch('address.country_by_name.' + name)
@@ -6,9 +6,8 @@ module Faker
6
6
 
7
7
  class << self
8
8
  def alpha(legacy_number = NOT_GIVEN, number: 32)
9
- if legacy_number != NOT_GIVEN
10
- warn_with_uplevel 'Passing `number` with the 1st argument of `Alphanumeric.alpha` is deprecated. Use keyword argument like `Alphanumeric.alpha(number: ...)` instead.', uplevel: 1
11
- number = legacy_number
9
+ warn_for_deprecated_arguments do |keywords|
10
+ keywords << :number if legacy_number != NOT_GIVEN
12
11
  end
13
12
  char_count = resolve(number)
14
13
  return '' if char_count.to_i < 1
@@ -31,22 +30,17 @@ module Faker
31
30
  #
32
31
  # @faker.version 2.1.3
33
32
  def alphanumeric(legacy_number = NOT_GIVEN, number: 32, min_alpha: 0, min_numeric: 0)
34
- if legacy_number != NOT_GIVEN
35
- warn_with_uplevel 'Passing `number` with the 1st argument of `Alphanumeric.alphanumeric` is deprecated. Use keyword argument like `Alphanumeric.alphanumeric(number: ...)` instead.', uplevel: 1
36
- number = legacy_number
33
+ warn_for_deprecated_arguments do |keywords|
34
+ keywords << :number if legacy_number != NOT_GIVEN
37
35
  end
38
36
  char_count = resolve(number)
39
37
  return '' if char_count.to_i < 1
40
38
  raise ArgumentError, 'min_alpha must be greater than or equal to 0' if min_alpha&.negative?
41
39
  raise ArgumentError, 'min_numeric must be greater than or equal to 0' if min_numeric&.negative?
42
40
 
43
- if min_alpha.zero? && min_numeric.zero?
44
- return Array.new(char_count) { sample(ALPHANUMS) }.join
45
- end
41
+ return Array.new(char_count) { sample(ALPHANUMS) }.join if min_alpha.zero? && min_numeric.zero?
46
42
 
47
- if min_alpha + min_numeric > char_count
48
- raise ArgumentError, 'min_alpha + min_numeric must be <= number'
49
- end
43
+ raise ArgumentError, 'min_alpha + min_numeric must be <= number' if min_alpha + min_numeric > char_count
50
44
 
51
45
  random_count = char_count - min_alpha - min_numeric
52
46
 
@@ -18,17 +18,10 @@ module Faker
18
18
  # rubocop:disable Metrics/ParameterLists
19
19
  def semantic_version(legacy_major = NOT_GIVEN, legacy_minor = NOT_GIVEN, legacy_patch = NOT_GIVEN, major: 0..9, minor: 0..9, patch: 1..9)
20
20
  # rubocop:enable Metrics/ParameterLists
21
- if legacy_major != NOT_GIVEN
22
- warn_with_uplevel 'Passing `major` with the 1st argument of `App.semantic_version` is deprecated. Use keyword argument like `App.semantic_version(major: ...)` instead.', uplevel: 1
23
- major = legacy_major
24
- end
25
- if legacy_minor != NOT_GIVEN
26
- warn_with_uplevel 'Passing `minor` with the 2nd argument of `App.semantic_version` is deprecated. Use keyword argument like `App.semantic_version(minor: ...)` instead.', uplevel: 1
27
- minor = legacy_minor
28
- end
29
- if legacy_patch != NOT_GIVEN
30
- warn_with_uplevel 'Passing `patch` with the 3rd argument of `App.semantic_version` is deprecated. Use keyword argument like `App.semantic_version(patch: ...)` instead.', uplevel: 1
31
- patch = legacy_patch
21
+ warn_for_deprecated_arguments do |keywords|
22
+ keywords << :major if legacy_major != NOT_GIVEN
23
+ keywords << :minor if legacy_minor != NOT_GIVEN
24
+ keywords << :patch if legacy_patch != NOT_GIVEN
32
25
  end
33
26
 
34
27
  [major, minor, patch].map { |chunk| sample(Array(chunk)) }.join('.')
@@ -8,25 +8,12 @@ module Faker
8
8
  # rubocop:disable Metrics/ParameterLists
9
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
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
11
+ warn_for_deprecated_arguments do |keywords|
12
+ keywords << :slug if legacy_slug != NOT_GIVEN
13
+ keywords << :size if legacy_size != NOT_GIVEN
14
+ keywords << :format if legacy_format != NOT_GIVEN
15
+ keywords << :set if legacy_set != NOT_GIVEN
16
+ keywords << :bgset if legacy_bgset != NOT_GIVEN
30
17
  end
31
18
 
32
19
  raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /^[0-9]+x[0-9]+$/
@@ -6,9 +6,8 @@ module Faker
6
6
 
7
7
  class << self
8
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
9
+ warn_for_deprecated_arguments do |keywords|
10
+ keywords << :digits if legacy_digits != NOT_GIVEN
12
11
  end
13
12
 
14
13
  output = ''
@@ -22,9 +21,8 @@ module Faker
22
21
  # Each country has it's own format for bank accounts
23
22
  # Many of them use letters in certain parts of the account
24
23
  # 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
24
+ warn_for_deprecated_arguments do |keywords|
25
+ keywords << :country_code if legacy_country_code != NOT_GIVEN
28
26
  end
29
27
 
30
28
  begin
@@ -4,9 +4,8 @@ module Faker
4
4
  class Boolean < Base
5
5
  class << self
6
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
7
+ warn_for_deprecated_arguments do |keywords|
8
+ keywords << :true_ratio if legacy_true_ratio != NOT_GIVEN
10
9
  end
11
10
 
12
11
  (rand < true_ratio)
@@ -7,13 +7,9 @@ module Faker
7
7
 
8
8
  # Fixed param added for testing a specific RUT and check digit combination.
9
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
10
+ warn_for_deprecated_arguments do |keywords|
11
+ keywords << :min_rut if legacy_min_rut != NOT_GIVEN
12
+ keywords << :fixed if legacy_fixed != NOT_GIVEN
17
13
  end
18
14
 
19
15
  @last_rut = fixed ? min_rut : rand_in_range(min_rut, 99_999_999)
@@ -44,13 +40,9 @@ module Faker
44
40
  end
45
41
 
46
42
  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
43
+ warn_for_deprecated_arguments do |keywords|
44
+ keywords << :min_rut if legacy_min_rut != NOT_GIVEN
45
+ keywords << :fixed if legacy_fixed != NOT_GIVEN
54
46
  end
55
47
 
56
48
  "#{rut(min_rut: min_rut, fixed: fixed)}-#{dv}"