faker 3.5.1 → 3.5.3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +118 -7
- data/README.md +76 -390
- data/lib/faker/books/lovecraft.rb +1 -1
- data/lib/faker/default/bank.rb +1 -5
- data/lib/faker/default/boolean.rb +2 -1
- data/lib/faker/default/code.rb +4 -0
- data/lib/faker/default/company.rb +2 -2
- data/lib/faker/default/driving_licence.rb +1 -1
- data/lib/faker/default/finance.rb +2 -2
- data/lib/faker/default/hipster.rb +1 -1
- data/lib/faker/default/html.rb +1 -1
- data/lib/faker/default/internet.rb +1 -1
- data/lib/faker/default/invoice.rb +2 -2
- data/lib/faker/default/json.rb +7 -2
- data/lib/faker/default/lorem.rb +1 -1
- data/lib/faker/default/markdown.rb +2 -2
- data/lib/faker/default/national_health_service.rb +1 -2
- data/lib/faker/default/placeholdit.rb +1 -1
- data/lib/faker/default/twitter.rb +194 -0
- data/lib/faker/default/types.rb +2 -2
- data/lib/faker/music/bossa_nova.rb +41 -0
- data/lib/faker/version.rb +1 -1
- data/lib/helpers/deprecator.rb +1 -1
- data/lib/locales/ar.yml +1602 -49
- data/lib/locales/de-CH.yml +31 -0
- data/lib/locales/ee.yml +2 -0
- data/lib/locales/en/cosmere.yml +1 -1
- data/lib/locales/en/elder_scrolls.yml +51 -52
- data/lib/locales/en/finance.yml +1 -1
- data/lib/locales/en/hobby.yml +0 -1
- data/lib/locales/en/overwatch.yml +1 -1
- data/lib/locales/en/rajnikanth.yml +1 -1
- data/lib/locales/en/restaurant.yml +1 -1
- data/lib/locales/en/street_fighter.yml +1 -1
- data/lib/locales/en-GB.yml +9 -7
- data/lib/locales/en-PAK.yml +24 -1
- data/lib/locales/fr/address.yml +761 -8
- data/lib/locales/ja/artist.yml +46 -0
- data/lib/locales/ja/book.yml +492 -3
- data/lib/locales/ja/lorem.yml +1 -1
- data/lib/locales/nl.yml +9 -1
- data/lib/locales/uk.yml +7 -7
- metadata +5 -7
- data/lib/faker/default/bossa_nova.rb +0 -33
|
@@ -267,7 +267,7 @@ module Faker
|
|
|
267
267
|
# Faker::Internet.mac_address(prefix: 'aa:44') #=> "aa:44:30:88:6e:95"
|
|
268
268
|
def mac_address(prefix: '')
|
|
269
269
|
prefix_digits = prefix.split(':').map { |d| d.to_i(16) }
|
|
270
|
-
address_digits = Array.new(
|
|
270
|
+
address_digits = Array.new(6 - prefix_digits.size) { rand(256) }
|
|
271
271
|
(prefix_digits + address_digits).map { |d| format('%02x', d) }.join(':')
|
|
272
272
|
end
|
|
273
273
|
|
|
@@ -13,8 +13,8 @@ module Faker
|
|
|
13
13
|
# @return [Integer]
|
|
14
14
|
#
|
|
15
15
|
# @example
|
|
16
|
-
# Faker::
|
|
17
|
-
# Faker::
|
|
16
|
+
# Faker::Invoice.amount_between #=> 0
|
|
17
|
+
# Faker::Invoice.amount_between(from: 0, to: 10) #=> 4.33
|
|
18
18
|
#
|
|
19
19
|
# @faker.version 1.9.0
|
|
20
20
|
def amount_between(from: 0, to: 0)
|
data/lib/faker/default/json.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Faker
|
|
2
4
|
class Json < Base
|
|
3
5
|
require 'json'
|
|
@@ -104,17 +106,20 @@ module Faker
|
|
|
104
106
|
end
|
|
105
107
|
|
|
106
108
|
def add_hash(key_array, hash, width, options)
|
|
107
|
-
string_to_eval = 'hash'
|
|
109
|
+
string_to_eval = 'hash'.dup
|
|
110
|
+
|
|
108
111
|
key_array.length.times do |index|
|
|
109
112
|
string_to_eval << "['#{key_array[index]}']"
|
|
110
113
|
end
|
|
111
114
|
string_to_eval << " = #{build_shallow_hash(width, options)}"
|
|
112
115
|
eval(string_to_eval)
|
|
116
|
+
|
|
113
117
|
hash
|
|
114
118
|
end
|
|
115
119
|
|
|
116
120
|
def build_keys_from_array(key_array)
|
|
117
|
-
key_string = ''
|
|
121
|
+
key_string = ''.dup
|
|
122
|
+
|
|
118
123
|
key_array.each do |value|
|
|
119
124
|
key_string << "['#{value}']"
|
|
120
125
|
end
|
data/lib/faker/default/lorem.rb
CHANGED
|
@@ -28,7 +28,7 @@ module Faker
|
|
|
28
28
|
def emphasis
|
|
29
29
|
paragraph = Faker::Lorem.paragraph(sentence_count: 3)
|
|
30
30
|
words = paragraph.split
|
|
31
|
-
position = rand(0..words.length - 1)
|
|
31
|
+
position = rand(0..(words.length - 1))
|
|
32
32
|
formatting = fetch('markdown.emphasis')
|
|
33
33
|
words[position] = "#{formatting}#{words[position]}#{formatting}"
|
|
34
34
|
words.join(' ')
|
|
@@ -133,7 +133,7 @@ module Faker
|
|
|
133
133
|
def random(*args)
|
|
134
134
|
method_list = available_methods
|
|
135
135
|
args&.each { |ex| method_list.delete_if { |meth| meth == ex.to_sym } }
|
|
136
|
-
send(method_list[Faker::Config.random.rand(0..method_list.length - 1)])
|
|
136
|
+
send(method_list[Faker::Config.random.rand(0..(method_list.length - 1))])
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
##
|
|
@@ -20,8 +20,7 @@ module Faker
|
|
|
20
20
|
# If the check digit is equivalent to 10, the number is invalid.
|
|
21
21
|
# See https://en.wikipedia.org/wiki/NHS_number
|
|
22
22
|
base_number -= 1 if check_digit(number: base_number) == 10
|
|
23
|
-
"#{base_number}#{check_digit(number: base_number)}".
|
|
24
|
-
.chars
|
|
23
|
+
"#{base_number}#{check_digit(number: base_number)}".chars
|
|
25
24
|
.insert(3, ' ')
|
|
26
25
|
.insert(7, ' ')
|
|
27
26
|
.join
|
|
@@ -17,6 +17,9 @@ module Faker
|
|
|
17
17
|
#
|
|
18
18
|
# @faker.version 1.7.3
|
|
19
19
|
def user(include_status: true, include_email: false)
|
|
20
|
+
warn('DEPRECATION WARNING: Faker::Twitter is deprecated. Use Faker::X instead. Some return attributes \
|
|
21
|
+
will be removed, check the docs for more details.')
|
|
22
|
+
|
|
20
23
|
user_id = id
|
|
21
24
|
background_image_url = Faker::LoremFlickr.image(size: '600x400')
|
|
22
25
|
profile_image_url = Faker::Avatar.image(slug: user_id, size: '48x48')
|
|
@@ -81,6 +84,9 @@ module Faker
|
|
|
81
84
|
#
|
|
82
85
|
# @faker.version 1.7.3
|
|
83
86
|
def status(include_user: true, include_photo: false)
|
|
87
|
+
warn('DEPRECATION WARNING: Faker::Twitter is deprecated. Use Faker::X instead. Some return attributes \
|
|
88
|
+
will be removed, check the docs for more details.')
|
|
89
|
+
|
|
84
90
|
status_id = id
|
|
85
91
|
status = {
|
|
86
92
|
id: status_id,
|
|
@@ -123,6 +129,8 @@ module Faker
|
|
|
123
129
|
#
|
|
124
130
|
# @faker.version 1.7.3
|
|
125
131
|
def screen_name
|
|
132
|
+
warn('DEPRECATION WARNING: Faker::Twitter is deprecated. Use Faker::X instead.')
|
|
133
|
+
|
|
126
134
|
Faker::Internet.username(specifier: nil, separators: ['_'])[0...20]
|
|
127
135
|
end
|
|
128
136
|
|
|
@@ -204,4 +212,190 @@ module Faker
|
|
|
204
212
|
end
|
|
205
213
|
end
|
|
206
214
|
end
|
|
215
|
+
|
|
216
|
+
class X < Base
|
|
217
|
+
class << self
|
|
218
|
+
##
|
|
219
|
+
# Produces a random X user based on X's v2 API.
|
|
220
|
+
#
|
|
221
|
+
# @return [Hash]
|
|
222
|
+
#
|
|
223
|
+
# @example
|
|
224
|
+
# Faker::X.user #=> { data: [{:id=>"8821452687517076614", :name=>"Lincoln Paucek", :screen_name=>"cody"...
|
|
225
|
+
#
|
|
226
|
+
# @faker.version 1.7.3
|
|
227
|
+
def user
|
|
228
|
+
author_id = Faker::Number.between(from: 1, to: 9_223_372_036_854_775_807)
|
|
229
|
+
|
|
230
|
+
{
|
|
231
|
+
data: [
|
|
232
|
+
{
|
|
233
|
+
author_id: author_id.to_s,
|
|
234
|
+
id: id.to_s,
|
|
235
|
+
text: Faker::Lorem.sentence
|
|
236
|
+
}
|
|
237
|
+
],
|
|
238
|
+
includes: {
|
|
239
|
+
users: [
|
|
240
|
+
{
|
|
241
|
+
public_metrics: {
|
|
242
|
+
followers_count: Faker::Number.between(to: 1, from: 1_000),
|
|
243
|
+
following_count: Faker::Number.between(to: 1, from: 200),
|
|
244
|
+
tweet_count: Faker::Number.between(to: 1, from: 10_000),
|
|
245
|
+
listed_count: Faker::Number.between(to: 1, from: 1_000)
|
|
246
|
+
},
|
|
247
|
+
username: screen_name,
|
|
248
|
+
pinned_tweet_id: Faker::Number.between(from: 1, to: 9_223_372_036_854_775_807).to_s,
|
|
249
|
+
entities: user_entities,
|
|
250
|
+
description: Faker::Lorem.sentence,
|
|
251
|
+
name: Faker::Name.name,
|
|
252
|
+
verified: Faker::Boolean.boolean(true_ratio: 0.1),
|
|
253
|
+
location: Faker::Internet.public_ip_v4_address,
|
|
254
|
+
id: author_id.to_s,
|
|
255
|
+
protected: Faker::Boolean.boolean(true_ratio: 0.1),
|
|
256
|
+
url: url,
|
|
257
|
+
profile_image_url: Faker::Avatar.image(slug: id, size: '48x48'),
|
|
258
|
+
created_at: created_at
|
|
259
|
+
}
|
|
260
|
+
]
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
##
|
|
266
|
+
# Produces a random X tweet with default attributes.
|
|
267
|
+
#
|
|
268
|
+
# @param include_user [Boolean] Include user details
|
|
269
|
+
# @param include_media [Boolean] Include user media (photo) details
|
|
270
|
+
# @return [Hash]
|
|
271
|
+
#
|
|
272
|
+
# @example
|
|
273
|
+
# Faker::X.tweet #=> { data: [{:id=>"8821452687517076614", :text=>"Ea et laboriosam vel non."...
|
|
274
|
+
# Faker::X.tweet(include_media: true) # Get a tweet object with a photo media attachment
|
|
275
|
+
# Faker::X.tweet(include_user: true) # Get a tweet object with an user details
|
|
276
|
+
#
|
|
277
|
+
# @faker.version 1.7.3
|
|
278
|
+
def tweet(include_media: false, include_user: false)
|
|
279
|
+
tweet = {}
|
|
280
|
+
tweet_object = tweet_item
|
|
281
|
+
includes = {}
|
|
282
|
+
|
|
283
|
+
if include_media
|
|
284
|
+
media_key = Faker::Number.between(from: 1, to: 9_223_372_036_854_775_807).to_s
|
|
285
|
+
|
|
286
|
+
includes[:media] = media(media_key)
|
|
287
|
+
tweet_object[:attachments] = { media_keys: [media_key] }
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
includes[:users] = user[:includes][:users] if include_user
|
|
291
|
+
|
|
292
|
+
tweet[:data] = [
|
|
293
|
+
tweet_object
|
|
294
|
+
]
|
|
295
|
+
|
|
296
|
+
unless includes.empty?
|
|
297
|
+
tweet[:includes] = includes
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
tweet
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
##
|
|
304
|
+
# Produces a random screen_name.
|
|
305
|
+
#
|
|
306
|
+
# @return [String]
|
|
307
|
+
#
|
|
308
|
+
# @example
|
|
309
|
+
# Faker::X.screen_name #=> "audreanne_hackett"
|
|
310
|
+
#
|
|
311
|
+
# @faker.version 1.7.3
|
|
312
|
+
def screen_name
|
|
313
|
+
Faker::Internet.username(specifier: nil, separators: ['_'])[0...20]
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
private
|
|
317
|
+
|
|
318
|
+
def id
|
|
319
|
+
Faker::Number.between(from: 1, to: 9_223_372_036_854_775_807)
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
def created_at
|
|
323
|
+
Faker::Date.between(from: '2006-03-21', to: ::Date.today).to_time.utc.iso8601(3)
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
def url
|
|
327
|
+
"https://t.co/#{Faker::Lorem.characters(number: 10)}"
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
def user_entities
|
|
331
|
+
entities = tweet_entities
|
|
332
|
+
|
|
333
|
+
{
|
|
334
|
+
url: {
|
|
335
|
+
urls: entities[:urls]
|
|
336
|
+
},
|
|
337
|
+
description: {
|
|
338
|
+
hashtags: entities[:hashtags]
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
def tweet_entities
|
|
344
|
+
display_url = Faker::Internet.url(host: 'example.com')
|
|
345
|
+
|
|
346
|
+
{
|
|
347
|
+
urls: [
|
|
348
|
+
{
|
|
349
|
+
start: 0,
|
|
350
|
+
end: 5,
|
|
351
|
+
url: url,
|
|
352
|
+
expanded_url: display_url,
|
|
353
|
+
display_url: display_url.sub('http://', '')
|
|
354
|
+
}
|
|
355
|
+
],
|
|
356
|
+
hashtags: [
|
|
357
|
+
{
|
|
358
|
+
start: 0,
|
|
359
|
+
end: 5,
|
|
360
|
+
tag: Faker::Lorem.word.capitalize
|
|
361
|
+
}
|
|
362
|
+
]
|
|
363
|
+
}
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
def media(media_key)
|
|
367
|
+
expanded_url = Faker::LoremFlickr.image(size: '1064x600')
|
|
368
|
+
|
|
369
|
+
[{
|
|
370
|
+
height: Faker::Number.between(to: 1, from: 1000),
|
|
371
|
+
media_key: media_key,
|
|
372
|
+
type: 'photo',
|
|
373
|
+
preview_image_url: expanded_url,
|
|
374
|
+
width: Faker::Number.between(to: 1, from: 2000),
|
|
375
|
+
alt_text: Faker::Lorem.sentence
|
|
376
|
+
}]
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
def tweet_item
|
|
380
|
+
conversation_id = id.to_s
|
|
381
|
+
|
|
382
|
+
{
|
|
383
|
+
id: conversation_id,
|
|
384
|
+
text: Faker::Lorem.sentence,
|
|
385
|
+
lang: sample(%w[en fr es pt it ja]),
|
|
386
|
+
conversation_id: conversation_id,
|
|
387
|
+
created_at: created_at,
|
|
388
|
+
author_id: Faker::Number.between(from: 1, to: 9_223_372_036_854_775_807).to_s,
|
|
389
|
+
public_metrics: {
|
|
390
|
+
retweet_count: Faker::Number.between(to: 1, from: 100),
|
|
391
|
+
reply_count: Faker::Number.between(to: 1, from: 20),
|
|
392
|
+
like_count: Faker::Number.between(to: 1, from: 25),
|
|
393
|
+
quote_count: Faker::Number.between(to: 1, from: 10)
|
|
394
|
+
},
|
|
395
|
+
possibly_sensitive: Faker::Boolean.boolean(true_ratio: 0.1),
|
|
396
|
+
entities: tweet_entities
|
|
397
|
+
}
|
|
398
|
+
end
|
|
399
|
+
end
|
|
400
|
+
end
|
|
207
401
|
end
|
data/lib/faker/default/types.rb
CHANGED
|
@@ -116,7 +116,7 @@ module Faker
|
|
|
116
116
|
#
|
|
117
117
|
# @faker.version 1.8.6
|
|
118
118
|
def random_type
|
|
119
|
-
type_to_use = SIMPLE_TYPES[rand(0..SIMPLE_TYPES.length - 1)]
|
|
119
|
+
type_to_use = SIMPLE_TYPES[rand(0..(SIMPLE_TYPES.length - 1))]
|
|
120
120
|
case type_to_use
|
|
121
121
|
when :string
|
|
122
122
|
rb_string
|
|
@@ -136,7 +136,7 @@ module Faker
|
|
|
136
136
|
# @faker.version 1.8.6
|
|
137
137
|
def random_complex_type
|
|
138
138
|
types = SIMPLE_TYPES + COMPLEX_TYPES
|
|
139
|
-
type_to_use = types[rand(0..types.length - 1)]
|
|
139
|
+
type_to_use = types[rand(0..(types.length - 1))]
|
|
140
140
|
case type_to_use
|
|
141
141
|
when :string
|
|
142
142
|
rb_string
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'music'
|
|
4
|
+
|
|
5
|
+
module Faker
|
|
6
|
+
class Music
|
|
7
|
+
class BossaNova < Base
|
|
8
|
+
class << self
|
|
9
|
+
##
|
|
10
|
+
# Produces the name of a bossa nova artist.
|
|
11
|
+
#
|
|
12
|
+
# @return [String]
|
|
13
|
+
#
|
|
14
|
+
# @example
|
|
15
|
+
# Faker::Music::BossaNova.artist #=> "Tom Jobin"
|
|
16
|
+
#
|
|
17
|
+
# @faker.version 1.8.3
|
|
18
|
+
def artist
|
|
19
|
+
fetch('bossa_nova.artists')
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
##
|
|
23
|
+
# Produces a bossa nova song.
|
|
24
|
+
#
|
|
25
|
+
# @return [String]
|
|
26
|
+
#
|
|
27
|
+
# @example
|
|
28
|
+
# Faker::Music::BossaNova.song #=> "Chega de Saudade"
|
|
29
|
+
#
|
|
30
|
+
# @faker.version 1.8.3
|
|
31
|
+
def song
|
|
32
|
+
fetch('bossa_nova.songs')
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
include Faker::Deprecator
|
|
39
|
+
|
|
40
|
+
deprecate_generator('BossaNova', Music::BossaNova)
|
|
41
|
+
end
|
data/lib/faker/version.rb
CHANGED