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
@@ -12,7 +12,7 @@ module Faker
12
12
  ].freeze
13
13
  ZA_RACE_DIGIT = '8'
14
14
  ZA_CITIZENSHIP_DIGITS = %w[0 1].freeze
15
- BRAZILIAN_ID_FORMAT = /(\d{1,2})(\d{3})(\d{3})([\dX])/
15
+ BRAZILIAN_ID_FORMAT = /(\d{1,2})(\d{3})(\d{3})([\dX])/.freeze
16
16
  BRAZILIAN_ID_FROM = 10_000_000
17
17
  BRAZILIAN_ID_TO = 99_999_999
18
18
 
@@ -79,9 +79,8 @@ module Faker
79
79
  end
80
80
 
81
81
  def brazilian_citizen_number(legacy_formatted = NOT_GIVEN, formatted: false)
82
- if legacy_formatted != NOT_GIVEN
83
- warn_with_uplevel 'Passing `formatted` with the 1st argument of `IDNumber.brazilian_citizen_number` is deprecated. Use keyword argument like `IDNumber.brazilian_citizen_number(formatted: ...)` instead.', uplevel: 1
84
- formatted = legacy_formatted
82
+ warn_for_deprecated_arguments do |keywords|
83
+ keywords << :formatted if legacy_formatted != NOT_GIVEN
85
84
  end
86
85
 
87
86
  digits = Faker::Number.leading_zero_number(digits: 9) until digits&.match(/(\d)((?!\1)\d)+/)
@@ -94,9 +93,8 @@ module Faker
94
93
  alias brazilian_cpf brazilian_citizen_number
95
94
 
96
95
  def brazilian_id(legacy_formatted = NOT_GIVEN, formatted: false)
97
- if legacy_formatted != NOT_GIVEN
98
- warn_with_uplevel 'Passing `formatted` with the 1st argument of `IDNumber.brazilian_id` is deprecated. Use keyword argument like `IDNumber.brazilian_id(formatted: ...)` instead.', uplevel: 1
99
- formatted = legacy_formatted
96
+ warn_for_deprecated_arguments do |keywords|
97
+ keywords << :formatted if legacy_formatted != NOT_GIVEN
100
98
  end
101
99
 
102
100
  digits = Faker::Number.between(to: BRAZILIAN_ID_FROM, from: BRAZILIAN_ID_TO).to_s
@@ -4,13 +4,9 @@ module Faker
4
4
  class Internet < Base
5
5
  class << self
6
6
  def email(legacy_name = NOT_GIVEN, legacy_separators = NOT_GIVEN, name: nil, separators: nil)
7
- if legacy_name != NOT_GIVEN
8
- warn_with_uplevel 'Passing `name` with the 1st argument of `Internet.email` is deprecated. Use keyword argument like `Internet.email(name: ...)` instead.', uplevel: 1
9
- name = legacy_name
10
- end
11
- if legacy_separators != NOT_GIVEN
12
- warn_with_uplevel 'Passing `separators` with the 2nd argument of `Internet.email` is deprecated. Use keyword argument like `Internet.email(separators: ...)` instead.', uplevel: 1
13
- separators = legacy_separators
7
+ warn_for_deprecated_arguments do |keywords|
8
+ keywords << :name if legacy_name != NOT_GIVEN
9
+ keywords << :separators if legacy_separators != NOT_GIVEN
14
10
  end
15
11
 
16
12
  if separators
@@ -21,31 +17,25 @@ module Faker
21
17
  end
22
18
 
23
19
  def free_email(legacy_name = NOT_GIVEN, name: nil)
24
- if legacy_name != NOT_GIVEN
25
- warn_with_uplevel 'Passing `name` with the 1st argument of `Internet.free_email` is deprecated. Use keyword argument like `Internet.free_email(name: ...)` instead.', uplevel: 1
26
- name = legacy_name
20
+ warn_for_deprecated_arguments do |keywords|
21
+ keywords << :name if legacy_name != NOT_GIVEN
27
22
  end
28
23
 
29
24
  [username(specifier: name), fetch('internet.free_email')].join('@')
30
25
  end
31
26
 
32
27
  def safe_email(legacy_name = NOT_GIVEN, name: nil)
33
- if legacy_name != NOT_GIVEN
34
- warn_with_uplevel 'Passing `name` with the 1st argument of `Internet.safe_email` is deprecated. Use keyword argument like `Internet.safe_email(name: ...)` instead.', uplevel: 1
35
- name = legacy_name
28
+ warn_for_deprecated_arguments do |keywords|
29
+ keywords << :name if legacy_name != NOT_GIVEN
36
30
  end
37
31
 
38
32
  [username(specifier: name), 'example.' + sample(%w[org com net])].join('@')
39
33
  end
40
34
 
41
35
  def username(legacy_specifier = NOT_GIVEN, legacy_separators = NOT_GIVEN, specifier: nil, separators: %w[. _])
42
- if legacy_specifier != NOT_GIVEN
43
- warn_with_uplevel 'Passing `specifier` with the 1st argument of `Internet.username` is deprecated. Use keyword argument like `Internet.username(specifier: ...)` instead.', uplevel: 1
44
- specifier = legacy_specifier
45
- end
46
- if legacy_separators != NOT_GIVEN
47
- warn_with_uplevel 'Passing `separators` with the 2nd argument of `Internet.username` is deprecated. Use keyword argument like `Internet.username(separators: ...)` instead.', uplevel: 1
48
- separators = legacy_separators
36
+ warn_for_deprecated_arguments do |keywords|
37
+ keywords << :specifier if legacy_specifier != NOT_GIVEN
38
+ keywords << :separators if legacy_separators != NOT_GIVEN
49
39
  end
50
40
 
51
41
  with_locale(:en) do
@@ -102,21 +92,11 @@ module Faker
102
92
  # @faker.version 2.1.3
103
93
  # rubocop:disable Metrics/ParameterLists
104
94
  def password(legacy_min_length = NOT_GIVEN, legacy_max_length = NOT_GIVEN, legacy_mix_case = NOT_GIVEN, legacy_special_characters = NOT_GIVEN, min_length: 8, max_length: 16, mix_case: true, special_characters: false)
105
- if legacy_min_length != NOT_GIVEN
106
- warn_with_uplevel 'Passing `min_length` with the 1st argument of `Internet.password` is deprecated. Use keyword argument like `Internet.password(min_length: ...)` instead.', uplevel: 1
107
- min_length = legacy_min_length
108
- end
109
- if legacy_max_length != NOT_GIVEN
110
- warn_with_uplevel 'Passing `max_length` with the 2nd argument of `Internet.password` is deprecated. Use keyword argument like `Internet.password(max_length: ...)` instead.', uplevel: 1
111
- max_length = legacy_max_length
112
- end
113
- if legacy_mix_case != NOT_GIVEN
114
- warn_with_uplevel 'Passing `mix_case` with the 3rd argument of `Internet.password` is deprecated. Use keyword argument like `Internet.password(mix_case: ...)` instead.', uplevel: 1
115
- mix_case = legacy_mix_case
116
- end
117
- if legacy_special_characters != NOT_GIVEN
118
- warn_with_uplevel 'Passing `special_characters` with the 4th argument of `Internet.password` is deprecated. Use keyword argument like `Internet.password(special_characters: ...)` instead.', uplevel: 1
119
- special_characters = legacy_special_characters
95
+ warn_for_deprecated_arguments do |keywords|
96
+ keywords << :min_length if legacy_min_length != NOT_GIVEN
97
+ keywords << :max_length if legacy_max_length != NOT_GIVEN
98
+ keywords << :mix_case if legacy_mix_case != NOT_GIVEN
99
+ keywords << :special_characters if legacy_special_characters != NOT_GIVEN
120
100
  end
121
101
 
122
102
  min_alpha = mix_case ? 2 : 0
@@ -149,9 +129,8 @@ module Faker
149
129
  end
150
130
 
151
131
  def domain_name(legacy_subdomain = NOT_GIVEN, subdomain: false)
152
- if legacy_subdomain != NOT_GIVEN
153
- warn_with_uplevel 'Passing `subdomain` with the 1st argument of `Internet.domain_name` is deprecated. Use keyword argument like `Internet.domain_name(subdomain: ...)` instead.', uplevel: 1
154
- subdomain = legacy_subdomain
132
+ warn_for_deprecated_arguments do |keywords|
133
+ keywords << :subdomain if legacy_subdomain != NOT_GIVEN
155
134
  end
156
135
 
157
136
  with_locale(:en) do
@@ -162,9 +141,8 @@ module Faker
162
141
  end
163
142
 
164
143
  def fix_umlauts(legacy_string = NOT_GIVEN, string: '')
165
- if legacy_string != NOT_GIVEN
166
- warn_with_uplevel 'Passing `string` with the 1st argument of `Internet.fix_umlauts` is deprecated. Use keyword argument like `Internet.fix_umlauts(string: ...)` instead.', uplevel: 1
167
- string = legacy_string
144
+ warn_for_deprecated_arguments do |keywords|
145
+ keywords << :string if legacy_string != NOT_GIVEN
168
146
  end
169
147
 
170
148
  Char.fix_umlauts(string)
@@ -179,9 +157,8 @@ module Faker
179
157
  end
180
158
 
181
159
  def mac_address(legacy_prefix = NOT_GIVEN, prefix: '')
182
- if legacy_prefix != NOT_GIVEN
183
- warn_with_uplevel 'Passing `prefix` with the 1st argument of `Internet.mac_address` is deprecated. Use keyword argument like `Internet.mac_address(prefix: ...)` instead.', uplevel: 1
184
- prefix = legacy_prefix
160
+ warn_for_deprecated_arguments do |keywords|
161
+ keywords << :prefix if legacy_prefix != NOT_GIVEN
185
162
  end
186
163
 
187
164
  prefix_digits = prefix.split(':').map { |d| d.to_i(16) }
@@ -259,30 +236,19 @@ module Faker
259
236
 
260
237
  def url(legacy_host = NOT_GIVEN, legacy_path = NOT_GIVEN, legacy_scheme = NOT_GIVEN, host: domain_name, path: "/#{username}", scheme: 'http')
261
238
  # rubocop:enable Metrics/ParameterLists
262
- if legacy_host != NOT_GIVEN
263
- warn_with_uplevel 'Passing `host` with the 1st argument of `Internet.url` is deprecated. Use keyword argument like `Internet.url(host: ...)` instead.', uplevel: 1
264
- host = legacy_host
265
- end
266
- if legacy_path != NOT_GIVEN
267
- warn_with_uplevel 'Passing `path` with the 2nd argument of `Internet.url` is deprecated. Use keyword argument like `Internet.url(path: ...)` instead.', uplevel: 1
268
- path = legacy_path
269
- end
270
- if legacy_scheme != NOT_GIVEN
271
- warn_with_uplevel 'Passing `scheme` with the 3rd argument of `Internet.url` is deprecated. Use keyword argument like `Internet.url(scheme: ...)` instead.', uplevel: 1
272
- scheme = legacy_scheme
239
+ warn_for_deprecated_arguments do |keywords|
240
+ keywords << :host if legacy_host != NOT_GIVEN
241
+ keywords << :path if legacy_path != NOT_GIVEN
242
+ keywords << :scheme if legacy_scheme != NOT_GIVEN
273
243
  end
274
244
 
275
245
  "#{scheme}://#{host}#{path}"
276
246
  end
277
247
 
278
248
  def slug(legacy_words = NOT_GIVEN, legacy_glue = NOT_GIVEN, words: nil, glue: nil)
279
- if legacy_words != NOT_GIVEN
280
- warn_with_uplevel 'Passing `words` with the 1st argument of `Internet.slug` is deprecated. Use keyword argument like `Internet.slug(words: ...)` instead.', uplevel: 1
281
- words = legacy_words
282
- end
283
- if legacy_glue != NOT_GIVEN
284
- warn_with_uplevel 'Passing `glue` with the 2nd argument of `Internet.slug` is deprecated. Use keyword argument like `Internet.slug(glue: ...)` instead.', uplevel: 1
285
- glue = legacy_glue
249
+ warn_for_deprecated_arguments do |keywords|
250
+ keywords << :words if legacy_words != NOT_GIVEN
251
+ keywords << :glue if legacy_glue != NOT_GIVEN
286
252
  end
287
253
 
288
254
  glue ||= sample(%w[- _])
@@ -294,9 +260,8 @@ module Faker
294
260
  end
295
261
 
296
262
  def user_agent(legacy_vendor = NOT_GIVEN, vendor: nil)
297
- if legacy_vendor != NOT_GIVEN
298
- warn_with_uplevel 'Passing `vendor` with the 1st argument of `Internet.user_agent` is deprecated. Use keyword argument like `Internet.user_agent(vendor: ...)` instead.', uplevel: 1
299
- vendor = legacy_vendor
263
+ warn_for_deprecated_arguments do |keywords|
264
+ keywords << :vendor if legacy_vendor != NOT_GIVEN
300
265
  end
301
266
 
302
267
  agent_hash = translate('faker.internet.user_agent')
@@ -7,13 +7,9 @@ module Faker
7
7
  class << self
8
8
  # Generate random amount between values with 2 decimals
9
9
  def amount_between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 0, to: 0)
10
- if legacy_from != NOT_GIVEN
11
- warn_with_uplevel 'Passing `from` with the 1st argument of `Invoice.amount_between` is deprecated. Use keyword argument like `Invoice.amount_between(from: ...)` instead.', uplevel: 1
12
- from = legacy_from
13
- end
14
- if legacy_to != NOT_GIVEN
15
- warn_with_uplevel 'Passing `to` with the 2nd argument of `Invoice.amount_between` is deprecated. Use keyword argument like `Invoice.amount_between(to: ...)` instead.', uplevel: 1
16
- to = legacy_to
10
+ warn_for_deprecated_arguments do |keywords|
11
+ keywords << :from if legacy_from != NOT_GIVEN
12
+ keywords << :to if legacy_to != NOT_GIVEN
17
13
  end
18
14
 
19
15
  Faker::Base.rand_in_range(from, to).round(2)
@@ -22,9 +18,8 @@ module Faker
22
18
  # International bank slip reference https://en.wikipedia.org/wiki/Creditor_Reference
23
19
  # ref is optional so that we can create unit tests
24
20
  def creditor_reference(legacy_ref = NOT_GIVEN, ref: '')
25
- if legacy_ref != NOT_GIVEN
26
- warn_with_uplevel 'Passing `ref` with the 1st argument of `Invoice.creditor_reference` is deprecated. Use keyword argument like `Invoice.creditor_reference(ref: ...)` instead.', uplevel: 1
27
- ref = legacy_ref
21
+ warn_for_deprecated_arguments do |keywords|
22
+ keywords << :ref if legacy_ref != NOT_GIVEN
28
23
  end
29
24
 
30
25
  ref = reference if ref.empty?
@@ -35,9 +30,8 @@ module Faker
35
30
  # Payment references have some rules in certain countries
36
31
  # ref is optional so that we can create unit tests
37
32
  def reference(legacy_ref = NOT_GIVEN, ref: '')
38
- if legacy_ref != NOT_GIVEN
39
- warn_with_uplevel 'Passing `ref` with the 1st argument of `Invoice.reference` is deprecated. Use keyword argument like `Invoice.reference(ref: ...)` instead.', uplevel: 1
40
- ref = legacy_ref
33
+ warn_for_deprecated_arguments do |keywords|
34
+ keywords << :ref if legacy_ref != NOT_GIVEN
41
35
  end
42
36
 
43
37
  pattern = fetch('invoice.reference.pattern')
@@ -4,13 +4,9 @@ module Faker
4
4
 
5
5
  class << self
6
6
  def shallow_json(legacy_width = NOT_GIVEN, legacy_options = NOT_GIVEN, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' })
7
- if legacy_width != NOT_GIVEN
8
- warn_with_uplevel 'Passing `width` with the 1st argument of `Json.shallow_json` is deprecated. Use keyword argument like `Json.shallow_json(width: ...)` instead.', uplevel: 1
9
- width = legacy_width
10
- end
11
- if legacy_options != NOT_GIVEN
12
- warn_with_uplevel 'Passing `options` with the 2nd argument of `Json.shallow_json` is deprecated. Use keyword argument like `Json.shallow_json(options: ...)` instead.', uplevel: 1
13
- options = legacy_options
7
+ warn_for_deprecated_arguments do |keywords|
8
+ keywords << :width if legacy_width != NOT_GIVEN
9
+ keywords << :options if legacy_options != NOT_GIVEN
14
10
  end
15
11
 
16
12
  options[:key] = 'Faker::' + options[:key]
@@ -23,17 +19,14 @@ module Faker
23
19
  # rubocop:disable Metrics/ParameterLists
24
20
  def add_depth_to_json(legacy_json = NOT_GIVEN, legacy_width = NOT_GIVEN, legacy_options = NOT_GIVEN, json: shallow_json, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' })
25
21
  # rubocop:enable Metrics/ParameterLists
26
- if legacy_json != NOT_GIVEN
27
- warn_with_uplevel 'Passing `json` with the 1st argument of `Json.add_depth_to_json` is deprecated. Use keyword argument like `Json.add_depth_to_json(json: ...)` instead.', uplevel: 1
28
- json = legacy_json
22
+ warn_for_deprecated_arguments do |keywords|
23
+ keywords << :json if legacy_json != NOT_GIVEN
29
24
  end
30
- if legacy_width != NOT_GIVEN
31
- warn_with_uplevel 'Passing `width` with the 2nd argument of `Json.add_depth_to_json` is deprecated. Use keyword argument like `Json.add_depth_to_json(width: ...)` instead.', uplevel: 1
32
- width = legacy_width
25
+ warn_for_deprecated_arguments do |keywords|
26
+ keywords << :width if legacy_width != NOT_GIVEN
33
27
  end
34
- if legacy_options != NOT_GIVEN
35
- warn_with_uplevel 'Passing `options` with the 3rd argument of `Json.add_depth_to_json` is deprecated. Use keyword argument like `Json.add_depth_to_json(options: ...)` instead.', uplevel: 1
36
- options = legacy_options
28
+ warn_for_deprecated_arguments do |keywords|
29
+ keywords << :options if legacy_options != NOT_GIVEN
37
30
  end
38
31
 
39
32
  options[:key] = 'Faker::' + options[:key]
@@ -9,13 +9,9 @@ module Faker
9
9
  end
10
10
 
11
11
  def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
12
- if legacy_number != NOT_GIVEN
13
- warn_with_uplevel 'Passing `number` with the 1st argument of `Lorem.words` is deprecated. Use keyword argument like `Lorem.words(number: ...)` instead.', uplevel: 1
14
- number = legacy_number
15
- end
16
- if legacy_supplemental != NOT_GIVEN
17
- warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Lorem.words` is deprecated. Use keyword argument like `Lorem.words(supplemental: ...)` instead.', uplevel: 1
18
- supplemental = legacy_supplemental
12
+ warn_for_deprecated_arguments do |keywords|
13
+ keywords << :number if legacy_number != NOT_GIVEN
14
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
19
15
  end
20
16
 
21
17
  resolved_num = resolve(number)
@@ -47,9 +43,8 @@ module Faker
47
43
  #
48
44
  # @faker.version 2.1.3
49
45
  def characters(legacy_number = NOT_GIVEN, number: 255, min_alpha: 0, min_numeric: 0)
50
- if legacy_number != NOT_GIVEN
51
- warn_with_uplevel 'Passing `number` with the 1st argument of `Lorem.characters` is deprecated. Use keyword argument like `Lorem.characters(number: ...)` instead.', uplevel: 1
52
- number = legacy_number
46
+ warn_for_deprecated_arguments do |keywords|
47
+ keywords << :number if legacy_number != NOT_GIVEN
53
48
  end
54
49
 
55
50
  Alphanumeric.alphanumeric(number: number, min_alpha: min_alpha, min_numeric: min_numeric)
@@ -62,30 +57,19 @@ module Faker
62
57
  # rubocop:disable Metrics/ParameterLists
63
58
  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: 0)
64
59
  # rubocop:enable Metrics/ParameterLists
65
- if legacy_word_count != NOT_GIVEN
66
- warn_with_uplevel 'Passing `word_count` with the 1st argument of `Lorem.sentence` is deprecated. Use keyword argument like `Lorem.sentence(word_count: ...)` instead.', uplevel: 1
67
- word_count = legacy_word_count
68
- end
69
- if legacy_supplemental != NOT_GIVEN
70
- warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Lorem.sentence` is deprecated. Use keyword argument like `Lorem.sentence(supplemental: ...)` instead.', uplevel: 1
71
- supplemental = legacy_supplemental
72
- end
73
- if legacy_random_words_to_add != NOT_GIVEN
74
- warn_with_uplevel 'Passing `random_words_to_add` with the 3rd argument of `Lorem.sentence` is deprecated. Use keyword argument like `Lorem.sentence(random_words_to_add: ...)` instead.', uplevel: 1
75
- random_words_to_add = legacy_random_words_to_add
60
+ warn_for_deprecated_arguments do |keywords|
61
+ keywords << :word_count if legacy_word_count != NOT_GIVEN
62
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
63
+ keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
76
64
  end
77
65
 
78
66
  words(number: word_count + rand(random_words_to_add.to_i), supplemental: supplemental).join(' ').capitalize + locale_period
79
67
  end
80
68
 
81
69
  def sentences(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
82
- if legacy_number != NOT_GIVEN
83
- warn_with_uplevel 'Passing `number` with the 1st argument of `Lorem.sentences` is deprecated. Use keyword argument like `Lorem.sentences(number: ...)` instead.', uplevel: 1
84
- number = legacy_number
85
- end
86
- if legacy_supplemental != NOT_GIVEN
87
- warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Lorem.sentences` is deprecated. Use keyword argument like `Lorem.sentences(supplemental: ...)` instead.', uplevel: 1
88
- supplemental = legacy_supplemental
70
+ warn_for_deprecated_arguments do |keywords|
71
+ keywords << :number if legacy_number != NOT_GIVEN
72
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
89
73
  end
90
74
 
91
75
  1.upto(resolve(number)).collect { sentence(word_count: 3, supplemental: supplemental) }
@@ -94,43 +78,30 @@ module Faker
94
78
  # rubocop:disable Metrics/ParameterLists
95
79
  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: 0)
96
80
  # rubocop:enable Metrics/ParameterLists
97
- if legacy_sentence_count != NOT_GIVEN
98
- warn_with_uplevel 'Passing `sentence_count` with the 1st argument of `Lorem.paragraph` is deprecated. Use keyword argument like `Lorem.paragraph(sentence_count: ...)` instead.', uplevel: 1
99
- sentence_count = legacy_sentence_count
100
- end
101
- if legacy_supplemental != NOT_GIVEN
102
- warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Lorem.paragraph` is deprecated. Use keyword argument like `Lorem.paragraph(supplemental: ...)` instead.', uplevel: 1
103
- supplemental = legacy_supplemental
104
- end
105
- if legacy_random_sentences_to_add != NOT_GIVEN
106
- warn_with_uplevel 'Passing `random_sentences_to_add` with the 3rd argument of `Lorem.paragraph` is deprecated. Use keyword argument like `Lorem.paragraph(random_sentences_to_add: ...)` instead.', uplevel: 1
107
- random_sentences_to_add = legacy_random_sentences_to_add
81
+ warn_for_deprecated_arguments do |keywords|
82
+ keywords << :sentence_count if legacy_sentence_count != NOT_GIVEN
83
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
84
+ keywords << :random_sentences_to_add if legacy_random_sentences_to_add != NOT_GIVEN
108
85
  end
109
86
 
110
87
  sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i), supplemental: supplemental).join(locale_space)
111
88
  end
112
89
 
113
90
  def paragraphs(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
114
- if legacy_number != NOT_GIVEN
115
- warn_with_uplevel 'Passing `number` with the 1st argument of `Lorem.paragraphs` is deprecated. Use keyword argument like `Lorem.paragraphs(number: ...)` instead.', uplevel: 1
116
- number = legacy_number
91
+ warn_for_deprecated_arguments do |keywords|
92
+ keywords << :number if legacy_number != NOT_GIVEN
117
93
  end
118
- if legacy_supplemental != NOT_GIVEN
119
- warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Lorem.paragraphs` is deprecated. Use keyword argument like `Lorem.paragraphs(supplemental: ...)` instead.', uplevel: 1
120
- supplemental = legacy_supplemental
94
+ warn_for_deprecated_arguments do |keywords|
95
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
121
96
  end
122
97
 
123
98
  1.upto(resolve(number)).collect { paragraph(sentence_count: 3, supplemental: supplemental) }
124
99
  end
125
100
 
126
101
  def paragraph_by_chars(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 256, supplemental: false)
127
- if legacy_number != NOT_GIVEN
128
- warn_with_uplevel 'Passing `number` with the 1st argument of `Lorem.paragraph_by_chars` is deprecated. Use keyword argument like `Lorem.paragraph_by_chars(number: ...)` instead.', uplevel: 1
129
- number = legacy_number
130
- end
131
- if legacy_supplemental != NOT_GIVEN
132
- warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Lorem.paragraph_by_chars` is deprecated. Use keyword argument like `Lorem.paragraph_by_chars(supplemental: ...)` instead.', uplevel: 1
133
- supplemental = legacy_supplemental
102
+ warn_for_deprecated_arguments do |keywords|
103
+ keywords << :number if legacy_number != NOT_GIVEN
104
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
134
105
  end
135
106
 
136
107
  paragraph = paragraph(sentence_count: 3, supplemental: supplemental)
@@ -143,30 +114,19 @@ module Faker
143
114
  # rubocop:disable Metrics/ParameterLists
144
115
  def question(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: 0)
145
116
  # rubocop:enable Metrics/ParameterLists
146
- if legacy_word_count != NOT_GIVEN
147
- warn_with_uplevel 'Passing `word_count` with the 1st argument of `Lorem.question` is deprecated. Use keyword argument like `Lorem.question(word_count: ...)` instead.', uplevel: 1
148
- word_count = legacy_word_count
149
- end
150
- if legacy_supplemental != NOT_GIVEN
151
- warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Lorem.question` is deprecated. Use keyword argument like `Lorem.question(supplemental: ...)` instead.', uplevel: 1
152
- supplemental = legacy_supplemental
153
- end
154
- if legacy_random_words_to_add != NOT_GIVEN
155
- warn_with_uplevel 'Passing `random_words_to_add` with the 3rd argument of `Lorem.question` is deprecated. Use keyword argument like `Lorem.question(random_words_to_add: ...)` instead.', uplevel: 1
156
- random_words_to_add = legacy_random_words_to_add
117
+ warn_for_deprecated_arguments do |keywords|
118
+ keywords << :word_count if legacy_word_count != NOT_GIVEN
119
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
120
+ keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
157
121
  end
158
122
 
159
123
  words(number: word_count + rand(random_words_to_add), supplemental: supplemental).join(' ').capitalize + locale_question_mark
160
124
  end
161
125
 
162
126
  def questions(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
163
- if legacy_number != NOT_GIVEN
164
- warn_with_uplevel 'Passing `number` with the 1st argument of `Lorem.questions` is deprecated. Use keyword argument like `Lorem.questions(number: ...)` instead.', uplevel: 1
165
- number = legacy_number
166
- end
167
- if legacy_supplemental != NOT_GIVEN
168
- warn_with_uplevel 'Passing `supplemental` with the 2nd argument of `Lorem.questions` is deprecated. Use keyword argument like `Lorem.questions(supplemental: ...)` instead.', uplevel: 1
169
- supplemental = legacy_supplemental
127
+ warn_for_deprecated_arguments do |keywords|
128
+ keywords << :number if legacy_number != NOT_GIVEN
129
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
170
130
  end
171
131
 
172
132
  1.upto(resolve(number)).collect { question(word_count: 3, supplemental: supplemental) }
@@ -8,17 +8,10 @@ module Faker
8
8
  # rubocop:disable Metrics/ParameterLists
9
9
  def image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: [], match_all: false)
10
10
  # rubocop:enable Metrics/ParameterLists
11
- if legacy_size != NOT_GIVEN
12
- warn_with_uplevel 'Passing `size` with the 1st argument of `LoremFlickr.image` is deprecated. Use keyword argument like `LoremFlickr.image(size: ...)` instead.', uplevel: 1
13
- size = legacy_size
14
- end
15
- if legacy_search_terms != NOT_GIVEN
16
- warn_with_uplevel 'Passing `search_terms` with the 2nd argument of `LoremFlickr.image` is deprecated. Use keyword argument like `LoremFlickr.image(search_terms: ...)` instead.', uplevel: 1
17
- search_terms = legacy_search_terms
18
- end
19
- if legacy_match_all != NOT_GIVEN
20
- warn_with_uplevel 'Passing `match_all` with the 3rd argument of `LoremFlickr.image` is deprecated. Use keyword argument like `LoremFlickr.image(match_all: ...)` instead.', uplevel: 1
21
- match_all = legacy_match_all
11
+ warn_for_deprecated_arguments do |keywords|
12
+ keywords << :size if legacy_size != NOT_GIVEN
13
+ keywords << :search_terms if legacy_search_terms != NOT_GIVEN
14
+ keywords << :match_all if legacy_match_all != NOT_GIVEN
22
15
  end
23
16
 
24
17
  build_url(size, nil, search_terms, match_all)
@@ -27,17 +20,10 @@ module Faker
27
20
  # rubocop:disable Metrics/ParameterLists
28
21
  def grayscale_image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: ['all'], match_all: false)
29
22
  # rubocop:enable Metrics/ParameterLists
30
- if legacy_size != NOT_GIVEN
31
- warn_with_uplevel 'Passing `size` with the 1st argument of `LoremFlickr.grayscale_image` is deprecated. Use keyword argument like `LoremFlickr.grayscale_image(size: ...)` instead.', uplevel: 1
32
- size = legacy_size
33
- end
34
- if legacy_search_terms != NOT_GIVEN
35
- warn_with_uplevel 'Passing `search_terms` with the 2nd argument of `LoremFlickr.grayscale_image` is deprecated. Use keyword argument like `LoremFlickr.grayscale_image(search_terms: ...)` instead.', uplevel: 1
36
- search_terms = legacy_search_terms
37
- end
38
- if legacy_match_all != NOT_GIVEN
39
- warn_with_uplevel 'Passing `match_all` with the 3rd argument of `LoremFlickr.grayscale_image` is deprecated. Use keyword argument like `LoremFlickr.grayscale_image(match_all: ...)` instead.', uplevel: 1
40
- match_all = legacy_match_all
23
+ warn_for_deprecated_arguments do |keywords|
24
+ keywords << :size if legacy_size != NOT_GIVEN
25
+ keywords << :search_terms if legacy_search_terms != NOT_GIVEN
26
+ keywords << :match_all if legacy_match_all != NOT_GIVEN
41
27
  end
42
28
 
43
29
  raise ArgumentError, 'Search terms must be specified for grayscale images' unless search_terms.any?
@@ -48,17 +34,10 @@ module Faker
48
34
  # rubocop:disable Metrics/ParameterLists
49
35
  def pixelated_image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: ['all'], match_all: false)
50
36
  # rubocop:enable Metrics/ParameterLists
51
- if legacy_size != NOT_GIVEN
52
- warn_with_uplevel 'Passing `size` with the 1st argument of `LoremFlickr.pixelated_image` is deprecated. Use keyword argument like `LoremFlickr.pixelated_image(size: ...)` instead.', uplevel: 1
53
- size = legacy_size
54
- end
55
- if legacy_search_terms != NOT_GIVEN
56
- warn_with_uplevel 'Passing `search_terms` with the 2nd argument of `LoremFlickr.pixelated_image` is deprecated. Use keyword argument like `LoremFlickr.pixelated_image(search_terms: ...)` instead.', uplevel: 1
57
- search_terms = legacy_search_terms
58
- end
59
- if legacy_match_all != NOT_GIVEN
60
- warn_with_uplevel 'Passing `match_all` with the 3rd argument of `LoremFlickr.pixelated_image` is deprecated. Use keyword argument like `LoremFlickr.pixelated_image(match_all: ...)` instead.', uplevel: 1
61
- match_all = legacy_match_all
37
+ warn_for_deprecated_arguments do |keywords|
38
+ keywords << :size if legacy_size != NOT_GIVEN
39
+ keywords << :search_terms if legacy_search_terms != NOT_GIVEN
40
+ keywords << :match_all if legacy_match_all != NOT_GIVEN
62
41
  end
63
42
 
64
43
  raise ArgumentError, 'Search terms must be specified for pixelated images' unless search_terms.any?
@@ -69,21 +48,11 @@ module Faker
69
48
  # rubocop:disable Metrics/ParameterLists
70
49
  def colorized_image(legacy_size = NOT_GIVEN, legacy_color = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', color: 'red', search_terms: ['all'], match_all: false)
71
50
  # rubocop:enable Metrics/ParameterLists
72
- if legacy_size != NOT_GIVEN
73
- warn_with_uplevel 'Passing `size` with the 1st argument of `LoremFlickr.colorized_image` is deprecated. Use keyword argument like `LoremFlickr.colorized_image(size: ...)` instead.', uplevel: 1
74
- size = legacy_size
75
- end
76
- if legacy_color != NOT_GIVEN
77
- warn_with_uplevel 'Passing `color` with the 2nd argument of `LoremFlickr.colorized_image` is deprecated. Use keyword argument like `LoremFlickr.colorized_image(color: ...)` instead.', uplevel: 1
78
- color = legacy_color
79
- end
80
- if legacy_search_terms != NOT_GIVEN
81
- warn_with_uplevel 'Passing `search_terms` with the 3rd argument of `LoremFlickr.colorized_image` is deprecated. Use keyword argument like `LoremFlickr.colorized_image(search_terms: ...)` instead.', uplevel: 1
82
- search_terms = legacy_search_terms
83
- end
84
- if legacy_match_all != NOT_GIVEN
85
- warn_with_uplevel 'Passing `match_all` with the 4th argument of `LoremFlickr.colorized_image` is deprecated. Use keyword argument like `LoremFlickr.colorized_image(match_all: ...)` instead.', uplevel: 1
86
- match_all = legacy_match_all
51
+ warn_for_deprecated_arguments do |keywords|
52
+ keywords << :size if legacy_size != NOT_GIVEN
53
+ keywords << :color if legacy_color != NOT_GIVEN
54
+ keywords << :search_terms if legacy_search_terms != NOT_GIVEN
55
+ keywords << :match_all if legacy_match_all != NOT_GIVEN
87
56
  end
88
57
 
89
58
  raise ArgumentError, 'Search terms must be specified for colorized images' unless search_terms.any?