faker 2.2.2 → 2.7.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +135 -0
- data/README.md +5 -2
- data/lib/faker/blockchain/aeternity.rb +70 -0
- data/lib/faker/blockchain/bitcoin.rb +26 -0
- data/lib/faker/blockchain/ethereum.rb +10 -0
- data/lib/faker/blockchain/tezos.rb +56 -0
- data/lib/faker/books/book.rb +36 -0
- data/lib/faker/books/culture_series.rb +49 -0
- data/lib/faker/books/dune.rb +56 -3
- data/lib/faker/books/lovecraft.rb +172 -0
- data/lib/faker/creature/animal.rb +9 -0
- data/lib/faker/creature/cat.rb +27 -0
- data/lib/faker/creature/dog.rb +72 -0
- data/lib/faker/creature/horse.rb +18 -0
- data/lib/faker/default/alphanumeric.rb +23 -6
- data/lib/faker/default/app.rb +46 -0
- data/lib/faker/default/appliance.rb +18 -0
- data/lib/faker/default/artist.rb +9 -0
- data/lib/faker/default/avatar.rb +32 -0
- data/lib/faker/default/boolean.rb +12 -1
- data/lib/faker/default/chuck_norris.rb +1 -1
- data/lib/faker/default/date.rb +83 -2
- data/lib/faker/default/dessert.rb +27 -0
- data/lib/faker/default/device.rb +54 -0
- data/lib/faker/default/driving_licence.rb +2 -2
- data/lib/faker/default/electrical_components.rb +27 -0
- data/lib/faker/default/gender.rb +18 -0
- data/lib/faker/default/greek_philosophers.rb +18 -0
- data/lib/faker/default/hacker.rb +59 -1
- data/lib/faker/default/house.rb +18 -0
- data/lib/faker/default/id_number.rb +29 -0
- data/lib/faker/default/industry_segments.rb +36 -0
- data/lib/faker/default/internet.rb +19 -11
- data/lib/faker/default/lorem.rb +8 -7
- data/lib/faker/default/marketing.rb +9 -0
- data/lib/faker/default/military.rb +45 -0
- data/lib/faker/default/nation.rb +48 -5
- data/lib/faker/default/nato_phonetic_alphabet.rb +9 -0
- data/lib/faker/default/number.rb +124 -0
- data/lib/faker/default/omniauth.rb +42 -0
- data/lib/faker/default/programming_language.rb +18 -0
- data/lib/faker/default/restaurant.rb +54 -2
- data/lib/faker/default/science.rb +27 -0
- data/lib/faker/default/source.rb +43 -2
- data/lib/faker/default/subscription.rb +45 -0
- data/lib/faker/default/superhero.rb +45 -0
- data/lib/faker/default/time.rb +85 -8
- data/lib/faker/default/world_cup.rb +50 -0
- data/lib/faker/games/dota.rb +47 -0
- data/lib/faker/games/elder_scrolls.rb +72 -0
- data/lib/faker/games/fallout.rb +37 -0
- data/lib/faker/games/game.rb +27 -0
- data/lib/faker/games/half_life.rb +27 -0
- data/lib/faker/games/heroes.rb +27 -0
- data/lib/faker/games/heroes_of_the_storm.rb +36 -0
- data/lib/faker/games/league_of_legends.rb +54 -0
- data/lib/faker/games/myst.rb +45 -0
- data/lib/faker/games/overwatch.rb +27 -0
- data/lib/faker/games/pokemon.rb +27 -0
- data/lib/faker/games/sonic_the_hedgehog.rb +27 -0
- data/lib/faker/games/super_smash_bros.rb +18 -0
- data/lib/faker/games/witcher.rb +54 -0
- data/lib/faker/games/world_of_warcraft.rb +18 -0
- data/lib/faker/games/zelda.rb +37 -1
- data/lib/faker/japanese_media/dragon_ball.rb +9 -0
- data/lib/faker/japanese_media/one_piece.rb +54 -0
- data/lib/faker/japanese_media/sword_art_online.rb +36 -0
- data/lib/faker/movies/back_to_the_future.rb +28 -0
- data/lib/faker/movies/ghostbusters.rb +28 -0
- data/lib/faker/movies/harry_potter.rb +54 -0
- data/lib/faker/movies/hitchhikers_guide_to_the_galaxy.rb +69 -0
- data/lib/faker/movies/hobbit.rb +37 -0
- data/lib/faker/movies/lebowski.rb +27 -0
- data/lib/faker/movies/lord_of_the_rings.rb +28 -0
- data/lib/faker/movies/movie.rb +9 -0
- data/lib/faker/movies/princess_bride.rb +19 -0
- data/lib/faker/movies/star_wars.rb +94 -0
- data/lib/faker/movies/v_for_vendetta.rb +29 -0
- data/lib/faker/music/grateful_dead.rb +18 -0
- data/lib/faker/music/phish.rb +9 -0
- data/lib/faker/music/rock_band.rb +9 -0
- data/lib/faker/music/umphreys_mcgee.rb +9 -0
- data/lib/faker/sports/basketball.rb +36 -0
- data/lib/faker/sports/football.rb +45 -0
- data/lib/faker/tv_shows/aqua_teen_hunger_force.rb +9 -0
- data/lib/faker/tv_shows/bojack_horseman.rb +28 -0
- data/lib/faker/tv_shows/breaking_bad.rb +18 -0
- data/lib/faker/tv_shows/buffy.rb +45 -0
- data/lib/faker/tv_shows/community.rb +19 -0
- data/lib/faker/tv_shows/dr_who.rb +78 -2
- data/lib/faker/tv_shows/dumb_and_dumber.rb +28 -0
- data/lib/faker/tv_shows/family_guy.rb +28 -0
- data/lib/faker/tv_shows/friends.rb +27 -0
- data/lib/faker/tv_shows/game_of_thrones.rb +46 -0
- data/lib/faker/tv_shows/hey_arnold.rb +27 -0
- data/lib/faker/tv_shows/how_i_met_your_mother.rb +37 -0
- data/lib/faker/tv_shows/michael_scott.rb +13 -0
- data/lib/faker/tv_shows/new_girl.rb +19 -0
- data/lib/faker/tv_shows/parks_and_rec.rb +18 -0
- data/lib/faker/tv_shows/rick_and_morty.rb +28 -0
- data/lib/faker/tv_shows/ru_paul.rb +18 -0
- data/lib/faker/tv_shows/seinfeld.rb +28 -0
- data/lib/faker/tv_shows/silicon_valley.rb +75 -0
- data/lib/faker/tv_shows/simpsons.rb +28 -0
- data/lib/faker/tv_shows/south_park.rb +19 -0
- data/lib/faker/tv_shows/star_trek.rb +36 -0
- data/lib/faker/tv_shows/stargate.rb +28 -0
- data/lib/faker/tv_shows/stranger_things.rb +19 -0
- data/lib/faker/tv_shows/the_expanse.rb +36 -0
- data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +28 -0
- data/lib/faker/tv_shows/the_it_crowd.rb +37 -0
- data/lib/faker/tv_shows/the_thick_of_it.rb +28 -0
- data/lib/faker/tv_shows/twin_peaks.rb +28 -0
- data/lib/faker/tv_shows/venture_bros.rb +38 -0
- data/lib/faker/version.rb +1 -1
- data/lib/locales/en-CA.yml +2 -1
- data/lib/locales/en-TH.yml +360 -0
- data/lib/locales/en/color.yml +1 -1
- data/lib/locales/en/dr_who.yml +1 -1
- data/lib/locales/en/science.yml +1 -1
- data/lib/locales/en/super_smash_bros.yml +1 -0
- data/lib/locales/fr-CA.yml +1 -1
- data/lib/locales/ja.yml +12 -9
- data/lib/locales/th.yml +380 -0
- metadata +41 -16
|
@@ -341,6 +341,48 @@ module Faker
|
|
|
341
341
|
}
|
|
342
342
|
end
|
|
343
343
|
|
|
344
|
+
##
|
|
345
|
+
# Generate a mock Omniauth response from Apple
|
|
346
|
+
#
|
|
347
|
+
# @param name [String] A specific name to return in the response
|
|
348
|
+
# @param email [String] A specific email to return in the response
|
|
349
|
+
# @param uid [String] A specific UID to return in the response
|
|
350
|
+
#
|
|
351
|
+
# @return [Hash] An auth hash in the format provided by omniauth-apple
|
|
352
|
+
def apple(name: nil, email: nil, uid: nil)
|
|
353
|
+
uid ||= "#{Number.number(digits: 6)}.#{Number.hexadecimal(digits: 32)}.#{Number.number(digits: 4)}"
|
|
354
|
+
auth = Omniauth.new(name: name, email: email)
|
|
355
|
+
{
|
|
356
|
+
provider: 'apple',
|
|
357
|
+
uid: uid,
|
|
358
|
+
info: {
|
|
359
|
+
sub: uid,
|
|
360
|
+
email: auth.email,
|
|
361
|
+
first_name: auth.first_name,
|
|
362
|
+
last_name: auth.last_name
|
|
363
|
+
},
|
|
364
|
+
credentials: {
|
|
365
|
+
token: Crypto.md5,
|
|
366
|
+
refresh_token: Crypto.md5,
|
|
367
|
+
expires_at: Time.forward.to_i,
|
|
368
|
+
expires: true
|
|
369
|
+
},
|
|
370
|
+
extra: {
|
|
371
|
+
raw_info: {
|
|
372
|
+
iss: 'https://appleid.apple.com',
|
|
373
|
+
aud: 'CLIENT_ID',
|
|
374
|
+
exp: Time.forward.to_i,
|
|
375
|
+
iat: Time.forward.to_i,
|
|
376
|
+
sub: uid,
|
|
377
|
+
at_hash: Crypto.md5,
|
|
378
|
+
auth_time: Time.forward.to_i,
|
|
379
|
+
email: auth.email,
|
|
380
|
+
email_verified: true
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
end
|
|
385
|
+
|
|
344
386
|
private
|
|
345
387
|
|
|
346
388
|
def gender
|
|
@@ -3,10 +3,28 @@
|
|
|
3
3
|
module Faker
|
|
4
4
|
class ProgrammingLanguage < Base
|
|
5
5
|
class << self
|
|
6
|
+
##
|
|
7
|
+
# Produces the name of a programming language.
|
|
8
|
+
#
|
|
9
|
+
# @return [String]
|
|
10
|
+
#
|
|
11
|
+
# @example
|
|
12
|
+
# Faker::ProgrammingLanguage.name #=> "Ruby"
|
|
13
|
+
#
|
|
14
|
+
# @faker.version 1.8.5
|
|
6
15
|
def name
|
|
7
16
|
fetch('programming_language.name')
|
|
8
17
|
end
|
|
9
18
|
|
|
19
|
+
##
|
|
20
|
+
# Produces the name of a programming language's creator.
|
|
21
|
+
#
|
|
22
|
+
# @return [String]
|
|
23
|
+
#
|
|
24
|
+
# @example
|
|
25
|
+
# Faker::ProgrammingLanguage.creator #=> "Yukihiro Matsumoto"
|
|
26
|
+
#
|
|
27
|
+
# @faker.version 1.8.5
|
|
10
28
|
def creator
|
|
11
29
|
fetch('programming_language.creator')
|
|
12
30
|
end
|
|
@@ -4,8 +4,60 @@ module Faker
|
|
|
4
4
|
class Restaurant < Base
|
|
5
5
|
flexible :restaurant
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
class << self
|
|
8
|
+
##
|
|
9
|
+
# Produces the name of a restaurant.
|
|
10
|
+
#
|
|
11
|
+
# @return [String]
|
|
12
|
+
#
|
|
13
|
+
# @example
|
|
14
|
+
# Faker::Restaurant.name #=> "Curry King"
|
|
15
|
+
#
|
|
16
|
+
# @faker.version 1.9.2
|
|
17
|
+
def name
|
|
18
|
+
bothify(parse('restaurant.name'))
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
##
|
|
22
|
+
# Produces a type of restaurant.
|
|
23
|
+
#
|
|
24
|
+
# @return [String]
|
|
25
|
+
#
|
|
26
|
+
# @example
|
|
27
|
+
# Faker::Restaurant.type #=> "Comfort Food"
|
|
28
|
+
#
|
|
29
|
+
# @faker.version 1.9.2
|
|
30
|
+
def type
|
|
31
|
+
fetch('restaurant.type')
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
##
|
|
35
|
+
# Produces a description of a restaurant.
|
|
36
|
+
#
|
|
37
|
+
# @return [String]
|
|
38
|
+
#
|
|
39
|
+
# @example
|
|
40
|
+
# Faker::Restaurant.description
|
|
41
|
+
# #=> "We are committed to using the finest ingredients in our recipes. No food leaves our kitchen that we ourselves would not eat."
|
|
42
|
+
#
|
|
43
|
+
# @faker.version 1.9.2
|
|
44
|
+
def description
|
|
45
|
+
fetch('restaurant.description')
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
##
|
|
49
|
+
# Produces a review for a restaurant.
|
|
50
|
+
#
|
|
51
|
+
# @return [String]
|
|
52
|
+
#
|
|
53
|
+
# @example
|
|
54
|
+
# Faker::Restaurant.review
|
|
55
|
+
# #=> "Brand new. Great design. Odd to hear pop music in a Mexican establishment. Music is a bit loud. It should be background."
|
|
56
|
+
#
|
|
57
|
+
# @faker.version 1.9.2
|
|
58
|
+
def review
|
|
59
|
+
fetch('restaurant.review')
|
|
60
|
+
end
|
|
9
61
|
end
|
|
10
62
|
end
|
|
11
63
|
end
|
|
@@ -3,14 +3,41 @@
|
|
|
3
3
|
module Faker
|
|
4
4
|
class Science < Base
|
|
5
5
|
class << self
|
|
6
|
+
##
|
|
7
|
+
# Produces the name of a element.
|
|
8
|
+
#
|
|
9
|
+
# @return [String]
|
|
10
|
+
#
|
|
11
|
+
# @example
|
|
12
|
+
# Faker::Science.element #=> "Carbon"
|
|
13
|
+
#
|
|
14
|
+
# @faker.version 1.8.5
|
|
6
15
|
def element
|
|
7
16
|
fetch('science.element')
|
|
8
17
|
end
|
|
9
18
|
|
|
19
|
+
##
|
|
20
|
+
# Produces the symbol of an element.
|
|
21
|
+
#
|
|
22
|
+
# @return [String]
|
|
23
|
+
#
|
|
24
|
+
# @example
|
|
25
|
+
# Faker::Science.element_symbol #=> "Pb"
|
|
26
|
+
#
|
|
27
|
+
# @faker.version 1.9.0
|
|
10
28
|
def element_symbol
|
|
11
29
|
fetch('science.element_symbol')
|
|
12
30
|
end
|
|
13
31
|
|
|
32
|
+
##
|
|
33
|
+
# Produces the name of a scientist.
|
|
34
|
+
#
|
|
35
|
+
# @return [String]
|
|
36
|
+
#
|
|
37
|
+
# @example
|
|
38
|
+
# Faker::Science.scientist #=> "Isaac Newton"
|
|
39
|
+
#
|
|
40
|
+
# @faker.version 1.8.5
|
|
14
41
|
def scientist
|
|
15
42
|
fetch('science.scientist')
|
|
16
43
|
end
|
data/lib/faker/default/source.rb
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
3
3
|
module Faker
|
|
4
4
|
class Source < Base
|
|
5
5
|
class << self
|
|
6
|
+
##
|
|
7
|
+
# Produces source code for Hello World in a given language.
|
|
8
|
+
#
|
|
9
|
+
# @param lang [Symbol] The programming language to use
|
|
10
|
+
# @return [String]
|
|
11
|
+
#
|
|
12
|
+
# @example
|
|
13
|
+
# Faker::Source.hello_world #=> "puts 'Hello World!'"
|
|
14
|
+
#
|
|
15
|
+
# @example
|
|
16
|
+
# Faker::Source.hello_world(lang: :javascript)
|
|
17
|
+
# #=> "alert('Hello World!');"
|
|
18
|
+
#
|
|
19
|
+
# @faker.version 1.9.0
|
|
6
20
|
def hello_world(legacy_lang = NOT_GIVEN, lang: :ruby)
|
|
7
21
|
warn_for_deprecated_arguments do |keywords|
|
|
8
22
|
keywords << :lang if legacy_lang != NOT_GIVEN
|
|
@@ -11,6 +25,20 @@ module Faker
|
|
|
11
25
|
fetch("source.hello_world.#{lang}")
|
|
12
26
|
end
|
|
13
27
|
|
|
28
|
+
##
|
|
29
|
+
# Produces source code for printing a string in a given language.
|
|
30
|
+
#
|
|
31
|
+
# @param str [String] The string to print
|
|
32
|
+
# @param lang [Symbol] The programming language to use
|
|
33
|
+
# @return [String]
|
|
34
|
+
#
|
|
35
|
+
# @example
|
|
36
|
+
# Faker::Source.print #=> "puts 'faker_string_to_print'"
|
|
37
|
+
# @example
|
|
38
|
+
# Faker::Source.print(str: 'foo bar', lang: :javascript)
|
|
39
|
+
# #=> "console.log('foo bar');"
|
|
40
|
+
#
|
|
41
|
+
# @faker.version 1.9.0
|
|
14
42
|
def print(legacy_str = NOT_GIVEN, legacy_lang = NOT_GIVEN, str: 'some string', lang: :ruby)
|
|
15
43
|
warn_for_deprecated_arguments do |keywords|
|
|
16
44
|
keywords << :str if legacy_str != NOT_GIVEN
|
|
@@ -18,16 +46,29 @@ module Faker
|
|
|
18
46
|
warn_for_deprecated_arguments do |keywords|
|
|
19
47
|
keywords << :lang if legacy_lang != NOT_GIVEN
|
|
20
48
|
end
|
|
21
|
-
|
|
22
49
|
code = fetch("source.print.#{lang}")
|
|
23
50
|
code.gsub('faker_string_to_print', str)
|
|
24
51
|
end
|
|
25
52
|
|
|
53
|
+
##
|
|
54
|
+
# Produces source code for printing 1 through 10 in a given language.
|
|
55
|
+
#
|
|
56
|
+
# @param lang [Symbol] The programming language to use
|
|
57
|
+
# @return [String]
|
|
58
|
+
#
|
|
59
|
+
# @example
|
|
60
|
+
# Faker::Source.print_1_to_10 #=> "(1..10).each { |i| puts i }"
|
|
61
|
+
# @example
|
|
62
|
+
# Faker::Source.print_1_to_10(lang: :javascript)
|
|
63
|
+
# # => "for (let i=0; i<10; i++) {
|
|
64
|
+
# # console.log(i);
|
|
65
|
+
# # }"
|
|
66
|
+
#
|
|
67
|
+
# @faker.version 1.9.0
|
|
26
68
|
def print_1_to_10(legacy_lang = NOT_GIVEN, lang: :ruby)
|
|
27
69
|
warn_for_deprecated_arguments do |keywords|
|
|
28
70
|
keywords << :lang if legacy_lang != NOT_GIVEN
|
|
29
71
|
end
|
|
30
|
-
|
|
31
72
|
fetch("source.print_1_to_10.#{lang}")
|
|
32
73
|
end
|
|
33
74
|
end
|
|
@@ -2,22 +2,67 @@
|
|
|
2
2
|
|
|
3
3
|
module Faker
|
|
4
4
|
class Subscription < Base
|
|
5
|
+
##
|
|
6
|
+
# Produces the name of a subscription plan.
|
|
7
|
+
#
|
|
8
|
+
# @return [String]
|
|
9
|
+
#
|
|
10
|
+
# @example
|
|
11
|
+
# Faker::Subscription.plan #=> "Platinum"
|
|
12
|
+
#
|
|
13
|
+
# @faker.version 1.9.2
|
|
5
14
|
def self.plan
|
|
6
15
|
fetch('subscription.plans')
|
|
7
16
|
end
|
|
8
17
|
|
|
18
|
+
##
|
|
19
|
+
# Produces a subscription status.
|
|
20
|
+
#
|
|
21
|
+
# @return [String]
|
|
22
|
+
#
|
|
23
|
+
# @example
|
|
24
|
+
# Faker::Subscription.status #=> "Active"
|
|
25
|
+
#
|
|
26
|
+
# @faker.version 1.9.2
|
|
9
27
|
def self.status
|
|
10
28
|
fetch('subscription.statuses')
|
|
11
29
|
end
|
|
12
30
|
|
|
31
|
+
##
|
|
32
|
+
# Produces the name of a payment method.
|
|
33
|
+
#
|
|
34
|
+
# @return [String]
|
|
35
|
+
#
|
|
36
|
+
# @example
|
|
37
|
+
# Faker::Subscription.payment_method #=> "PayPal"
|
|
38
|
+
#
|
|
39
|
+
# @faker.version 1.9.2
|
|
13
40
|
def self.payment_method
|
|
14
41
|
fetch('subscription.payment_methods')
|
|
15
42
|
end
|
|
16
43
|
|
|
44
|
+
##
|
|
45
|
+
# Produces the name of a subscription term.
|
|
46
|
+
#
|
|
47
|
+
# @return [String]
|
|
48
|
+
#
|
|
49
|
+
# @example
|
|
50
|
+
# Faker::Subscription.subscription_term #=> "Annual"
|
|
51
|
+
#
|
|
52
|
+
# @faker.version 1.9.2
|
|
17
53
|
def self.subscription_term
|
|
18
54
|
fetch('subscription.subscription_terms')
|
|
19
55
|
end
|
|
20
56
|
|
|
57
|
+
##
|
|
58
|
+
# Produces the name of a payment term.
|
|
59
|
+
#
|
|
60
|
+
# @return [String]
|
|
61
|
+
#
|
|
62
|
+
# @example
|
|
63
|
+
# Faker::Subscription.payment_term #=> "Monthly"
|
|
64
|
+
#
|
|
65
|
+
# @faker.version 1.9.2
|
|
21
66
|
def self.payment_term
|
|
22
67
|
fetch('subscription.payment_terms')
|
|
23
68
|
end
|
|
@@ -3,22 +3,67 @@
|
|
|
3
3
|
module Faker
|
|
4
4
|
class Superhero < Base
|
|
5
5
|
class << self
|
|
6
|
+
##
|
|
7
|
+
# Produces a superpower.
|
|
8
|
+
#
|
|
9
|
+
# @return [String]
|
|
10
|
+
#
|
|
11
|
+
# @example
|
|
12
|
+
# Faker::Superhero.power #=> "Photokinesis"
|
|
13
|
+
#
|
|
14
|
+
# @faker.version 1.6.2
|
|
6
15
|
def power
|
|
7
16
|
fetch('superhero.power')
|
|
8
17
|
end
|
|
9
18
|
|
|
19
|
+
##
|
|
20
|
+
# Produces a superhero name prefix.
|
|
21
|
+
#
|
|
22
|
+
# @return [String]
|
|
23
|
+
#
|
|
24
|
+
# @example
|
|
25
|
+
# Faker::Superhero.prefix #=> "the Fated"
|
|
26
|
+
#
|
|
27
|
+
# @faker.version 1.6.2
|
|
10
28
|
def prefix
|
|
11
29
|
fetch('superhero.prefix')
|
|
12
30
|
end
|
|
13
31
|
|
|
32
|
+
##
|
|
33
|
+
# Produces a superhero name suffix.
|
|
34
|
+
#
|
|
35
|
+
# @return [String]
|
|
36
|
+
#
|
|
37
|
+
# @example
|
|
38
|
+
# Faker::Superhero.suffix #=> "Captain"
|
|
39
|
+
#
|
|
40
|
+
# @faker.version 1.6.2
|
|
14
41
|
def suffix
|
|
15
42
|
fetch('superhero.suffix')
|
|
16
43
|
end
|
|
17
44
|
|
|
45
|
+
##
|
|
46
|
+
# Produces a superhero descriptor.
|
|
47
|
+
#
|
|
48
|
+
# @return [String]
|
|
49
|
+
#
|
|
50
|
+
# @example
|
|
51
|
+
# Faker::Superhero.descriptor #=> "Bizarro"
|
|
52
|
+
#
|
|
53
|
+
# @faker.version 1.6.2
|
|
18
54
|
def descriptor
|
|
19
55
|
fetch('superhero.descriptor')
|
|
20
56
|
end
|
|
21
57
|
|
|
58
|
+
##
|
|
59
|
+
# Produces a random superhero name.
|
|
60
|
+
#
|
|
61
|
+
# @return [String]
|
|
62
|
+
#
|
|
63
|
+
# @example
|
|
64
|
+
# Faker::Superhero.name #=> "Magnificent Shatterstar"
|
|
65
|
+
#
|
|
66
|
+
# @faker.version 1.6.2
|
|
22
67
|
def name
|
|
23
68
|
parse('superhero.name')
|
|
24
69
|
end
|
data/lib/faker/default/time.rb
CHANGED
|
@@ -14,8 +14,31 @@ module Faker
|
|
|
14
14
|
|
|
15
15
|
class << self
|
|
16
16
|
# rubocop:disable Metrics/ParameterLists
|
|
17
|
+
# rubocop:disable Style/AsciiComments
|
|
18
|
+
|
|
19
|
+
##
|
|
20
|
+
# Produce a random time between two times.
|
|
21
|
+
#
|
|
22
|
+
# @param from [Time, Date, DateTime] The start of the usable time range.
|
|
23
|
+
# @param to [Time, Date, DateTime] The end of the usable time range.
|
|
24
|
+
# @param format [Symbol] The name of a DateTime format to use.
|
|
25
|
+
# @return [Time]
|
|
26
|
+
#
|
|
27
|
+
# @example
|
|
28
|
+
# # Random Stringified time between two times, formatted to the specified I18n format
|
|
29
|
+
# # (Examples are from a Rails console with rails-i18n 5.1.1 defaults loaded)
|
|
30
|
+
# I18n.locale = 'en-US'
|
|
31
|
+
# Faker::Time.between(from: DateTime.now - 1, to: DateTime.now, format: :default) #=> "Tue, 16 Oct 2018 10:48:27 AM -05:00"
|
|
32
|
+
# Faker::Time.between(from: DateTime.now - 1, to: DateTime.now, format: :short) #=> "15 Oct 10:48 AM"
|
|
33
|
+
# Faker::Time.between(from: DateTime.now - 1, to: DateTime.now, format: :long) #=> "October 15, 2018 10:48 AM"
|
|
34
|
+
#
|
|
35
|
+
# I18n.locale = 'ja'
|
|
36
|
+
# Faker::Time.between(from: DateTime.now - 1, to: DateTime.now, format: :default) #=> "2018/10/15 10:48:27"
|
|
37
|
+
# Faker::Time.between(from: DateTime.now - 1, to: DateTime.now, format: :short) #=> "18/10/15 10:48"
|
|
38
|
+
# Faker::Time.between(from: DateTime.now - 1, to: DateTime.now, format: :long) #=> "2018年10月16日(火) 10時48分27秒 -0500"
|
|
39
|
+
#
|
|
40
|
+
# @faker.version 1.5.0
|
|
17
41
|
def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_format = NOT_GIVEN, from:, to:, format: nil)
|
|
18
|
-
# rubocop:enable Metrics/ParameterLists
|
|
19
42
|
warn_for_deprecated_arguments do |keywords|
|
|
20
43
|
keywords << :from if legacy_from != NOT_GIVEN
|
|
21
44
|
keywords << :to if legacy_to != NOT_GIVEN
|
|
@@ -28,10 +51,37 @@ module Faker
|
|
|
28
51
|
time = Faker::Base.rand_in_range(from, to)
|
|
29
52
|
time_with_format(time, format)
|
|
30
53
|
end
|
|
31
|
-
|
|
32
|
-
|
|
54
|
+
# rubocop:enable Style/AsciiComments
|
|
55
|
+
|
|
56
|
+
##
|
|
57
|
+
# Produce a random time between two dates.
|
|
58
|
+
#
|
|
59
|
+
# @param from [Date] The start of the usable time range.
|
|
60
|
+
# @param to [Date] The end of the usable time range.
|
|
61
|
+
# @param period [Symbol] The time of day, if any. See {TIME_RANGES}.
|
|
62
|
+
# @param format [Symbol] The name of a DateTime format to use.
|
|
63
|
+
# @return [Time]
|
|
64
|
+
#
|
|
65
|
+
# @example
|
|
66
|
+
# Faker::Time.between_dates(from: Date.today - 1, to: Date.today, period: :all)
|
|
67
|
+
# #=> "2014-09-19 07:03:30 -0700"
|
|
68
|
+
# Faker::Time.between_dates(from: Date.today - 1, to: Date.today, period: :day)
|
|
69
|
+
# #=> "2014-09-18 16:28:13 -0700"
|
|
70
|
+
# Faker::Time.between_dates(from: Date.today - 1, to: Date.today, period: :night)
|
|
71
|
+
# #=> "2014-09-20 19:39:38 -0700"
|
|
72
|
+
# Faker::Time.between_dates(from: Date.today - 1, to: Date.today, period: :morning)
|
|
73
|
+
# #=> "2014-09-19 08:07:52 -0700"
|
|
74
|
+
# Faker::Time.between_dates(from: Date.today - 1, to: Date.today, period: :afternoon)
|
|
75
|
+
# #=> "2014-09-18 12:10:34 -0700"
|
|
76
|
+
# Faker::Time.between_dates(from: Date.today - 1, to: Date.today, period: :evening)
|
|
77
|
+
# #=> "2014-09-19 20:21:03 -0700"
|
|
78
|
+
# Faker::Time.between_dates(from: Date.today - 1, to: Date.today, period: :midnight)
|
|
79
|
+
# #=> "2014-09-20 00:40:14 -0700"
|
|
80
|
+
# Faker::Time.between_dates(from: Date.today - 5, to: Date.today + 5, period: :afternoon, format: :default)
|
|
81
|
+
# #=> "Fri, 19 Oct 2018 15:17:46 -0500"
|
|
82
|
+
#
|
|
83
|
+
# @faker.version 1.0.0
|
|
33
84
|
def between_dates(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_period = NOT_GIVEN, legacy_format = NOT_GIVEN, from:, to:, period: :all, format: nil)
|
|
34
|
-
# rubocop:enable Metrics/ParameterLists
|
|
35
85
|
warn_for_deprecated_arguments do |keywords|
|
|
36
86
|
keywords << :from if legacy_from != NOT_GIVEN
|
|
37
87
|
keywords << :to if legacy_to != NOT_GIVEN
|
|
@@ -44,9 +94,22 @@ module Faker
|
|
|
44
94
|
time_with_format(time, format)
|
|
45
95
|
end
|
|
46
96
|
|
|
47
|
-
|
|
97
|
+
##
|
|
98
|
+
# Produce a random time in the future (up to N days).
|
|
99
|
+
#
|
|
100
|
+
# @param days [Integer] The maximum number of days to go into the future.
|
|
101
|
+
# @param period [Symbol] The time of day, if any. See {TIME_RANGES}.
|
|
102
|
+
# @param format [Symbol] The name of a DateTime format to use.
|
|
103
|
+
# @return [Time]
|
|
104
|
+
#
|
|
105
|
+
# @example
|
|
106
|
+
# Faker::Time.forward(days: 23, period: :morning)
|
|
107
|
+
# # => "2014-09-26 06:54:47 -0700"
|
|
108
|
+
# Faker::Time.forward(days: 5, period: :evening, format: :long)
|
|
109
|
+
# #=> "October 21, 2018 20:47"
|
|
110
|
+
#
|
|
111
|
+
# @faker.version 1.5.0
|
|
48
112
|
def forward(legacy_days = NOT_GIVEN, legacy_period = NOT_GIVEN, legacy_format = NOT_GIVEN, days: 365, period: :all, format: nil)
|
|
49
|
-
# rubocop:enable Metrics/ParameterLists
|
|
50
113
|
warn_for_deprecated_arguments do |keywords|
|
|
51
114
|
keywords << :days if legacy_days != NOT_GIVEN
|
|
52
115
|
keywords << :period if legacy_period != NOT_GIVEN
|
|
@@ -56,9 +119,22 @@ module Faker
|
|
|
56
119
|
time_with_format(date_with_random_time(Faker::Date.forward(days: days), period), format)
|
|
57
120
|
end
|
|
58
121
|
|
|
59
|
-
|
|
122
|
+
##
|
|
123
|
+
# Produce a random time in the past (up to N days).
|
|
124
|
+
#
|
|
125
|
+
# @param days [Integer] The maximum number of days to go into the past.
|
|
126
|
+
# @param period [Symbol] The time of day, if any. See {TIME_RANGES}.
|
|
127
|
+
# @param format [Symbol] The name of a DateTime format to use.
|
|
128
|
+
# @return [Time]
|
|
129
|
+
#
|
|
130
|
+
# @example
|
|
131
|
+
# Faker::Time.backward(days: 14, period: :evening)
|
|
132
|
+
# #=> "2014-09-17 19:56:33 -0700"
|
|
133
|
+
# Faker::Time.backward(days: 5, period: :morning, format: :short)
|
|
134
|
+
# #=> "14 Oct 07:44"
|
|
135
|
+
#
|
|
136
|
+
# @faker.version 1.5.0
|
|
60
137
|
def backward(legacy_days = NOT_GIVEN, legacy_period = NOT_GIVEN, legacy_format = NOT_GIVEN, days: 365, period: :all, format: nil)
|
|
61
|
-
# rubocop:enable Metrics/ParameterLists
|
|
62
138
|
warn_for_deprecated_arguments do |keywords|
|
|
63
139
|
keywords << :days if legacy_days != NOT_GIVEN
|
|
64
140
|
keywords << :period if legacy_period != NOT_GIVEN
|
|
@@ -67,6 +143,7 @@ module Faker
|
|
|
67
143
|
|
|
68
144
|
time_with_format(date_with_random_time(Faker::Date.backward(days: days), period), format)
|
|
69
145
|
end
|
|
146
|
+
# rubocop:enable Metrics/ParameterLists
|
|
70
147
|
|
|
71
148
|
private
|
|
72
149
|
|