faker 1.9.6 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +189 -6
- data/README.md +5 -1
- data/lib/faker/books/dune.rb +2 -2
- data/lib/faker/books/lovecraft.rb +18 -18
- data/lib/faker/creature/animal.rb +1 -1
- data/lib/faker/creature/cat.rb +1 -1
- data/lib/faker/creature/dog.rb +1 -1
- data/lib/faker/creature/horse.rb +1 -1
- data/lib/faker/default/address.rb +3 -3
- data/lib/faker/default/alphanumeric.rb +4 -4
- data/lib/faker/default/avatar.rb +1 -1
- data/lib/faker/default/bank.rb +2 -2
- data/lib/faker/default/boolean.rb +1 -1
- data/lib/faker/default/cannabis.rb +4 -0
- data/lib/faker/default/chile_rut.rb +3 -3
- data/lib/faker/default/code.rb +5 -5
- data/lib/faker/default/commerce.rb +4 -4
- data/lib/faker/default/company.rb +2 -2
- data/lib/faker/default/crypto_coin.rb +9 -4
- data/lib/faker/default/date.rb +9 -9
- data/lib/faker/default/demographic.rb +1 -1
- data/lib/faker/default/device.rb +2 -2
- data/lib/faker/default/driving_licence.rb +2 -2
- data/lib/faker/default/educator.rb +0 -3
- data/lib/faker/default/file.rb +3 -3
- data/lib/faker/default/fillmurray.rb +2 -2
- data/lib/faker/default/finance.rb +1 -1
- data/lib/faker/default/hipster.rb +16 -16
- data/lib/faker/default/id_number.rb +47 -10
- data/lib/faker/default/internet.rb +22 -21
- data/lib/faker/default/invoice.rb +3 -3
- data/lib/faker/default/json.rb +2 -2
- data/lib/faker/default/lorem.rb +20 -20
- data/lib/faker/default/lorem_flickr.rb +4 -4
- data/lib/faker/default/lorem_pixel.rb +1 -1
- data/lib/faker/default/markdown.rb +7 -7
- data/lib/faker/default/measurement.rb +8 -8
- data/lib/faker/default/name.rb +2 -4
- data/lib/faker/default/nhs.rb +7 -7
- data/lib/faker/default/number.rb +35 -32
- data/lib/faker/default/omniauth.rb +11 -11
- data/lib/faker/default/phone_number.rb +1 -1
- data/lib/faker/default/placeholdit.rb +1 -1
- data/lib/faker/default/relationship.rb +1 -1
- data/lib/faker/default/source.rb +2 -2
- data/lib/faker/default/south_africa.rb +1 -1
- data/lib/faker/default/space.rb +2 -2
- data/lib/faker/default/string.rb +1 -1
- data/lib/faker/default/stripe.rb +4 -4
- data/lib/faker/default/time.rb +23 -8
- data/lib/faker/default/twitter.rb +30 -30
- data/lib/faker/default/types.rb +7 -7
- data/lib/faker/default/vehicle.rb +5 -5
- data/lib/faker/default/world_cup.rb +2 -2
- data/lib/faker/games/dota.rb +1 -1
- data/lib/faker/games/elder_scrolls.rb +1 -1
- data/lib/faker/games/fallout.rb +1 -1
- data/lib/faker/games/half_life.rb +1 -1
- data/lib/faker/games/heroes.rb +1 -1
- data/lib/faker/games/heroes_of_the_storm.rb +1 -1
- data/lib/faker/games/league_of_legends.rb +1 -1
- data/lib/faker/games/myst.rb +1 -1
- data/lib/faker/games/overwatch.rb +1 -1
- data/lib/faker/games/pokemon.rb +1 -1
- data/lib/faker/games/sonic_the_hedgehog.rb +1 -1
- data/lib/faker/games/super_smash_bros.rb +1 -1
- data/lib/faker/games/witcher.rb +1 -1
- data/lib/faker/games/world_of_warcraft.rb +1 -1
- data/lib/faker/games/zelda.rb +1 -1
- data/lib/faker/japanese_media/dragon_ball.rb +1 -1
- data/lib/faker/japanese_media/one_piece.rb +1 -1
- data/lib/faker/japanese_media/sword_art_online.rb +1 -1
- data/lib/faker/movies/back_to_the_future.rb +1 -1
- data/lib/faker/movies/ghostbusters.rb +1 -1
- data/lib/faker/movies/harry_potter.rb +1 -1
- data/lib/faker/movies/hitchhikers_guide_to_the_galaxy.rb +1 -1
- data/lib/faker/movies/hobbit.rb +1 -1
- data/lib/faker/movies/lebowski.rb +1 -1
- data/lib/faker/movies/lord_of_the_rings.rb +1 -1
- data/lib/faker/movies/princess_bride.rb +1 -1
- data/lib/faker/movies/star_wars.rb +2 -2
- data/lib/faker/movies/v_for_vendetta.rb +1 -1
- data/lib/faker/tv_shows/aqua_teen_hunger_force.rb +1 -1
- data/lib/faker/tv_shows/bojack_horseman.rb +1 -1
- data/lib/faker/tv_shows/breaking_bad.rb +1 -1
- data/lib/faker/tv_shows/buffy.rb +1 -1
- data/lib/faker/tv_shows/community.rb +1 -1
- data/lib/faker/tv_shows/dr_who.rb +1 -1
- data/lib/faker/tv_shows/dumb_and_dumber.rb +1 -1
- data/lib/faker/tv_shows/family_guy.rb +1 -1
- data/lib/faker/tv_shows/friends.rb +1 -1
- data/lib/faker/tv_shows/game_of_thrones.rb +1 -1
- data/lib/faker/tv_shows/hey_arnold.rb +1 -1
- data/lib/faker/tv_shows/how_i_met_your_mother.rb +1 -1
- data/lib/faker/tv_shows/michael_scott.rb +1 -1
- data/lib/faker/tv_shows/new_girl.rb +1 -1
- data/lib/faker/tv_shows/parks_and_rec.rb +1 -1
- data/lib/faker/tv_shows/rick_and_morty.rb +1 -1
- data/lib/faker/tv_shows/ru_paul.rb +1 -1
- data/lib/faker/tv_shows/seinfeld.rb +1 -1
- data/lib/faker/tv_shows/silicon_valley.rb +1 -1
- data/lib/faker/tv_shows/simpsons.rb +1 -1
- data/lib/faker/tv_shows/south_park.rb +1 -1
- data/lib/faker/tv_shows/star_trek.rb +1 -1
- data/lib/faker/tv_shows/stargate.rb +1 -1
- data/lib/faker/tv_shows/stranger_things.rb +1 -1
- data/lib/faker/tv_shows/the_expanse.rb +1 -1
- data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +1 -1
- data/lib/faker/tv_shows/the_it_crowd.rb +1 -1
- data/lib/faker/tv_shows/the_thick_of_it.rb +1 -1
- data/lib/faker/tv_shows/twin_peaks.rb +1 -1
- data/lib/faker/tv_shows/venture_bros.rb +1 -1
- data/lib/faker/version.rb +1 -1
- data/lib/locales/en-IND.yml +1 -1
- data/lib/locales/en.yml +4 -1
- data/lib/locales/en/address.yml +1 -4
- data/lib/locales/en/animal.yml +2 -2
- data/lib/locales/en/cannabis.yml +1 -0
- data/lib/locales/en/space.yml +1 -1
- data/lib/locales/en/super_smash_bros.yml +4 -0
- data/lib/locales/vi.yml +1 -1
- metadata +9 -17
- data/lib/faker/default/creature.rb +0 -6
- data/lib/faker/default/games.rb +0 -6
- data/lib/faker/default/japanese_media.rb +0 -6
- data/lib/faker/default/movies.rb +0 -6
- data/lib/faker/default/tv_shows.rb +0 -6
- data/lib/faker/deprecate/unreleased/football.rb +0 -35
- data/lib/faker/deprecate/unreleased/movies/grateful_dead.rb +0 -22
@@ -10,12 +10,12 @@ module Faker
|
|
10
10
|
|
11
11
|
def initialize(name: nil, email: nil)
|
12
12
|
@name = name || "#{Name.first_name} #{Name.last_name}"
|
13
|
-
@email = email || Internet.safe_email(self.name)
|
13
|
+
@email = email || Internet.safe_email(name: self.name)
|
14
14
|
@first_name, @last_name = self.name.split
|
15
15
|
end
|
16
16
|
|
17
17
|
class << self
|
18
|
-
def google(name: nil, email: nil, uid: Number.number(9))
|
18
|
+
def google(name: nil, email: nil, uid: Number.number(digits: 9).to_s)
|
19
19
|
auth = Omniauth.new(name: name, email: email)
|
20
20
|
{
|
21
21
|
provider: 'google_oauth2',
|
@@ -44,7 +44,7 @@ module Faker
|
|
44
44
|
profile: "https://plus.google.com/#{uid}",
|
45
45
|
picture: image,
|
46
46
|
gender: gender,
|
47
|
-
birthday: Date.backward(36_400).strftime('%Y-%m-%d'),
|
47
|
+
birthday: Date.backward(days: 36_400).strftime('%Y-%m-%d'),
|
48
48
|
local: 'en',
|
49
49
|
hd: "#{Company.name.downcase}.com"
|
50
50
|
},
|
@@ -52,7 +52,7 @@ module Faker
|
|
52
52
|
'iss' => 'accounts.google.com',
|
53
53
|
'at_hash' => Crypto.md5,
|
54
54
|
'email_verified' => true,
|
55
|
-
'sub' => Number.number(28).to_s,
|
55
|
+
'sub' => Number.number(digits: 28).to_s,
|
56
56
|
'azp' => 'APP_ID',
|
57
57
|
'email' => auth.email,
|
58
58
|
'aud' => 'APP_ID',
|
@@ -64,7 +64,7 @@ module Faker
|
|
64
64
|
}
|
65
65
|
end
|
66
66
|
|
67
|
-
def facebook(name: nil, email: nil, username: nil, uid: Number.number(7))
|
67
|
+
def facebook(name: nil, email: nil, username: nil, uid: Number.number(digits: 7).to_s)
|
68
68
|
auth = Omniauth.new(name: name, email: email)
|
69
69
|
username ||= "#{auth.first_name.downcase[0]}#{auth.last_name.downcase}"
|
70
70
|
{
|
@@ -92,7 +92,7 @@ module Faker
|
|
92
92
|
link: "http://www.facebook.com/#{username}",
|
93
93
|
username: username,
|
94
94
|
location: {
|
95
|
-
id: Number.number(9),
|
95
|
+
id: Number.number(digits: 9).to_s,
|
96
96
|
name: city_state
|
97
97
|
},
|
98
98
|
gender: gender,
|
@@ -106,7 +106,7 @@ module Faker
|
|
106
106
|
}
|
107
107
|
end
|
108
108
|
|
109
|
-
def twitter(name: nil, nickname: nil, uid: Number.number(6))
|
109
|
+
def twitter(name: nil, nickname: nil, uid: Number.number(digits: 6).to_s)
|
110
110
|
auth = Omniauth.new(name: name)
|
111
111
|
nickname ||= auth.name.downcase.delete(' ')
|
112
112
|
location = city_state
|
@@ -179,7 +179,7 @@ module Faker
|
|
179
179
|
}
|
180
180
|
end
|
181
181
|
|
182
|
-
def linkedin(name: nil, email: nil, uid: Number.number(6))
|
182
|
+
def linkedin(name: nil, email: nil, uid: Number.number(digits: 6).to_s)
|
183
183
|
auth = Omniauth.new(name: name, email: email)
|
184
184
|
first_name = auth.first_name.downcase
|
185
185
|
last_name = auth.last_name.downcase
|
@@ -242,7 +242,7 @@ module Faker
|
|
242
242
|
}
|
243
243
|
end
|
244
244
|
|
245
|
-
def github(name: nil, email: nil, uid: Number.number(8))
|
245
|
+
def github(name: nil, email: nil, uid: Number.number(digits: 8).to_s)
|
246
246
|
auth = Omniauth.new(name: name, email: email)
|
247
247
|
login = auth.name.downcase.tr(' ', '-')
|
248
248
|
html_url = "https://github.com/#{login}"
|
@@ -293,8 +293,8 @@ module Faker
|
|
293
293
|
public_gists: random_number_from_range(1..1000),
|
294
294
|
followers: random_number_from_range(1..1000),
|
295
295
|
following: random_number_from_range(1..1000),
|
296
|
-
created_at: Time.backward(36_400).iso8601,
|
297
|
-
updated_at: Time.backward(2).iso8601
|
296
|
+
created_at: Time.backward(days: 36_400).iso8601,
|
297
|
+
updated_at: Time.backward(days: 2).iso8601
|
298
298
|
}
|
299
299
|
}
|
300
300
|
}
|
@@ -40,7 +40,7 @@ module Faker
|
|
40
40
|
# US and Canada only
|
41
41
|
# Can be used for both extensions and last four digits of phone number.
|
42
42
|
# Since extensions can be of variable length, this method taks a length parameter
|
43
|
-
def subscriber_number(length
|
43
|
+
def subscriber_number(length: 4)
|
44
44
|
rand.to_s[2..(1 + length)]
|
45
45
|
end
|
46
46
|
|
@@ -5,7 +5,7 @@ module Faker
|
|
5
5
|
class << self
|
6
6
|
SUPPORTED_FORMATS = %w[png jpg gif jpeg].freeze
|
7
7
|
|
8
|
-
def image(size
|
8
|
+
def image(size: '300x300', format: 'png', background_color: nil, text_color: nil, text: nil)
|
9
9
|
background_color = generate_color if background_color == :random
|
10
10
|
text_color = generate_color if text_color == :random
|
11
11
|
|
data/lib/faker/default/source.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Faker
|
4
4
|
class Source < Base
|
5
5
|
class << self
|
6
|
-
def hello_world(lang
|
6
|
+
def hello_world(lang: :ruby)
|
7
7
|
fetch("source.hello_world.#{lang}")
|
8
8
|
end
|
9
9
|
|
@@ -12,7 +12,7 @@ module Faker
|
|
12
12
|
code.gsub('faker_string_to_print', str)
|
13
13
|
end
|
14
14
|
|
15
|
-
def print_1_to_10(lang
|
15
|
+
def print_1_to_10(lang: :ruby)
|
16
16
|
fetch("source.print_1_to_10.#{lang}")
|
17
17
|
end
|
18
18
|
end
|
data/lib/faker/default/space.rb
CHANGED
data/lib/faker/default/string.rb
CHANGED
data/lib/faker/default/stripe.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Faker
|
4
4
|
class Stripe < Base
|
5
5
|
class << self
|
6
|
-
def valid_card(card_type
|
6
|
+
def valid_card(card_type: nil)
|
7
7
|
valid_cards = translate('faker.stripe.valid_cards').keys
|
8
8
|
|
9
9
|
if card_type.nil?
|
@@ -18,7 +18,7 @@ module Faker
|
|
18
18
|
fetch('stripe.valid_cards.' + card_type)
|
19
19
|
end
|
20
20
|
|
21
|
-
def valid_token(card_type
|
21
|
+
def valid_token(card_type: nil)
|
22
22
|
valid_tokens = translate('faker.stripe.valid_tokens').keys
|
23
23
|
|
24
24
|
if card_type.nil?
|
@@ -33,7 +33,7 @@ module Faker
|
|
33
33
|
fetch('stripe.valid_tokens.' + card_type)
|
34
34
|
end
|
35
35
|
|
36
|
-
def invalid_card(card_error
|
36
|
+
def invalid_card(card_error: nil)
|
37
37
|
invalid_cards = translate('faker.stripe.invalid_cards').keys
|
38
38
|
|
39
39
|
if card_error.nil?
|
@@ -57,7 +57,7 @@ module Faker
|
|
57
57
|
rand_in_range(start_year, start_year + 5).to_s
|
58
58
|
end
|
59
59
|
|
60
|
-
def ccv(card_type
|
60
|
+
def ccv(card_type: nil)
|
61
61
|
(card_type.to_s == 'amex' ? rand_in_range(1000, 9999) : rand_in_range(100, 999)).to_s
|
62
62
|
end
|
63
63
|
end
|
data/lib/faker/default/time.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Faker
|
4
|
-
class Time <
|
4
|
+
class Time < Base
|
5
5
|
TIME_RANGES = {
|
6
6
|
all: (0..23),
|
7
7
|
day: (9..17),
|
@@ -13,17 +13,26 @@ module Faker
|
|
13
13
|
}.freeze
|
14
14
|
|
15
15
|
class << self
|
16
|
-
def between(from
|
17
|
-
|
16
|
+
def between(from:, to:, format: nil)
|
17
|
+
from = get_time_object(from)
|
18
|
+
to = get_time_object(to)
|
19
|
+
|
20
|
+
time = Faker::Base.rand_in_range(from, to)
|
21
|
+
time_with_format(time, format)
|
22
|
+
end
|
23
|
+
|
24
|
+
def between_dates(from:, to:, period: :all, format: nil)
|
25
|
+
date = Faker::Date.between(from: from, to: to)
|
26
|
+
time = date_with_random_time(date, period)
|
18
27
|
time_with_format(time, format)
|
19
28
|
end
|
20
29
|
|
21
|
-
def forward(days
|
22
|
-
time_with_format(date_with_random_time(
|
30
|
+
def forward(days: 365, period: :all, format: nil)
|
31
|
+
time_with_format(date_with_random_time(Faker::Date.forward(days: days), period), format)
|
23
32
|
end
|
24
33
|
|
25
|
-
def backward(days
|
26
|
-
time_with_format(date_with_random_time(
|
34
|
+
def backward(days: 365, period: :all, format: nil)
|
35
|
+
time_with_format(date_with_random_time(Faker::Date.backward(days: days), period), format)
|
27
36
|
end
|
28
37
|
|
29
38
|
private
|
@@ -33,7 +42,7 @@ module Faker
|
|
33
42
|
end
|
34
43
|
|
35
44
|
def time_with_format(time, format)
|
36
|
-
format.nil? ? time : I18n.
|
45
|
+
format.nil? ? time : I18n.localize(time, format: format)
|
37
46
|
end
|
38
47
|
|
39
48
|
def hours(period)
|
@@ -49,6 +58,12 @@ module Faker
|
|
49
58
|
def seconds
|
50
59
|
sample((0..59).to_a)
|
51
60
|
end
|
61
|
+
|
62
|
+
def get_time_object(time)
|
63
|
+
time = ::Time.parse(time) if time.is_a? String
|
64
|
+
time = time.to_time if time.respond_to?(:to_time)
|
65
|
+
time
|
66
|
+
end
|
52
67
|
end
|
53
68
|
end
|
54
69
|
end
|
@@ -5,49 +5,49 @@ module Faker
|
|
5
5
|
class << self
|
6
6
|
def user(include_status: true, include_email: false)
|
7
7
|
user_id = id
|
8
|
-
background_image_url = Faker::LoremPixel.image('600x400') # TODO: Make the dimensions change
|
9
|
-
profile_image_url = Faker::Avatar.image(user_id, '48x48')
|
8
|
+
background_image_url = Faker::LoremPixel.image(size: '600x400') # TODO: Make the dimensions change
|
9
|
+
profile_image_url = Faker::Avatar.image(slug: user_id, size: '48x48')
|
10
10
|
user = {
|
11
11
|
id: user_id,
|
12
12
|
id_str: user_id.to_s,
|
13
|
-
contributors_enabled: Faker::Boolean.boolean(0.1),
|
13
|
+
contributors_enabled: Faker::Boolean.boolean(true_ratio: 0.1),
|
14
14
|
created_at: created_at,
|
15
|
-
default_profile_image: Faker::Boolean.boolean(0.1),
|
16
|
-
default_profile: Faker::Boolean.boolean(0.1),
|
15
|
+
default_profile_image: Faker::Boolean.boolean(true_ratio: 0.1),
|
16
|
+
default_profile: Faker::Boolean.boolean(true_ratio: 0.1),
|
17
17
|
description: Faker::Lorem.sentence,
|
18
18
|
entities: user_entities,
|
19
|
-
favourites_count: Faker::Number.between(1, 100_000),
|
19
|
+
favourites_count: Faker::Number.between(to: 1, from: 100_000),
|
20
20
|
follow_request_sent: false,
|
21
|
-
followers_count: Faker::Number.between(1, 10_000_000),
|
21
|
+
followers_count: Faker::Number.between(to: 1, from: 10_000_000),
|
22
22
|
following: false,
|
23
|
-
friends_count: Faker::Number.between(1, 100_000),
|
24
|
-
geo_enabled: Faker::Boolean.boolean(0.1),
|
25
|
-
is_translation_enabled: Faker::Boolean.boolean(0.1),
|
26
|
-
is_translator: Faker::Boolean.boolean(0.1),
|
23
|
+
friends_count: Faker::Number.between(to: 1, from: 100_000),
|
24
|
+
geo_enabled: Faker::Boolean.boolean(true_ratio: 0.1),
|
25
|
+
is_translation_enabled: Faker::Boolean.boolean(true_ratio: 0.1),
|
26
|
+
is_translator: Faker::Boolean.boolean(true_ratio: 0.1),
|
27
27
|
lang: Faker::Address.country_code,
|
28
|
-
listed_count: Faker::Number.between(1, 1000),
|
28
|
+
listed_count: Faker::Number.between(to: 1, from: 1000),
|
29
29
|
location: "#{Faker::Address.city}, #{Faker::Address.state_abbr}, #{Faker::Address.country_code}",
|
30
30
|
name: Faker::Name.name,
|
31
31
|
notifications: false,
|
32
32
|
profile_background_color: Faker::Color.hex_color,
|
33
33
|
profile_background_image_url_https: background_image_url,
|
34
34
|
profile_background_image_url: background_image_url.sub('https://', 'http://'),
|
35
|
-
profile_background_tile: Faker::Boolean.boolean(0.1),
|
36
|
-
profile_banner_url: Faker::LoremPixel.image('1500x500'),
|
35
|
+
profile_background_tile: Faker::Boolean.boolean(true_ratio: 0.1),
|
36
|
+
profile_banner_url: Faker::LoremPixel.image(size: '1500x500'),
|
37
37
|
profile_image_url_https: profile_image_url,
|
38
38
|
profile_image_url: profile_image_url.sub('https://', 'http://'),
|
39
39
|
profile_link_color: Faker::Color.hex_color,
|
40
40
|
profile_sidebar_border_color: Faker::Color.hex_color,
|
41
41
|
profile_sidebar_fill_color: Faker::Color.hex_color,
|
42
42
|
profile_text_color: Faker::Color.hex_color,
|
43
|
-
profile_use_background_image: Faker::Boolean.boolean(0.4),
|
44
|
-
protected: Faker::Boolean.boolean(0.1),
|
43
|
+
profile_use_background_image: Faker::Boolean.boolean(true_ratio: 0.4),
|
44
|
+
protected: Faker::Boolean.boolean(true_ratio: 0.1),
|
45
45
|
screen_name: screen_name,
|
46
|
-
statuses_count: Faker::Number.between(1, 100_000),
|
46
|
+
statuses_count: Faker::Number.between(to: 1, from: 100_000),
|
47
47
|
time_zone: Faker::Address.time_zone,
|
48
|
-
url: Faker::Internet.url('example.com'),
|
48
|
+
url: Faker::Internet.url(host: 'example.com'),
|
49
49
|
utc_offset: utc_offset,
|
50
|
-
verified: Faker::Boolean.boolean(0.1)
|
50
|
+
verified: Faker::Boolean.boolean(true_ratio: 0.1)
|
51
51
|
}
|
52
52
|
user[:status] = Faker::Twitter.status(include_user: false) if include_status
|
53
53
|
user[:email] = Faker::Internet.safe_email if include_email
|
@@ -63,7 +63,7 @@ module Faker
|
|
63
63
|
coordinates: nil,
|
64
64
|
created_at: created_at,
|
65
65
|
entities: status_entities(include_photo: include_photo),
|
66
|
-
favorite_count: Faker::Number.between(1, 10_000),
|
66
|
+
favorite_count: Faker::Number.between(to: 1, from: 10_000),
|
67
67
|
favorited: false,
|
68
68
|
geo: nil,
|
69
69
|
in_reply_to_screen_name: nil,
|
@@ -74,11 +74,11 @@ module Faker
|
|
74
74
|
lang: Faker::Address.country_code,
|
75
75
|
nil: nil,
|
76
76
|
place: nil,
|
77
|
-
possibly_sensitive: Faker::Boolean.boolean(0.1),
|
78
|
-
retweet_count: Faker::Number.between(1, 10_000),
|
77
|
+
possibly_sensitive: Faker::Boolean.boolean(true_ratio: 0.1),
|
78
|
+
retweet_count: Faker::Number.between(to: 1, from: 10_000),
|
79
79
|
retweeted_status: nil,
|
80
80
|
retweeted: false,
|
81
|
-
source: "<a href=\"#{Faker::Internet.url('example.com')}\" rel=\"nofollow\">#{Faker::Company.name}</a>",
|
81
|
+
source: "<a href=\"#{Faker::Internet.url(host: 'example.com')}\" rel=\"nofollow\">#{Faker::Company.name}</a>",
|
82
82
|
text: Faker::Lorem.sentence,
|
83
83
|
truncated: false
|
84
84
|
}
|
@@ -88,21 +88,21 @@ module Faker
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def screen_name
|
91
|
-
Faker::Internet.username(nil, ['_'])[0...20]
|
91
|
+
Faker::Internet.username(specifier: nil, separators: ['_'])[0...20]
|
92
92
|
end
|
93
93
|
|
94
94
|
private
|
95
95
|
|
96
96
|
def id
|
97
|
-
Faker::Number.between(1, 9_223_372_036_854_775_807)
|
97
|
+
Faker::Number.between(from: 1, to: 9_223_372_036_854_775_807)
|
98
98
|
end
|
99
99
|
|
100
100
|
def created_at
|
101
|
-
Faker::Date.between('2006-03-21', ::Date.today).strftime('%a %b %d %H:%M:%S %z %Y')
|
101
|
+
Faker::Date.between(from: '2006-03-21', to: ::Date.today).strftime('%a %b %d %H:%M:%S %z %Y')
|
102
102
|
end
|
103
103
|
|
104
104
|
def utc_offset
|
105
|
-
Faker::Number.between(-43_200, 50_400)
|
105
|
+
Faker::Number.between(to: -43_200, from: 50_400)
|
106
106
|
end
|
107
107
|
|
108
108
|
def user_entities
|
@@ -130,7 +130,7 @@ module Faker
|
|
130
130
|
def photo_entity
|
131
131
|
# TODO: Dynamic image sizes
|
132
132
|
# TODO: Return accurate indices
|
133
|
-
media_url = Faker::LoremPixel.image('1064x600')
|
133
|
+
media_url = Faker::LoremPixel.image(size: '1064x600')
|
134
134
|
media_id = id
|
135
135
|
{
|
136
136
|
id: media_id,
|
@@ -141,9 +141,9 @@ module Faker
|
|
141
141
|
],
|
142
142
|
media_url: media_url.sub('https://', 'http://'),
|
143
143
|
media_url_https: media_url,
|
144
|
-
url: Faker::Internet.url('example.com'),
|
144
|
+
url: Faker::Internet.url(host: 'example.com'),
|
145
145
|
display_url: 'example.com',
|
146
|
-
expanded_url: Faker::Internet.url('example.com'),
|
146
|
+
expanded_url: Faker::Internet.url(host: 'example.com'),
|
147
147
|
type: 'photo',
|
148
148
|
sizes: {
|
149
149
|
medium: {
|
data/lib/faker/default/types.rb
CHANGED
@@ -7,7 +7,7 @@ module Faker
|
|
7
7
|
COMPLEX_TYPES = %i[hash array].freeze
|
8
8
|
|
9
9
|
class << self
|
10
|
-
def rb_string(words
|
10
|
+
def rb_string(words: 1)
|
11
11
|
resolved_num = resolve(words)
|
12
12
|
word_list =
|
13
13
|
translate('faker.lorem.words')
|
@@ -20,23 +20,23 @@ module Faker
|
|
20
20
|
sample(CHARACTERS)
|
21
21
|
end
|
22
22
|
|
23
|
-
def rb_integer(from
|
23
|
+
def rb_integer(from: 0, to: 100)
|
24
24
|
rand(from..to).to_i
|
25
25
|
end
|
26
26
|
|
27
|
-
def rb_hash(
|
27
|
+
def rb_hash(number: 1, type: random_type)
|
28
28
|
{}.tap do |hsh|
|
29
|
-
Lorem.words(
|
29
|
+
Lorem.words(number: number * 2).uniq.first(number).each do |s|
|
30
30
|
hsh.merge!(s.to_sym => type)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
def complex_rb_hash(
|
36
|
-
rb_hash(
|
35
|
+
def complex_rb_hash(number: 1)
|
36
|
+
rb_hash(number: number, type: random_complex_type)
|
37
37
|
end
|
38
38
|
|
39
|
-
def rb_array(len
|
39
|
+
def rb_array(len: 1)
|
40
40
|
[].tap do |ar|
|
41
41
|
len.times do
|
42
42
|
ar.push random_type
|
@@ -26,7 +26,7 @@ module Faker
|
|
26
26
|
fetch('vehicle.makes')
|
27
27
|
end
|
28
28
|
|
29
|
-
def model(make_of_model
|
29
|
+
def model(make_of_model: '')
|
30
30
|
return fetch("vehicle.models_by_make.#{make}") if make_of_model.empty?
|
31
31
|
|
32
32
|
fetch("vehicle.models_by_make.#{make_of_model}")
|
@@ -35,7 +35,7 @@ module Faker
|
|
35
35
|
def make_and_model
|
36
36
|
m = make
|
37
37
|
|
38
|
-
"#{m} #{model(m)}"
|
38
|
+
"#{m} #{model(make_of_model: m)}"
|
39
39
|
end
|
40
40
|
|
41
41
|
def style
|
@@ -82,16 +82,16 @@ module Faker
|
|
82
82
|
alias door_count doors
|
83
83
|
|
84
84
|
def year
|
85
|
-
Faker::Time.backward(rand_in_range(365, 5475), :all, '%Y').to_i
|
85
|
+
Faker::Time.backward(days: rand_in_range(365, 5475), period: :all, format: '%Y').to_i
|
86
86
|
end
|
87
87
|
|
88
|
-
def mileage(min
|
88
|
+
def mileage(min: MILEAGE_MIN, max: MILEAGE_MAX)
|
89
89
|
rand_in_range(min, max)
|
90
90
|
end
|
91
91
|
|
92
92
|
alias kilometrage mileage
|
93
93
|
|
94
|
-
def license_plate(state_abreviation
|
94
|
+
def license_plate(state_abreviation: '')
|
95
95
|
return regexify(bothify(fetch('vehicle.license_plate'))) if state_abreviation.empty?
|
96
96
|
|
97
97
|
key = 'vehicle.license_plate_by_state.' + state_abreviation
|