faker 3.1.0 → 3.2.1

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 (92) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +107 -5
  3. data/README.md +16 -4
  4. data/lib/faker/default/chile_rut.rb +23 -17
  5. data/lib/faker/default/code.rb +60 -18
  6. data/lib/faker/default/company.rb +44 -5
  7. data/lib/faker/default/date.rb +61 -5
  8. data/lib/faker/default/driving_licence.rb +19 -8
  9. data/lib/faker/default/food.rb +13 -0
  10. data/lib/faker/default/html.rb +230 -0
  11. data/lib/faker/default/id_number.rb +17 -3
  12. data/lib/faker/default/internet.rb +62 -31
  13. data/lib/faker/default/lorem.rb +23 -15
  14. data/lib/faker/default/marketing.rb +1 -1
  15. data/lib/faker/default/omniauth.rb +1 -1
  16. data/lib/faker/default/release notes.md +59 -0
  17. data/lib/faker/default/twitter.rb +1 -1
  18. data/lib/faker/default/types.rb +3 -2
  19. data/lib/faker/default/vehicle.rb +19 -9
  20. data/lib/faker/games/dnd.rb +49 -7
  21. data/lib/faker/games/final_fantasy_xiv.rb +73 -0
  22. data/lib/faker/movies/avatar.rb +49 -0
  23. data/lib/faker/quotes/quote.rb +13 -0
  24. data/lib/faker/sports/chess.rb +90 -0
  25. data/lib/faker/travel/airport.rb +43 -0
  26. data/lib/faker/travel/train_station.rb +54 -0
  27. data/lib/faker/tv_shows/archer.rb +51 -0
  28. data/lib/faker/tv_shows/south_park.rb +15 -0
  29. data/lib/faker/version.rb +1 -1
  30. data/lib/faker.rb +13 -6
  31. data/lib/helpers/positional_generator.rb +480 -0
  32. data/lib/locales/README.md +18 -2
  33. data/lib/locales/ar.yml +1 -0
  34. data/lib/locales/bg.yml +1 -1
  35. data/lib/locales/da-DK.yml +1 -0
  36. data/lib/locales/de-AT.yml +1 -1
  37. data/lib/locales/de-CH.yml +4336 -11
  38. data/lib/locales/de.yml +1 -0
  39. data/lib/locales/en/airport.yml +381 -0
  40. data/lib/locales/en/archer.yml +75 -0
  41. data/lib/locales/en/avatar.yml +31 -0
  42. data/lib/locales/en/chess.yml +103 -0
  43. data/lib/locales/en/company.yml +1 -0
  44. data/lib/locales/en/dnd.yml +186 -1
  45. data/lib/locales/en/final_fantasy_xiv.yml +754 -0
  46. data/lib/locales/en/food.yml +12 -0
  47. data/lib/locales/en/internet.yml +3 -0
  48. data/lib/locales/en/minecraft.yml +4 -4
  49. data/lib/locales/en/mitch_hedberg.yml +46 -0
  50. data/lib/locales/en/opera.yml +1 -1
  51. data/lib/locales/en/south_park.yml +360 -2
  52. data/lib/locales/en/star_wars.yml +1 -1
  53. data/lib/locales/en/train_station.yml +280 -0
  54. data/lib/locales/en-AU.yml +1 -0
  55. data/lib/locales/en-CA.yml +1 -0
  56. data/lib/locales/en-GB.yml +2 -0
  57. data/lib/locales/en-MS.yml +1 -0
  58. data/lib/locales/en-NG.yml +1 -0
  59. data/lib/locales/en-NZ.yml +1 -0
  60. data/lib/locales/en-PAK.yml +1 -0
  61. data/lib/locales/en-SG.yml +1 -0
  62. data/lib/locales/en-UG.yml +1 -0
  63. data/lib/locales/en-US.yml +1 -0
  64. data/lib/locales/en-ZA.yml +1 -0
  65. data/lib/locales/en-au-ocker.yml +2 -0
  66. data/lib/locales/es-AR.yml +1 -0
  67. data/lib/locales/es-MX.yml +1 -0
  68. data/lib/locales/es.yml +2 -1
  69. data/lib/locales/fi-FI.yml +1 -0
  70. data/lib/locales/fr/name.yml +2 -1
  71. data/lib/locales/fr-CA.yml +1 -0
  72. data/lib/locales/fr-CH.yml +1 -0
  73. data/lib/locales/hy.yml +1 -0
  74. data/lib/locales/it.yml +1 -0
  75. data/lib/locales/ja/sport.yml +130 -0
  76. data/lib/locales/ko.yml +1 -0
  77. data/lib/locales/mi-NZ.yml +2 -0
  78. data/lib/locales/nb-NO.yml +1 -0
  79. data/lib/locales/nl.yml +1 -0
  80. data/lib/locales/pl.yml +1 -0
  81. data/lib/locales/pt-BR.yml +1 -0
  82. data/lib/locales/pt.yml +1 -0
  83. data/lib/locales/ru.yml +1 -0
  84. data/lib/locales/sk.yml +1 -0
  85. data/lib/locales/sv.yml +1 -0
  86. data/lib/locales/tr.yml +1 -0
  87. data/lib/locales/uk.yml +4 -1
  88. data/lib/locales/vi.yml +1 -0
  89. data/lib/locales/zh-CN.yml +1 -0
  90. data/lib/locales/zh-TW.yml +1 -0
  91. metadata +23 -147
  92. data/lib/faker/default/fillmurray.rb +0 -36
@@ -5,6 +5,19 @@ module Faker
5
5
  flexible :food
6
6
 
7
7
  class << self
8
+ ##
9
+ # Retrieves an allergen.
10
+ #
11
+ # @return [String]
12
+ #
13
+ # @example
14
+ # Faker::Food.allergen #=> "Peanuts"
15
+ #
16
+ # @faker.version next
17
+ def allergen
18
+ fetch('food.allergens')
19
+ end
20
+
8
21
  ##
9
22
  # Retrieves a typical dish from each country.
10
23
  #
@@ -0,0 +1,230 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Faker
4
+ class HTML < Base
5
+ class << self
6
+ ##
7
+ # Produces a random HTML header format.
8
+ #
9
+ # @return [String]
10
+ #
11
+ # @example
12
+ # Faker::HTML.heading #=> "<h5>Autem</h5>"
13
+ #
14
+ # @faker.version 3.2.1
15
+ def heading
16
+ level = rand(1..6)
17
+ "<h#{level}>#{Lorem.word.capitalize}</h#{level}>"
18
+ end
19
+
20
+ ##
21
+ # Produces a random HTML paragraph format.
22
+ #
23
+ # @param sentence_count [Integer] The number of sentences in the paragraph.
24
+ # @param supplemental [Boolean] Include supplemental text.
25
+ # @param random_sentences_to_add [Integer] The number of random sentences to add to the paragraph.
26
+ # @param exclude_words [Array<String>] Words to exclude from the generated paragraph.
27
+ # @return [String]
28
+ #
29
+ # @example
30
+ # Faker::HTML.paragraph #=> "<p>Incidunt atque quis</p>"
31
+ #
32
+ # @faker.version 3.2.1
33
+ def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 0, exclude_words: nil)
34
+ "<p>#{Faker::Lorem.paragraph(sentence_count: sentence_count, supplemental: supplemental, random_sentences_to_add: random_sentences_to_add, exclude_words: exclude_words)}</p>"
35
+ end
36
+
37
+ ##
38
+ # Produces a random emphasis formatting on a random word in two HTML paragraphs.
39
+ #
40
+ # @return [String]
41
+ #
42
+ # @example
43
+ # Faker::HTML.emphasis #=> "<em>repellat id impedit</em>"
44
+ #
45
+ # @faker.version 3.2.1
46
+ def emphasis
47
+ "<em>#{Faker::Lorem.paragraph(sentence_count: 1)}</em>"
48
+ end
49
+
50
+ ##
51
+ # Produces a random ordered list in HTML format, with at least one element.
52
+ #
53
+ # @return [String]
54
+ #
55
+ # @example
56
+ # Faker::HTML.ordered_list #=> "<ol>\n<li>Qui reiciendis non consequatur atque.</li>\n<li>Quo doloremque veritatis tempora aut.</li>\n<li>Aspernatur.</li>\n<li>Ea ab.</li>\n<li>Qui.</li>\n<li>Sit pariatur nemo eveniet.</li>\n<li>Molestiae aut.</li>\n<li>Nihil molestias iure placeat.</li>\n<li>Dolore autem quisquam.</li>\n</ol>"
57
+ #
58
+ # @faker.version 3.2.1
59
+ def ordered_list
60
+ number = rand(1..10)
61
+
62
+ items = []
63
+ number.times do
64
+ items << "<li>#{Faker::Lorem.sentence(word_count: 1)}</li>"
65
+ end
66
+
67
+ "<ol>\n#{items.join("\n")}\n</ol>"
68
+ end
69
+
70
+ ##
71
+ # Produces a random unordered list of items between 1 and 10 randomly in HTML format.
72
+ #
73
+ # @return [String]
74
+ #
75
+ # @example
76
+ # Faker::HTML.unordered_list #=> "<ul>\n<li>Voluptatum aliquid tempora molestiae facilis non sed.</li>\n<li>Nostrum omnis iste impedit voluptatum dolor.</li>\n<li>Esse quidem et facere.</li>\n</ul>"
77
+ #
78
+ # @faker.version 3.2.1
79
+ def unordered_list
80
+ number = rand(1..10)
81
+
82
+ items = []
83
+ number.times do
84
+ items << "<li>#{Faker::Lorem.sentence(word_count: 1)}</li>"
85
+ end
86
+
87
+ "<ul>\n#{items.join("\n")}\n</ul>"
88
+ end
89
+
90
+ ##
91
+ # Produces a random code block formatted in HTML.
92
+ #
93
+ # @return [String]
94
+ #
95
+ # @example
96
+ # Faker::HTML.code #=> "<code>Eos quasi qui.</code>"
97
+ #
98
+ # @faker.version 3.2.1
99
+ def code
100
+ "<code>#{Lorem.sentence(word_count: 1)}</code>"
101
+ end
102
+
103
+ ##
104
+ # Produces a random HTML table.
105
+ #
106
+ # @return [String]
107
+ #
108
+ # @example
109
+ # Faker::HTML.table #=> "<table>\n<thead>\n<th>ad</th>\n<th>similique</th>\n<th>voluptatem</th>\n</thead>\n<tbody>\n<td>corrupti</td>\n<td>est</td>\n<td>rerum</td>\n<td>molestiae</td>\n<td>quidem</td>\n<td>et</td>\n<td>in</td>\n<td>tempora</td>\n<td>at</td>\n<\tbody>\n<tfoot>\n<td>voluptatem</td>\n<td>debitis</td>\n<td>rem</td>\n</tfoot>\n</table>"
110
+ #
111
+ # @faker.version 3.2.1
112
+ def table
113
+ header_row = generate_table_row('th', 3)
114
+ footer_row = generate_table_row('td', 3)
115
+
116
+ body_rows = []
117
+ 3.times do
118
+ row = generate_table_row('td', 3)
119
+ body_rows << row
120
+ end
121
+
122
+ thead = "<thead>\n#{header_row}</thead>"
123
+ tbody = "<tbody>\n#{body_rows.join("\n")}</tbody>"
124
+ tfoot = "<tfoot>\n#{footer_row}</tfoot>"
125
+
126
+ "<table>\n#{thead}\n#{tbody}\n#{tfoot}\n</table>"
127
+ end
128
+
129
+ ##
130
+ # Generates a random <script> tag with the `src` attribute set to a random URL.
131
+ #
132
+ # @return [String]
133
+ #
134
+ # @example
135
+ # Faker::HTML.script #=> "<script src=\"http://gulgowski.name/jordan.weimann.js\"></script>"
136
+ #
137
+ # @faker.version 3.2.1
138
+ def script
139
+ "<script src=\"#{Faker::Internet.url}.js\"></script>"
140
+ end
141
+
142
+ ##
143
+ # Generates a random <link> tag with the `rel` attribute set to "stylesheet" and the `href` attribute set to a random URL.
144
+ #
145
+ # @param rel [String] The rel of the link tag.
146
+ # @return [String]
147
+ #
148
+ # @example
149
+ # Faker::HTML.link #=> "<link rel=\"stylesheet\" href=\"http://fay.io/darryl.barrows.css\">"
150
+ #
151
+ # @faker.version 3.2.1
152
+ def link(rel: 'stylesheet')
153
+ "<link rel=\"#{rel}\" href=\"#{Faker::Internet.url}.css\">"
154
+ end
155
+
156
+ ##
157
+ # Generates HTML content with customizable attributes for any HTML tag.
158
+ #
159
+ # @param tag [String] The HTML tag to generate.
160
+ # @param content [String] The Content of the HTML tag.
161
+ # @param attributes [Hash] The attributes to include in the tag.
162
+ # @return [String]
163
+ #
164
+ # @example
165
+ # Faker::HTML.element(tag: 'div', content: "This is a div with XSS attributes.", attributes: {class: 'xss', onclick: "alert('XSS')"}) #=> "<div class=\"xss\" onclick=\"alert('XSS')\">This is a div with XSS attributes.</div>"
166
+ #
167
+ # @faker.version 3.2.1
168
+ def element(tag: 'div', content: Lorem.sentence(word_count: 3), attributes: { class: Lorem.word, onclick: "#{Lorem.word}()" })
169
+ attribute_string = attributes.map { |key, value| "#{key}=\"#{value}\"" }.join(' ')
170
+ "<#{tag} #{attribute_string}>#{content}</#{tag}>"
171
+ end
172
+
173
+ ##
174
+ # Produces a random method from the methods above, excluding the methods listed in the arguments.
175
+ #
176
+ # @overload random(methods)
177
+ # @param methods [Symbol] Specify which methods to exclude.
178
+ #
179
+ # @return [String]
180
+ #
181
+ # @example
182
+ # Faker::HTML.random #=> returns output from a single method outlined above
183
+ # Faker::HTML.random(exclude: [:table]) #=> returns output from any single method outlined above except for "table"
184
+ # Faker::HTML.random(exclude: [:ordered_list, :unordered_list]) #=> returns output from any single method outlined above except for either ordered_list and unordered_list
185
+ #
186
+ # @faker.version 3.2.1
187
+ def random(exclude: [])
188
+ method_list = available_methods
189
+ exclude.each { |ex| method_list.delete_if { |meth| meth == ex.to_sym } }
190
+ send(method_list[Faker::Config.random.rand(0..method_list.length - 1)])
191
+ end
192
+
193
+ ##
194
+ # Generates a random HTML content sandwich, starting with a header, followed by paragraphs, and random elements.
195
+ #
196
+ # @param sentences [Integer] The number of sentences in each paragraph.
197
+ # @param repeat [Integer] The number of times to repeat the pattern (header, paragraph, random).
198
+ # @return [String]
199
+ #
200
+ # @example
201
+ # Faker::HTML.sandwich(sentences: 3, repeat: 2) #=> returns a sandwich of HTML content with 2 repetitions, each having a header, paragraph, and random element
202
+ #
203
+ # @faker.version 3.2.1
204
+ def sandwich(sentences: 3, repeat: 1)
205
+ text_block = []
206
+ text_block << heading
207
+ repeat.times do
208
+ text_block << paragraph(sentence_count: sentences)
209
+ text_block << random(exclude: %i[script link])
210
+ end
211
+ text_block.join("\n")
212
+ end
213
+
214
+ private
215
+
216
+ def available_methods
217
+ (HTML.public_methods(false) - Base.methods).sort
218
+ end
219
+
220
+ def generate_table_row(tag, cell_count)
221
+ row = "<tr>\n"
222
+ cell_count.times do
223
+ row += "<#{tag == 'th' ? 'th' : 'td'}>#{Lorem.word}</#{tag == 'th' ? 'th' : 'td'}>\n"
224
+ end
225
+ row += "</tr>\n"
226
+ row
227
+ end
228
+ end
229
+ end
230
+ end
@@ -46,9 +46,23 @@ module Faker
46
46
  end
47
47
 
48
48
  def ssn_valid
49
- ssn = regexify(/[0-8]\d{2}-\d{2}-\d{4}/)
50
- # We could still have all 0s in one segment or another
51
- INVALID_SSN.any? { |regex| regex =~ ssn } ? ssn_valid : ssn
49
+ generate(:string) do |g|
50
+ g.computed(name: :first) do
51
+ range = [1..665, 667..899].sample(random: Faker::Config.random)
52
+ n = Faker::Base.rand(range)
53
+ format('%03d', n)
54
+ end
55
+ g.lit('-')
56
+ g.computed(name: :second) do
57
+ n = Faker::Base.rand(1..99)
58
+ format('%02d', n)
59
+ end
60
+ g.lit('-')
61
+ g.computed(name: :third) do
62
+ n = Faker::Base.rand(1..9999)
63
+ format('%04d', n)
64
+ end
65
+ end
52
66
  end
53
67
 
54
68
  ##
@@ -15,6 +15,8 @@ module Faker
15
15
  ].each(&:freeze).freeze
16
16
 
17
17
  class << self
18
+ extend Gem::Deprecate
19
+
18
20
  ##
19
21
  # Returns the email address
20
22
  #
@@ -25,10 +27,11 @@ module Faker
25
27
  # @param domain [String]
26
28
  #
27
29
  # @example
28
- # Faker::Internet.email #=> "samsmith@faker.com"
29
- # Faker::Internet.email(name: 'smith') #=> "smith@faker.com"
30
- # Faker::Internet.email(name: 'sam smith', separators: ['-']) #=> "sam-smith@faker.com"
31
- # Faker::Internet.email(name: 'sam smith', separators: ['-'], domain: 'gmail') #=> "sam-smith@gmail.com"
30
+ # Faker::Internet.email #=> "renee@zieme.test"
31
+ # Faker::Internet.email(name: 'smith') #=> "smith@bergnaum.test"
32
+ # Faker::Internet.email(name: 'sam smith', separators: ['-']) #=> "smith-sam@tromp.example"
33
+ # Faker::Internet.email(name: 'sam smith', separators: ['-'], domain: 'test') #=> "sam-smith@test.example"
34
+ # Faker::Internet.email(domain: 'gmail.com') #=> "foo@gmail.com"
32
35
  def email(name: nil, separators: nil, domain: nil)
33
36
  local_part = if separators
34
37
  username(specifier: name, separators: separators)
@@ -37,7 +40,14 @@ module Faker
37
40
  end
38
41
 
39
42
  sanitized_local_part = sanitize_email_local_part(local_part)
40
- construct_email(sanitized_local_part, domain_name(domain: domain))
43
+
44
+ generate_domain = if domain.nil?
45
+ domain_name
46
+ else
47
+ domain_name(domain: domain)
48
+ end
49
+
50
+ construct_email(sanitized_local_part, generate_domain)
41
51
  end
42
52
 
43
53
  ##
@@ -56,6 +66,7 @@ module Faker
56
66
  fetch('internet.free_email')
57
67
  )
58
68
  end
69
+ deprecate :free_email, :email, 2023, 10
59
70
 
60
71
  ##
61
72
  # Returns the email address with fixed domain name as 'example'
@@ -73,6 +84,7 @@ module Faker
73
84
  "example.#{sample(%w[org com net])}"
74
85
  )
75
86
  end
87
+ deprecate :safe_email, :email, 2023, 10
76
88
 
77
89
  ##
78
90
  # Returns the username
@@ -147,7 +159,8 @@ module Faker
147
159
  #
148
160
  # @faker.version 2.1.3
149
161
  def password(min_length: 8, max_length: 16, mix_case: true, special_characters: false)
150
- raise ArgumentError, 'max_length must be more than min_length' if max_length < min_length
162
+ raise ArgumentError, 'min_length and max_length must be greater than or equal to one' if min_length < 1 || max_length < 1
163
+ raise ArgumentError, 'min_length must be smaller than or equal to max_length' unless min_length <= max_length
151
164
 
152
165
  character_types = []
153
166
  required_min_length = 0
@@ -170,23 +183,27 @@ module Faker
170
183
  character_bag = []
171
184
 
172
185
  # use lower_chars by default and add upper_chars if mix_case
173
- lower_chars = ('a'..'z').to_a
174
- password << lower_chars[rand(lower_chars.count - 1)]
186
+ lower_chars = self::LLetters
187
+ password << sample(lower_chars)
175
188
  character_bag += lower_chars
176
189
 
177
- if character_types.include?(:mix_case)
178
- upper_chars = ('A'..'Z').to_a
179
- password << upper_chars[rand(upper_chars.count - 1)]
190
+ digits = ('0'..'9').to_a
191
+ password << sample(digits)
192
+ character_bag += digits
193
+
194
+ if mix_case
195
+ upper_chars = self::ULetters
196
+ password << sample(upper_chars)
180
197
  character_bag += upper_chars
181
198
  end
182
199
 
183
- if character_types.include?(:special_characters)
200
+ if special_characters
184
201
  special_chars = %w[! @ # $ % ^ & *]
185
- password << special_chars[rand(special_chars.count - 1)]
202
+ password << sample(special_chars)
186
203
  character_bag += special_chars
187
204
  end
188
205
 
189
- password << character_bag[rand(character_bag.count - 1)] while password.length < target_length
206
+ password << sample(character_bag) while password.length < target_length
190
207
 
191
208
  shuffle(password).join
192
209
  end
@@ -200,10 +217,12 @@ module Faker
200
217
  # @param domain [String]
201
218
  #
202
219
  # @example
203
- # Faker::Internet.domain_name #=> "test.net"
204
- # Faker::Internet.domain_name(subdomain: true) #=> "test.faker.io"
205
- # Faker::Internet.domain_name(subdomain: true, domain: 'example') #=> "faker.example.com"
206
- # Faker::Internet.domain_name(domain: 'faker') #=> "faker.org"
220
+ # Faker::Internet.domain_name #=> "altenwerth-gerhold.example"
221
+ # Faker::Internet.domain_name(subdomain: true) #=> "metz.mclaughlin-brekke.test"
222
+ # Faker::Internet.domain_name(subdomain: true, domain: 'faker') #=> "foo.faker.test"
223
+ # Faker::Internet.domain_name(domain: 'faker-ruby.org') #=> "faker-ruby.org"
224
+ # Faker::Internet.domain_name(subdomain: true, domain: 'faker-ruby.org') #=> "foo.faker-ruby.org"
225
+ # Faker::Internet.domain_name(subdomain: true, domain: 'faker.faker-ruby.org') #=> "faker.faker-ruby.org"
207
226
  def domain_name(subdomain: false, domain: nil)
208
227
  with_locale(:en) do
209
228
  if domain
@@ -211,12 +230,18 @@ module Faker
211
230
  .split('.')
212
231
  .map { |domain_part| Char.prepare(domain_part) }
213
232
  .tap do |domain_elements|
214
- domain_elements << domain_suffix if domain_elements.length < 2
215
- domain_elements.unshift(Char.prepare(domain_word)) if subdomain && domain_elements.length < 3
233
+ if domain_elements.length < 2
234
+ domain_elements << domain_suffix(safe: true)
235
+ end
236
+ if subdomain && domain_elements.length < 3
237
+ domain_elements.unshift(Char.prepare(domain_word))
238
+ end
216
239
  end.join('.')
217
240
  else
218
- [domain_word, domain_suffix].tap do |domain_elements|
219
- domain_elements.unshift(Char.prepare(domain_word)) if subdomain
241
+ [domain_word, domain_suffix(safe: true)].tap do |domain_elements|
242
+ if subdomain
243
+ domain_elements.unshift(Char.prepare(domain_word))
244
+ end
220
245
  end.join('.')
221
246
  end
222
247
  end
@@ -253,10 +278,16 @@ module Faker
253
278
  # @return [String]
254
279
  #
255
280
  # @example
256
- # Faker::Internet.domain_suffix #=> "com"
257
- # Faker::Internet.domain_suffix #=> "biz"
258
- def domain_suffix
259
- fetch('internet.domain_suffix')
281
+ # Faker::Internet.domain_suffix #=> "com"
282
+ # Faker::Internet.domain_suffix #=> "biz"
283
+ # Faker::Internet.domain_suffix(safe: true) #=> "example"
284
+ # Faker::Internet.domain_suffix(safe: true) #=> "test"
285
+ def domain_suffix(safe: nil)
286
+ if safe
287
+ fetch('internet.safe_domain_suffix')
288
+ else
289
+ fetch('internet.domain_suffix')
290
+ end
260
291
  end
261
292
 
262
293
  ##
@@ -421,10 +452,10 @@ module Faker
421
452
  # @param scheme [String]
422
453
  #
423
454
  # @example
424
- # Faker::Internet.url #=> "http://sipes-okon.com/hung.macejkovic"
455
+ # Faker::Internet.url #=> "http://treutel.test/demarcus"
425
456
  # Faker::Internet.url(host: 'faker') #=> "http://faker/shad"
426
- # Faker::Internet.url(host: 'faker', path: '/fake_test_path') #=> "http://faker/fake_test_path"
427
- # Faker::Internet.url(host: 'faker', path: '/fake_test_path', scheme: 'https') #=> "https://faker/fake_test_path"
457
+ # Faker::Internet.url(host: 'faker', path: '/docs') #=> "http://faker/docs"
458
+ # Faker::Internet.url(host: 'faker', path: '/docs', scheme: 'https') #=> "https://faker/docs"
428
459
  def url(host: domain_name, path: "/#{username}", scheme: 'http')
429
460
  "#{scheme}://#{host}#{path}"
430
461
  end
@@ -542,10 +573,10 @@ module Faker
542
573
  ##
543
574
  # Produces a randomized hash of internet user details
544
575
  # @example
545
- # Faker::Internet.user #=> { username: 'alexie', email: 'alexie@example.net' }
576
+ # Faker::Internet.user #=> { username: 'alexie', email: 'trudie@grant.test' }
546
577
  #
547
578
  # @example
548
- # Faker::Internet.user('username', 'email', 'password') #=> { username: 'alexie', email: 'alexie@example.net', password: 'DtEf9P8wS31iMyC' }
579
+ # Faker::Internet.user('username', 'email', 'password') #=> { username: 'alexie', email: 'gayle@kohler.test', password: 'DtEf9P8wS31iMyC' }
549
580
  #
550
581
  # @return [hash]
551
582
  #
@@ -10,10 +10,13 @@ module Faker
10
10
  #
11
11
  # @example
12
12
  # Faker::Lorem.word #=> "soluto"
13
+ # Faker::Lorem.word(exclude_words: 'error') #=> "nisi"
14
+ # Faker::Lorem.word(exclude_words: 'id, error') #=> "et"
15
+ # Faker::Lorem.word(exclude_words: ['id', 'error']) #=> "consequatur"
13
16
  #
14
17
  # @faker.version 2.1.3
15
- def word
16
- sample(translate('faker.lorem.words'))
18
+ def word(exclude_words: nil)
19
+ words(number: 1, exclude_words: exclude_words).first
17
20
  end
18
21
 
19
22
  ##
@@ -28,14 +31,19 @@ module Faker
28
31
  # Faker::Lorem.words #=> ["hic", "quia", "nihil"]
29
32
  # Faker::Lorem.words(number: 4) #=> ["est", "temporibus", "et", "quaerat"]
30
33
  # Faker::Lorem.words(number: 4, supplemental: true) #=> ["nisi", "sit", "allatus", "consequatur"]
34
+ # Faker::Lorem.words(number: 4, supplemental: true, exclude_words: 'sit') #=> ["nisi", "allatus", "consequatur", "aut"]
31
35
  #
32
36
  # @faker.version 2.1.3
33
- def words(number: 3, supplemental: false)
37
+ def words(number: 3, supplemental: false, exclude_words: nil)
34
38
  resolved_num = resolve(number)
35
39
  word_list = (
36
40
  translate('faker.lorem.words') +
37
41
  (supplemental ? translate('faker.lorem.supplemental') : [])
38
42
  )
43
+ if exclude_words
44
+ exclude_words = exclude_words.split(', ') if exclude_words.instance_of?(::String)
45
+ word_list -= exclude_words
46
+ end
39
47
  word_list *= ((resolved_num / word_list.length) + 1)
40
48
  shuffle(word_list)[0, resolved_num]
41
49
  end
@@ -103,8 +111,8 @@ module Faker
103
111
  # Faker::Lorem.sentence(word_count: 5, supplemental: true, random_words_to_add:2) #=> "Crinis quo cruentus velit animi vomer."
104
112
  #
105
113
  # @faker.version 2.1.3
106
- def sentence(word_count: 4, supplemental: false, random_words_to_add: 0)
107
- words(number: word_count + rand(random_words_to_add.to_i), supplemental: supplemental).join(locale_space).capitalize + locale_period
114
+ def sentence(word_count: 4, supplemental: false, random_words_to_add: 0, exclude_words: nil)
115
+ words(number: word_count + rand(random_words_to_add.to_i), supplemental: supplemental, exclude_words: exclude_words).join(locale_space).capitalize + locale_period
108
116
  end
109
117
 
110
118
  ##
@@ -121,8 +129,8 @@ module Faker
121
129
  # Faker::Lorem.sentences(number: 2, supplemental: true) #=> ["Cito cena ad.", "Solvo animus allatus."]
122
130
  #
123
131
  # @faker.version 2.1.3
124
- def sentences(number: 3, supplemental: false)
125
- 1.upto(resolve(number)).collect { sentence(word_count: 3, supplemental: supplemental) }
132
+ def sentences(number: 3, supplemental: false, exclude_words: nil)
133
+ 1.upto(resolve(number)).collect { sentence(word_count: 3, supplemental: supplemental, exclude_words: exclude_words) }
126
134
  end
127
135
 
128
136
  ##
@@ -145,8 +153,8 @@ module Faker
145
153
  # #=> "Texo tantillus tamisium. Tribuo amissio tamisium. Facere aut canis."
146
154
  #
147
155
  # @faker.version 2.1.3
148
- def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 0)
149
- sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i), supplemental: supplemental).join(locale_space)
156
+ def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 0, exclude_words: nil)
157
+ sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i), supplemental: supplemental, exclude_words: exclude_words).join(locale_space)
150
158
  end
151
159
 
152
160
  ##
@@ -163,8 +171,8 @@ module Faker
163
171
  # Faker::Lorem.paragraphs(number:2, supplemental: true)
164
172
  #
165
173
  # @faker.version 2.1.3
166
- def paragraphs(number: 3, supplemental: false)
167
- 1.upto(resolve(number)).collect { paragraph(sentence_count: 3, supplemental: supplemental) }
174
+ def paragraphs(number: 3, supplemental: false, exclude_words: nil)
175
+ 1.upto(resolve(number)).collect { paragraph(sentence_count: 3, supplemental: supplemental, exclude_words: exclude_words) }
168
176
  end
169
177
 
170
178
  ##
@@ -205,8 +213,8 @@ module Faker
205
213
  # Faker::Lorem.question(word_count: 2, supplemental: true, random_words_to_add: 2) #=> "Depulso uter ut?"
206
214
  #
207
215
  # @faker.version 2.1.3
208
- def question(word_count: 4, supplemental: false, random_words_to_add: 0)
209
- words(number: word_count + rand(random_words_to_add), supplemental: supplemental).join(' ').capitalize + locale_question_mark
216
+ def question(word_count: 4, supplemental: false, random_words_to_add: 0, exclude_words: nil)
217
+ words(number: word_count + rand(random_words_to_add), supplemental: supplemental, exclude_words: exclude_words).join(' ').capitalize + locale_question_mark
210
218
  end
211
219
 
212
220
  ##
@@ -223,8 +231,8 @@ module Faker
223
231
  # Faker::Lorem.questions(number: 2, supplemental: true) #=> ["Acceptus subito cetera?", "Aro sulum cubicularis?"]
224
232
  #
225
233
  # @faker.version 2.1.3
226
- def questions(number: 3, supplemental: false)
227
- 1.upto(resolve(number)).collect { question(word_count: 3, supplemental: supplemental) }
234
+ def questions(number: 3, supplemental: false, exclude_words: nil)
235
+ 1.upto(resolve(number)).collect { question(word_count: 3, supplemental: supplemental, exclude_words: exclude_words) }
228
236
  end
229
237
 
230
238
  private
@@ -6,7 +6,7 @@ module Faker
6
6
 
7
7
  class << self
8
8
  ##
9
- # Produces the name of a video game console or platform.
9
+ # Produces a few marketing buzzwords.
10
10
  #
11
11
  # @return [String]
12
12
  #
@@ -12,7 +12,7 @@ module Faker
12
12
  super()
13
13
 
14
14
  @name = name || "#{Name.first_name} #{Name.last_name}"
15
- @email = email || Internet.safe_email(name: self.name)
15
+ @email = email || Internet.email(name: self.name)
16
16
  @first_name, @last_name = self.name.split
17
17
  end
18
18
 
@@ -0,0 +1,59 @@
1
+
2
+
3
+ ## What's Changed
4
+ * Add Final Fantasy XIV by @old-dead-account in https://github.com/faker-ruby/faker/pull/2742
5
+ * Update rubocop requirement from = 1.50.1 to = 1.50.2 by @dependabot in https://github.com/faker-ruby/faker/pull/2752
6
+ * Update South Park by @IvanReyesO7 in https://github.com/faker-ruby/faker/pull/2744
7
+ * add tests for password and fix an edge case by @DeepakRaj228 in https://github.com/faker-ruby/faker/pull/2741
8
+ * Speed up Internet::Password generation using constants by @MicBruz in https://github.com/faker-ruby/faker/pull/2725
9
+ * Add the Ukrainian country calling code by @kyrylo in https://github.com/faker-ruby/faker/pull/2758
10
+ * Update test-unit requirement from = 3.5.7 to = 3.5.8 by @dependabot in https://github.com/faker-ruby/faker/pull/2760
11
+ * Bump i18n from 1.12.0 to 1.13.0 by @dependabot in https://github.com/faker-ruby/faker/pull/2756
12
+ * Update rubocop-minitest requirement from = 0.30.0 to = 0.31.0 by @dependabot in https://github.com/faker-ruby/faker/pull/2759
13
+ * Remove broken chars from minecraft.yml by @ujihisa in https://github.com/faker-ruby/faker/pull/2765
14
+ * Update test-unit requirement from = 3.5.8 to = 3.5.9 by @dependabot in https://github.com/faker-ruby/faker/pull/2766
15
+ * Add `exclude_words` filter to `Faker::Lorem.word` generator by @geophilusd in https://github.com/faker-ruby/faker/pull/2761
16
+ * Improve de-CH locale with new formats and content by @stefnnn in https://github.com/faker-ruby/faker/pull/2768
17
+ * Add Japanese translations for Sports category. by @yamat47 in https://github.com/faker-ruby/faker/pull/2770
18
+ * Fix flaky specs for `name` and `id` by @ruban-thilak in https://github.com/faker-ruby/faker/pull/2782
19
+ * Add type support for Faker::Types.rb_array by @ruban-thilak in https://github.com/faker-ruby/faker/pull/2771
20
+ * Added Archer into tv category. by @lepari23 in https://github.com/faker-ruby/faker/pull/2750
21
+ * Add train station generator by @AngusDSR in https://github.com/faker-ruby/faker/pull/2755
22
+ * Fixes `Faker::Music::Opera.saint_saens` issue by @devashishTaneja in https://github.com/faker-ruby/faker/pull/2792
23
+ * Add custom start date for `Faker::Date.forward` by @luciagirasoles in https://github.com/faker-ruby/faker/pull/2791
24
+ * Fix flaky specs for dota `test_player` by @ruban-thilak in https://github.com/faker-ruby/faker/pull/2798
25
+ * Update minitest requirement from = 5.18.0 to = 5.18.1 by @dependabot in https://github.com/faker-ruby/faker/pull/2781
26
+ * Update test-unit requirement from = 3.5.9 to = 3.6.1 by @dependabot in https://github.com/faker-ruby/faker/pull/2788
27
+ * Introduce PositionalGenerator by @mike-burns in https://github.com/faker-ruby/faker/pull/2710
28
+ * Bump rubocop 1.54.2 + offenses fixes by @stefannibrasil in https://github.com/faker-ruby/faker/pull/2801
29
+ * Add prefixes to french name locale (`Faker::Name.name`) by @thdaraujo in https://github.com/faker-ruby/faker/pull/2800
30
+ * Add `max_rut` option to `Faker::ChileRut.rut` by @hacktivista in https://github.com/faker-ruby/faker/pull/2778
31
+ * Fix locale setting by @mateusdeap in https://github.com/faker-ruby/faker/pull/2734
32
+ * Test default locale + and update README by @stefannibrasil in https://github.com/faker-ruby/faker/pull/2802
33
+ * Bump minitest from 5.18.1 to 5.19.0 by @dependabot in https://github.com/faker-ruby/faker/pull/2804
34
+ * Bump rubocop from 1.54.2 to 1.55.0 by @dependabot in https://github.com/faker-ruby/faker/pull/2803
35
+ * Bump rubocop from 1.55.0 to 1.55.1 by @dependabot in https://github.com/faker-ruby/faker/pull/2805
36
+ * Add Faker::Date.day_of_week_between by @aramvisser in https://github.com/faker-ruby/faker/pull/2713
37
+ * Html generator for Faker by @ruban-thilak in https://github.com/faker-ruby/faker/pull/2769
38
+ * Bump rubocop from 1.55.1 to 1.56.0 by @dependabot in https://github.com/faker-ruby/faker/pull/2807
39
+
40
+ ## New Contributors
41
+ * @old-dead-account made their first contribution in https://github.com/faker-ruby/faker/pull/2742
42
+ * @IvanReyesO7 made their first contribution in https://github.com/faker-ruby/faker/pull/2744
43
+ * @DeepakRaj228 made their first contribution in https://github.com/faker-ruby/faker/pull/2741
44
+ * @MicBruz made their first contribution in https://github.com/faker-ruby/faker/pull/2725
45
+ * @kyrylo made their first contribution in https://github.com/faker-ruby/faker/pull/2758
46
+ * @ujihisa made their first contribution in https://github.com/faker-ruby/faker/pull/2765
47
+ * @geophilusd made their first contribution in https://github.com/faker-ruby/faker/pull/2761
48
+ * @stefnnn made their first contribution in https://github.com/faker-ruby/faker/pull/2768
49
+ * @yamat47 made their first contribution in https://github.com/faker-ruby/faker/pull/2770
50
+ * @ruban-thilak made their first contribution in https://github.com/faker-ruby/faker/pull/2782
51
+ * @lepari23 made their first contribution in https://github.com/faker-ruby/faker/pull/2750
52
+ * @AngusDSR made their first contribution in https://github.com/faker-ruby/faker/pull/2755
53
+ * @devashishTaneja made their first contribution in https://github.com/faker-ruby/faker/pull/2792
54
+ * @mike-burns made their first contribution in https://github.com/faker-ruby/faker/pull/2710
55
+ * @hacktivista made their first contribution in https://github.com/faker-ruby/faker/pull/2778
56
+ * @mateusdeap made their first contribution in https://github.com/faker-ruby/faker/pull/2734
57
+ * @aramvisser made their first contribution in https://github.com/faker-ruby/faker/pull/2713
58
+
59
+ **Full Changelog**: https://github.com/faker-ruby/faker/compare/v3.2.0...v3.2.1
@@ -63,7 +63,7 @@ module Faker
63
63
  verified: Faker::Boolean.boolean(true_ratio: 0.1)
64
64
  }
65
65
  user[:status] = Faker::Twitter.status(include_user: false) if include_status
66
- user[:email] = Faker::Internet.safe_email if include_email
66
+ user[:email] = Faker::Internet.email if include_email
67
67
  user
68
68
  end
69
69