faker 2.1.0 → 2.2.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 +93 -3
- data/README.md +3 -3
- data/lib/faker.rb +56 -1
- data/lib/faker/blockchain/tezos.rb +6 -6
- data/lib/faker/books/dune.rb +10 -2
- data/lib/faker/books/lovecraft.rb +38 -7
- data/lib/faker/default/address.rb +25 -5
- data/lib/faker/default/alphanumeric.rb +39 -7
- data/lib/faker/default/app.rb +9 -1
- data/lib/faker/default/avatar.rb +11 -1
- data/lib/faker/default/bank.rb +10 -2
- data/lib/faker/default/boolean.rb +5 -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/hipster.rb +45 -6
- data/lib/faker/default/id_number.rb +48 -3
- data/lib/faker/default/internet.rb +89 -13
- data/lib/faker/default/invoice.rb +16 -3
- data/lib/faker/default/json.rb +19 -2
- data/lib/faker/default/lorem.rb +80 -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 +50 -9
- data/lib/faker/default/phone_number.rb +5 -1
- data/lib/faker/default/placeholdit.rb +11 -1
- data/lib/faker/default/relationship.rb +5 -1
- data/lib/faker/default/source.rb +18 -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/movies/star_wars.rb +6 -4
- data/lib/faker/version.rb +1 -1
- data/lib/locales/en.yml +0 -49
- data/lib/locales/en/science.yml +1 -1
- metadata +18 -18
data/lib/faker/default/app.rb
CHANGED
@@ -15,7 +15,15 @@ module Faker
|
|
15
15
|
parse('app.author')
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
# rubocop:disable Metrics/ParameterLists
|
19
|
+
def semantic_version(legacy_major = NOT_GIVEN, legacy_minor = NOT_GIVEN, legacy_patch = NOT_GIVEN, major: 0..9, minor: 0..9, patch: 1..9)
|
20
|
+
# rubocop:enable Metrics/ParameterLists
|
21
|
+
warn_for_deprecated_arguments do |keywords|
|
22
|
+
keywords << :major if legacy_major != NOT_GIVEN
|
23
|
+
keywords << :minor if legacy_minor != NOT_GIVEN
|
24
|
+
keywords << :patch if legacy_patch != NOT_GIVEN
|
25
|
+
end
|
26
|
+
|
19
27
|
[major, minor, patch].map { |chunk| sample(Array(chunk)) }.join('.')
|
20
28
|
end
|
21
29
|
end
|
data/lib/faker/default/avatar.rb
CHANGED
@@ -5,7 +5,17 @@ module Faker
|
|
5
5
|
class << self
|
6
6
|
SUPPORTED_FORMATS = %w[png jpg bmp].freeze
|
7
7
|
|
8
|
-
|
8
|
+
# rubocop:disable Metrics/ParameterLists
|
9
|
+
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)
|
10
|
+
# rubocop:enable Metrics/ParameterLists
|
11
|
+
warn_for_deprecated_arguments do |keywords|
|
12
|
+
keywords << :slug if legacy_slug != NOT_GIVEN
|
13
|
+
keywords << :size if legacy_size != NOT_GIVEN
|
14
|
+
keywords << :format if legacy_format != NOT_GIVEN
|
15
|
+
keywords << :set if legacy_set != NOT_GIVEN
|
16
|
+
keywords << :bgset if legacy_bgset != NOT_GIVEN
|
17
|
+
end
|
18
|
+
|
9
19
|
raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /^[0-9]+x[0-9]+$/
|
10
20
|
raise ArgumentError, "Supported formats are #{SUPPORTED_FORMATS.join(', ')}" unless SUPPORTED_FORMATS.include?(format)
|
11
21
|
|
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,11 @@
|
|
3
3
|
module Faker
|
4
4
|
class Boolean < Base
|
5
5
|
class << self
|
6
|
-
def boolean(true_ratio: 0.5)
|
6
|
+
def boolean(legacy_true_ratio = NOT_GIVEN, true_ratio: 0.5)
|
7
|
+
warn_for_deprecated_arguments do |keywords|
|
8
|
+
keywords << :true_ratio if legacy_true_ratio != NOT_GIVEN
|
9
|
+
end
|
10
|
+
|
7
11
|
(rand < true_ratio)
|
8
12
|
end
|
9
13
|
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}"
|
@@ -8,7 +8,15 @@ module Faker
|
|
8
8
|
random_word =~ /\s/ ? word : random_word
|
9
9
|
end
|
10
10
|
|
11
|
-
|
11
|
+
# rubocop:disable Metrics/ParameterLists
|
12
|
+
def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_spaces_allowed = NOT_GIVEN, number: 3, supplemental: false, spaces_allowed: false)
|
13
|
+
# rubocop:enable Metrics/ParameterLists
|
14
|
+
warn_for_deprecated_arguments do |keywords|
|
15
|
+
keywords << :number if legacy_number != NOT_GIVEN
|
16
|
+
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
17
|
+
keywords << :spaces_allowed if legacy_spaces_allowed != NOT_GIVEN
|
18
|
+
end
|
19
|
+
|
12
20
|
resolved_num = resolve(number)
|
13
21
|
word_list = (
|
14
22
|
translate('faker.hipster.words') +
|
@@ -22,11 +30,24 @@ module Faker
|
|
22
30
|
words.each_with_index { |w, i| words[i] = word if w =~ /\s/ }
|
23
31
|
end
|
24
32
|
|
25
|
-
|
33
|
+
# rubocop:disable Metrics/ParameterLists
|
34
|
+
def sentence(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, supplemental: false, random_words_to_add: 6)
|
35
|
+
# rubocop:enable Metrics/ParameterLists
|
36
|
+
warn_for_deprecated_arguments do |keywords|
|
37
|
+
keywords << :word_count if legacy_word_count != NOT_GIVEN
|
38
|
+
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
39
|
+
keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
|
40
|
+
end
|
41
|
+
|
26
42
|
words(number: word_count + rand(random_words_to_add.to_i).to_i, supplemental: supplemental, spaces_allowed: true).join(' ').capitalize + '.'
|
27
43
|
end
|
28
44
|
|
29
|
-
def sentences(number: 3, supplemental: false)
|
45
|
+
def sentences(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
|
46
|
+
warn_for_deprecated_arguments do |keywords|
|
47
|
+
keywords << :number if legacy_number != NOT_GIVEN
|
48
|
+
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
49
|
+
end
|
50
|
+
|
30
51
|
[].tap do |sentences|
|
31
52
|
1.upto(resolve(number)) do
|
32
53
|
sentences << sentence(word_count: 3, supplemental: supplemental)
|
@@ -34,11 +55,24 @@ module Faker
|
|
34
55
|
end
|
35
56
|
end
|
36
57
|
|
37
|
-
|
58
|
+
# rubocop:disable Metrics/ParameterLists
|
59
|
+
def paragraph(legacy_sentence_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_sentences_to_add = NOT_GIVEN, sentence_count: 3, supplemental: false, random_sentences_to_add: 3)
|
60
|
+
# rubocop:enable Metrics/ParameterLists
|
61
|
+
warn_for_deprecated_arguments do |keywords|
|
62
|
+
keywords << :sentence_count if legacy_sentence_count != NOT_GIVEN
|
63
|
+
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
64
|
+
keywords << :random_sentences_to_add if legacy_random_sentences_to_add != NOT_GIVEN
|
65
|
+
end
|
66
|
+
|
38
67
|
sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i, supplemental: supplemental).join(' ')
|
39
68
|
end
|
40
69
|
|
41
|
-
def paragraphs(number: 3, supplemental: false)
|
70
|
+
def paragraphs(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
|
71
|
+
warn_for_deprecated_arguments do |keywords|
|
72
|
+
keywords << :number if legacy_number != NOT_GIVEN
|
73
|
+
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
74
|
+
end
|
75
|
+
|
42
76
|
[].tap do |paragraphs|
|
43
77
|
1.upto(resolve(number)) do
|
44
78
|
paragraphs << paragraph(sentence_count: 3, supplemental: supplemental)
|
@@ -46,7 +80,12 @@ module Faker
|
|
46
80
|
end
|
47
81
|
end
|
48
82
|
|
49
|
-
def paragraph_by_chars(characters: 256, supplemental: false)
|
83
|
+
def paragraph_by_chars(legacy_characters = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, characters: 256, supplemental: false)
|
84
|
+
warn_for_deprecated_arguments do |keywords|
|
85
|
+
keywords << :characters if legacy_characters != NOT_GIVEN
|
86
|
+
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
87
|
+
end
|
88
|
+
|
50
89
|
paragraph = paragraph(sentence_count: 3, supplemental: supplemental)
|
51
90
|
|
52
91
|
paragraph += ' ' + paragraph(sentence_count: 3, supplemental: supplemental) while paragraph.length < characters
|