faker 2.1.2 → 2.3.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 +88 -7
- data/README.md +2 -3
- data/lib/faker.rb +56 -1
- 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/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/driving_licence.rb +10 -4
- 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/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/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/measurement.rb +40 -8
- data/lib/faker/default/name.rb +5 -1
- 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/source.rb +59 -3
- data/lib/faker/default/string.rb +5 -1
- data/lib/faker/default/stripe.rb +20 -4
- 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 +5 -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/overwatch.rb +27 -0
- data/lib/faker/games/super_smash_bros.rb +18 -0
- data/lib/faker/games/zelda.rb +36 -0
- data/lib/faker/movies/star_wars.rb +6 -4
- 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 +1 -1
- metadata +31 -15
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)
|
@@ -6,10 +6,16 @@ module Faker
|
|
6
6
|
NI_CHANCE = 0.03 # NI Pop is about 3% of total UK population
|
7
7
|
|
8
8
|
class << self
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
# rubocop:disable Metrics/ParameterLists
|
10
|
+
def british_driving_licence(legacy_last_name = NOT_GIVEN, legacy_initials = NOT_GIVEN, legacy_gender = NOT_GIVEN, legacy_date_of_birth = NOT_GIVEN, last_name: Faker::Name.last_name, initials: Faker::Name.initials, gender: random_gender, date_of_birth: Faker::Date.birthday(min_age: 18, max_age: 65))
|
11
|
+
# rubocop:enable Metrics/ParameterLists
|
12
|
+
warn_for_deprecated_arguments do |keywords|
|
13
|
+
keywords << :last_name if legacy_last_name != NOT_GIVEN
|
14
|
+
keywords << :initials if legacy_initials != NOT_GIVEN
|
15
|
+
keywords << :gender if legacy_gender != NOT_GIVEN
|
16
|
+
keywords << :date_of_birth if legacy_date_of_birth != NOT_GIVEN
|
17
|
+
end
|
18
|
+
|
13
19
|
[
|
14
20
|
gb_licence_padding(last_name, 5),
|
15
21
|
gb_licence_year(date_of_birth, gender),
|
data/lib/faker/default/file.rb
CHANGED
@@ -3,7 +3,15 @@
|
|
3
3
|
module Faker
|
4
4
|
class File < Base
|
5
5
|
class << self
|
6
|
-
|
6
|
+
# rubocop:disable Metrics/ParameterLists
|
7
|
+
def dir(legacy_segment_count = NOT_GIVEN, legacy_root = NOT_GIVEN, legacy_directory_separator = NOT_GIVEN, segment_count: 3, root: nil, directory_separator: '/')
|
8
|
+
# rubocop:enable Metrics/ParameterLists
|
9
|
+
warn_for_deprecated_arguments do |keywords|
|
10
|
+
keywords << :segment_count if legacy_segment_count != NOT_GIVEN
|
11
|
+
keywords << :root if legacy_root != NOT_GIVEN
|
12
|
+
keywords << :directory_separator if legacy_directory_separator != NOT_GIVEN
|
13
|
+
end
|
14
|
+
|
7
15
|
Array
|
8
16
|
.new(segment_count) { Faker::Internet.slug }
|
9
17
|
.unshift(root)
|
@@ -20,7 +28,16 @@ module Faker
|
|
20
28
|
fetch('file.mime_type')
|
21
29
|
end
|
22
30
|
|
23
|
-
|
31
|
+
# rubocop:disable Metrics/ParameterLists
|
32
|
+
def file_name(legacy_dir = NOT_GIVEN, legacy_name = NOT_GIVEN, legacy_ext = NOT_GIVEN, legacy_directory_separator = NOT_GIVEN, dir: nil, name: nil, ext: nil, directory_separator: '/')
|
33
|
+
# rubocop:enable Metrics/ParameterLists
|
34
|
+
warn_for_deprecated_arguments do |keywords|
|
35
|
+
keywords << :dir if legacy_dir != NOT_GIVEN
|
36
|
+
keywords << :name if legacy_name != NOT_GIVEN
|
37
|
+
keywords << :ext if legacy_ext != NOT_GIVEN
|
38
|
+
keywords << :directory_separator if legacy_directory_separator != NOT_GIVEN
|
39
|
+
end
|
40
|
+
|
24
41
|
dir ||= dir(segment_count: 1)
|
25
42
|
name ||= Faker::Lorem.word.downcase
|
26
43
|
ext ||= extension
|
@@ -3,7 +3,15 @@
|
|
3
3
|
module Faker
|
4
4
|
class Fillmurray < Base
|
5
5
|
class << self
|
6
|
-
|
6
|
+
# rubocop:disable Metrics/ParameterLists
|
7
|
+
def image(legacy_grayscale = NOT_GIVEN, legacy_width = NOT_GIVEN, legacy_height = NOT_GIVEN, grayscale: false, width: 200, height: 200)
|
8
|
+
# rubocop:enable Metrics/ParameterLists
|
9
|
+
warn_for_deprecated_arguments do |keywords|
|
10
|
+
keywords << :grayscale if legacy_grayscale != NOT_GIVEN
|
11
|
+
keywords << :width if legacy_width != NOT_GIVEN
|
12
|
+
keywords << :height if legacy_height != NOT_GIVEN
|
13
|
+
end
|
14
|
+
|
7
15
|
raise ArgumentError, 'Width should be a number' unless width.to_s =~ /^\d+$/
|
8
16
|
raise ArgumentError, 'Height should be a number' unless height.to_s =~ /^\d+$/
|
9
17
|
raise ArgumentError, 'Grayscale should be a boolean' unless [true, false].include?(grayscale)
|
@@ -26,7 +26,11 @@ module Faker
|
|
26
26
|
template.gsub('L', luhn_digit.to_s)
|
27
27
|
end
|
28
28
|
|
29
|
-
def vat_number(country: 'BR')
|
29
|
+
def vat_number(legacy_country = NOT_GIVEN, country: 'BR')
|
30
|
+
warn_for_deprecated_arguments do |keywords|
|
31
|
+
keywords << :country if legacy_country != NOT_GIVEN
|
32
|
+
end
|
33
|
+
|
30
34
|
numerify(fetch("finance.vat_number.#{country}"))
|
31
35
|
rescue I18n::MissingTranslationData
|
32
36
|
raise ArgumentError, "Could not find vat number for #{country}"
|
data/lib/faker/default/gender.rb
CHANGED
@@ -3,10 +3,28 @@
|
|
3
3
|
module Faker
|
4
4
|
class Gender < Base
|
5
5
|
class << self
|
6
|
+
##
|
7
|
+
# Produces the name of a gender identity.
|
8
|
+
#
|
9
|
+
# @return [String]
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# Faker::Gender.type #=> "Non-binary"
|
13
|
+
#
|
14
|
+
# @faker.version 1.9.0
|
6
15
|
def type
|
7
16
|
fetch('gender.types')
|
8
17
|
end
|
9
18
|
|
19
|
+
##
|
20
|
+
# Produces either 'Male' or 'Female'.
|
21
|
+
#
|
22
|
+
# @return [String]
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# Faker::Gender.binary_type #=> "Female"
|
26
|
+
#
|
27
|
+
# @faker.version 1.9.0
|
10
28
|
def binary_type
|
11
29
|
fetch('gender.binary_types')
|
12
30
|
end
|
data/lib/faker/default/hacker.rb
CHANGED
@@ -1,35 +1,93 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Port of http://shinytoylabs.com/jargon/
|
4
3
|
module Faker
|
4
|
+
# Port of http://shinytoylabs.com/jargon/
|
5
|
+
# Are you having trouble writing tech-savvy dialogue for your latest screenplay?
|
6
|
+
# Worry not! Hollywood-grade technical talk is ready to fill out any form where you need to look smart.
|
5
7
|
class Hacker < Base
|
6
8
|
flexible :hacker
|
7
9
|
|
8
10
|
class << self
|
11
|
+
##
|
12
|
+
# Produces something smart.
|
13
|
+
#
|
14
|
+
# @return [String]
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
# Faker::Hacker.say_something_smart
|
18
|
+
# #=> "Try to compress the SQL interface, maybe it will program the back-end hard drive!"
|
19
|
+
#
|
20
|
+
# @faker.version 1.4.0
|
9
21
|
def say_something_smart
|
10
22
|
sample(phrases)
|
11
23
|
end
|
12
24
|
|
25
|
+
##
|
26
|
+
# Short technical abbreviations.
|
27
|
+
#
|
28
|
+
# @return [String]
|
29
|
+
#
|
30
|
+
# @example
|
31
|
+
# Faker::Hacker.abbreviation #=> "RAM"
|
32
|
+
#
|
33
|
+
# @faker.version 1.4.0
|
13
34
|
def abbreviation
|
14
35
|
fetch('hacker.abbreviation')
|
15
36
|
end
|
16
37
|
|
38
|
+
##
|
39
|
+
# Hacker-centric adjectives.
|
40
|
+
#
|
41
|
+
# @return [String]
|
42
|
+
#
|
43
|
+
# @example
|
44
|
+
# Faker::Hacker.adjective #=> "open-source"
|
45
|
+
#
|
46
|
+
# @faker.version 1.4.0
|
17
47
|
def adjective
|
18
48
|
fetch('hacker.adjective')
|
19
49
|
end
|
20
50
|
|
51
|
+
##
|
52
|
+
# Only the best hacker-related nouns.
|
53
|
+
#
|
54
|
+
# @return [String]
|
55
|
+
#
|
56
|
+
# @example
|
57
|
+
# Faker::Hacker.noun #=> "bandwidth"
|
58
|
+
#
|
59
|
+
# @faker.version 1.4.0
|
21
60
|
def noun
|
22
61
|
fetch('hacker.noun')
|
23
62
|
end
|
24
63
|
|
64
|
+
##
|
65
|
+
# Actions that hackers take.
|
66
|
+
#
|
67
|
+
# @return [String]
|
68
|
+
#
|
69
|
+
# @example
|
70
|
+
# Faker::Hacker.verb #=> "bypass"
|
71
|
+
#
|
72
|
+
# @faker.version 1.4.0
|
25
73
|
def verb
|
26
74
|
fetch('hacker.verb')
|
27
75
|
end
|
28
76
|
|
77
|
+
##
|
78
|
+
# Produces a verb that ends with '-ing'.
|
79
|
+
#
|
80
|
+
# @return [String]
|
81
|
+
#
|
82
|
+
# @example
|
83
|
+
# Faker::Hacker.ingverb #=> "synthesizing"
|
84
|
+
#
|
85
|
+
# @faker.version 1.4.0
|
29
86
|
def ingverb
|
30
87
|
fetch('hacker.ingverb')
|
31
88
|
end
|
32
89
|
|
90
|
+
# @private
|
33
91
|
def phrases
|
34
92
|
["If we #{verb} the #{noun}, we can get to the #{abbreviation} #{noun} through the #{adjective} #{abbreviation} #{noun}!",
|
35
93
|
"We need to #{verb} the #{adjective} #{abbreviation} #{noun}!",
|