faker 2.1.2 → 2.4.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 +113 -7
- data/README.md +4 -4
- 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 +210 -7
- 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/address.rb +25 -5
- data/lib/faker/default/alphanumeric.rb +56 -7
- data/lib/faker/default/app.rb +54 -1
- data/lib/faker/default/appliance.rb +18 -0
- data/lib/faker/default/artist.rb +9 -0
- data/lib/faker/default/avatar.rb +42 -1
- data/lib/faker/default/bank.rb +10 -2
- data/lib/faker/default/boolean.rb +16 -1
- data/lib/faker/default/chile_rut.rb +12 -2
- data/lib/faker/default/code.rb +16 -3
- data/lib/faker/default/commerce.rb +17 -3
- data/lib/faker/default/company.rb +10 -2
- data/lib/faker/default/crypto_coin.rb +15 -3
- data/lib/faker/default/date.rb +37 -5
- data/lib/faker/default/demographic.rb +5 -1
- data/lib/faker/default/dessert.rb +27 -0
- data/lib/faker/default/device.rb +54 -0
- data/lib/faker/default/driving_licence.rb +10 -4
- data/lib/faker/default/electrical_components.rb +27 -0
- data/lib/faker/default/file.rb +19 -2
- data/lib/faker/default/fillmurray.rb +9 -1
- 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 +45 -6
- data/lib/faker/default/house.rb +18 -0
- data/lib/faker/default/id_number.rb +11 -3
- data/lib/faker/default/industry_segments.rb +36 -0
- data/lib/faker/default/internet.rb +94 -13
- data/lib/faker/default/invoice.rb +16 -3
- data/lib/faker/default/json.rb +19 -2
- data/lib/faker/default/lorem.rb +81 -10
- data/lib/faker/default/lorem_flickr.rb +38 -5
- data/lib/faker/default/lorem_pixel.rb +10 -1
- data/lib/faker/default/markdown.rb +6 -1
- 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 +5 -1
- data/lib/faker/default/nato_phonetic_alphabet.rb +9 -0
- data/lib/faker/default/nhs.rb +5 -1
- data/lib/faker/default/number.rb +56 -11
- data/lib/faker/default/omniauth.rb +92 -9
- 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/science.rb +27 -0
- data/lib/faker/default/source.rb +59 -3
- 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 +37 -4
- data/lib/faker/default/twitter.rb +32 -18
- data/lib/faker/default/types.rb +27 -5
- data/lib/faker/default/vehicle.rb +17 -4
- data/lib/faker/default/world_cup.rb +11 -2
- data/lib/faker/games/dota.rb +52 -1
- 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 +36 -0
- data/lib/faker/japanese_media/dragon_ball.rb +9 -0
- data/lib/faker/japanese_media/sword_art_online.rb +36 -0
- data/lib/faker/movies/hobbit.rb +37 -0
- data/lib/faker/movies/movie.rb +9 -0
- data/lib/faker/movies/star_wars.rb +6 -4
- 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/tv_shows/breaking_bad.rb +18 -0
- data/lib/faker/version.rb +1 -1
- data/lib/locales/en-CA.yml +1 -1
- data/lib/locales/en/science.yml +1 -1
- data/lib/locales/ja.yml +8 -9
- metadata +31 -14
data/lib/faker/default/avatar.rb
CHANGED
@@ -3,9 +3,50 @@
|
|
3
3
|
module Faker
|
4
4
|
class Avatar < Base
|
5
5
|
class << self
|
6
|
+
# @private
|
6
7
|
SUPPORTED_FORMATS = %w[png jpg bmp].freeze
|
7
8
|
|
8
|
-
|
9
|
+
##
|
10
|
+
# Produces a URL for an avatar from robohash.org
|
11
|
+
#
|
12
|
+
# @param slug [String, nil]
|
13
|
+
# @param size [String] image size in pixels, in the format of 'AxB'
|
14
|
+
# @param format [String] The image file format
|
15
|
+
# @param set [String] The avatar set to use
|
16
|
+
# @param bgset [String, nil] The background set to use
|
17
|
+
# @return [String] A robohash.org URL
|
18
|
+
#
|
19
|
+
# @example
|
20
|
+
# Faker::Avatar.image
|
21
|
+
# #=> "https://robohash.org/sitsequiquia.png?size=300x300&set=set1"
|
22
|
+
# @example
|
23
|
+
# Faker::Avatar.image(slug: "my-own-slug")
|
24
|
+
# #=> "https://robohash.org/my-own-slug.png?size=300x300&set=set1"
|
25
|
+
# @example
|
26
|
+
# Faker::Avatar.image(slug: "my-own-slug", size: "50x50")
|
27
|
+
# #=> "https://robohash.org/my-own-slug.png?size=50x50&set=set1"
|
28
|
+
# @example
|
29
|
+
# Faker::Avatar.image(slug: "my-own-slug", size: "50x50", format: "jpg")
|
30
|
+
# #=> "https://robohash.org/my-own-slug.jpg?size=50x50&set=set1"
|
31
|
+
# @example
|
32
|
+
# Faker::Avatar.image(slug: "my-own-slug", size: "50x50", format: "bmp")
|
33
|
+
# #=> "https://robohash.org/my-own-slug.bmp?size=50x50&set=set1"
|
34
|
+
# @example
|
35
|
+
# Faker::Avatar.image(slug: "my-own-slug", size: "50x50", format: "bmp", set: "set1", bgset: "bg1")
|
36
|
+
# #=> "https://robohash.org/my-own-slug.bmp?size=50x50&set=set1&bgset=bg1"
|
37
|
+
#
|
38
|
+
# @faker.version 1.4.3
|
39
|
+
# rubocop:disable Metrics/ParameterLists
|
40
|
+
def image(legacy_slug = NOT_GIVEN, legacy_size = NOT_GIVEN, legacy_format = NOT_GIVEN, legacy_set = NOT_GIVEN, legacy_bgset = NOT_GIVEN, slug: nil, size: '300x300', format: 'png', set: 'set1', bgset: nil)
|
41
|
+
# rubocop:enable Metrics/ParameterLists
|
42
|
+
warn_for_deprecated_arguments do |keywords|
|
43
|
+
keywords << :slug if legacy_slug != NOT_GIVEN
|
44
|
+
keywords << :size if legacy_size != NOT_GIVEN
|
45
|
+
keywords << :format if legacy_format != NOT_GIVEN
|
46
|
+
keywords << :set if legacy_set != NOT_GIVEN
|
47
|
+
keywords << :bgset if legacy_bgset != NOT_GIVEN
|
48
|
+
end
|
49
|
+
|
9
50
|
raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /^[0-9]+x[0-9]+$/
|
10
51
|
raise ArgumentError, "Supported formats are #{SUPPORTED_FORMATS.join(', ')}" unless SUPPORTED_FORMATS.include?(format)
|
11
52
|
|
data/lib/faker/default/bank.rb
CHANGED
@@ -5,7 +5,11 @@ module Faker
|
|
5
5
|
flexible :bank
|
6
6
|
|
7
7
|
class << self
|
8
|
-
def account_number(digits: 10)
|
8
|
+
def account_number(legacy_digits = NOT_GIVEN, digits: 10)
|
9
|
+
warn_for_deprecated_arguments do |keywords|
|
10
|
+
keywords << :digits if legacy_digits != NOT_GIVEN
|
11
|
+
end
|
12
|
+
|
9
13
|
output = ''
|
10
14
|
|
11
15
|
output += rand.to_s[2..-1] while output.length < digits
|
@@ -13,10 +17,14 @@ module Faker
|
|
13
17
|
output[0...digits]
|
14
18
|
end
|
15
19
|
|
16
|
-
def iban(country_code: 'GB')
|
20
|
+
def iban(legacy_country_code = NOT_GIVEN, country_code: 'GB')
|
17
21
|
# Each country has it's own format for bank accounts
|
18
22
|
# Many of them use letters in certain parts of the account
|
19
23
|
# Using regex patterns we can create virtually any type of bank account
|
24
|
+
warn_for_deprecated_arguments do |keywords|
|
25
|
+
keywords << :country_code if legacy_country_code != NOT_GIVEN
|
26
|
+
end
|
27
|
+
|
20
28
|
begin
|
21
29
|
pattern = fetch("bank.iban_details.#{country_code.downcase}.bban_pattern")
|
22
30
|
rescue I18n::MissingTranslationData
|
@@ -3,7 +3,22 @@
|
|
3
3
|
module Faker
|
4
4
|
class Boolean < Base
|
5
5
|
class << self
|
6
|
-
|
6
|
+
##
|
7
|
+
# Produces a boolean
|
8
|
+
#
|
9
|
+
# @param true_ratio [Float] The likelihood (as a float, out of 1.0) for the method to return `true`.
|
10
|
+
# @return [Boolean]
|
11
|
+
#
|
12
|
+
# @example
|
13
|
+
# Faker::Boolean.boolean #=> true
|
14
|
+
# @example
|
15
|
+
# Faker::Boolean.boolean(true_ratio: 0.2) #=> false
|
16
|
+
#
|
17
|
+
# @faker.version 1.6.2
|
18
|
+
def boolean(legacy_true_ratio = NOT_GIVEN, true_ratio: 0.5)
|
19
|
+
warn_for_deprecated_arguments do |keywords|
|
20
|
+
keywords << :true_ratio if legacy_true_ratio != NOT_GIVEN
|
21
|
+
end
|
7
22
|
(rand < true_ratio)
|
8
23
|
end
|
9
24
|
end
|
@@ -6,7 +6,12 @@ module Faker
|
|
6
6
|
@last_rut = nil
|
7
7
|
|
8
8
|
# Fixed param added for testing a specific RUT and check digit combination.
|
9
|
-
def rut(min_rut: 1, fixed: false)
|
9
|
+
def rut(legacy_min_rut = NOT_GIVEN, legacy_fixed = NOT_GIVEN, min_rut: 1, fixed: false)
|
10
|
+
warn_for_deprecated_arguments do |keywords|
|
11
|
+
keywords << :min_rut if legacy_min_rut != NOT_GIVEN
|
12
|
+
keywords << :fixed if legacy_fixed != NOT_GIVEN
|
13
|
+
end
|
14
|
+
|
10
15
|
@last_rut = fixed ? min_rut : rand_in_range(min_rut, 99_999_999)
|
11
16
|
end
|
12
17
|
|
@@ -34,7 +39,12 @@ module Faker
|
|
34
39
|
dv
|
35
40
|
end
|
36
41
|
|
37
|
-
def full_rut(min_rut: 0, fixed: false)
|
42
|
+
def full_rut(legacy_min_rut = NOT_GIVEN, legacy_fixed = NOT_GIVEN, min_rut: 0, fixed: false)
|
43
|
+
warn_for_deprecated_arguments do |keywords|
|
44
|
+
keywords << :min_rut if legacy_min_rut != NOT_GIVEN
|
45
|
+
keywords << :fixed if legacy_fixed != NOT_GIVEN
|
46
|
+
end
|
47
|
+
|
38
48
|
"#{rut(min_rut: min_rut, fixed: fixed)}-#{dv}"
|
39
49
|
end
|
40
50
|
|
data/lib/faker/default/code.rb
CHANGED
@@ -12,13 +12,21 @@ 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(base: 10)
|
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(base: 13)
|
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
|
|
@@ -30,7 +38,12 @@ module Faker
|
|
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(min_age: 18, max_age: 65)
|
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
|
+
|
34
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]
|
@@ -7,7 +7,11 @@ module Faker
|
|
7
7
|
fetch('color.name')
|
8
8
|
end
|
9
9
|
|
10
|
-
def promotion_code(digits: 6)
|
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'),
|
@@ -15,7 +19,12 @@ module Faker
|
|
15
19
|
].join
|
16
20
|
end
|
17
21
|
|
18
|
-
def department(max: 3, fixed_amount: false)
|
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(range: 0..100.0, as_string: false)
|
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(length: 9)
|
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
|
@@ -7,15 +7,27 @@ module Faker
|
|
7
7
|
ACRONYM = 1
|
8
8
|
URL_LOGO = 2
|
9
9
|
|
10
|
-
def coin_name(coin: coin_array)
|
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(coin: coin_array)
|
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(coin: coin_array)
|
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
|
|
data/lib/faker/default/date.rb
CHANGED
@@ -3,14 +3,31 @@
|
|
3
3
|
module Faker
|
4
4
|
class Date < Base
|
5
5
|
class << self
|
6
|
-
def between(from:, to:)
|
6
|
+
def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from:, to:)
|
7
|
+
warn_for_deprecated_arguments do |keywords|
|
8
|
+
keywords << :from if legacy_from != NOT_GIVEN
|
9
|
+
keywords << :to if legacy_to != NOT_GIVEN
|
10
|
+
end
|
11
|
+
|
7
12
|
from = get_date_object(from)
|
8
13
|
to = get_date_object(to)
|
9
14
|
|
10
15
|
Faker::Base.rand_in_range(from, to)
|
11
16
|
end
|
12
17
|
|
13
|
-
|
18
|
+
# rubocop:disable Metrics/ParameterLists
|
19
|
+
def between_except(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_excepted = NOT_GIVEN, from:, to:, excepted:)
|
20
|
+
# rubocop:enable Metrics/ParameterLists
|
21
|
+
warn_for_deprecated_arguments do |keywords|
|
22
|
+
keywords << :from if legacy_from != NOT_GIVEN
|
23
|
+
end
|
24
|
+
warn_for_deprecated_arguments do |keywords|
|
25
|
+
keywords << :to if legacy_to != NOT_GIVEN
|
26
|
+
end
|
27
|
+
warn_for_deprecated_arguments do |keywords|
|
28
|
+
keywords << :excepted if legacy_excepted != NOT_GIVEN
|
29
|
+
end
|
30
|
+
|
14
31
|
raise ArgumentError, 'From date, to date and excepted date must not be the same' if from == to && to == excepted
|
15
32
|
|
16
33
|
excepted = get_date_object(excepted)
|
@@ -21,21 +38,36 @@ module Faker
|
|
21
38
|
end
|
22
39
|
end
|
23
40
|
|
24
|
-
def forward(days: 365)
|
41
|
+
def forward(legacy_days = NOT_GIVEN, days: 365)
|
42
|
+
warn_for_deprecated_arguments do |keywords|
|
43
|
+
keywords << :days if legacy_days != NOT_GIVEN
|
44
|
+
end
|
45
|
+
|
25
46
|
from = ::Date.today + 1
|
26
47
|
to = ::Date.today + days
|
27
48
|
|
28
49
|
between(from: from, to: to).to_date
|
29
50
|
end
|
30
51
|
|
31
|
-
def backward(days: 365)
|
52
|
+
def backward(legacy_days = NOT_GIVEN, days: 365)
|
53
|
+
warn_for_deprecated_arguments do |keywords|
|
54
|
+
keywords << :days if legacy_days != NOT_GIVEN
|
55
|
+
end
|
56
|
+
|
32
57
|
from = ::Date.today - days
|
33
58
|
to = ::Date.today - 1
|
34
59
|
|
35
60
|
between(from: from, to: to).to_date
|
36
61
|
end
|
37
62
|
|
38
|
-
def birthday(min_age: 18, max_age: 65)
|
63
|
+
def birthday(legacy_min_age = NOT_GIVEN, legacy_max_age = NOT_GIVEN, min_age: 18, max_age: 65)
|
64
|
+
warn_for_deprecated_arguments do |keywords|
|
65
|
+
keywords << :min_age if legacy_min_age != NOT_GIVEN
|
66
|
+
end
|
67
|
+
warn_for_deprecated_arguments do |keywords|
|
68
|
+
keywords << :max_age if legacy_max_age != NOT_GIVEN
|
69
|
+
end
|
70
|
+
|
39
71
|
t = ::Date.today
|
40
72
|
|
41
73
|
from = birthday_date(t, max_age)
|
@@ -23,7 +23,11 @@ module Faker
|
|
23
23
|
fetch('demographic.sex')
|
24
24
|
end
|
25
25
|
|
26
|
-
def height(unit: :metric)
|
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,26 +3,80 @@
|
|
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
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
81
|
Faker::Number.between(from: 1, to: 1000)
|
28
82
|
end
|