faker 2.19.0 → 3.2.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 +346 -7
- data/History.md +1 -1
- data/README.md +198 -104
- data/lib/faker/blockchain/aeternity.rb +1 -1
- data/lib/faker/blockchain/ethereum.rb +1 -1
- data/lib/faker/blockchain/tezos.rb +1 -1
- data/lib/faker/books/dune.rb +2 -10
- data/lib/faker/books/lovecraft.rb +7 -38
- data/lib/faker/books/the_kingkiller_chronicle.rb +61 -0
- data/lib/faker/default/address.rb +5 -25
- data/lib/faker/default/alphanumeric.rb +2 -8
- data/lib/faker/default/app.rb +1 -10
- data/lib/faker/default/avatar.rb +1 -12
- data/lib/faker/default/bank.rb +9 -17
- data/lib/faker/default/boolean.rb +1 -4
- data/lib/faker/default/chile_rut.rb +8 -14
- data/lib/faker/default/code.rb +11 -24
- data/lib/faker/default/color.rb +77 -6
- data/lib/faker/default/commerce.rb +3 -17
- data/lib/faker/default/company.rb +23 -20
- data/lib/faker/default/crypto_coin.rb +3 -15
- data/lib/faker/default/date.rb +5 -38
- data/lib/faker/default/demographic.rb +1 -5
- data/lib/faker/default/driving_licence.rb +1 -11
- data/lib/faker/default/drone.rb +1 -1
- data/lib/faker/default/file.rb +5 -24
- data/lib/faker/default/finance.rb +17 -7
- data/lib/faker/default/food.rb +14 -1
- data/lib/faker/default/hipster.rb +6 -45
- data/lib/faker/default/id_number.rb +108 -11
- data/lib/faker/default/internet.rb +168 -129
- data/lib/faker/default/invoice.rb +4 -17
- data/lib/faker/default/json.rb +2 -20
- data/lib/faker/default/lorem.rb +20 -76
- data/lib/faker/default/lorem_flickr.rb +4 -32
- data/lib/faker/default/markdown.rb +6 -11
- data/lib/faker/default/marketing.rb +1 -1
- data/lib/faker/default/measurement.rb +16 -48
- data/lib/faker/default/name.rb +1 -5
- data/lib/faker/default/nation.rb +0 -3
- data/lib/faker/default/nhs.rb +2 -6
- data/lib/faker/default/number.rb +10 -55
- data/lib/faker/default/omniauth.rb +51 -41
- data/lib/faker/default/phone_number.rb +2 -6
- data/lib/faker/default/placeholdit.rb +1 -12
- data/lib/faker/default/relationship.rb +1 -5
- data/lib/faker/default/religion.rb +6 -0
- data/lib/faker/default/source.rb +3 -16
- data/lib/faker/default/string.rb +1 -8
- data/lib/faker/default/stripe.rb +4 -20
- data/lib/faker/default/time.rb +4 -34
- data/lib/faker/default/twitter.rb +7 -23
- data/lib/faker/default/types.rb +5 -27
- data/lib/faker/default/vehicle.rb +29 -51
- data/lib/faker/default/vulnerability_identifier.rb +23 -0
- data/lib/faker/default/world_cup.rb +2 -11
- data/lib/faker/games/clash_of_clans.rb +1 -1
- data/lib/faker/games/dnd.rb +49 -7
- data/lib/faker/games/dota.rb +1 -5
- data/lib/faker/games/minecraft.rb +1 -1
- data/lib/faker/games/myst.rb +1 -1
- data/lib/faker/games/tarkov.rb +205 -0
- data/lib/faker/japanese_media/cowboy_bebop.rb +61 -0
- data/lib/faker/japanese_media/fullmetal_alchemist_brotherhood.rb +48 -0
- data/lib/faker/japanese_media/kamen_rider.rb +102 -0
- data/lib/faker/japanese_media/one_piece.rb +1 -1
- data/lib/faker/movies/avatar.rb +49 -0
- data/lib/faker/movies/hackers.rb +48 -0
- data/lib/faker/movies/star_wars.rb +1 -5
- data/lib/faker/movies/tron.rb +161 -0
- data/lib/faker/quotes/quote.rb +13 -0
- data/lib/faker/religion/bible.rb +50 -0
- data/lib/faker/sports/chess.rb +90 -0
- data/lib/faker/sports/mountaineering.rb +22 -0
- data/lib/faker/sports/sport.rb +116 -0
- data/lib/faker/travel/airport.rb +43 -0
- data/lib/faker/tv_shows/brooklyn_nine_nine.rb +38 -0
- data/lib/faker/tv_shows/michael_scott.rb +0 -3
- data/lib/faker/tv_shows/spongebob.rb +50 -0
- data/lib/faker/version.rb +1 -1
- data/lib/faker.rb +15 -64
- data/lib/helpers/base58.rb +1 -1
- data/lib/helpers/unique_generator.rb +13 -11
- data/lib/locales/ar.yml +6 -1
- data/lib/locales/bg.yml +1 -1
- data/lib/locales/da-DK.yml +1 -1
- data/lib/locales/de-AT.yml +3 -4
- data/lib/locales/de-CH.yml +1 -1
- data/lib/locales/de.yml +1 -1
- data/lib/locales/en/address.yml +2 -3
- data/lib/locales/en/airport.yml +381 -0
- data/lib/locales/en/australia.yml +3 -4
- data/lib/locales/en/avatar.yml +31 -0
- data/lib/locales/en/bible.yml +90 -0
- data/lib/locales/en/brooklyn_nine_nine.yml +35 -0
- data/lib/locales/en/cat.yml +1 -1
- data/lib/locales/en/chess.yml +103 -0
- data/lib/locales/en/coffee.yml +1 -1
- data/lib/locales/en/company.yml +1 -0
- data/lib/locales/en/computer.yml +23 -4
- data/lib/locales/en/cowboy_bebop.yml +163 -0
- data/lib/locales/en/dnd.yml +186 -1
- data/lib/locales/en/dota.yml +113 -0
- data/lib/locales/en/file.yml +9 -1
- data/lib/locales/en/finance.yml +3 -1
- data/lib/locales/en/fma_brotherhood.yml +78 -0
- data/lib/locales/en/food.yml +12 -0
- data/lib/locales/en/game.yml +11 -0
- data/lib/locales/en/hackers.yml +53 -0
- data/lib/locales/en/heroes.yml +2 -2
- data/lib/locales/en/internet.yml +140 -3
- data/lib/locales/en/kamen_rider.yml +452 -0
- data/lib/locales/en/mitch_hedberg.yml +46 -0
- data/lib/locales/en/mountain.yml +14 -1
- data/lib/locales/en/mountaineering.yml +14 -0
- data/lib/locales/en/movie.yml +2 -1
- data/lib/locales/en/naruto.yml +2 -3
- data/lib/locales/en/one_piece.yml +1 -1
- data/lib/locales/en/opera.yml +1 -1
- data/lib/locales/en/overwatch.yml +5 -7
- data/lib/locales/en/source.yml +5 -0
- data/lib/locales/en/spongebob.yml +489 -0
- data/lib/locales/en/sport.yml +130 -0
- data/lib/locales/en/star_wars.yml +1 -1
- data/lib/locales/en/stranger_thing.yml +1 -1
- data/lib/locales/en/super_smash_bros.yml +2 -0
- data/lib/locales/en/tarkov.yml +593 -0
- data/lib/locales/en/the_kingkiller_chronicle.yml +56 -0
- data/lib/locales/en/tron.yml +227 -0
- data/lib/locales/en/vehicle.yml +2809 -75
- data/lib/locales/en-AU.yml +2 -2
- data/lib/locales/en-CA.yml +2 -1
- data/lib/locales/en-GB.yml +2 -1
- data/lib/locales/en-MS.yml +1 -0
- data/lib/locales/en-NG.yml +1 -0
- data/lib/locales/en-NZ.yml +1 -0
- data/lib/locales/en-PAK.yml +1 -0
- data/lib/locales/en-SG.yml +1 -0
- data/lib/locales/en-UG.yml +1 -0
- data/lib/locales/en-US.yml +2 -2
- data/lib/locales/en-ZA.yml +1 -1
- data/lib/locales/en-au-ocker.yml +2 -0
- data/lib/locales/es-AR.yml +3 -2
- data/lib/locales/es-MX.yml +1 -1
- data/lib/locales/es.yml +2 -2
- data/lib/locales/fi-FI.yml +3 -1
- data/lib/locales/fr/address.yml +0 -1
- data/lib/locales/fr/adjective.yml +266 -0
- data/lib/locales/fr/ancient.yml +141 -0
- data/lib/locales/fr-CA.yml +1 -1
- data/lib/locales/fr-CH.yml +1 -1
- data/lib/locales/hy.yml +2 -1
- data/lib/locales/it.yml +1 -0
- data/lib/locales/ja/address.yml +258 -4169
- data/lib/locales/ja/adjective.yml +148 -0
- data/lib/locales/ja/dog.yml +1 -0
- data/lib/locales/ja/emotion.yml +51 -0
- data/lib/locales/ja/lorem.yml +2 -2
- data/lib/locales/ja/naruto.yml +230 -0
- data/lib/locales/ja/relationship.yml +10 -0
- data/lib/locales/ja/super_mario.yml +1 -1
- data/lib/locales/ja/super_smash_bros.yml +8 -0
- data/lib/locales/ko.yml +1 -0
- data/lib/locales/lt.yml +34 -0
- data/lib/locales/lv.yml +1 -1
- data/lib/locales/mi-NZ.yml +283 -0
- data/lib/locales/nb-NO.yml +1 -0
- data/lib/locales/nl.yml +1 -0
- data/lib/locales/pl.yml +2 -2
- data/lib/locales/pt-BR.yml +5 -0
- data/lib/locales/pt.yml +1 -1
- data/lib/locales/ru.yml +1 -0
- data/lib/locales/sk.yml +1 -0
- data/lib/locales/sv.yml +1 -0
- data/lib/locales/th.yml +76 -76
- data/lib/locales/tr.yml +1 -0
- data/lib/locales/uk.yml +1 -0
- data/lib/locales/vi.yml +1 -0
- data/lib/locales/zh-CN.yml +1 -0
- data/lib/locales/zh-TW.yml +1 -0
- metadata +96 -33
- data/lib/faker/default/fillmurray.rb +0 -45
- data/lib/faker/default/lorem_pixel.rb +0 -70
- /data/lib/faker/default/{faker_adjective.rb → adjective.rb} +0 -0
@@ -151,6 +151,19 @@ module Faker
|
|
151
151
|
fetch('company.profession')
|
152
152
|
end
|
153
153
|
|
154
|
+
##
|
155
|
+
# Produces a company department.
|
156
|
+
#
|
157
|
+
# @return [String]
|
158
|
+
#
|
159
|
+
# @example
|
160
|
+
# Faker::Company.department #=> "Information Technology"
|
161
|
+
#
|
162
|
+
# @faker.version next
|
163
|
+
def department
|
164
|
+
fetch('company.department')
|
165
|
+
end
|
166
|
+
|
154
167
|
##
|
155
168
|
# Produces a company spanish organisation number.
|
156
169
|
#
|
@@ -296,7 +309,7 @@ module Faker
|
|
296
309
|
result = Array.new(3) { rand(1..9) } + Array.new(7) { rand(10) }
|
297
310
|
break if (weight_sum(result, weights) % 11) == result[9]
|
298
311
|
end
|
299
|
-
result.join
|
312
|
+
result.join
|
300
313
|
end
|
301
314
|
|
302
315
|
##
|
@@ -309,11 +322,7 @@ module Faker
|
|
309
322
|
#
|
310
323
|
# @faker.version 1.9.1
|
311
324
|
# Get a random Polish register of national economy number. More info https://pl.wikipedia.org/wiki/REGON
|
312
|
-
def polish_register_of_national_economy(
|
313
|
-
warn_for_deprecated_arguments do |keywords|
|
314
|
-
keywords << :length if legacy_length != NOT_GIVEN
|
315
|
-
end
|
316
|
-
|
325
|
+
def polish_register_of_national_economy(length: 9)
|
317
326
|
raise ArgumentError, 'Length should be 9 or 14' unless [9, 14].include? length
|
318
327
|
|
319
328
|
random_digits = []
|
@@ -321,7 +330,7 @@ module Faker
|
|
321
330
|
random_digits = Array.new(length) { rand(10) }
|
322
331
|
break if collect_regon_sum(random_digits) == random_digits.last
|
323
332
|
end
|
324
|
-
random_digits.join
|
333
|
+
random_digits.join
|
325
334
|
end
|
326
335
|
|
327
336
|
##
|
@@ -334,7 +343,7 @@ module Faker
|
|
334
343
|
#
|
335
344
|
# @faker.version 1.9.2
|
336
345
|
def south_african_pty_ltd_registration_number
|
337
|
-
regexify(
|
346
|
+
regexify(%r{\d{4}/\d{4,10}/07})
|
338
347
|
end
|
339
348
|
|
340
349
|
##
|
@@ -347,7 +356,7 @@ module Faker
|
|
347
356
|
#
|
348
357
|
# @faker.version 1.9.2
|
349
358
|
def south_african_close_corporation_registration_number
|
350
|
-
regexify(
|
359
|
+
regexify(%r{(CK\d{2}|\d{4})/\d{4,10}/23})
|
351
360
|
end
|
352
361
|
|
353
362
|
##
|
@@ -360,7 +369,7 @@ module Faker
|
|
360
369
|
#
|
361
370
|
# @faker.version 1.9.2
|
362
371
|
def south_african_listed_company_registration_number
|
363
|
-
regexify(
|
372
|
+
regexify(%r{\d{4}/\d{4,10}/06})
|
364
373
|
end
|
365
374
|
|
366
375
|
##
|
@@ -373,7 +382,7 @@ module Faker
|
|
373
382
|
#
|
374
383
|
# @faker.version 1.9.2
|
375
384
|
def south_african_trust_registration_number
|
376
|
-
regexify(
|
385
|
+
regexify(%r{IT\d{2,4}/\d{2,10}})
|
377
386
|
end
|
378
387
|
|
379
388
|
##
|
@@ -385,11 +394,7 @@ module Faker
|
|
385
394
|
# Faker::Company.brazilian_company_number #=> "37205322000500"
|
386
395
|
#
|
387
396
|
# @faker.version 1.9.2
|
388
|
-
def brazilian_company_number(
|
389
|
-
warn_for_deprecated_arguments do |keywords|
|
390
|
-
keywords << :formatted if legacy_formatted != NOT_GIVEN
|
391
|
-
end
|
392
|
-
|
397
|
+
def brazilian_company_number(formatted: false)
|
393
398
|
digits = Array.new(8) { Faker::Number.digit.to_i } + [0, 0, 0, Faker::Number.non_zero_digit.to_i]
|
394
399
|
|
395
400
|
factors = [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, 6].cycle
|
@@ -459,7 +464,7 @@ module Faker
|
|
459
464
|
def luhn_algorithm(number)
|
460
465
|
multiplications = []
|
461
466
|
|
462
|
-
number.to_s.reverse.
|
467
|
+
number.to_s.reverse.chars.each_with_index do |digit, i|
|
463
468
|
multiplications << if i.even?
|
464
469
|
digit.to_i * 2
|
465
470
|
else
|
@@ -511,7 +516,6 @@ module Faker
|
|
511
516
|
sum
|
512
517
|
end
|
513
518
|
|
514
|
-
# rubocop:disable Style/AsciiComments
|
515
519
|
#
|
516
520
|
# For more on Russian tax number algorithm here:
|
517
521
|
# https://ru.wikipedia.org/wiki/Идентификационный_номер_налогоплательщика#Вычисление_контрольных_цифр
|
@@ -526,7 +530,6 @@ module Faker
|
|
526
530
|
# Faker::Comnpany.russian_tax_number
|
527
531
|
# Faker::Comnpany.russian_tax_number(region: 'AZ')
|
528
532
|
# Faker::Comnpany.russian_tax_number(region: 'AZ', type: false)
|
529
|
-
# rubocop:enable Style/AsciiComments
|
530
533
|
def inn_number(region, type)
|
531
534
|
n10 = [2, 4, 10, 3, 5, 9, 4, 6, 8]
|
532
535
|
n11 = [7, 2, 4, 10, 3, 5, 9, 4, 6, 8]
|
@@ -555,7 +558,7 @@ module Faker
|
|
555
558
|
def spanish_cif_control_digit(organization_type, code)
|
556
559
|
letters = %w[J A B C D E F G H I]
|
557
560
|
|
558
|
-
control = code.
|
561
|
+
control = code.chars.each_with_index.inject(0) do |sum, (value, index)|
|
559
562
|
if (index + 1).even?
|
560
563
|
sum + value.to_i
|
561
564
|
else
|
@@ -16,11 +16,7 @@ module Faker
|
|
16
16
|
# Faker::CryptoCoin.coin_name #=> "Bitcoin"
|
17
17
|
#
|
18
18
|
# @faker.version 1.9.2
|
19
|
-
def coin_name(
|
20
|
-
warn_for_deprecated_arguments do |keywords|
|
21
|
-
keywords << :coin if legacy_coin != NOT_GIVEN
|
22
|
-
end
|
23
|
-
|
19
|
+
def coin_name(coin: coin_array)
|
24
20
|
coin[COIN_NAME]
|
25
21
|
end
|
26
22
|
|
@@ -33,11 +29,7 @@ module Faker
|
|
33
29
|
# Faker::CryptoCoin.acronym #=> "BTC"
|
34
30
|
#
|
35
31
|
# @faker.version 1.9.2
|
36
|
-
def acronym(
|
37
|
-
warn_for_deprecated_arguments do |keywords|
|
38
|
-
keywords << :coin if legacy_coin != NOT_GIVEN
|
39
|
-
end
|
40
|
-
|
32
|
+
def acronym(coin: coin_array)
|
41
33
|
coin[ACRONYM]
|
42
34
|
end
|
43
35
|
|
@@ -50,11 +42,7 @@ module Faker
|
|
50
42
|
# Faker::CryptoCoin.url_logo #=> "https://i.imgur.com/EFz61Ei.png"
|
51
43
|
#
|
52
44
|
# @faker.version 1.9.2
|
53
|
-
def url_logo(
|
54
|
-
warn_for_deprecated_arguments do |keywords|
|
55
|
-
keywords << :coin if legacy_coin != NOT_GIVEN
|
56
|
-
end
|
57
|
-
|
45
|
+
def url_logo(coin: coin_array)
|
58
46
|
coin[URL_LOGO]
|
59
47
|
end
|
60
48
|
|
data/lib/faker/default/date.rb
CHANGED
@@ -17,20 +17,13 @@ module Faker
|
|
17
17
|
# Faker::Date.between(from: 2.days.ago, to: Date.today) #=> #<Date: 2014-09-24>
|
18
18
|
#
|
19
19
|
# @faker.version 1.0.0
|
20
|
-
def between(
|
21
|
-
warn_for_deprecated_arguments do |keywords|
|
22
|
-
keywords << :from if legacy_from != NOT_GIVEN
|
23
|
-
keywords << :to if legacy_to != NOT_GIVEN
|
24
|
-
end
|
25
|
-
|
20
|
+
def between(from:, to:)
|
26
21
|
from = get_date_object(from)
|
27
22
|
to = get_date_object(to)
|
28
23
|
|
29
24
|
Faker::Base.rand_in_range(from, to)
|
30
25
|
end
|
31
26
|
|
32
|
-
# rubocop:disable Metrics/ParameterLists
|
33
|
-
|
34
27
|
##
|
35
28
|
# Produce a random date between two dates.
|
36
29
|
#
|
@@ -46,17 +39,7 @@ module Faker
|
|
46
39
|
# Faker::Date.between_except(from: 1.year.ago, to: 1.year.from_now, excepted: Date.today) #=> #<Date: 2014-10-03>
|
47
40
|
#
|
48
41
|
# @faker.version 1.6.2
|
49
|
-
def between_except(
|
50
|
-
warn_for_deprecated_arguments do |keywords|
|
51
|
-
keywords << :from if legacy_from != NOT_GIVEN
|
52
|
-
end
|
53
|
-
warn_for_deprecated_arguments do |keywords|
|
54
|
-
keywords << :to if legacy_to != NOT_GIVEN
|
55
|
-
end
|
56
|
-
warn_for_deprecated_arguments do |keywords|
|
57
|
-
keywords << :excepted if legacy_excepted != NOT_GIVEN
|
58
|
-
end
|
59
|
-
|
42
|
+
def between_except(from:, to:, excepted:)
|
60
43
|
raise ArgumentError, 'From date, to date and excepted date must not be the same' if from == to && to == excepted
|
61
44
|
|
62
45
|
excepted = get_date_object(excepted)
|
@@ -66,7 +49,6 @@ module Faker
|
|
66
49
|
break date.to_date if date != excepted
|
67
50
|
end
|
68
51
|
end
|
69
|
-
# rubocop:enable Metrics/ParameterLists
|
70
52
|
|
71
53
|
##
|
72
54
|
# Produce a random date in the future (up to N days).
|
@@ -78,11 +60,7 @@ module Faker
|
|
78
60
|
# Faker::Date.forward(days: 23) #=> #<Date: 2014-10-03>
|
79
61
|
#
|
80
62
|
# @faker.version 1.0.0
|
81
|
-
def forward(
|
82
|
-
warn_for_deprecated_arguments do |keywords|
|
83
|
-
keywords << :days if legacy_days != NOT_GIVEN
|
84
|
-
end
|
85
|
-
|
63
|
+
def forward(days: 365)
|
86
64
|
from = ::Date.today + 1
|
87
65
|
to = ::Date.today + days
|
88
66
|
|
@@ -99,11 +77,7 @@ module Faker
|
|
99
77
|
# Faker::Date.backward(days: 14) #=> #<Date: 2019-09-12>
|
100
78
|
#
|
101
79
|
# @faker.version 1.0.0
|
102
|
-
def backward(
|
103
|
-
warn_for_deprecated_arguments do |keywords|
|
104
|
-
keywords << :days if legacy_days != NOT_GIVEN
|
105
|
-
end
|
106
|
-
|
80
|
+
def backward(days: 365)
|
107
81
|
from = ::Date.today - days
|
108
82
|
to = ::Date.today - 1
|
109
83
|
|
@@ -121,14 +95,7 @@ module Faker
|
|
121
95
|
# Faker::Date.birthday(min_age: 18, max_age: 65) #=> #<Date: 1986-03-28>
|
122
96
|
#
|
123
97
|
# @faker.version 1.4.3
|
124
|
-
def birthday(
|
125
|
-
warn_for_deprecated_arguments do |keywords|
|
126
|
-
keywords << :min_age if legacy_min_age != NOT_GIVEN
|
127
|
-
end
|
128
|
-
warn_for_deprecated_arguments do |keywords|
|
129
|
-
keywords << :max_age if legacy_max_age != NOT_GIVEN
|
130
|
-
end
|
131
|
-
|
98
|
+
def birthday(min_age: 18, max_age: 65)
|
132
99
|
t = ::Date.today
|
133
100
|
|
134
101
|
from = birthday_date(t, max_age)
|
@@ -80,11 +80,7 @@ module Faker
|
|
80
80
|
# Faker::Demographic.height(unit: :imperial) #=> "6 ft, 2 in"
|
81
81
|
#
|
82
82
|
# @faker.version 1.7.3
|
83
|
-
def height(
|
84
|
-
warn_for_deprecated_arguments do |keywords|
|
85
|
-
keywords << :unit if legacy_unit != NOT_GIVEN
|
86
|
-
end
|
87
|
-
|
83
|
+
def height(unit: :metric)
|
88
84
|
case unit
|
89
85
|
when :imperial
|
90
86
|
inches = rand_in_range(57, 86)
|
@@ -6,8 +6,6 @@ module Faker
|
|
6
6
|
NI_CHANCE = 0.03 # NI Pop is about 3% of total UK population
|
7
7
|
|
8
8
|
class << self
|
9
|
-
# rubocop:disable Metrics/ParameterLists
|
10
|
-
|
11
9
|
##
|
12
10
|
# Produces a random British driving licence number.
|
13
11
|
#
|
@@ -25,14 +23,7 @@ module Faker
|
|
25
23
|
# date_of_birth: Date.parse("1986-10-24")) #=> "OCARR815246J91HT"
|
26
24
|
#
|
27
25
|
# @faker.version 1.9.2
|
28
|
-
def british_driving_licence(
|
29
|
-
warn_for_deprecated_arguments do |keywords|
|
30
|
-
keywords << :last_name if legacy_last_name != NOT_GIVEN
|
31
|
-
keywords << :initials if legacy_initials != NOT_GIVEN
|
32
|
-
keywords << :gender if legacy_gender != NOT_GIVEN
|
33
|
-
keywords << :date_of_birth if legacy_date_of_birth != NOT_GIVEN
|
34
|
-
end
|
35
|
-
|
26
|
+
def british_driving_licence(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))
|
36
27
|
[
|
37
28
|
gb_licence_padding(last_name, 5),
|
38
29
|
gb_licence_year(date_of_birth, gender),
|
@@ -40,7 +31,6 @@ module Faker
|
|
40
31
|
gb_licence_checksum
|
41
32
|
].join
|
42
33
|
end
|
43
|
-
# rubocop:enable Metrics/ParameterLists
|
44
34
|
|
45
35
|
##
|
46
36
|
# Produces a random Northern Irish licence number.
|
data/lib/faker/default/drone.rb
CHANGED
data/lib/faker/default/file.rb
CHANGED
@@ -3,8 +3,6 @@
|
|
3
3
|
module Faker
|
4
4
|
class File < Base
|
5
5
|
class << self
|
6
|
-
# rubocop:disable Metrics/ParameterLists
|
7
|
-
|
8
6
|
##
|
9
7
|
# Produces a random directory name.
|
10
8
|
#
|
@@ -20,13 +18,7 @@ module Faker
|
|
20
18
|
# Faker::File.dir(segment_count: 3, root: nil, directory_separator: '\\') #=> "aut-ullam\\quia_quisquam\\ut-eos"
|
21
19
|
#
|
22
20
|
# @faker.version 1.6.4
|
23
|
-
def dir(
|
24
|
-
warn_for_deprecated_arguments do |keywords|
|
25
|
-
keywords << :segment_count if legacy_segment_count != NOT_GIVEN
|
26
|
-
keywords << :root if legacy_root != NOT_GIVEN
|
27
|
-
keywords << :directory_separator if legacy_directory_separator != NOT_GIVEN
|
28
|
-
end
|
29
|
-
|
21
|
+
def dir(segment_count: 3, root: nil, directory_separator: ::File::Separator)
|
30
22
|
Array
|
31
23
|
.new(segment_count) { Faker::Internet.slug }
|
32
24
|
.unshift(root)
|
@@ -34,7 +26,6 @@ module Faker
|
|
34
26
|
.join(directory_separator)
|
35
27
|
.squeeze(directory_separator)
|
36
28
|
end
|
37
|
-
# rubocop:enable Metrics/ParameterLists
|
38
29
|
|
39
30
|
##
|
40
31
|
# Produces a random file extension.
|
@@ -57,13 +48,11 @@ module Faker
|
|
57
48
|
# @example
|
58
49
|
# Faker::File.mime_type #=> "application/pdf"
|
59
50
|
#
|
60
|
-
# @faker.version
|
61
|
-
def mime_type
|
62
|
-
fetch('file.mime_type')
|
51
|
+
# @faker.version next
|
52
|
+
def mime_type(media_type: nil)
|
53
|
+
media_type ? fetch("file.mime_type.#{media_type}") : sample(sample(translate('faker.file.mime_type').values))
|
63
54
|
end
|
64
55
|
|
65
|
-
# rubocop:disable Metrics/ParameterLists
|
66
|
-
|
67
56
|
##
|
68
57
|
# Produces a random file name.
|
69
58
|
#
|
@@ -80,21 +69,13 @@ module Faker
|
|
80
69
|
# Faker::File.file_name(dir: 'foo/bar', name: 'baz', ext: 'mp3', directory_separator: '\\') #=> "foo/bar\\baz.mp3"
|
81
70
|
#
|
82
71
|
# @faker.version 1.6.4
|
83
|
-
def file_name(
|
84
|
-
warn_for_deprecated_arguments do |keywords|
|
85
|
-
keywords << :dir if legacy_dir != NOT_GIVEN
|
86
|
-
keywords << :name if legacy_name != NOT_GIVEN
|
87
|
-
keywords << :ext if legacy_ext != NOT_GIVEN
|
88
|
-
keywords << :directory_separator if legacy_directory_separator != NOT_GIVEN
|
89
|
-
end
|
90
|
-
|
72
|
+
def file_name(dir: nil, name: nil, ext: nil, directory_separator: ::File::Separator)
|
91
73
|
dir ||= dir(segment_count: 1)
|
92
74
|
name ||= Faker::Lorem.word.downcase
|
93
75
|
ext ||= extension
|
94
76
|
|
95
77
|
[dir, name].join(directory_separator) + ".#{ext}"
|
96
78
|
end
|
97
|
-
# rubocop:enable Metrics/ParameterLists
|
98
79
|
end
|
99
80
|
end
|
100
81
|
end
|
@@ -28,9 +28,9 @@ module Faker
|
|
28
28
|
|
29
29
|
# calculate the luhn checksum digit
|
30
30
|
multiplier = 1
|
31
|
-
luhn_sum = template.gsub(/[^0-9]/, '').
|
31
|
+
luhn_sum = template.gsub(/[^0-9]/, '').chars.reverse.map(&:to_i).inject(0) do |sum, digit|
|
32
32
|
multiplier = (multiplier == 2 ? 1 : 2)
|
33
|
-
sum + (digit * multiplier).to_s.
|
33
|
+
sum + (digit * multiplier).to_s.chars.map(&:to_i).inject(0) { |digit_sum, cur| digit_sum + cur }
|
34
34
|
end
|
35
35
|
|
36
36
|
# the sum plus whatever the last digit is must be a multiple of 10. So, the
|
@@ -52,11 +52,7 @@ module Faker
|
|
52
52
|
# Faker::Finance.vat_number('ZA') #=> "ZA79494416181"
|
53
53
|
#
|
54
54
|
# @faker.version 1.9.2
|
55
|
-
def vat_number(
|
56
|
-
warn_for_deprecated_arguments do |keywords|
|
57
|
-
keywords << :country if legacy_country != NOT_GIVEN
|
58
|
-
end
|
59
|
-
|
55
|
+
def vat_number(country: 'BR')
|
60
56
|
numerify(fetch("finance.vat_number.#{country}"))
|
61
57
|
rescue I18n::MissingTranslationData
|
62
58
|
raise ArgumentError, "Could not find vat number for #{country}"
|
@@ -97,6 +93,20 @@ module Faker
|
|
97
93
|
def stock_market
|
98
94
|
fetch('finance.stock_market')
|
99
95
|
end
|
96
|
+
|
97
|
+
##
|
98
|
+
# Returns a random condominium fiscal code.
|
99
|
+
#
|
100
|
+
# @param country [String] Two capital letter country code to use for the vat number.
|
101
|
+
# @return [String]
|
102
|
+
#
|
103
|
+
# @example
|
104
|
+
# Faker::Finance.condominium_fiscal_code #=> "012345678"
|
105
|
+
#
|
106
|
+
# @faker.version next
|
107
|
+
def condominium_fiscal_code(country: 'IT')
|
108
|
+
numerify(fetch("finance.condominium_fiscal_code.#{country}"))
|
109
|
+
end
|
100
110
|
end
|
101
111
|
end
|
102
112
|
end
|
data/lib/faker/default/food.rb
CHANGED
@@ -5,6 +5,19 @@ module Faker
|
|
5
5
|
flexible :food
|
6
6
|
|
7
7
|
class << self
|
8
|
+
##
|
9
|
+
# Retrieves an allergen.
|
10
|
+
#
|
11
|
+
# @return [String]
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# Faker::Food.allergen #=> "Peanuts"
|
15
|
+
#
|
16
|
+
# @faker.version next
|
17
|
+
def allergen
|
18
|
+
fetch('food.allergens')
|
19
|
+
end
|
20
|
+
|
8
21
|
##
|
9
22
|
# Retrieves a typical dish from each country.
|
10
23
|
#
|
@@ -97,7 +110,7 @@ module Faker
|
|
97
110
|
end
|
98
111
|
|
99
112
|
##
|
100
|
-
# Retrieves metric
|
113
|
+
# Retrieves metric measurements
|
101
114
|
#
|
102
115
|
# @return [String]
|
103
116
|
#
|
@@ -17,8 +17,6 @@ module Faker
|
|
17
17
|
random_word =~ /\s/ ? word : random_word
|
18
18
|
end
|
19
19
|
|
20
|
-
# rubocop:disable Metrics/ParameterLists
|
21
|
-
|
22
20
|
##
|
23
21
|
# Produces a random hipster word.
|
24
22
|
#
|
@@ -34,13 +32,7 @@ module Faker
|
|
34
32
|
# Faker::Hipster.words(number: 4, supplemental: true, spaces_allowed: true) #=> ["qui", "magni", "craft beer", "est"]
|
35
33
|
#
|
36
34
|
# @faker.version 1.6.0
|
37
|
-
def words(
|
38
|
-
warn_for_deprecated_arguments do |keywords|
|
39
|
-
keywords << :number if legacy_number != NOT_GIVEN
|
40
|
-
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
41
|
-
keywords << :spaces_allowed if legacy_spaces_allowed != NOT_GIVEN
|
42
|
-
end
|
43
|
-
|
35
|
+
def words(number: 3, supplemental: false, spaces_allowed: false)
|
44
36
|
resolved_num = resolve(number)
|
45
37
|
word_list = (
|
46
38
|
translate('faker.hipster.words') +
|
@@ -73,16 +65,9 @@ module Faker
|
|
73
65
|
# Faker::Hipster.sentence(word_count: 3, supplemental: true, random_words_to_add: 0, open_compounds_allowed: false) #=> "Dreamcatcher umami fixie."
|
74
66
|
#
|
75
67
|
# @faker.version 1.6.0
|
76
|
-
def sentence(
|
77
|
-
warn_for_deprecated_arguments do |keywords|
|
78
|
-
keywords << :word_count if legacy_word_count != NOT_GIVEN
|
79
|
-
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
80
|
-
keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
|
81
|
-
end
|
82
|
-
|
68
|
+
def sentence(word_count: 4, supplemental: false, random_words_to_add: 6, open_compounds_allowed: true)
|
83
69
|
"#{words(number: word_count + rand(random_words_to_add.to_i).to_i, supplemental: supplemental, spaces_allowed: open_compounds_allowed).join(' ').capitalize}."
|
84
70
|
end
|
85
|
-
# rubocop:enable Metrics/ParameterLists
|
86
71
|
|
87
72
|
##
|
88
73
|
# Produces random hipster sentences.
|
@@ -97,12 +82,7 @@ module Faker
|
|
97
82
|
# Faker::Hipster.sentences(number: 1, supplemental: true) #=> ["Et sustainable optio aesthetic et."]
|
98
83
|
#
|
99
84
|
# @faker.version 1.6.0
|
100
|
-
def sentences(
|
101
|
-
warn_for_deprecated_arguments do |keywords|
|
102
|
-
keywords << :number if legacy_number != NOT_GIVEN
|
103
|
-
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
104
|
-
end
|
105
|
-
|
85
|
+
def sentences(number: 3, supplemental: false)
|
106
86
|
[].tap do |sentences|
|
107
87
|
1.upto(resolve(number)) do
|
108
88
|
sentences << sentence(word_count: 3, supplemental: supplemental)
|
@@ -110,8 +90,6 @@ module Faker
|
|
110
90
|
end
|
111
91
|
end
|
112
92
|
|
113
|
-
# rubocop:disable Metrics/ParameterLists
|
114
|
-
|
115
93
|
##
|
116
94
|
# Produces a random hipster paragraph.
|
117
95
|
#
|
@@ -128,16 +106,9 @@ module Faker
|
|
128
106
|
# Faker::Hipster.paragraph(sentence_count: 2, supplemental: true, random_sentences_to_add: 4) #=> "Deep v gluten-free unde waistcoat aperiam migas voluptas dolorum. Aut drinking illo sustainable sapiente. Direct trade fanny pack kale chips ennui semiotics."
|
129
107
|
#
|
130
108
|
# @faker.version 1.6.0
|
131
|
-
def paragraph(
|
132
|
-
warn_for_deprecated_arguments do |keywords|
|
133
|
-
keywords << :sentence_count if legacy_sentence_count != NOT_GIVEN
|
134
|
-
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
135
|
-
keywords << :random_sentences_to_add if legacy_random_sentences_to_add != NOT_GIVEN
|
136
|
-
end
|
137
|
-
|
109
|
+
def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 3)
|
138
110
|
sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i, supplemental: supplemental).join(' ')
|
139
111
|
end
|
140
|
-
# rubocop:enable Metrics/ParameterLists
|
141
112
|
|
142
113
|
##
|
143
114
|
# Produces random hipster paragraphs.
|
@@ -152,12 +123,7 @@ module Faker
|
|
152
123
|
# Faker::Hipster.paragraphs(number: 1, supplemental: true) #=> ["Quae direct trade pbr&b quo taxidermy autem loko. Umami quas ratione migas cardigan sriracha minima. Tenetur perspiciatis pickled sed eum doloribus truffaut. Excepturi dreamcatcher meditation."]
|
153
124
|
#
|
154
125
|
# @faker.version 1.6.0
|
155
|
-
def paragraphs(
|
156
|
-
warn_for_deprecated_arguments do |keywords|
|
157
|
-
keywords << :number if legacy_number != NOT_GIVEN
|
158
|
-
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
159
|
-
end
|
160
|
-
|
126
|
+
def paragraphs(number: 3, supplemental: false)
|
161
127
|
[].tap do |paragraphs|
|
162
128
|
1.upto(resolve(number)) do
|
163
129
|
paragraphs << paragraph(sentence_count: 3, supplemental: supplemental)
|
@@ -177,12 +143,7 @@ module Faker
|
|
177
143
|
# Faker::Hipster.paragraph_by_chars(characters: 256, supplemental: false) #=> "Hella kogi blog narwhal sartorial selfies mustache schlitz. Bespoke normcore kitsch cred hella fixie. Park aesthetic fixie migas twee. Cliche mustache brunch tumblr fixie godard. Drinking pop-up synth hoodie dreamcatcher typewriter. Kitsch biodiesel green."
|
178
144
|
#
|
179
145
|
# @faker.version 1.6.0
|
180
|
-
def paragraph_by_chars(
|
181
|
-
warn_for_deprecated_arguments do |keywords|
|
182
|
-
keywords << :characters if legacy_characters != NOT_GIVEN
|
183
|
-
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
184
|
-
end
|
185
|
-
|
146
|
+
def paragraph_by_chars(characters: 256, supplemental: false)
|
186
147
|
paragraph = paragraph(sentence_count: 3, supplemental: supplemental)
|
187
148
|
|
188
149
|
paragraph += " #{paragraph(sentence_count: 3, supplemental: supplemental)}" while paragraph.length < characters
|