faker 2.1.2 → 2.4.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 (105) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +113 -7
  3. data/README.md +4 -4
  4. data/lib/faker.rb +56 -1
  5. data/lib/faker/blockchain/aeternity.rb +70 -0
  6. data/lib/faker/blockchain/bitcoin.rb +26 -0
  7. data/lib/faker/blockchain/ethereum.rb +10 -0
  8. data/lib/faker/blockchain/tezos.rb +62 -6
  9. data/lib/faker/books/book.rb +36 -0
  10. data/lib/faker/books/culture_series.rb +49 -0
  11. data/lib/faker/books/dune.rb +66 -5
  12. data/lib/faker/books/lovecraft.rb +210 -7
  13. data/lib/faker/creature/animal.rb +9 -0
  14. data/lib/faker/creature/cat.rb +27 -0
  15. data/lib/faker/creature/dog.rb +72 -0
  16. data/lib/faker/creature/horse.rb +18 -0
  17. data/lib/faker/default/address.rb +25 -5
  18. data/lib/faker/default/alphanumeric.rb +56 -7
  19. data/lib/faker/default/app.rb +54 -1
  20. data/lib/faker/default/appliance.rb +18 -0
  21. data/lib/faker/default/artist.rb +9 -0
  22. data/lib/faker/default/avatar.rb +42 -1
  23. data/lib/faker/default/bank.rb +10 -2
  24. data/lib/faker/default/boolean.rb +16 -1
  25. data/lib/faker/default/chile_rut.rb +12 -2
  26. data/lib/faker/default/code.rb +16 -3
  27. data/lib/faker/default/commerce.rb +17 -3
  28. data/lib/faker/default/company.rb +10 -2
  29. data/lib/faker/default/crypto_coin.rb +15 -3
  30. data/lib/faker/default/date.rb +37 -5
  31. data/lib/faker/default/demographic.rb +5 -1
  32. data/lib/faker/default/dessert.rb +27 -0
  33. data/lib/faker/default/device.rb +54 -0
  34. data/lib/faker/default/driving_licence.rb +10 -4
  35. data/lib/faker/default/electrical_components.rb +27 -0
  36. data/lib/faker/default/file.rb +19 -2
  37. data/lib/faker/default/fillmurray.rb +9 -1
  38. data/lib/faker/default/finance.rb +5 -1
  39. data/lib/faker/default/gender.rb +18 -0
  40. data/lib/faker/default/greek_philosophers.rb +18 -0
  41. data/lib/faker/default/hacker.rb +59 -1
  42. data/lib/faker/default/hipster.rb +45 -6
  43. data/lib/faker/default/house.rb +18 -0
  44. data/lib/faker/default/id_number.rb +11 -3
  45. data/lib/faker/default/industry_segments.rb +36 -0
  46. data/lib/faker/default/internet.rb +94 -13
  47. data/lib/faker/default/invoice.rb +16 -3
  48. data/lib/faker/default/json.rb +19 -2
  49. data/lib/faker/default/lorem.rb +81 -10
  50. data/lib/faker/default/lorem_flickr.rb +38 -5
  51. data/lib/faker/default/lorem_pixel.rb +10 -1
  52. data/lib/faker/default/markdown.rb +6 -1
  53. data/lib/faker/default/marketing.rb +9 -0
  54. data/lib/faker/default/measurement.rb +40 -8
  55. data/lib/faker/default/military.rb +45 -0
  56. data/lib/faker/default/name.rb +5 -1
  57. data/lib/faker/default/nato_phonetic_alphabet.rb +9 -0
  58. data/lib/faker/default/nhs.rb +5 -1
  59. data/lib/faker/default/number.rb +56 -11
  60. data/lib/faker/default/omniauth.rb +92 -9
  61. data/lib/faker/default/phone_number.rb +5 -1
  62. data/lib/faker/default/placeholdit.rb +11 -1
  63. data/lib/faker/default/programming_language.rb +18 -0
  64. data/lib/faker/default/relationship.rb +5 -1
  65. data/lib/faker/default/science.rb +27 -0
  66. data/lib/faker/default/source.rb +59 -3
  67. data/lib/faker/default/string.rb +5 -1
  68. data/lib/faker/default/stripe.rb +20 -4
  69. data/lib/faker/default/subscription.rb +45 -0
  70. data/lib/faker/default/superhero.rb +45 -0
  71. data/lib/faker/default/time.rb +37 -4
  72. data/lib/faker/default/twitter.rb +32 -18
  73. data/lib/faker/default/types.rb +27 -5
  74. data/lib/faker/default/vehicle.rb +17 -4
  75. data/lib/faker/default/world_cup.rb +11 -2
  76. data/lib/faker/games/dota.rb +52 -1
  77. data/lib/faker/games/elder_scrolls.rb +72 -0
  78. data/lib/faker/games/fallout.rb +37 -0
  79. data/lib/faker/games/game.rb +27 -0
  80. data/lib/faker/games/half_life.rb +27 -0
  81. data/lib/faker/games/heroes.rb +27 -0
  82. data/lib/faker/games/heroes_of_the_storm.rb +36 -0
  83. data/lib/faker/games/league_of_legends.rb +54 -0
  84. data/lib/faker/games/myst.rb +45 -0
  85. data/lib/faker/games/overwatch.rb +27 -0
  86. data/lib/faker/games/pokemon.rb +27 -0
  87. data/lib/faker/games/sonic_the_hedgehog.rb +27 -0
  88. data/lib/faker/games/super_smash_bros.rb +18 -0
  89. data/lib/faker/games/witcher.rb +54 -0
  90. data/lib/faker/games/world_of_warcraft.rb +18 -0
  91. data/lib/faker/games/zelda.rb +36 -0
  92. data/lib/faker/japanese_media/dragon_ball.rb +9 -0
  93. data/lib/faker/japanese_media/sword_art_online.rb +36 -0
  94. data/lib/faker/movies/hobbit.rb +37 -0
  95. data/lib/faker/movies/movie.rb +9 -0
  96. data/lib/faker/movies/star_wars.rb +6 -4
  97. data/lib/faker/music/grateful_dead.rb +18 -0
  98. data/lib/faker/music/phish.rb +9 -0
  99. data/lib/faker/music/rock_band.rb +9 -0
  100. data/lib/faker/tv_shows/breaking_bad.rb +18 -0
  101. data/lib/faker/version.rb +1 -1
  102. data/lib/locales/en-CA.yml +1 -1
  103. data/lib/locales/en/science.yml +1 -1
  104. data/lib/locales/ja.yml +8 -9
  105. metadata +31 -14
@@ -3,7 +3,12 @@
3
3
  module Faker
4
4
  class Internet < Base
5
5
  class << self
6
- def email(name: nil, separators: nil)
6
+ def email(legacy_name = NOT_GIVEN, legacy_separators = NOT_GIVEN, name: nil, separators: nil)
7
+ warn_for_deprecated_arguments do |keywords|
8
+ keywords << :name if legacy_name != NOT_GIVEN
9
+ keywords << :separators if legacy_separators != NOT_GIVEN
10
+ end
11
+
7
12
  if separators
8
13
  [username(specifier: name, separators: separators), domain_name].join('@')
9
14
  else
@@ -11,15 +16,28 @@ module Faker
11
16
  end
12
17
  end
13
18
 
14
- def free_email(name: nil)
19
+ def free_email(legacy_name = NOT_GIVEN, name: nil)
20
+ warn_for_deprecated_arguments do |keywords|
21
+ keywords << :name if legacy_name != NOT_GIVEN
22
+ end
23
+
15
24
  [username(specifier: name), fetch('internet.free_email')].join('@')
16
25
  end
17
26
 
18
- def safe_email(name: nil)
27
+ def safe_email(legacy_name = NOT_GIVEN, name: nil)
28
+ warn_for_deprecated_arguments do |keywords|
29
+ keywords << :name if legacy_name != NOT_GIVEN
30
+ end
31
+
19
32
  [username(specifier: name), 'example.' + sample(%w[org com net])].join('@')
20
33
  end
21
34
 
22
- def username(specifier: nil, separators: %w[. _])
35
+ def username(legacy_specifier = NOT_GIVEN, legacy_separators = NOT_GIVEN, specifier: nil, separators: %w[. _])
36
+ warn_for_deprecated_arguments do |keywords|
37
+ keywords << :specifier if legacy_specifier != NOT_GIVEN
38
+ keywords << :separators if legacy_separators != NOT_GIVEN
39
+ end
40
+
23
41
  with_locale(:en) do
24
42
  return shuffle(specifier.scan(/[[:word:]]+/)).join(sample(separators)).downcase if specifier.respond_to?(:scan)
25
43
 
@@ -55,8 +73,39 @@ module Faker
55
73
  end
56
74
  end
57
75
 
58
- def password(min_length: 8, max_length: 16, mix_case: true, special_characters: false)
59
- temp = Lorem.characters(number: min_length)
76
+ ##
77
+ # Produces a randomized string of characters suitable for passwords
78
+ #
79
+ # @param min_length [Integer] The minimum length of the password
80
+ # @param max_length [Integer] The maximum length of the password
81
+ # @param mix_case [Boolean] Toggles if uppercased letters are allowed. If true, at least one will be added.
82
+ # @param special_characters [Boolean] Toggles if special characters are allowed. If true, at least one will be added.
83
+ #
84
+ # @return [String]
85
+ #
86
+ # @example
87
+ # Faker::Internet.password #=> "Vg5mSvY1UeRg7"
88
+ # @example
89
+ # Faker::Internet.password(min_length: 8) #=> "YfGjIk0hGzDqS0"
90
+ # @example
91
+ # Faker::Internet.password(min_length: 10, max_length: 20) #=> "EoC9ShWd1hWq4vBgFw"
92
+ # @example
93
+ # Faker::Internet.password(min_length: 10, max_length: 20, mix_case: true) #=> "3k5qS15aNmG"
94
+ # @example
95
+ # Faker::Internet.password(min_length: 10, max_length: 20, mix_case: true, special_characters: true) #=> "*%NkOnJsH4"
96
+ #
97
+ # @faker.version 2.1.3
98
+ # rubocop:disable Metrics/ParameterLists
99
+ 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)
100
+ warn_for_deprecated_arguments do |keywords|
101
+ keywords << :min_length if legacy_min_length != NOT_GIVEN
102
+ keywords << :max_length if legacy_max_length != NOT_GIVEN
103
+ keywords << :mix_case if legacy_mix_case != NOT_GIVEN
104
+ keywords << :special_characters if legacy_special_characters != NOT_GIVEN
105
+ end
106
+
107
+ min_alpha = mix_case ? 2 : 0
108
+ temp = Lorem.characters(number: min_length, min_alpha: min_alpha)
60
109
  diff_length = max_length - min_length
61
110
 
62
111
  if diff_length.positive?
@@ -65,8 +114,12 @@ module Faker
65
114
  end
66
115
 
67
116
  if mix_case
117
+ alpha_count = 0
68
118
  temp.chars.each_with_index do |char, index|
69
- temp[index] = char.upcase if index.even?
119
+ if char =~ /[[:alpha:]]/
120
+ temp[index] = char.upcase if alpha_count.even?
121
+ alpha_count += 1
122
+ end
70
123
  end
71
124
  end
72
125
 
@@ -80,7 +133,11 @@ module Faker
80
133
  temp
81
134
  end
82
135
 
83
- def domain_name(subdomain: false)
136
+ def domain_name(legacy_subdomain = NOT_GIVEN, subdomain: false)
137
+ warn_for_deprecated_arguments do |keywords|
138
+ keywords << :subdomain if legacy_subdomain != NOT_GIVEN
139
+ end
140
+
84
141
  with_locale(:en) do
85
142
  domain_elements = [Char.prepare(domain_word), domain_suffix]
86
143
  domain_elements.unshift(Char.prepare(domain_word)) if subdomain
@@ -88,7 +145,11 @@ module Faker
88
145
  end
89
146
  end
90
147
 
91
- def fix_umlauts(string: '')
148
+ def fix_umlauts(legacy_string = NOT_GIVEN, string: '')
149
+ warn_for_deprecated_arguments do |keywords|
150
+ keywords << :string if legacy_string != NOT_GIVEN
151
+ end
152
+
92
153
  Char.fix_umlauts(string)
93
154
  end
94
155
 
@@ -100,7 +161,11 @@ module Faker
100
161
  fetch('internet.domain_suffix')
101
162
  end
102
163
 
103
- def mac_address(prefix: '')
164
+ def mac_address(legacy_prefix = NOT_GIVEN, prefix: '')
165
+ warn_for_deprecated_arguments do |keywords|
166
+ keywords << :prefix if legacy_prefix != NOT_GIVEN
167
+ end
168
+
104
169
  prefix_digits = prefix.split(':').map { |d| d.to_i(16) }
105
170
  address_digits = Array.new((6 - prefix_digits.size)) { rand(256) }
106
171
  (prefix_digits + address_digits).map { |d| format('%02x', d) }.join(':')
@@ -174,11 +239,23 @@ module Faker
174
239
  "#{ip_v6_address}/#{rand(1..127)}"
175
240
  end
176
241
 
177
- def url(host: domain_name, path: "/#{username}", scheme: 'http')
242
+ def url(legacy_host = NOT_GIVEN, legacy_path = NOT_GIVEN, legacy_scheme = NOT_GIVEN, host: domain_name, path: "/#{username}", scheme: 'http')
243
+ # rubocop:enable Metrics/ParameterLists
244
+ warn_for_deprecated_arguments do |keywords|
245
+ keywords << :host if legacy_host != NOT_GIVEN
246
+ keywords << :path if legacy_path != NOT_GIVEN
247
+ keywords << :scheme if legacy_scheme != NOT_GIVEN
248
+ end
249
+
178
250
  "#{scheme}://#{host}#{path}"
179
251
  end
180
252
 
181
- def slug(words: nil, glue: nil)
253
+ def slug(legacy_words = NOT_GIVEN, legacy_glue = NOT_GIVEN, words: nil, glue: nil)
254
+ warn_for_deprecated_arguments do |keywords|
255
+ keywords << :words if legacy_words != NOT_GIVEN
256
+ keywords << :glue if legacy_glue != NOT_GIVEN
257
+ end
258
+
182
259
  glue ||= sample(%w[- _])
183
260
  (words || Faker::Lorem.words(number: 2).join(' ')).delete(',.').gsub(' ', glue).downcase
184
261
  end
@@ -187,7 +264,11 @@ module Faker
187
264
  shuffle(rand(16**64).to_s(16).rjust(64, '0').chars.to_a).join
188
265
  end
189
266
 
190
- def user_agent(vendor: nil)
267
+ def user_agent(legacy_vendor = NOT_GIVEN, vendor: nil)
268
+ warn_for_deprecated_arguments do |keywords|
269
+ keywords << :vendor if legacy_vendor != NOT_GIVEN
270
+ end
271
+
191
272
  agent_hash = translate('faker.internet.user_agent')
192
273
  agents = vendor.respond_to?(:to_sym) && agent_hash[vendor.to_sym] || agent_hash[sample(agent_hash.keys)]
193
274
  sample(agents)
@@ -6,13 +6,22 @@ module Faker
6
6
 
7
7
  class << self
8
8
  # Generate random amount between values with 2 decimals
9
- def amount_between(from: 0, to: 0)
9
+ def amount_between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 0, to: 0)
10
+ warn_for_deprecated_arguments do |keywords|
11
+ keywords << :from if legacy_from != NOT_GIVEN
12
+ keywords << :to if legacy_to != NOT_GIVEN
13
+ end
14
+
10
15
  Faker::Base.rand_in_range(from, to).round(2)
11
16
  end
12
17
 
13
18
  # International bank slip reference https://en.wikipedia.org/wiki/Creditor_Reference
14
19
  # ref is optional so that we can create unit tests
15
- def creditor_reference(ref: '')
20
+ def creditor_reference(legacy_ref = NOT_GIVEN, ref: '')
21
+ warn_for_deprecated_arguments do |keywords|
22
+ keywords << :ref if legacy_ref != NOT_GIVEN
23
+ end
24
+
16
25
  ref = reference if ref.empty?
17
26
 
18
27
  'RF' + iban_checksum('RF', ref) + ref
@@ -20,7 +29,11 @@ module Faker
20
29
 
21
30
  # Payment references have some rules in certain countries
22
31
  # ref is optional so that we can create unit tests
23
- def reference(ref: '')
32
+ def reference(legacy_ref = NOT_GIVEN, ref: '')
33
+ warn_for_deprecated_arguments do |keywords|
34
+ keywords << :ref if legacy_ref != NOT_GIVEN
35
+ end
36
+
24
37
  pattern = fetch('invoice.reference.pattern')
25
38
 
26
39
  ref = Base.regexify(/#{pattern}/) if ref.empty?
@@ -3,7 +3,12 @@ module Faker
3
3
  require 'json'
4
4
 
5
5
  class << self
6
- def shallow_json(width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' })
6
+ def shallow_json(legacy_width = NOT_GIVEN, legacy_options = NOT_GIVEN, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' })
7
+ warn_for_deprecated_arguments do |keywords|
8
+ keywords << :width if legacy_width != NOT_GIVEN
9
+ keywords << :options if legacy_options != NOT_GIVEN
10
+ end
11
+
7
12
  options[:key] = 'Faker::' + options[:key]
8
13
  options[:value] = 'Faker::' + options[:value]
9
14
 
@@ -11,7 +16,19 @@ module Faker
11
16
  JSON.generate(hash)
12
17
  end
13
18
 
14
- def add_depth_to_json(json: shallow_json, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' })
19
+ # rubocop:disable Metrics/ParameterLists
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' })
21
+ # rubocop:enable Metrics/ParameterLists
22
+ warn_for_deprecated_arguments do |keywords|
23
+ keywords << :json if legacy_json != NOT_GIVEN
24
+ end
25
+ warn_for_deprecated_arguments do |keywords|
26
+ keywords << :width if legacy_width != NOT_GIVEN
27
+ end
28
+ warn_for_deprecated_arguments do |keywords|
29
+ keywords << :options if legacy_options != NOT_GIVEN
30
+ end
31
+
15
32
  options[:key] = 'Faker::' + options[:key]
16
33
  options[:value] = 'Faker::' + options[:value]
17
34
 
@@ -8,7 +8,12 @@ module Faker
8
8
  sample(translate('faker.lorem.words'))
9
9
  end
10
10
 
11
- def words(number: 3, supplemental: false)
11
+ def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
12
+ warn_for_deprecated_arguments do |keywords|
13
+ keywords << :number if legacy_number != NOT_GIVEN
14
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
15
+ end
16
+
12
17
  resolved_num = resolve(number)
13
18
  word_list = (
14
19
  translate('faker.lorem.words') +
@@ -22,31 +27,84 @@ module Faker
22
27
  sample(Types::CHARACTERS)
23
28
  end
24
29
 
25
- def characters(number: 255)
26
- Alphanumeric.alphanumeric(number: number)
30
+ ##
31
+ # Produces a random string of alphanumeric characters
32
+ #
33
+ # @param number [Integer] The number of characters to generate
34
+ # @param min_alpha [Integer] The minimum number of alphabetic to add to the string
35
+ # @param min_numeric [Integer] The minimum number of numbers to add to the string
36
+ #
37
+ # @return [String]
38
+ #
39
+ # @example
40
+ # Faker::Lorem.characters #=> "uw1ep04lhs0c4d931n1jmrspprf5w..."
41
+ # Faker::Lorem.characters(number: 10) #=> "ang9cbhoa8"
42
+ # Faker::Lorem.characters(number: 10, min_alpha: 4) #=> "ang9cbhoa8"
43
+ # Faker::Lorem.characters(number: 10, min_alpha: 4, min_numeric: 1) #=> "ang9cbhoa8"
44
+ #
45
+ # @faker.version 2.1.3
46
+ def characters(legacy_number = NOT_GIVEN, number: 255, min_alpha: 0, min_numeric: 0)
47
+ warn_for_deprecated_arguments do |keywords|
48
+ keywords << :number if legacy_number != NOT_GIVEN
49
+ end
50
+
51
+ Alphanumeric.alphanumeric(number: number, min_alpha: min_alpha, min_numeric: min_numeric)
27
52
  end
28
53
 
29
54
  def multibyte
30
55
  sample(translate('faker.lorem.multibyte')).pack('C*').force_encoding('utf-8')
31
56
  end
32
57
 
33
- def sentence(word_count: 4, supplemental: false, random_words_to_add: 0)
58
+ # rubocop:disable Metrics/ParameterLists
59
+ 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)
60
+ # rubocop:enable Metrics/ParameterLists
61
+ warn_for_deprecated_arguments do |keywords|
62
+ keywords << :word_count if legacy_word_count != NOT_GIVEN
63
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
64
+ keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
65
+ end
66
+
34
67
  words(number: word_count + rand(random_words_to_add.to_i), supplemental: supplemental).join(' ').capitalize + locale_period
35
68
  end
36
69
 
37
- def sentences(number: 3, supplemental: false)
70
+ def sentences(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
71
+ warn_for_deprecated_arguments do |keywords|
72
+ keywords << :number if legacy_number != NOT_GIVEN
73
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
74
+ end
75
+
38
76
  1.upto(resolve(number)).collect { sentence(word_count: 3, supplemental: supplemental) }
39
77
  end
40
78
 
41
- def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 0)
79
+ # rubocop:disable Metrics/ParameterLists
80
+ 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)
81
+ # rubocop:enable Metrics/ParameterLists
82
+ warn_for_deprecated_arguments do |keywords|
83
+ keywords << :sentence_count if legacy_sentence_count != NOT_GIVEN
84
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
85
+ keywords << :random_sentences_to_add if legacy_random_sentences_to_add != NOT_GIVEN
86
+ end
87
+
42
88
  sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i), supplemental: supplemental).join(locale_space)
43
89
  end
44
90
 
45
- def paragraphs(number: 3, supplemental: false)
91
+ def paragraphs(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
92
+ warn_for_deprecated_arguments do |keywords|
93
+ keywords << :number if legacy_number != NOT_GIVEN
94
+ end
95
+ warn_for_deprecated_arguments do |keywords|
96
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
97
+ end
98
+
46
99
  1.upto(resolve(number)).collect { paragraph(sentence_count: 3, supplemental: supplemental) }
47
100
  end
48
101
 
49
- def paragraph_by_chars(number: 256, supplemental: false)
102
+ def paragraph_by_chars(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 256, supplemental: false)
103
+ warn_for_deprecated_arguments do |keywords|
104
+ keywords << :number if legacy_number != NOT_GIVEN
105
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
106
+ end
107
+
50
108
  paragraph = paragraph(sentence_count: 3, supplemental: supplemental)
51
109
 
52
110
  paragraph += ' ' + paragraph(sentence_count: 3, supplemental: supplemental) while paragraph.length < number
@@ -54,11 +112,24 @@ module Faker
54
112
  paragraph[0...number - 1] + '.'
55
113
  end
56
114
 
57
- def question(word_count: 4, supplemental: false, random_words_to_add: 0)
115
+ # rubocop:disable Metrics/ParameterLists
116
+ 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)
117
+ # rubocop:enable Metrics/ParameterLists
118
+ warn_for_deprecated_arguments do |keywords|
119
+ keywords << :word_count if legacy_word_count != NOT_GIVEN
120
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
121
+ keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
122
+ end
123
+
58
124
  words(number: word_count + rand(random_words_to_add), supplemental: supplemental).join(' ').capitalize + locale_question_mark
59
125
  end
60
126
 
61
- def questions(number: 3, supplemental: false)
127
+ def questions(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
128
+ warn_for_deprecated_arguments do |keywords|
129
+ keywords << :number if legacy_number != NOT_GIVEN
130
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
131
+ end
132
+
62
133
  1.upto(resolve(number)).collect { question(word_count: 3, supplemental: supplemental) }
63
134
  end
64
135
 
@@ -5,23 +5,56 @@ module Faker
5
5
  class << self
6
6
  SUPPORTED_COLORIZATIONS = %w[red green blue].freeze
7
7
 
8
- def image(size: '300x300', search_terms: [], match_all: false)
8
+ # rubocop:disable Metrics/ParameterLists
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
+ # rubocop:enable Metrics/ParameterLists
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
15
+ end
16
+
9
17
  build_url(size, nil, search_terms, match_all)
10
18
  end
11
19
 
12
- def grayscale_image(size: '300x300', search_terms: ['all'], match_all: false)
20
+ # rubocop:disable Metrics/ParameterLists
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)
22
+ # rubocop:enable Metrics/ParameterLists
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
27
+ end
28
+
13
29
  raise ArgumentError, 'Search terms must be specified for grayscale images' unless search_terms.any?
14
30
 
15
31
  build_url(size, 'g', search_terms, match_all)
16
32
  end
17
33
 
18
- def pixelated_image(size: '300x300', search_terms: ['all'], match_all: false)
34
+ # rubocop:disable Metrics/ParameterLists
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)
36
+ # rubocop:enable Metrics/ParameterLists
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
41
+ end
42
+
19
43
  raise ArgumentError, 'Search terms must be specified for pixelated images' unless search_terms.any?
20
44
 
21
45
  build_url(size, 'p', search_terms, match_all)
22
46
  end
23
47
 
24
- def colorized_image(size: '300x300', color: 'red', search_terms: ['all'], match_all: false)
48
+ # rubocop:disable Metrics/ParameterLists
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)
50
+ # rubocop:enable Metrics/ParameterLists
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
56
+ end
57
+
25
58
  raise ArgumentError, 'Search terms must be specified for colorized images' unless search_terms.any?
26
59
  raise ArgumentError, "Supported colorizations are #{SUPPORTED_COLORIZATIONS.join(', ')}" unless SUPPORTED_COLORIZATIONS.include?(color)
27
60
 
@@ -33,7 +66,7 @@ module Faker
33
66
  def build_url(size, format, search_terms, match_all)
34
67
  raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /^[0-9]+x[0-9]+$/
35
68
 
36
- url_parts = ['http://loremflickr.com']
69
+ url_parts = ['https://loremflickr.com']
37
70
  url_parts << format
38
71
  url_parts += size.split('x')
39
72
  url_parts << search_terms.compact.join(',') if search_terms.any?