faker 2.15.1 → 3.4.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 +848 -34
- data/README.md +225 -103
- data/lib/faker/blockchain/aeternity.rb +1 -1
- data/lib/faker/blockchain/bitcoin.rb +2 -2
- data/lib/faker/blockchain/ethereum.rb +1 -1
- data/lib/faker/blockchain/tezos.rb +31 -3
- data/lib/faker/books/dune.rb +2 -10
- data/lib/faker/books/lovecraft.rb +9 -41
- data/lib/faker/books/the_kingkiller_chronicle.rb +61 -0
- data/lib/faker/creature/bird.rb +203 -0
- data/lib/faker/default/address.rb +7 -27
- 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 +25 -17
- data/lib/faker/default/barcode.rb +33 -22
- data/lib/faker/default/boolean.rb +1 -4
- data/lib/faker/default/cannabis.rb +10 -0
- data/lib/faker/default/chile_rut.rb +25 -25
- data/lib/faker/default/chuck_norris.rb +1 -0
- data/lib/faker/default/code.rb +71 -42
- data/lib/faker/default/color.rb +77 -6
- data/lib/faker/default/commerce.rb +31 -17
- data/lib/faker/default/company.rb +137 -22
- data/lib/faker/default/crypto.rb +26 -4
- data/lib/faker/default/crypto_coin.rb +3 -15
- data/lib/faker/default/date.rb +65 -42
- data/lib/faker/default/demographic.rb +1 -5
- data/lib/faker/default/driving_licence.rb +20 -18
- data/lib/faker/default/drone.rb +1 -1
- data/lib/faker/default/educator.rb +13 -0
- data/lib/faker/default/emotion.rb +33 -0
- data/lib/faker/default/file.rb +5 -22
- data/lib/faker/default/finance.rb +30 -7
- data/lib/faker/default/food.rb +27 -1
- data/lib/faker/default/hipster.rb +8 -48
- data/lib/faker/default/hobby.rb +22 -0
- data/lib/faker/default/html.rb +230 -0
- data/lib/faker/default/id_number.rb +175 -27
- data/lib/faker/default/internet.rb +333 -114
- data/lib/faker/default/invoice.rb +4 -17
- data/lib/faker/default/json.rb +4 -21
- data/lib/faker/default/lorem.rb +175 -73
- data/lib/faker/default/lorem_flickr.rb +4 -37
- data/lib/faker/default/markdown.rb +10 -13
- 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 → national_health_service.rb} +9 -8
- data/lib/faker/default/number.rb +33 -61
- data/lib/faker/default/omniauth.rb +55 -52
- data/lib/faker/default/phone_number.rb +36 -21
- data/lib/faker/default/placeholdit.rb +10 -20
- data/lib/faker/default/relationship.rb +1 -5
- data/lib/faker/default/religion.rb +6 -0
- data/lib/faker/default/science.rb +108 -0
- data/lib/faker/default/source.rb +3 -16
- data/lib/faker/default/south_africa.rb +3 -3
- data/lib/faker/default/string.rb +1 -7
- data/lib/faker/default/stripe.rb +4 -20
- data/lib/faker/default/tea.rb +41 -0
- data/lib/faker/{music/show.rb → default/theater.rb} +11 -8
- data/lib/faker/default/time.rb +4 -34
- data/lib/faker/default/twitter.rb +7 -23
- data/lib/faker/default/types.rb +12 -34
- data/lib/faker/default/vehicle.rb +44 -54
- 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 +14 -5
- data/lib/faker/games/final_fantasy_xiv.rb +73 -0
- 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/games/touhou.rb +75 -0
- data/lib/faker/games/witcher.rb +39 -0
- data/lib/faker/japanese_media/cowboy_bebop.rb +61 -0
- data/lib/faker/japanese_media/fullmetal_alchemist_brotherhood.rb +51 -0
- data/lib/faker/japanese_media/kamen_rider.rb +102 -0
- data/lib/faker/japanese_media/one_piece.rb +1 -1
- data/lib/faker/locations/australia.rb +52 -0
- data/lib/faker/movies/avatar.rb +49 -0
- data/lib/faker/movies/hackers.rb +48 -0
- data/lib/faker/movies/star_wars.rb +73 -5
- data/lib/faker/movies/{room.rb → the_room.rb} +4 -4
- data/lib/faker/movies/tron.rb +161 -0
- data/lib/faker/music/hiphop.rb +3 -3
- data/lib/faker/music/music.rb +12 -0
- data/lib/faker/music/rock_band.rb +12 -0
- data/lib/faker/music/smashing_pumpkins.rb +64 -0
- data/lib/faker/quotes/quote.rb +13 -0
- data/lib/faker/quotes/rajnikanth.rb +1 -0
- data/lib/faker/quotes/shakespeare.rb +34 -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/travel/train_station.rb +54 -0
- data/lib/faker/tv_shows/archer.rb +51 -0
- data/lib/faker/tv_shows/big_bang_theory.rb +1 -1
- 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/south_park.rb +15 -0
- data/lib/faker/tv_shows/spongebob.rb +50 -0
- data/lib/faker/tv_shows/suits.rb +1 -1
- data/lib/faker/tv_shows/supernatural.rb +48 -0
- data/lib/faker/tv_shows/the_office.rb +37 -0
- data/lib/faker/version.rb +2 -2
- data/lib/faker.rb +26 -67
- data/lib/helpers/base58.rb +1 -1
- data/lib/helpers/deprecator.rb +53 -0
- data/lib/helpers/positional_generator.rb +480 -0
- data/lib/helpers/unique_generator.rb +13 -14
- data/lib/locales/README.md +18 -2
- data/lib/locales/ar.yml +6 -1
- data/lib/locales/bg.yml +1 -2
- data/lib/locales/da-DK.yml +529 -35
- data/lib/locales/de-AT.yml +3487 -27
- data/lib/locales/de-CH.yml +4328 -12
- data/lib/locales/de.yml +7185 -99
- data/lib/locales/ee.yml +0 -1
- data/lib/locales/en/address.yml +1826 -562
- data/lib/locales/en/airport.yml +381 -0
- data/lib/locales/en/animal.yml +1 -1
- data/lib/locales/en/archer.yml +75 -0
- data/lib/locales/en/australia.yml +108 -0
- data/lib/locales/en/avatar.yml +31 -0
- data/lib/locales/en/bank.yml +1 -1
- data/lib/locales/en/bible.yml +90 -0
- data/lib/locales/en/bird.yml +1281 -0
- data/lib/locales/en/book.yml +487 -3
- 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/commerce.yml +17 -0
- data/lib/locales/en/community.yml +17 -17
- 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/device.yml +112 -4
- data/lib/locales/en/dnd.yml +186 -1
- data/lib/locales/en/dog.yml +262 -7
- data/lib/locales/en/dota.yml +173 -0
- data/lib/locales/en/dune.yml +266 -397
- data/lib/locales/en/educator.yml +6 -0
- data/lib/locales/en/emotion.yml +480 -0
- data/lib/locales/en/file.yml +9 -1
- data/lib/locales/en/final_fantasy_xiv.yml +754 -0
- data/lib/locales/en/finance.yml +27 -4
- data/lib/locales/en/food.yml +1067 -10
- data/lib/locales/en/football.yml +3 -3
- data/lib/locales/en/fullmetal_alchemist_brotherhood.yml +78 -0
- data/lib/locales/en/game.yml +11 -0
- data/lib/locales/en/hackers.yml +53 -0
- data/lib/locales/en/harry_potter.yml +1 -1
- data/lib/locales/en/heroes.yml +2 -2
- data/lib/locales/en/hobby.yml +171 -0
- data/lib/locales/en/horse.yml +2 -2
- data/lib/locales/en/id_number.yml +1 -1
- data/lib/locales/en/internet.yml +136 -3
- data/lib/locales/en/kamen_rider.yml +452 -0
- data/lib/locales/en/kpop.yml +7 -7
- data/lib/locales/en/lebowski.yml +1 -1
- data/lib/locales/en/lovecraft.yml +76 -6
- data/lib/locales/en/minecraft.yml +4 -4
- 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/music.yml +152 -142
- data/lib/locales/en/naruto.yml +2 -3
- data/lib/locales/en/one_piece.yml +1 -1
- data/lib/locales/en/opera.yml +2 -2
- data/lib/locales/en/overwatch.yml +5 -7
- data/lib/locales/en/phone_number.yml +78 -3
- data/lib/locales/en/rock_band.yml +1 -0
- data/lib/locales/en/science.yml +481 -3
- data/lib/locales/en/shakespeare.yml +21 -24
- data/lib/locales/en/smashing_pumpkins.yml +382 -0
- data/lib/locales/en/source.yml +5 -0
- data/lib/locales/en/south_park.yml +360 -2
- data/lib/locales/en/space.yml +1 -1
- 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 +7 -2
- data/lib/locales/en/supernatural.yml +141 -0
- data/lib/locales/en/tarkov.yml +593 -0
- data/lib/locales/en/tea.yml +172 -0
- data/lib/locales/en/the_kingkiller_chronicle.yml +56 -0
- data/lib/locales/en/the_office.yml +86 -0
- data/lib/locales/en/{room.yml → the_room.yml} +1 -1
- data/lib/locales/en/{show.yml → theater.yml} +1 -1
- data/lib/locales/en/touhou.yml +839 -0
- data/lib/locales/en/train_station.yml +280 -0
- data/lib/locales/en/tron.yml +227 -0
- data/lib/locales/en/vehicle.yml +2809 -75
- data/lib/locales/en/witcher.yml +37 -0
- data/lib/locales/en-AU.yml +718 -47
- data/lib/locales/en-CA.yml +373 -18
- data/lib/locales/en-GB.yml +116 -8
- data/lib/locales/en-IND.yml +1259 -17
- data/lib/locales/en-KE.yml +212 -0
- data/lib/locales/en-MS.yml +364 -17
- data/lib/locales/en-NEP.yml +212 -38
- data/lib/locales/en-NG.yml +1 -0
- data/lib/locales/en-NZ.yml +1153 -123
- data/lib/locales/en-PAK.yml +369 -10
- data/lib/locales/en-SG.yml +581 -16
- data/lib/locales/en-UG.yml +1 -0
- data/lib/locales/en-US.yml +6914 -74
- data/lib/locales/en-ZA.yml +1 -1
- data/lib/locales/en-au-ocker.yml +266 -22
- data/lib/locales/es-AR.yml +4570 -0
- data/lib/locales/es-MX.yml +1 -2
- data/lib/locales/es.yml +2 -3
- data/lib/locales/fi-FI.yml +3 -1
- data/lib/locales/fr/address.yml +20 -0
- data/lib/locales/fr/adjective.yml +266 -0
- data/lib/locales/fr/ancient.yml +141 -0
- data/lib/locales/fr/animal.yml +5 -0
- data/lib/locales/fr/appliance.yml +4 -0
- data/lib/locales/fr/book.yml +7 -0
- data/lib/locales/fr/color.yml +4 -0
- data/lib/locales/fr/company.yml +17 -0
- data/lib/locales/fr/compass.yml +23 -0
- data/lib/locales/fr/demographic.yml +4 -0
- data/lib/locales/fr/gender.yml +6 -0
- data/lib/locales/fr/internet.yml +4 -0
- data/lib/locales/fr/lorem.yml +5 -0
- data/lib/locales/fr/measurement.yml +7 -0
- data/lib/locales/fr/name.yml +22 -0
- data/lib/locales/fr/phone_number.yml +7 -0
- data/lib/locales/fr/pokemon.yml +7 -0
- data/lib/locales/fr-CA.yml +2733 -44
- data/lib/locales/fr-CH.yml +1 -2
- data/lib/locales/fr.yml +2 -118
- data/lib/locales/hy.yml +3624 -119
- data/lib/locales/id.yml +839 -12
- data/lib/locales/it.yml +1304 -32
- data/lib/locales/ja/README.md +13 -0
- data/lib/locales/ja/address.yml +120539 -0
- data/lib/locales/ja/adjective.yml +148 -0
- data/lib/locales/ja/ancient.yml +4 -0
- data/lib/locales/ja/animal.yml +5 -0
- data/lib/locales/ja/bank.yml +4 -0
- data/lib/locales/ja/book.yml +7 -0
- data/lib/locales/ja/cat.yml +5 -0
- data/lib/locales/ja/coffee.yml +4 -0
- data/lib/locales/ja/color.yml +4 -0
- data/lib/locales/ja/commerce.yml +11 -0
- data/lib/locales/ja/company.yml +8 -0
- data/lib/locales/ja/dog.yml +6 -0
- data/lib/locales/ja/emotion.yml +51 -0
- data/lib/locales/ja/food.yml +4 -0
- data/lib/locales/ja/football.yml +115 -0
- data/lib/locales/ja/gender.yml +4 -0
- data/lib/locales/ja/lorem.yml +9 -0
- data/lib/locales/ja/name.yml +13 -0
- data/lib/locales/ja/naruto.yml +230 -0
- data/lib/locales/ja/overwatch.yml +5 -0
- data/lib/locales/ja/phone_number.yml +7 -0
- data/lib/locales/ja/pokemon.yml +7 -0
- data/lib/locales/ja/relationship.yml +10 -0
- data/lib/locales/ja/restaurant.yml +11 -0
- data/lib/locales/ja/space.yml +5 -0
- data/lib/locales/ja/sport.yml +130 -0
- data/lib/locales/ja/studio_ghibli.yml +112 -0
- data/lib/locales/ja/subscription.yml +8 -0
- data/lib/locales/ja/super_mario.yml +9 -0
- data/lib/locales/ja/super_smash_bros.yml +8 -0
- data/lib/locales/ja/touhou.yml +466 -0
- data/lib/locales/ja/university.yml +9 -0
- data/lib/locales/ja/zelda.yml +5 -0
- data/lib/locales/ko.yml +1361 -20
- data/lib/locales/lt.yml +315 -0
- data/lib/locales/lv.yml +1 -2
- data/lib/locales/mi-NZ.yml +283 -0
- data/lib/locales/nb-NO.yml +518 -29
- data/lib/locales/nl.yml +1 -1
- data/lib/locales/pl.yml +1 -2
- data/lib/locales/pt-BR.yml +8157 -660
- data/lib/locales/pt.yml +844 -45
- data/lib/locales/ru.yml +1355 -32
- data/lib/locales/sk.yml +4410 -43
- data/lib/locales/sv.yml +100 -0
- data/lib/locales/th.yml +76 -76
- data/lib/locales/tr.yml +1 -2
- data/lib/locales/uk.yml +1808 -44
- data/lib/locales/vi.yml +1 -0
- data/lib/locales/zh-CN/bank.yml +17 -0
- data/lib/locales/zh-CN.yml +1 -0
- data/lib/locales/zh-TW.yml +1 -0
- metadata +134 -133
- data/History.md +0 -176
- data/lib/faker/default/fillmurray.rb +0 -45
- data/lib/faker/default/lorem_pixel.rb +0 -69
- data/lib/locales/ja.yml +0 -105
- /data/lib/faker/default/{faker_adjective.rb → adjective.rb} +0 -0
data/lib/faker/default/drone.rb
CHANGED
@@ -72,6 +72,19 @@ module Faker
|
|
72
72
|
parse('educator.secondary_school')
|
73
73
|
end
|
74
74
|
|
75
|
+
##
|
76
|
+
# Produces a primary school.
|
77
|
+
#
|
78
|
+
# @return [String]
|
79
|
+
#
|
80
|
+
# @example
|
81
|
+
# Faker::Educator.primary_school #=> "Brighthurst Elementary School"
|
82
|
+
#
|
83
|
+
# @faker.version next
|
84
|
+
def primary_school
|
85
|
+
parse('educator.primary_school')
|
86
|
+
end
|
87
|
+
|
75
88
|
##
|
76
89
|
# Produces a campus name.
|
77
90
|
#
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Faker
|
4
|
+
class Emotion < Base
|
5
|
+
class << self
|
6
|
+
##
|
7
|
+
# Produces an emotion noun.
|
8
|
+
#
|
9
|
+
# @return [String]
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# Faker::Emotion.noun #=> "amazement"
|
13
|
+
#
|
14
|
+
# @faker.version next
|
15
|
+
def noun
|
16
|
+
fetch('emotion.noun')
|
17
|
+
end
|
18
|
+
|
19
|
+
##
|
20
|
+
# Produces an emotion adjective.
|
21
|
+
#
|
22
|
+
# @return [String]
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# Faker::Emotion.adjective # => "nonplussed"
|
26
|
+
#
|
27
|
+
# @faker.version next
|
28
|
+
def adjective
|
29
|
+
fetch('emotion.adjective')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/faker/default/file.rb
CHANGED
@@ -18,15 +18,7 @@ module Faker
|
|
18
18
|
# Faker::File.dir(segment_count: 3, root: nil, directory_separator: '\\') #=> "aut-ullam\\quia_quisquam\\ut-eos"
|
19
19
|
#
|
20
20
|
# @faker.version 1.6.4
|
21
|
-
|
22
|
-
def dir(legacy_segment_count = NOT_GIVEN, legacy_root = NOT_GIVEN, legacy_directory_separator = NOT_GIVEN, segment_count: 3, root: nil, directory_separator: ::File::Separator)
|
23
|
-
# rubocop:enable Metrics/ParameterLists
|
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)
|
@@ -56,9 +48,9 @@ module Faker
|
|
56
48
|
# @example
|
57
49
|
# Faker::File.mime_type #=> "application/pdf"
|
58
50
|
#
|
59
|
-
# @faker.version
|
60
|
-
def mime_type
|
61
|
-
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))
|
62
54
|
end
|
63
55
|
|
64
56
|
##
|
@@ -77,16 +69,7 @@ module Faker
|
|
77
69
|
# Faker::File.file_name(dir: 'foo/bar', name: 'baz', ext: 'mp3', directory_separator: '\\') #=> "foo/bar\\baz.mp3"
|
78
70
|
#
|
79
71
|
# @faker.version 1.6.4
|
80
|
-
|
81
|
-
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: ::File::Separator)
|
82
|
-
# rubocop:enable Metrics/ParameterLists
|
83
|
-
warn_for_deprecated_arguments do |keywords|
|
84
|
-
keywords << :dir if legacy_dir != NOT_GIVEN
|
85
|
-
keywords << :name if legacy_name != NOT_GIVEN
|
86
|
-
keywords << :ext if legacy_ext != NOT_GIVEN
|
87
|
-
keywords << :directory_separator if legacy_directory_separator != NOT_GIVEN
|
88
|
-
end
|
89
|
-
|
72
|
+
def file_name(dir: nil, name: nil, ext: nil, directory_separator: ::File::Separator)
|
90
73
|
dir ||= dir(segment_count: 1)
|
91
74
|
name ||= Faker::Lorem.word.downcase
|
92
75
|
ext ||= extension
|
@@ -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}"
|
@@ -84,6 +80,33 @@ module Faker
|
|
84
80
|
rescue I18n::MissingTranslationData
|
85
81
|
raise ArgumentError, "Could not find market named #{market}"
|
86
82
|
end
|
83
|
+
|
84
|
+
##
|
85
|
+
# Returns a randomly-selected stock market.
|
86
|
+
#
|
87
|
+
# @return [String]
|
88
|
+
#
|
89
|
+
# @example
|
90
|
+
# Faker::Finance.stock_market #=> 'NASDAQ'
|
91
|
+
#
|
92
|
+
# @faker.version next
|
93
|
+
def stock_market
|
94
|
+
fetch('finance.stock_market')
|
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
|
87
110
|
end
|
88
111
|
end
|
89
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
|
#
|
@@ -108,6 +121,19 @@ module Faker
|
|
108
121
|
def metric_measurement
|
109
122
|
fetch('food.metric_measurements')
|
110
123
|
end
|
124
|
+
|
125
|
+
##
|
126
|
+
# Retrieves ethnic category
|
127
|
+
#
|
128
|
+
# @return [String]
|
129
|
+
#
|
130
|
+
# @example
|
131
|
+
# Faker::Food.ethnic_category #=> "Indian cuisine"
|
132
|
+
#
|
133
|
+
# @faker.version next
|
134
|
+
def ethnic_category
|
135
|
+
fetch('food.ethnic_category')
|
136
|
+
end
|
111
137
|
end
|
112
138
|
end
|
113
139
|
end
|
@@ -32,25 +32,16 @@ module Faker
|
|
32
32
|
# Faker::Hipster.words(number: 4, supplemental: true, spaces_allowed: true) #=> ["qui", "magni", "craft beer", "est"]
|
33
33
|
#
|
34
34
|
# @faker.version 1.6.0
|
35
|
-
|
36
|
-
def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_spaces_allowed = NOT_GIVEN, number: 3, supplemental: false, spaces_allowed: false)
|
37
|
-
# rubocop:enable Metrics/ParameterLists
|
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') +
|
47
39
|
(supplemental ? translate('faker.lorem.words') : [])
|
48
40
|
)
|
49
41
|
word_list *= ((resolved_num / word_list.length) + 1)
|
42
|
+
words = sample(word_list, resolved_num)
|
43
|
+
return words if spaces_allowed
|
50
44
|
|
51
|
-
return shuffle(word_list)[0, resolved_num] if spaces_allowed
|
52
|
-
|
53
|
-
words = shuffle(word_list)[0, resolved_num]
|
54
45
|
words.each_with_index { |w, i| words[i] = word if w =~ /\s/ }
|
55
46
|
end
|
56
47
|
|
@@ -73,15 +64,7 @@ module Faker
|
|
73
64
|
# Faker::Hipster.sentence(word_count: 3, supplemental: true, random_words_to_add: 0, open_compounds_allowed: false) #=> "Dreamcatcher umami fixie."
|
74
65
|
#
|
75
66
|
# @faker.version 1.6.0
|
76
|
-
|
77
|
-
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, open_compounds_allowed: true)
|
78
|
-
# rubocop:enable Metrics/ParameterLists
|
79
|
-
warn_for_deprecated_arguments do |keywords|
|
80
|
-
keywords << :word_count if legacy_word_count != NOT_GIVEN
|
81
|
-
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
82
|
-
keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
|
83
|
-
end
|
84
|
-
|
67
|
+
def sentence(word_count: 4, supplemental: false, random_words_to_add: 6, open_compounds_allowed: true)
|
85
68
|
"#{words(number: word_count + rand(random_words_to_add.to_i).to_i, supplemental: supplemental, spaces_allowed: open_compounds_allowed).join(' ').capitalize}."
|
86
69
|
end
|
87
70
|
|
@@ -98,12 +81,7 @@ module Faker
|
|
98
81
|
# Faker::Hipster.sentences(number: 1, supplemental: true) #=> ["Et sustainable optio aesthetic et."]
|
99
82
|
#
|
100
83
|
# @faker.version 1.6.0
|
101
|
-
def sentences(
|
102
|
-
warn_for_deprecated_arguments do |keywords|
|
103
|
-
keywords << :number if legacy_number != NOT_GIVEN
|
104
|
-
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
105
|
-
end
|
106
|
-
|
84
|
+
def sentences(number: 3, supplemental: false)
|
107
85
|
[].tap do |sentences|
|
108
86
|
1.upto(resolve(number)) do
|
109
87
|
sentences << sentence(word_count: 3, supplemental: supplemental)
|
@@ -127,15 +105,7 @@ module Faker
|
|
127
105
|
# 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."
|
128
106
|
#
|
129
107
|
# @faker.version 1.6.0
|
130
|
-
|
131
|
-
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)
|
132
|
-
# rubocop:enable Metrics/ParameterLists
|
133
|
-
warn_for_deprecated_arguments do |keywords|
|
134
|
-
keywords << :sentence_count if legacy_sentence_count != NOT_GIVEN
|
135
|
-
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
136
|
-
keywords << :random_sentences_to_add if legacy_random_sentences_to_add != NOT_GIVEN
|
137
|
-
end
|
138
|
-
|
108
|
+
def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 3)
|
139
109
|
sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i, supplemental: supplemental).join(' ')
|
140
110
|
end
|
141
111
|
|
@@ -152,12 +122,7 @@ module Faker
|
|
152
122
|
# 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
123
|
#
|
154
124
|
# @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
|
-
|
125
|
+
def paragraphs(number: 3, supplemental: false)
|
161
126
|
[].tap do |paragraphs|
|
162
127
|
1.upto(resolve(number)) do
|
163
128
|
paragraphs << paragraph(sentence_count: 3, supplemental: supplemental)
|
@@ -177,12 +142,7 @@ module Faker
|
|
177
142
|
# 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
143
|
#
|
179
144
|
# @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
|
-
|
145
|
+
def paragraph_by_chars(characters: 256, supplemental: false)
|
186
146
|
paragraph = paragraph(sentence_count: 3, supplemental: supplemental)
|
187
147
|
|
188
148
|
paragraph += " #{paragraph(sentence_count: 3, supplemental: supplemental)}" while paragraph.length < characters
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Faker
|
4
|
+
class Hobby < Base
|
5
|
+
flexible :hobby
|
6
|
+
|
7
|
+
class << self
|
8
|
+
##
|
9
|
+
# Retrieves a typical hobby activity.
|
10
|
+
#
|
11
|
+
# @return [String]
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# Faker::Hobby.activity #=> "Cooking"
|
15
|
+
#
|
16
|
+
# @faker.version next
|
17
|
+
def activity
|
18
|
+
fetch('hobby.activity')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,230 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Faker
|
4
|
+
class HTML < Base
|
5
|
+
class << self
|
6
|
+
##
|
7
|
+
# Produces a random HTML header format.
|
8
|
+
#
|
9
|
+
# @return [String]
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# Faker::HTML.heading #=> "<h5>Autem</h5>"
|
13
|
+
#
|
14
|
+
# @faker.version 3.2.1
|
15
|
+
def heading
|
16
|
+
level = rand(1..6)
|
17
|
+
"<h#{level}>#{Lorem.word.capitalize}</h#{level}>"
|
18
|
+
end
|
19
|
+
|
20
|
+
##
|
21
|
+
# Produces a random HTML paragraph format.
|
22
|
+
#
|
23
|
+
# @param sentence_count [Integer] The number of sentences in the paragraph.
|
24
|
+
# @param supplemental [Boolean] Include supplemental text.
|
25
|
+
# @param random_sentences_to_add [Integer] The number of random sentences to add to the paragraph.
|
26
|
+
# @param exclude_words [Array<String>] Words to exclude from the generated paragraph.
|
27
|
+
# @return [String]
|
28
|
+
#
|
29
|
+
# @example
|
30
|
+
# Faker::HTML.paragraph #=> "<p>Incidunt atque quis</p>"
|
31
|
+
#
|
32
|
+
# @faker.version 3.2.1
|
33
|
+
def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 0, exclude_words: nil)
|
34
|
+
"<p>#{Faker::Lorem.paragraph(sentence_count: sentence_count, supplemental: supplemental, random_sentences_to_add: random_sentences_to_add, exclude_words: exclude_words)}</p>"
|
35
|
+
end
|
36
|
+
|
37
|
+
##
|
38
|
+
# Produces a random emphasis formatting on a random word in two HTML paragraphs.
|
39
|
+
#
|
40
|
+
# @return [String]
|
41
|
+
#
|
42
|
+
# @example
|
43
|
+
# Faker::HTML.emphasis #=> "<em>repellat id impedit</em>"
|
44
|
+
#
|
45
|
+
# @faker.version 3.2.1
|
46
|
+
def emphasis
|
47
|
+
"<em>#{Faker::Lorem.paragraph(sentence_count: 1)}</em>"
|
48
|
+
end
|
49
|
+
|
50
|
+
##
|
51
|
+
# Produces a random ordered list in HTML format, with at least one element.
|
52
|
+
#
|
53
|
+
# @return [String]
|
54
|
+
#
|
55
|
+
# @example
|
56
|
+
# Faker::HTML.ordered_list #=> "<ol>\n<li>Qui reiciendis non consequatur atque.</li>\n<li>Quo doloremque veritatis tempora aut.</li>\n<li>Aspernatur.</li>\n<li>Ea ab.</li>\n<li>Qui.</li>\n<li>Sit pariatur nemo eveniet.</li>\n<li>Molestiae aut.</li>\n<li>Nihil molestias iure placeat.</li>\n<li>Dolore autem quisquam.</li>\n</ol>"
|
57
|
+
#
|
58
|
+
# @faker.version 3.2.1
|
59
|
+
def ordered_list
|
60
|
+
number = rand(1..10)
|
61
|
+
|
62
|
+
items = []
|
63
|
+
number.times do
|
64
|
+
items << "<li>#{Faker::Lorem.sentence(word_count: 1)}</li>"
|
65
|
+
end
|
66
|
+
|
67
|
+
"<ol>\n#{items.join("\n")}\n</ol>"
|
68
|
+
end
|
69
|
+
|
70
|
+
##
|
71
|
+
# Produces a random unordered list of items between 1 and 10 randomly in HTML format.
|
72
|
+
#
|
73
|
+
# @return [String]
|
74
|
+
#
|
75
|
+
# @example
|
76
|
+
# Faker::HTML.unordered_list #=> "<ul>\n<li>Voluptatum aliquid tempora molestiae facilis non sed.</li>\n<li>Nostrum omnis iste impedit voluptatum dolor.</li>\n<li>Esse quidem et facere.</li>\n</ul>"
|
77
|
+
#
|
78
|
+
# @faker.version 3.2.1
|
79
|
+
def unordered_list
|
80
|
+
number = rand(1..10)
|
81
|
+
|
82
|
+
items = []
|
83
|
+
number.times do
|
84
|
+
items << "<li>#{Faker::Lorem.sentence(word_count: 1)}</li>"
|
85
|
+
end
|
86
|
+
|
87
|
+
"<ul>\n#{items.join("\n")}\n</ul>"
|
88
|
+
end
|
89
|
+
|
90
|
+
##
|
91
|
+
# Produces a random code block formatted in HTML.
|
92
|
+
#
|
93
|
+
# @return [String]
|
94
|
+
#
|
95
|
+
# @example
|
96
|
+
# Faker::HTML.code #=> "<code>Eos quasi qui.</code>"
|
97
|
+
#
|
98
|
+
# @faker.version 3.2.1
|
99
|
+
def code
|
100
|
+
"<code>#{Lorem.sentence(word_count: 1)}</code>"
|
101
|
+
end
|
102
|
+
|
103
|
+
##
|
104
|
+
# Produces a random HTML table.
|
105
|
+
#
|
106
|
+
# @return [String]
|
107
|
+
#
|
108
|
+
# @example
|
109
|
+
# Faker::HTML.table #=> "<table>\n<thead>\n<th>ad</th>\n<th>similique</th>\n<th>voluptatem</th>\n</thead>\n<tbody>\n<td>corrupti</td>\n<td>est</td>\n<td>rerum</td>\n<td>molestiae</td>\n<td>quidem</td>\n<td>et</td>\n<td>in</td>\n<td>tempora</td>\n<td>at</td>\n<\tbody>\n<tfoot>\n<td>voluptatem</td>\n<td>debitis</td>\n<td>rem</td>\n</tfoot>\n</table>"
|
110
|
+
#
|
111
|
+
# @faker.version 3.2.1
|
112
|
+
def table
|
113
|
+
header_row = generate_table_row('th', 3)
|
114
|
+
footer_row = generate_table_row('td', 3)
|
115
|
+
|
116
|
+
body_rows = []
|
117
|
+
3.times do
|
118
|
+
row = generate_table_row('td', 3)
|
119
|
+
body_rows << row
|
120
|
+
end
|
121
|
+
|
122
|
+
thead = "<thead>\n#{header_row}</thead>"
|
123
|
+
tbody = "<tbody>\n#{body_rows.join("\n")}</tbody>"
|
124
|
+
tfoot = "<tfoot>\n#{footer_row}</tfoot>"
|
125
|
+
|
126
|
+
"<table>\n#{thead}\n#{tbody}\n#{tfoot}\n</table>"
|
127
|
+
end
|
128
|
+
|
129
|
+
##
|
130
|
+
# Generates a random <script> tag with the `src` attribute set to a random URL.
|
131
|
+
#
|
132
|
+
# @return [String]
|
133
|
+
#
|
134
|
+
# @example
|
135
|
+
# Faker::HTML.script #=> "<script src=\"http://gulgowski.name/jordan.weimann.js\"></script>"
|
136
|
+
#
|
137
|
+
# @faker.version 3.2.1
|
138
|
+
def script
|
139
|
+
"<script src=\"#{Faker::Internet.url}.js\"></script>"
|
140
|
+
end
|
141
|
+
|
142
|
+
##
|
143
|
+
# Generates a random <link> tag with the `rel` attribute set to "stylesheet" and the `href` attribute set to a random URL.
|
144
|
+
#
|
145
|
+
# @param rel [String] The rel of the link tag.
|
146
|
+
# @return [String]
|
147
|
+
#
|
148
|
+
# @example
|
149
|
+
# Faker::HTML.link #=> "<link rel=\"stylesheet\" href=\"http://fay.io/darryl.barrows.css\">"
|
150
|
+
#
|
151
|
+
# @faker.version 3.2.1
|
152
|
+
def link(rel: 'stylesheet')
|
153
|
+
"<link rel=\"#{rel}\" href=\"#{Faker::Internet.url}.css\">"
|
154
|
+
end
|
155
|
+
|
156
|
+
##
|
157
|
+
# Generates HTML content with customizable attributes for any HTML tag.
|
158
|
+
#
|
159
|
+
# @param tag [String] The HTML tag to generate.
|
160
|
+
# @param content [String] The Content of the HTML tag.
|
161
|
+
# @param attributes [Hash] The attributes to include in the tag.
|
162
|
+
# @return [String]
|
163
|
+
#
|
164
|
+
# @example
|
165
|
+
# Faker::HTML.element(tag: 'div', content: "This is a div with XSS attributes.", attributes: {class: 'xss', onclick: "alert('XSS')"}) #=> "<div class=\"xss\" onclick=\"alert('XSS')\">This is a div with XSS attributes.</div>"
|
166
|
+
#
|
167
|
+
# @faker.version 3.2.1
|
168
|
+
def element(tag: 'div', content: Lorem.sentence(word_count: 3), attributes: { class: Lorem.word, onclick: "#{Lorem.word}()" })
|
169
|
+
attribute_string = attributes.map { |key, value| "#{key}=\"#{value}\"" }.join(' ')
|
170
|
+
"<#{tag} #{attribute_string}>#{content}</#{tag}>"
|
171
|
+
end
|
172
|
+
|
173
|
+
##
|
174
|
+
# Produces a random method from the methods above, excluding the methods listed in the arguments.
|
175
|
+
#
|
176
|
+
# @overload random(methods)
|
177
|
+
# @param methods [Symbol] Specify which methods to exclude.
|
178
|
+
#
|
179
|
+
# @return [String]
|
180
|
+
#
|
181
|
+
# @example
|
182
|
+
# Faker::HTML.random #=> returns output from a single method outlined above
|
183
|
+
# Faker::HTML.random(exclude: [:table]) #=> returns output from any single method outlined above except for "table"
|
184
|
+
# Faker::HTML.random(exclude: [:ordered_list, :unordered_list]) #=> returns output from any single method outlined above except for either ordered_list and unordered_list
|
185
|
+
#
|
186
|
+
# @faker.version 3.2.1
|
187
|
+
def random(exclude: [])
|
188
|
+
method_list = available_methods
|
189
|
+
exclude.each { |ex| method_list.delete_if { |meth| meth == ex.to_sym } }
|
190
|
+
send(method_list[Faker::Config.random.rand(0..method_list.length - 1)])
|
191
|
+
end
|
192
|
+
|
193
|
+
##
|
194
|
+
# Generates a random HTML content sandwich, starting with a header, followed by paragraphs, and random elements.
|
195
|
+
#
|
196
|
+
# @param sentences [Integer] The number of sentences in each paragraph.
|
197
|
+
# @param repeat [Integer] The number of times to repeat the pattern (header, paragraph, random).
|
198
|
+
# @return [String]
|
199
|
+
#
|
200
|
+
# @example
|
201
|
+
# Faker::HTML.sandwich(sentences: 3, repeat: 2) #=> returns a sandwich of HTML content with 2 repetitions, each having a header, paragraph, and random element
|
202
|
+
#
|
203
|
+
# @faker.version 3.2.1
|
204
|
+
def sandwich(sentences: 3, repeat: 1)
|
205
|
+
text_block = []
|
206
|
+
text_block << heading
|
207
|
+
repeat.times do
|
208
|
+
text_block << paragraph(sentence_count: sentences)
|
209
|
+
text_block << random(exclude: %i[script link])
|
210
|
+
end
|
211
|
+
text_block.join("\n")
|
212
|
+
end
|
213
|
+
|
214
|
+
private
|
215
|
+
|
216
|
+
def available_methods
|
217
|
+
(HTML.public_methods(false) - Base.methods).sort
|
218
|
+
end
|
219
|
+
|
220
|
+
def generate_table_row(tag, cell_count)
|
221
|
+
row = "<tr>\n"
|
222
|
+
cell_count.times do
|
223
|
+
row += "<#{tag == 'th' ? 'th' : 'td'}>#{Lorem.word}</#{tag == 'th' ? 'th' : 'td'}>\n"
|
224
|
+
end
|
225
|
+
row += "</tr>\n"
|
226
|
+
row
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|