faker 1.9.6 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +386 -6
- data/README.md +12 -5
- data/lib/faker.rb +56 -1
- 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 +62 -6
- data/lib/faker/books/book.rb +36 -0
- data/lib/faker/books/culture_series.rb +49 -0
- data/lib/faker/books/dune.rb +66 -5
- data/lib/faker/books/lovecraft.rb +221 -18
- data/lib/faker/creature/animal.rb +10 -1
- data/lib/faker/creature/cat.rb +28 -1
- data/lib/faker/creature/dog.rb +73 -1
- data/lib/faker/creature/horse.rb +19 -1
- data/lib/faker/default/address.rb +25 -5
- data/lib/faker/default/alphanumeric.rb +58 -9
- data/lib/faker/default/app.rb +55 -1
- data/lib/faker/default/appliance.rb +18 -0
- data/lib/faker/default/artist.rb +9 -0
- data/lib/faker/default/avatar.rb +43 -1
- data/lib/faker/default/bank.rb +10 -2
- data/lib/faker/default/boolean.rb +16 -1
- data/lib/faker/default/cannabis.rb +4 -0
- data/lib/faker/default/chile_rut.rb +13 -3
- data/lib/faker/default/chuck_norris.rb +1 -1
- data/lib/faker/default/code.rb +18 -5
- data/lib/faker/default/commerce.rb +18 -4
- data/lib/faker/default/company.rb +11 -3
- data/lib/faker/default/crypto_coin.rb +21 -4
- data/lib/faker/default/date.rb +122 -9
- data/lib/faker/default/demographic.rb +5 -1
- data/lib/faker/default/dessert.rb +27 -0
- data/lib/faker/default/device.rb +56 -2
- data/lib/faker/default/driving_licence.rb +13 -7
- data/lib/faker/default/educator.rb +0 -3
- data/lib/faker/default/electrical_components.rb +27 -0
- data/lib/faker/default/file.rb +20 -3
- data/lib/faker/default/fillmurray.rb +10 -2
- data/lib/faker/default/finance.rb +5 -1
- 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/hipster.rb +55 -16
- data/lib/faker/default/house.rb +18 -0
- data/lib/faker/default/id_number.rb +85 -11
- data/lib/faker/default/industry_segments.rb +36 -0
- data/lib/faker/default/internet.rb +107 -22
- data/lib/faker/default/invoice.rb +16 -3
- data/lib/faker/default/json.rb +19 -2
- data/lib/faker/default/lorem.rb +91 -20
- data/lib/faker/default/lorem_flickr.rb +38 -5
- data/lib/faker/default/lorem_pixel.rb +10 -1
- data/lib/faker/default/markdown.rb +12 -7
- data/lib/faker/default/marketing.rb +9 -0
- data/lib/faker/default/measurement.rb +40 -8
- data/lib/faker/default/military.rb +45 -0
- data/lib/faker/default/name.rb +6 -4
- data/lib/faker/default/nation.rb +48 -5
- data/lib/faker/default/nato_phonetic_alphabet.rb +9 -0
- data/lib/faker/default/nhs.rb +11 -7
- data/lib/faker/default/number.rb +202 -30
- data/lib/faker/default/omniauth.rb +98 -15
- data/lib/faker/default/phone_number.rb +5 -1
- data/lib/faker/default/placeholdit.rb +11 -1
- data/lib/faker/default/programming_language.rb +18 -0
- data/lib/faker/default/relationship.rb +5 -1
- data/lib/faker/default/restaurant.rb +54 -2
- data/lib/faker/default/science.rb +27 -0
- data/lib/faker/default/source.rb +59 -3
- data/lib/faker/default/south_africa.rb +1 -1
- data/lib/faker/default/space.rb +2 -2
- data/lib/faker/default/string.rb +5 -1
- data/lib/faker/default/stripe.rb +20 -4
- data/lib/faker/default/subscription.rb +45 -0
- data/lib/faker/default/superhero.rb +45 -0
- data/lib/faker/default/time.rb +133 -8
- data/lib/faker/default/twitter.rb +62 -48
- data/lib/faker/default/types.rb +29 -7
- data/lib/faker/default/vehicle.rb +19 -6
- data/lib/faker/default/world_cup.rb +61 -2
- data/lib/faker/games/dota.rb +53 -2
- data/lib/faker/games/elder_scrolls.rb +73 -1
- data/lib/faker/games/fallout.rb +38 -1
- data/lib/faker/games/game.rb +27 -0
- data/lib/faker/games/half_life.rb +28 -1
- data/lib/faker/games/heroes.rb +28 -1
- data/lib/faker/games/heroes_of_the_storm.rb +37 -1
- data/lib/faker/games/league_of_legends.rb +55 -1
- data/lib/faker/games/myst.rb +46 -1
- data/lib/faker/games/overwatch.rb +28 -1
- data/lib/faker/games/pokemon.rb +28 -1
- data/lib/faker/games/sonic_the_hedgehog.rb +28 -1
- data/lib/faker/games/super_smash_bros.rb +19 -1
- data/lib/faker/games/witcher.rb +55 -1
- data/lib/faker/games/world_of_warcraft.rb +19 -1
- data/lib/faker/games/zelda.rb +38 -2
- data/lib/faker/japanese_media/dragon_ball.rb +10 -1
- data/lib/faker/japanese_media/one_piece.rb +55 -1
- data/lib/faker/japanese_media/sword_art_online.rb +37 -1
- data/lib/faker/movies/back_to_the_future.rb +29 -1
- data/lib/faker/movies/ghostbusters.rb +29 -1
- data/lib/faker/movies/harry_potter.rb +55 -1
- data/lib/faker/movies/hitchhikers_guide_to_the_galaxy.rb +70 -1
- data/lib/faker/movies/hobbit.rb +38 -1
- data/lib/faker/movies/lebowski.rb +28 -1
- data/lib/faker/movies/lord_of_the_rings.rb +29 -1
- data/lib/faker/movies/movie.rb +9 -0
- data/lib/faker/movies/princess_bride.rb +20 -1
- data/lib/faker/movies/star_wars.rb +101 -5
- data/lib/faker/movies/v_for_vendetta.rb +30 -1
- 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 +10 -1
- data/lib/faker/tv_shows/bojack_horseman.rb +29 -1
- data/lib/faker/tv_shows/breaking_bad.rb +19 -1
- data/lib/faker/tv_shows/buffy.rb +46 -1
- data/lib/faker/tv_shows/community.rb +20 -1
- data/lib/faker/tv_shows/dr_who.rb +79 -3
- data/lib/faker/tv_shows/dumb_and_dumber.rb +29 -1
- data/lib/faker/tv_shows/family_guy.rb +29 -1
- data/lib/faker/tv_shows/friends.rb +28 -1
- data/lib/faker/tv_shows/game_of_thrones.rb +47 -1
- data/lib/faker/tv_shows/hey_arnold.rb +28 -1
- data/lib/faker/tv_shows/how_i_met_your_mother.rb +38 -1
- data/lib/faker/tv_shows/michael_scott.rb +14 -1
- data/lib/faker/tv_shows/new_girl.rb +20 -1
- data/lib/faker/tv_shows/parks_and_rec.rb +19 -1
- data/lib/faker/tv_shows/rick_and_morty.rb +29 -1
- data/lib/faker/tv_shows/ru_paul.rb +19 -1
- data/lib/faker/tv_shows/seinfeld.rb +29 -1
- data/lib/faker/tv_shows/silicon_valley.rb +76 -1
- data/lib/faker/tv_shows/simpsons.rb +29 -1
- data/lib/faker/tv_shows/south_park.rb +20 -1
- data/lib/faker/tv_shows/star_trek.rb +37 -1
- data/lib/faker/tv_shows/stargate.rb +29 -1
- data/lib/faker/tv_shows/stranger_things.rb +20 -1
- data/lib/faker/tv_shows/the_expanse.rb +37 -1
- data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +29 -1
- data/lib/faker/tv_shows/the_it_crowd.rb +38 -1
- data/lib/faker/tv_shows/the_thick_of_it.rb +29 -1
- data/lib/faker/tv_shows/twin_peaks.rb +29 -1
- data/lib/faker/tv_shows/venture_bros.rb +39 -1
- data/lib/faker/version.rb +1 -1
- data/lib/locales/en-CA.yml +2 -1
- data/lib/locales/en-IND.yml +1 -1
- data/lib/locales/en-TH.yml +360 -0
- 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/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/space.yml +1 -1
- data/lib/locales/en/super_smash_bros.yml +5 -0
- data/lib/locales/fr-CA.yml +1 -1
- data/lib/locales/ja.yml +12 -9
- data/lib/locales/th.yml +380 -0
- data/lib/locales/vi.yml +1 -1
- metadata +44 -27
- 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
data/lib/faker/default/code.rb
CHANGED
@@ -12,26 +12,39 @@ module Faker
|
|
12
12
|
|
13
13
|
# By default generates 10 sign isbn code in format 123456789-X
|
14
14
|
# You can pass 13 to generate new 13 sign code
|
15
|
-
def isbn(
|
15
|
+
def isbn(legacy_base = NOT_GIVEN, base: 10)
|
16
|
+
warn_for_deprecated_arguments do |keywords|
|
17
|
+
keywords << :base if legacy_base != NOT_GIVEN
|
18
|
+
end
|
19
|
+
|
16
20
|
base == 13 ? generate_base13_isbn : generate_base10_isbn
|
17
21
|
end
|
18
22
|
|
19
23
|
# By default generates 13 sign ean code in format 1234567890123
|
20
24
|
# You can pass 8 to generate ean8 code
|
21
|
-
def ean(
|
25
|
+
def ean(legacy_base = NOT_GIVEN, base: 13)
|
26
|
+
warn_for_deprecated_arguments do |keywords|
|
27
|
+
keywords << :base if legacy_base != NOT_GIVEN
|
28
|
+
end
|
29
|
+
|
22
30
|
base == 8 ? generate_base8_ean : generate_base13_ean
|
23
31
|
end
|
24
32
|
|
25
33
|
def rut
|
26
|
-
value = Number.number(8)
|
34
|
+
value = Number.number(digits: 8).to_s
|
27
35
|
vd = rut_verificator_digit(value)
|
28
36
|
value << "-#{vd}"
|
29
37
|
end
|
30
38
|
|
31
39
|
# By default generates a Singaporean NRIC ID for someone
|
32
40
|
# who is born between the age of 18 and 65.
|
33
|
-
def nric(
|
34
|
-
|
41
|
+
def nric(legacy_min_age = NOT_GIVEN, legacy_max_age = NOT_GIVEN, min_age: 18, max_age: 65)
|
42
|
+
warn_for_deprecated_arguments do |keywords|
|
43
|
+
keywords << :min_age if legacy_min_age != NOT_GIVEN
|
44
|
+
keywords << :max_age if legacy_max_age != NOT_GIVEN
|
45
|
+
end
|
46
|
+
|
47
|
+
birthyear = Date.birthday(min_age: min_age, max_age: max_age).year
|
35
48
|
prefix = birthyear < 2000 ? 'S' : 'T'
|
36
49
|
values = birthyear.to_s[-2..-1]
|
37
50
|
values << regexify(/\d{5}/)
|
@@ -7,15 +7,24 @@ module Faker
|
|
7
7
|
fetch('color.name')
|
8
8
|
end
|
9
9
|
|
10
|
-
def promotion_code(
|
10
|
+
def promotion_code(legacy_digits = NOT_GIVEN, digits: 6)
|
11
|
+
warn_for_deprecated_arguments do |keywords|
|
12
|
+
keywords << :digits if legacy_digits != NOT_GIVEN
|
13
|
+
end
|
14
|
+
|
11
15
|
[
|
12
16
|
fetch('commerce.promotion_code.adjective'),
|
13
17
|
fetch('commerce.promotion_code.noun'),
|
14
|
-
Faker::Number.number(digits)
|
18
|
+
Faker::Number.number(digits: digits)
|
15
19
|
].join
|
16
20
|
end
|
17
21
|
|
18
|
-
def department(
|
22
|
+
def department(legacy_max = NOT_GIVEN, legacy_fixed_amount = NOT_GIVEN, max: 3, fixed_amount: false)
|
23
|
+
warn_for_deprecated_arguments do |keywords|
|
24
|
+
keywords << :max if legacy_max != NOT_GIVEN
|
25
|
+
keywords << :fixed_amount if legacy_fixed_amount != NOT_GIVEN
|
26
|
+
end
|
27
|
+
|
19
28
|
num = max if fixed_amount
|
20
29
|
num ||= 1 + rand(max)
|
21
30
|
|
@@ -34,7 +43,12 @@ module Faker
|
|
34
43
|
fetch('commerce.product_name.material')
|
35
44
|
end
|
36
45
|
|
37
|
-
def price(
|
46
|
+
def price(legacy_range = NOT_GIVEN, legacy_as_string = NOT_GIVEN, range: 0..100.0, as_string: false)
|
47
|
+
warn_for_deprecated_arguments do |keywords|
|
48
|
+
keywords << :range if legacy_range != NOT_GIVEN
|
49
|
+
keywords << :as_string if legacy_as_string != NOT_GIVEN
|
50
|
+
end
|
51
|
+
|
38
52
|
price = (rand(range) * 100).floor / 100.0
|
39
53
|
if as_string
|
40
54
|
price_parts = price.to_s.split('.')
|
@@ -126,7 +126,11 @@ module Faker
|
|
126
126
|
end
|
127
127
|
|
128
128
|
# Get a random Polish register of national economy number. More info https://pl.wikipedia.org/wiki/REGON
|
129
|
-
def polish_register_of_national_economy(
|
129
|
+
def polish_register_of_national_economy(legacy_length = NOT_GIVEN, length: 9)
|
130
|
+
warn_for_deprecated_arguments do |keywords|
|
131
|
+
keywords << :length if legacy_length != NOT_GIVEN
|
132
|
+
end
|
133
|
+
|
130
134
|
raise ArgumentError, 'Length should be 9 or 14' unless [9, 14].include? length
|
131
135
|
|
132
136
|
random_digits = []
|
@@ -153,7 +157,11 @@ module Faker
|
|
153
157
|
regexify(/IT\d{2,4}\/\d{2,10}/)
|
154
158
|
end
|
155
159
|
|
156
|
-
def brazilian_company_number(formatted: false)
|
160
|
+
def brazilian_company_number(legacy_formatted = NOT_GIVEN, formatted: false)
|
161
|
+
warn_for_deprecated_arguments do |keywords|
|
162
|
+
keywords << :formatted if legacy_formatted != NOT_GIVEN
|
163
|
+
end
|
164
|
+
|
157
165
|
digits = Array.new(8) { Faker::Number.digit.to_i } + [0, 0, 0, Faker::Number.non_zero_digit.to_i]
|
158
166
|
|
159
167
|
factors = [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, 6].cycle
|
@@ -198,7 +206,7 @@ module Faker
|
|
198
206
|
def luhn_algorithm(number)
|
199
207
|
multiplications = []
|
200
208
|
|
201
|
-
number.reverse.split(//).each_with_index do |digit, i|
|
209
|
+
number.to_s.reverse.split(//).each_with_index do |digit, i|
|
202
210
|
multiplications << if i.even?
|
203
211
|
digit.to_i * 2
|
204
212
|
else
|
@@ -7,15 +7,27 @@ module Faker
|
|
7
7
|
ACRONYM = 1
|
8
8
|
URL_LOGO = 2
|
9
9
|
|
10
|
-
def coin_name(
|
10
|
+
def coin_name(legacy_coin = NOT_GIVEN, coin: coin_array)
|
11
|
+
warn_for_deprecated_arguments do |keywords|
|
12
|
+
keywords << :coin if legacy_coin != NOT_GIVEN
|
13
|
+
end
|
14
|
+
|
11
15
|
coin[COIN_NAME]
|
12
16
|
end
|
13
17
|
|
14
|
-
def acronym(
|
18
|
+
def acronym(legacy_coin = NOT_GIVEN, coin: coin_array)
|
19
|
+
warn_for_deprecated_arguments do |keywords|
|
20
|
+
keywords << :coin if legacy_coin != NOT_GIVEN
|
21
|
+
end
|
22
|
+
|
15
23
|
coin[ACRONYM]
|
16
24
|
end
|
17
25
|
|
18
|
-
def url_logo(
|
26
|
+
def url_logo(legacy_coin = NOT_GIVEN, coin: coin_array)
|
27
|
+
warn_for_deprecated_arguments do |keywords|
|
28
|
+
keywords << :coin if legacy_coin != NOT_GIVEN
|
29
|
+
end
|
30
|
+
|
19
31
|
coin[URL_LOGO]
|
20
32
|
end
|
21
33
|
|
@@ -25,7 +37,12 @@ module Faker
|
|
25
37
|
|
26
38
|
def coin_hash
|
27
39
|
coin = coin_array
|
28
|
-
|
40
|
+
|
41
|
+
{
|
42
|
+
name: coin_name(coin: coin),
|
43
|
+
acronym: acronym(coin: coin),
|
44
|
+
url_logo: url_logo(coin: coin)
|
45
|
+
}
|
29
46
|
end
|
30
47
|
end
|
31
48
|
end
|
data/lib/faker/default/date.rb
CHANGED
@@ -3,45 +3,158 @@
|
|
3
3
|
module Faker
|
4
4
|
class Date < Base
|
5
5
|
class << self
|
6
|
-
|
6
|
+
##
|
7
|
+
# Produce a random date between two dates.
|
8
|
+
#
|
9
|
+
# @param from [Date] The start of the usable date range.
|
10
|
+
# @param to [Date] The end of the usable date range.
|
11
|
+
# @return [Date]
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# Faker::Date.between(from: 2.days.ago, to: Date.today)
|
15
|
+
# #=> #<Date: 2014-09-24>
|
16
|
+
#
|
17
|
+
# @faker.version 1.0.0
|
18
|
+
def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from:, to:)
|
19
|
+
warn_for_deprecated_arguments do |keywords|
|
20
|
+
keywords << :from if legacy_from != NOT_GIVEN
|
21
|
+
keywords << :to if legacy_to != NOT_GIVEN
|
22
|
+
end
|
23
|
+
|
7
24
|
from = get_date_object(from)
|
8
25
|
to = get_date_object(to)
|
9
26
|
|
10
27
|
Faker::Base.rand_in_range(from, to)
|
11
28
|
end
|
12
29
|
|
13
|
-
|
30
|
+
# rubocop:disable Metrics/ParameterLists
|
31
|
+
|
32
|
+
##
|
33
|
+
# Produce a random date between two dates.
|
34
|
+
#
|
35
|
+
# @param from [Date] The start of the usable date range.
|
36
|
+
# @param to [Date] The end of the usable date range.
|
37
|
+
# @param excepted [Date] A date to exclude.
|
38
|
+
# @return [Date]
|
39
|
+
#
|
40
|
+
# @example
|
41
|
+
# Faker::Date.between_except(from: 1.year.ago, to: 1.year.from_now, excepted: Date.today)
|
42
|
+
# #=> #<Date: 2014-10-03>
|
43
|
+
#
|
44
|
+
# @faker.version 1.6.2
|
45
|
+
def between_except(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_excepted = NOT_GIVEN, from:, to:, excepted:)
|
46
|
+
warn_for_deprecated_arguments do |keywords|
|
47
|
+
keywords << :from if legacy_from != NOT_GIVEN
|
48
|
+
end
|
49
|
+
warn_for_deprecated_arguments do |keywords|
|
50
|
+
keywords << :to if legacy_to != NOT_GIVEN
|
51
|
+
end
|
52
|
+
warn_for_deprecated_arguments do |keywords|
|
53
|
+
keywords << :excepted if legacy_excepted != NOT_GIVEN
|
54
|
+
end
|
55
|
+
|
14
56
|
raise ArgumentError, 'From date, to date and excepted date must not be the same' if from == to && to == excepted
|
15
57
|
|
16
58
|
excepted = get_date_object(excepted)
|
17
59
|
|
18
60
|
loop do
|
19
|
-
date = between(from, to)
|
61
|
+
date = between(from: from, to: to)
|
20
62
|
break date.to_date if date != excepted
|
21
63
|
end
|
22
64
|
end
|
65
|
+
# rubocop:enable Metrics/ParameterLists
|
66
|
+
|
67
|
+
##
|
68
|
+
# Produce a random date in the future (up to N days).
|
69
|
+
#
|
70
|
+
# @param days [Integer] The maximum number of days to go into the future.
|
71
|
+
# @return [Date]
|
72
|
+
#
|
73
|
+
# @example
|
74
|
+
# Faker::Date.forward(days: 23) #=> #<Date: 2014-10-03>
|
75
|
+
#
|
76
|
+
# @faker.version 1.0.0
|
77
|
+
def forward(legacy_days = NOT_GIVEN, days: 365)
|
78
|
+
warn_for_deprecated_arguments do |keywords|
|
79
|
+
keywords << :days if legacy_days != NOT_GIVEN
|
80
|
+
end
|
23
81
|
|
24
|
-
def forward(days = 365)
|
25
82
|
from = ::Date.today + 1
|
26
83
|
to = ::Date.today + days
|
27
84
|
|
28
|
-
between(from, to).to_date
|
85
|
+
between(from: from, to: to).to_date
|
29
86
|
end
|
30
87
|
|
31
|
-
|
88
|
+
##
|
89
|
+
# Produce a random date in the past (up to N days).
|
90
|
+
#
|
91
|
+
# @param days [Integer] The maximum number of days to go into the past.
|
92
|
+
# @return [Date]
|
93
|
+
#
|
94
|
+
# @example
|
95
|
+
# Faker::Date.backward(days: 14) #=> #<Date: 2019-09-12>
|
96
|
+
#
|
97
|
+
# @faker.version 1.0.0
|
98
|
+
def backward(legacy_days = NOT_GIVEN, days: 365)
|
99
|
+
warn_for_deprecated_arguments do |keywords|
|
100
|
+
keywords << :days if legacy_days != NOT_GIVEN
|
101
|
+
end
|
102
|
+
|
32
103
|
from = ::Date.today - days
|
33
104
|
to = ::Date.today - 1
|
34
105
|
|
35
|
-
between(from, to).to_date
|
106
|
+
between(from: from, to: to).to_date
|
36
107
|
end
|
37
108
|
|
38
|
-
|
109
|
+
##
|
110
|
+
# Produce a random date in the past (up to N days).
|
111
|
+
#
|
112
|
+
# @param min_age [Integer] The minimum age that the birthday would imply.
|
113
|
+
# @param max_age [Integer] The maximum age that the birthday would imply.
|
114
|
+
# @return [Date]
|
115
|
+
#
|
116
|
+
# @example
|
117
|
+
# Faker::Date.birthday(min_age: 18, max_age: 65) #=> #<Date: 1986-03-28>
|
118
|
+
#
|
119
|
+
# @faker.version 1.4.3
|
120
|
+
def birthday(legacy_min_age = NOT_GIVEN, legacy_max_age = NOT_GIVEN, min_age: 18, max_age: 65)
|
121
|
+
warn_for_deprecated_arguments do |keywords|
|
122
|
+
keywords << :min_age if legacy_min_age != NOT_GIVEN
|
123
|
+
end
|
124
|
+
warn_for_deprecated_arguments do |keywords|
|
125
|
+
keywords << :max_age if legacy_max_age != NOT_GIVEN
|
126
|
+
end
|
127
|
+
|
39
128
|
t = ::Date.today
|
40
129
|
|
41
130
|
from = birthday_date(t, max_age)
|
42
131
|
to = birthday_date(t, min_age)
|
43
132
|
|
44
|
-
between(from, to).to_date
|
133
|
+
between(from: from, to: to).to_date
|
134
|
+
end
|
135
|
+
|
136
|
+
##
|
137
|
+
# Produces a date in the year and/or month specified.
|
138
|
+
#
|
139
|
+
# @param month [Integer] represents the month of the date
|
140
|
+
# @param year [Integer] represents the year of the date
|
141
|
+
# @return [Date]
|
142
|
+
#
|
143
|
+
# @example
|
144
|
+
# Faker::Date.in_date_period #=> #<Date: 2019-09-01>
|
145
|
+
#
|
146
|
+
# @example
|
147
|
+
# Faker::Date.in_date_period(year: 2018, month: 2) #=> #<Date: 2018-02-26>
|
148
|
+
#
|
149
|
+
# @example
|
150
|
+
# Faker::Date.in_date_period(month: 2) #=> #<Date: 2019-02-26>
|
151
|
+
#
|
152
|
+
# @faker.version next
|
153
|
+
def in_date_period(month: nil, year: ::Date.today.year)
|
154
|
+
from = ::Date.new(year, month || 1, 1)
|
155
|
+
to = ::Date.new(year, month || 12, ::Date.civil(year, month || 12, -1).day)
|
156
|
+
|
157
|
+
between(from: from, to: to).to_date
|
45
158
|
end
|
46
159
|
|
47
160
|
private
|
@@ -23,7 +23,11 @@ module Faker
|
|
23
23
|
fetch('demographic.sex')
|
24
24
|
end
|
25
25
|
|
26
|
-
def height(
|
26
|
+
def height(legacy_unit = NOT_GIVEN, unit: :metric)
|
27
|
+
warn_for_deprecated_arguments do |keywords|
|
28
|
+
keywords << :unit if legacy_unit != NOT_GIVEN
|
29
|
+
end
|
30
|
+
|
27
31
|
case unit
|
28
32
|
when :imperial
|
29
33
|
inches = rand_in_range(57, 86)
|
@@ -5,14 +5,41 @@ module Faker
|
|
5
5
|
flexible :dessert
|
6
6
|
|
7
7
|
class << self
|
8
|
+
##
|
9
|
+
# Produces the name of a dessert variety.
|
10
|
+
#
|
11
|
+
# @return [String]
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# Faker::Dessert.variety #=> "Cake"
|
15
|
+
#
|
16
|
+
# @faker.version 1.8.0
|
8
17
|
def variety
|
9
18
|
fetch('dessert.variety')
|
10
19
|
end
|
11
20
|
|
21
|
+
##
|
22
|
+
# Produces the name of a dessert topping.
|
23
|
+
#
|
24
|
+
# @return [String]
|
25
|
+
#
|
26
|
+
# @example
|
27
|
+
# Faker::Dessert.topping #=> "Gummy Bears"
|
28
|
+
#
|
29
|
+
# @faker.version 1.8.0
|
12
30
|
def topping
|
13
31
|
fetch('dessert.topping')
|
14
32
|
end
|
15
33
|
|
34
|
+
##
|
35
|
+
# Produces the name of a dessert flavor.
|
36
|
+
#
|
37
|
+
# @return [String]
|
38
|
+
#
|
39
|
+
# @example
|
40
|
+
# Faker::Dessert.flavor #=> "Salted Caramel"
|
41
|
+
#
|
42
|
+
# @faker.version 1.8.0
|
16
43
|
def flavor
|
17
44
|
fetch('dessert.flavor')
|
18
45
|
end
|
data/lib/faker/default/device.rb
CHANGED
@@ -3,28 +3,82 @@
|
|
3
3
|
module Faker
|
4
4
|
class Device < Base
|
5
5
|
class << self
|
6
|
+
##
|
7
|
+
# Produces a build number between 1 and 500.
|
8
|
+
#
|
9
|
+
# @return [Integer]
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# Faker::Device.build_number #=> 5
|
13
|
+
#
|
14
|
+
# @faker.version 1.9.0
|
6
15
|
def build_number
|
7
|
-
Faker::Number.between(1, 500)
|
16
|
+
Faker::Number.between(from: 1, to: 500)
|
8
17
|
end
|
9
18
|
|
19
|
+
##
|
20
|
+
# Produces the name of a manufacturer for a device.
|
21
|
+
#
|
22
|
+
# @return [String]
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# Faker::Device.manufacturer #=> "Apple"
|
26
|
+
#
|
27
|
+
# @faker.version 1.9.0
|
10
28
|
def manufacturer
|
11
29
|
fetch('device.manufacturer')
|
12
30
|
end
|
13
31
|
|
32
|
+
##
|
33
|
+
# Produces a model name for a device.
|
34
|
+
#
|
35
|
+
# @return [String]
|
36
|
+
#
|
37
|
+
# @example
|
38
|
+
# Faker::Device.model_name #=> "iPhone 4"
|
39
|
+
#
|
40
|
+
# @faker.version 1.9.0
|
14
41
|
def model_name
|
15
42
|
fetch('device.model_name')
|
16
43
|
end
|
17
44
|
|
45
|
+
##
|
46
|
+
# Produces the name of a platform for a device.
|
47
|
+
#
|
48
|
+
# @return [String]
|
49
|
+
#
|
50
|
+
# @example
|
51
|
+
# Faker::Device.platform #=> "webOS"
|
52
|
+
#
|
53
|
+
# @faker.version 1.9.0
|
18
54
|
def platform
|
19
55
|
fetch('device.platform')
|
20
56
|
end
|
21
57
|
|
58
|
+
##
|
59
|
+
# Produces a serial code for a device.
|
60
|
+
#
|
61
|
+
# @return [String]
|
62
|
+
#
|
63
|
+
# @example
|
64
|
+
# Faker::Device.serial #=> "ejfjnRNInxh0363JC2WM"
|
65
|
+
#
|
66
|
+
# @faker.version 1.9.0
|
22
67
|
def serial
|
23
68
|
fetch('device.serial')
|
24
69
|
end
|
25
70
|
|
71
|
+
##
|
72
|
+
# Produces a version number between 1 and 1000.
|
73
|
+
#
|
74
|
+
# @return [Integer]
|
75
|
+
#
|
76
|
+
# @example
|
77
|
+
# Faker::Device.version #=> 42
|
78
|
+
#
|
79
|
+
# @faker.version 1.9.0
|
26
80
|
def version
|
27
|
-
Faker::Number.between(1, 1000)
|
81
|
+
Faker::Number.between(from: 1, to: 1000)
|
28
82
|
end
|
29
83
|
end
|
30
84
|
end
|