faker 2.1.2 → 2.3.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 (77) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +88 -7
  3. data/README.md +2 -3
  4. data/lib/faker.rb +56 -1
  5. data/lib/faker/blockchain/bitcoin.rb +26 -0
  6. data/lib/faker/blockchain/ethereum.rb +10 -0
  7. data/lib/faker/blockchain/tezos.rb +62 -6
  8. data/lib/faker/books/book.rb +36 -0
  9. data/lib/faker/books/culture_series.rb +49 -0
  10. data/lib/faker/books/dune.rb +66 -5
  11. data/lib/faker/books/lovecraft.rb +210 -7
  12. data/lib/faker/creature/animal.rb +9 -0
  13. data/lib/faker/creature/cat.rb +27 -0
  14. data/lib/faker/creature/dog.rb +72 -0
  15. data/lib/faker/creature/horse.rb +18 -0
  16. data/lib/faker/default/address.rb +25 -5
  17. data/lib/faker/default/alphanumeric.rb +56 -7
  18. data/lib/faker/default/app.rb +54 -1
  19. data/lib/faker/default/artist.rb +9 -0
  20. data/lib/faker/default/avatar.rb +42 -1
  21. data/lib/faker/default/bank.rb +10 -2
  22. data/lib/faker/default/boolean.rb +16 -1
  23. data/lib/faker/default/chile_rut.rb +12 -2
  24. data/lib/faker/default/code.rb +16 -3
  25. data/lib/faker/default/commerce.rb +17 -3
  26. data/lib/faker/default/company.rb +10 -2
  27. data/lib/faker/default/crypto_coin.rb +15 -3
  28. data/lib/faker/default/date.rb +37 -5
  29. data/lib/faker/default/demographic.rb +5 -1
  30. data/lib/faker/default/driving_licence.rb +10 -4
  31. data/lib/faker/default/file.rb +19 -2
  32. data/lib/faker/default/fillmurray.rb +9 -1
  33. data/lib/faker/default/finance.rb +5 -1
  34. data/lib/faker/default/gender.rb +18 -0
  35. data/lib/faker/default/hacker.rb +59 -1
  36. data/lib/faker/default/hipster.rb +45 -6
  37. data/lib/faker/default/house.rb +18 -0
  38. data/lib/faker/default/id_number.rb +11 -3
  39. data/lib/faker/default/internet.rb +94 -13
  40. data/lib/faker/default/invoice.rb +16 -3
  41. data/lib/faker/default/json.rb +19 -2
  42. data/lib/faker/default/lorem.rb +81 -10
  43. data/lib/faker/default/lorem_flickr.rb +38 -5
  44. data/lib/faker/default/lorem_pixel.rb +10 -1
  45. data/lib/faker/default/markdown.rb +6 -1
  46. data/lib/faker/default/measurement.rb +40 -8
  47. data/lib/faker/default/name.rb +5 -1
  48. data/lib/faker/default/nhs.rb +5 -1
  49. data/lib/faker/default/number.rb +56 -11
  50. data/lib/faker/default/omniauth.rb +92 -9
  51. data/lib/faker/default/phone_number.rb +5 -1
  52. data/lib/faker/default/placeholdit.rb +11 -1
  53. data/lib/faker/default/programming_language.rb +18 -0
  54. data/lib/faker/default/relationship.rb +5 -1
  55. data/lib/faker/default/source.rb +59 -3
  56. data/lib/faker/default/string.rb +5 -1
  57. data/lib/faker/default/stripe.rb +20 -4
  58. data/lib/faker/default/time.rb +37 -4
  59. data/lib/faker/default/twitter.rb +32 -18
  60. data/lib/faker/default/types.rb +27 -5
  61. data/lib/faker/default/vehicle.rb +17 -4
  62. data/lib/faker/default/world_cup.rb +11 -2
  63. data/lib/faker/games/dota.rb +5 -1
  64. data/lib/faker/games/elder_scrolls.rb +72 -0
  65. data/lib/faker/games/fallout.rb +37 -0
  66. data/lib/faker/games/game.rb +27 -0
  67. data/lib/faker/games/half_life.rb +27 -0
  68. data/lib/faker/games/overwatch.rb +27 -0
  69. data/lib/faker/games/super_smash_bros.rb +18 -0
  70. data/lib/faker/games/zelda.rb +36 -0
  71. data/lib/faker/movies/star_wars.rb +6 -4
  72. data/lib/faker/tv_shows/breaking_bad.rb +18 -0
  73. data/lib/faker/version.rb +1 -1
  74. data/lib/locales/en-CA.yml +1 -1
  75. data/lib/locales/en/science.yml +1 -1
  76. data/lib/locales/ja.yml +1 -1
  77. metadata +31 -15
@@ -8,7 +8,15 @@ module Faker
8
8
  random_word =~ /\s/ ? word : random_word
9
9
  end
10
10
 
11
- def words(number: 3, supplemental: false, spaces_allowed: false)
11
+ # rubocop:disable Metrics/ParameterLists
12
+ def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_spaces_allowed = NOT_GIVEN, number: 3, supplemental: false, spaces_allowed: false)
13
+ # rubocop:enable Metrics/ParameterLists
14
+ 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
18
+ end
19
+
12
20
  resolved_num = resolve(number)
13
21
  word_list = (
14
22
  translate('faker.hipster.words') +
@@ -22,11 +30,24 @@ module Faker
22
30
  words.each_with_index { |w, i| words[i] = word if w =~ /\s/ }
23
31
  end
24
32
 
25
- def sentence(word_count: 4, supplemental: false, random_words_to_add: 6)
33
+ # rubocop:disable Metrics/ParameterLists
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)
35
+ # rubocop:enable Metrics/ParameterLists
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
40
+ end
41
+
26
42
  words(number: word_count + rand(random_words_to_add.to_i).to_i, supplemental: supplemental, spaces_allowed: true).join(' ').capitalize + '.'
27
43
  end
28
44
 
29
- def sentences(number: 3, supplemental: false)
45
+ def sentences(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
46
+ warn_for_deprecated_arguments do |keywords|
47
+ keywords << :number if legacy_number != NOT_GIVEN
48
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
49
+ end
50
+
30
51
  [].tap do |sentences|
31
52
  1.upto(resolve(number)) do
32
53
  sentences << sentence(word_count: 3, supplemental: supplemental)
@@ -34,11 +55,24 @@ module Faker
34
55
  end
35
56
  end
36
57
 
37
- def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 3)
58
+ # rubocop:disable Metrics/ParameterLists
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)
60
+ # rubocop:enable Metrics/ParameterLists
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
65
+ end
66
+
38
67
  sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i, supplemental: supplemental).join(' ')
39
68
  end
40
69
 
41
- def paragraphs(number: 3, supplemental: false)
70
+ def paragraphs(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
+
42
76
  [].tap do |paragraphs|
43
77
  1.upto(resolve(number)) do
44
78
  paragraphs << paragraph(sentence_count: 3, supplemental: supplemental)
@@ -46,7 +80,12 @@ module Faker
46
80
  end
47
81
  end
48
82
 
49
- def paragraph_by_chars(characters: 256, supplemental: false)
83
+ def paragraph_by_chars(legacy_characters = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, characters: 256, supplemental: false)
84
+ warn_for_deprecated_arguments do |keywords|
85
+ keywords << :characters if legacy_characters != NOT_GIVEN
86
+ keywords << :supplemental if legacy_supplemental != NOT_GIVEN
87
+ end
88
+
50
89
  paragraph = paragraph(sentence_count: 3, supplemental: supplemental)
51
90
 
52
91
  paragraph += ' ' + paragraph(sentence_count: 3, supplemental: supplemental) while paragraph.length < characters
@@ -3,10 +3,28 @@
3
3
  module Faker
4
4
  class House < Base
5
5
  class << self
6
+ ##
7
+ # Produces the name of a piece of furniture.
8
+ #
9
+ # @return [String]
10
+ #
11
+ # @example
12
+ # Faker::House.furniture #=> "chair"
13
+ #
14
+ # @faker.version 1.9.2
6
15
  def furniture
7
16
  fetch('house.furniture')
8
17
  end
9
18
 
19
+ ##
20
+ # Produces the name of a room in a house.
21
+ #
22
+ # @return [String]
23
+ #
24
+ # @example
25
+ # Faker::House.room #=> "kitchen"
26
+ #
27
+ # @faker.version 1.9.2
10
28
  def room
11
29
  fetch('house.rooms')
12
30
  end
@@ -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
 
@@ -78,7 +78,11 @@ module Faker
78
78
  [id_number, south_african_id_checksum_digit(id_number)].join
79
79
  end
80
80
 
81
- def brazilian_citizen_number(formatted: false)
81
+ def brazilian_citizen_number(legacy_formatted = NOT_GIVEN, formatted: false)
82
+ warn_for_deprecated_arguments do |keywords|
83
+ keywords << :formatted if legacy_formatted != NOT_GIVEN
84
+ end
85
+
82
86
  digits = Faker::Number.leading_zero_number(digits: 9) until digits&.match(/(\d)((?!\1)\d)+/)
83
87
  first_digit = brazilian_citizen_number_checksum_digit(digits)
84
88
  second_digit = brazilian_citizen_number_checksum_digit(digits + first_digit)
@@ -88,7 +92,11 @@ module Faker
88
92
 
89
93
  alias brazilian_cpf brazilian_citizen_number
90
94
 
91
- def brazilian_id(formatted: false)
95
+ def brazilian_id(legacy_formatted = NOT_GIVEN, formatted: false)
96
+ warn_for_deprecated_arguments do |keywords|
97
+ keywords << :formatted if legacy_formatted != NOT_GIVEN
98
+ end
99
+
92
100
  digits = Faker::Number.between(to: BRAZILIAN_ID_FROM, from: BRAZILIAN_ID_TO).to_s
93
101
  check_digit = brazilian_id_checksum_digit(digits)
94
102
  number = [digits, check_digit].join
@@ -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