faker 2.11.0 → 2.18.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 +421 -13
- data/History.md +4 -4
- data/README.md +33 -3
- data/lib/faker.rb +28 -23
- data/lib/faker/blockchain/aeternity.rb +4 -4
- data/lib/faker/blockchain/bitcoin.rb +2 -2
- data/lib/faker/blockchain/tezos.rb +30 -2
- data/lib/faker/books/dune.rb +15 -2
- data/lib/faker/books/lovecraft.rb +8 -4
- data/lib/faker/creature/bird.rb +203 -0
- data/lib/faker/default/address.rb +35 -5
- data/lib/faker/default/app.rb +1 -1
- data/lib/faker/default/avatar.rb +1 -1
- data/lib/faker/default/bank.rb +96 -3
- data/lib/faker/default/barcode.rb +165 -0
- data/lib/faker/default/beer.rb +3 -3
- data/lib/faker/default/blood.rb +48 -0
- data/lib/faker/default/business.rb +1 -1
- data/lib/faker/default/camera.rb +46 -0
- data/lib/faker/default/cannabis.rb +10 -0
- data/lib/faker/default/chile_rut.rb +47 -3
- data/lib/faker/default/chuck_norris.rb +1 -0
- data/lib/faker/default/code.rb +98 -17
- data/lib/faker/default/commerce.rb +74 -11
- data/lib/faker/default/company.rb +96 -11
- data/lib/faker/default/compass.rb +135 -0
- data/lib/faker/default/computer.rb +63 -0
- data/lib/faker/default/construction.rb +54 -0
- data/lib/faker/default/cosmere.rb +90 -0
- data/lib/faker/default/crypto.rb +17 -4
- data/lib/faker/default/crypto_coin.rb +45 -0
- data/lib/faker/default/date.rb +16 -12
- data/lib/faker/default/driving_licence.rb +67 -1
- data/lib/faker/default/drone.rb +332 -0
- data/lib/faker/default/educator.rb +13 -0
- data/lib/faker/default/faker_adjective.rb +35 -0
- data/lib/faker/default/file.rb +53 -2
- data/lib/faker/default/finance.rb +45 -0
- data/lib/faker/default/food.rb +1 -1
- data/lib/faker/default/gender.rb +1 -1
- data/lib/faker/default/hipster.rb +107 -10
- data/lib/faker/default/id_number.rb +122 -2
- data/lib/faker/default/internet.rb +266 -12
- data/lib/faker/default/internet_http.rb +48 -0
- data/lib/faker/default/invoice.rb +33 -6
- data/lib/faker/default/json.rb +61 -5
- data/lib/faker/default/lorem.rb +160 -5
- data/lib/faker/default/lorem_flickr.rb +67 -7
- data/lib/faker/default/lorem_pixel.rb +23 -0
- data/lib/faker/default/markdown.rb +91 -0
- data/lib/faker/default/measurement.rb +93 -2
- data/lib/faker/default/military.rb +26 -0
- data/lib/faker/default/mountain.rb +33 -0
- data/lib/faker/default/name.rb +98 -0
- data/lib/faker/default/nhs.rb +19 -0
- data/lib/faker/default/number.rb +28 -13
- data/lib/faker/default/omniauth.rb +62 -14
- data/lib/faker/default/phone_number.rb +88 -5
- data/lib/faker/default/placeholdit.rb +23 -1
- data/lib/faker/default/relationship.rb +1 -1
- data/lib/faker/default/science.rb +26 -0
- data/lib/faker/default/slack_emoji.rb +81 -0
- data/lib/faker/default/south_africa.rb +90 -0
- data/lib/faker/default/space.rb +1 -1
- data/lib/faker/default/string.rb +20 -3
- data/lib/faker/default/stripe.rb +64 -3
- data/lib/faker/default/tea.rb +41 -0
- data/lib/faker/default/twitter.rb +35 -0
- data/lib/faker/default/types.rb +84 -3
- data/lib/faker/default/university.rb +45 -0
- data/lib/faker/default/vehicle.rb +184 -4
- data/lib/faker/default/verb.rb +45 -0
- data/lib/faker/default/world_cup.rb +4 -4
- data/lib/faker/fantasy/tolkien.rb +67 -0
- data/lib/faker/games/clash_of_clans.rb +48 -0
- data/lib/faker/games/control.rb +113 -0
- data/lib/faker/games/dnd.rb +136 -0
- data/lib/faker/games/elder_scrolls.rb +26 -0
- data/lib/faker/games/heroes.rb +13 -0
- data/lib/faker/games/heroes_of_the_storm.rb +16 -5
- data/lib/faker/games/minecraft.rb +113 -0
- data/lib/faker/games/street_fighter.rb +61 -0
- data/lib/faker/games/super_mario.rb +48 -0
- data/lib/faker/games/touhou.rb +75 -0
- data/lib/faker/games/warhammer_fantasy.rb +74 -0
- data/lib/faker/games/witcher.rb +39 -0
- data/lib/faker/games/world_of_warcraft.rb +26 -1
- data/lib/faker/japanese_media/conan.rb +48 -0
- data/lib/faker/japanese_media/doraemon.rb +48 -0
- data/lib/faker/japanese_media/dragon_ball.rb +26 -0
- data/lib/faker/japanese_media/naruto.rb +61 -0
- data/lib/faker/japanese_media/studio_ghibli.rb +48 -0
- data/lib/faker/movies/departed.rb +49 -0
- data/lib/faker/movies/hobbit.rb +4 -4
- data/lib/faker/movies/how_to_train_your_dragon.rb +48 -0
- data/lib/faker/movies/lord_of_the_rings.rb +3 -3
- data/lib/faker/movies/movie.rb +13 -0
- data/lib/faker/movies/room.rb +63 -0
- data/lib/faker/movies/star_wars.rb +74 -2
- data/lib/faker/music/hiphop.rb +48 -0
- data/lib/faker/music/music.rb +12 -0
- data/lib/faker/music/opera.rb +237 -1
- data/lib/faker/music/pearl_jam.rb +50 -0
- data/lib/faker/music/phish.rb +27 -1
- data/lib/faker/music/prince.rb +64 -0
- data/lib/faker/music/rock_band.rb +12 -0
- data/lib/faker/music/rush.rb +37 -0
- data/lib/faker/music/show.rb +49 -0
- data/lib/faker/quotes/quote.rb +80 -1
- data/lib/faker/quotes/rajnikanth.rb +1 -0
- data/lib/faker/quotes/shakespeare.rb +70 -0
- data/lib/faker/sports/volleyball.rb +74 -0
- data/lib/faker/tv_shows/aqua_teen_hunger_force.rb +13 -0
- data/lib/faker/tv_shows/big_bang_theory.rb +37 -0
- data/lib/faker/tv_shows/buffy.rb +17 -4
- data/lib/faker/tv_shows/dr_who.rb +1 -1
- data/lib/faker/tv_shows/final_space.rb +51 -0
- data/lib/faker/tv_shows/futurama.rb +65 -0
- data/lib/faker/tv_shows/simpsons.rb +14 -0
- data/lib/faker/tv_shows/suits.rb +37 -0
- data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +17 -4
- data/lib/faker/version.rb +1 -1
- data/lib/helpers/base58.rb +1 -1
- data/lib/helpers/char.rb +22 -27
- data/lib/helpers/unique_generator.rb +0 -2
- data/lib/locales/de-AT.yml +4 -2
- data/lib/locales/de-CH.yml +1696 -1
- data/lib/locales/de.yml +4 -2
- data/lib/locales/en-AU.yml +50 -10
- data/lib/locales/en-CA.yml +2 -0
- data/lib/locales/en-GB.yml +1 -1
- data/lib/locales/en-IND.yml +2 -1
- data/lib/locales/en-MS.yml +2 -1
- data/lib/locales/en-NEP.yml +4 -1
- data/lib/locales/en-NZ.yml +3 -1
- data/lib/locales/en-PAK.yml +2 -1
- data/lib/locales/en-SG.yml +2 -1
- data/lib/locales/en-US.yml +37 -11
- data/lib/locales/en-au-ocker.yml +2 -1
- data/lib/locales/en.yml +0 -3
- data/lib/locales/en/address.yml +2 -0
- data/lib/locales/en/adjective.yml +179 -0
- data/lib/locales/en/animal.yml +1 -1
- data/lib/locales/en/aqua_teen_hunger_force.yml +33 -1
- data/lib/locales/en/bank.yml +1 -1
- data/lib/locales/en/barcode.yml +24 -0
- data/lib/locales/en/big_bang_theory.yml +38 -0
- data/lib/locales/en/bird.yml +1281 -0
- data/lib/locales/en/blood.yml +13 -0
- data/lib/locales/en/book.yml +487 -3
- data/lib/locales/en/buffy.yml +1 -1
- data/lib/locales/en/camera.yml +611 -0
- data/lib/locales/en/clash_of_clan.yml +101 -0
- data/lib/locales/en/company.yml +2 -2
- data/lib/locales/en/computer.yml +36 -0
- data/lib/locales/en/conan.yml +171 -0
- data/lib/locales/en/control.yml +247 -0
- data/lib/locales/en/demographic.yml +218 -5
- data/lib/locales/en/departed.yml +50 -0
- data/lib/locales/en/device.yml +112 -4
- data/lib/locales/en/dnd.yml +451 -0
- data/lib/locales/en/doraemon.yml +286 -0
- data/lib/locales/en/dota.yml +531 -63
- data/lib/locales/en/dragon_ball.yml +243 -1
- data/lib/locales/en/driving_license.yml +181 -0
- data/lib/locales/en/drone.yml +95 -0
- data/lib/locales/en/dune.yml +270 -131
- data/lib/locales/en/educator.yml +6 -0
- data/lib/locales/en/elder_scrolls.yml +583 -9
- data/lib/locales/en/fallout.yml +311 -133
- data/lib/locales/en/final_space.yml +37 -0
- data/lib/locales/en/finance.yml +53 -0
- data/lib/locales/en/football.yml +3 -3
- data/lib/locales/en/fresh_prince_of_bel_air.yml +1 -1
- data/lib/locales/en/futurama.yml +344 -0
- data/lib/locales/en/half_life.yml +84 -3
- data/lib/locales/en/heroes.yml +408 -3
- data/lib/locales/en/heroes_of_the_storm.yml +131 -4
- data/lib/locales/en/house.yml +1 -1
- data/lib/locales/en/how_to_train_your_dragon.yml +174 -0
- data/lib/locales/en/jack_handey.yml +54 -0
- data/lib/locales/en/league_of_legends.yml +285 -6
- data/lib/locales/en/lebowski.yml +1 -1
- data/lib/locales/en/lovecraft.yml +76 -6
- data/lib/locales/en/military.yml +179 -5
- data/lib/locales/en/minecraft.yml +663 -0
- data/lib/locales/en/mountain.yml +158 -0
- data/lib/locales/en/movie.yml +192 -1
- data/lib/locales/en/music.yml +461 -29
- data/lib/locales/en/myst.yml +87 -31
- data/lib/locales/en/name.yml +5 -4
- data/lib/locales/en/naruto.yml +231 -0
- data/lib/locales/en/one_piece.yml +2 -2
- data/lib/locales/en/opera.yml +168 -0
- data/lib/locales/en/overwatch.yml +2650 -2622
- data/lib/locales/en/pearl_jam.yml +213 -0
- data/lib/locales/en/phish.yml +392 -1
- data/lib/locales/en/pokemon.yml +417 -4
- data/lib/locales/en/prince.yml +227 -0
- data/lib/locales/en/quote.yml +692 -163
- data/lib/locales/en/rock_band.yml +1 -0
- data/lib/locales/en/room.yml +68 -0
- data/lib/locales/en/rush.yml +32 -0
- data/lib/locales/en/science.yml +355 -3
- data/lib/locales/en/shakespeare.yml +21 -24
- data/lib/locales/en/show.yml +597 -0
- data/lib/locales/en/simpsons.yml +668 -0
- data/lib/locales/en/source.yml +30 -0
- data/lib/locales/en/space.yml +1 -1
- data/lib/locales/en/star_trek.yml +1 -1
- data/lib/locales/en/star_wars.yml +568 -220
- data/lib/locales/en/street_fighter.yml +1524 -0
- data/lib/locales/en/studio_ghibli.yml +107 -0
- data/lib/locales/en/suits.yml +45 -0
- data/lib/locales/en/super_mario.yml +58 -0
- data/lib/locales/en/super_smash_bros.yml +18 -4
- data/lib/locales/en/tea.yml +172 -0
- data/lib/locales/en/tolkien.yml +2453 -0
- data/lib/locales/en/touhou.yml +839 -0
- data/lib/locales/en/volleyball.yml +501 -0
- data/lib/locales/en/warhammer_fantasy.yml +582 -0
- data/lib/locales/en/witcher.yml +426 -7
- data/lib/locales/en/world_of_warcraft.yml +122 -4
- data/lib/locales/en/zelda.yml +962 -4
- data/lib/locales/es-AR.yml +4603 -0
- data/lib/locales/es.yml +56 -0
- data/lib/locales/fi-FI.yml +1 -1
- data/lib/locales/fr-CA.yml +21 -5
- data/lib/locales/fr-CH.yml +2 -2
- data/lib/locales/fr.yml +1 -113
- data/lib/locales/fr/address.yml +21 -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 +5 -0
- data/lib/locales/fr/lorem.yml +5 -0
- data/lib/locales/fr/measurement.yml +7 -0
- data/lib/locales/fr/name.yml +21 -0
- data/lib/locales/fr/phone_number.yml +7 -0
- data/lib/locales/fr/pokemon.yml +9 -0
- data/lib/locales/id.yml +3 -1
- data/lib/locales/it.yml +2 -1
- data/lib/locales/ja/README.md +13 -0
- data/lib/locales/ja/address.yml +17 -0
- data/lib/locales/ja/ancient.yml +4 -0
- data/lib/locales/ja/bank.yml +4 -0
- data/lib/locales/ja/book.yml +7 -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/creature.yml +9 -0
- data/lib/locales/ja/food.yml +4 -0
- data/lib/locales/ja/games.yml +18 -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/phone_number.yml +7 -0
- data/lib/locales/ja/restaurant.yml +11 -0
- data/lib/locales/ja/space.yml +5 -0
- data/lib/locales/ja/subscription.yml +8 -0
- data/lib/locales/ja/university.yml +9 -0
- data/lib/locales/ko.yml +94 -2
- data/lib/locales/nb-NO.yml +4 -2
- data/lib/locales/pt-BR.yml +3 -1
- data/lib/locales/pt.yml +3 -1
- data/lib/locales/ru.yml +42 -1
- data/lib/locales/sk.yml +4 -2
- data/lib/locales/uk.yml +2 -0
- metadata +133 -24
- data/lib/locales/en/hobbit.yml +0 -19
- data/lib/locales/en/lord_of_the_rings.yml +0 -6
- data/lib/locales/ja.yml +0 -101
@@ -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,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Faker
|
4
|
+
class Adjective < Base
|
5
|
+
flexible :adjective
|
6
|
+
|
7
|
+
class << self
|
8
|
+
##
|
9
|
+
# Produces a positive adjective.
|
10
|
+
#
|
11
|
+
# @return [String]
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# Faker::Adjective.positive #=> "Kind"
|
15
|
+
#
|
16
|
+
# @faker.version next
|
17
|
+
def positive
|
18
|
+
fetch('adjective.positive')
|
19
|
+
end
|
20
|
+
|
21
|
+
##
|
22
|
+
# Produces a negative adjective.
|
23
|
+
#
|
24
|
+
# @return [String]
|
25
|
+
#
|
26
|
+
# @example
|
27
|
+
# Faker::Adjective.negative #=> "Creepy"
|
28
|
+
#
|
29
|
+
# @faker.version next
|
30
|
+
def negative
|
31
|
+
fetch('adjective.negative')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/faker/default/file.rb
CHANGED
@@ -4,8 +4,23 @@ module Faker
|
|
4
4
|
class File < Base
|
5
5
|
class << self
|
6
6
|
# rubocop:disable Metrics/ParameterLists
|
7
|
+
|
8
|
+
##
|
9
|
+
# Produces a random directory name.
|
10
|
+
#
|
11
|
+
# @param segment_count [Integer] Specifies the number of nested folders in the generated string.
|
12
|
+
# @param root [String] Specifies the root of the generated string.
|
13
|
+
# @param directory_separator [String] Specifies the separator between the segments.
|
14
|
+
# @return [String]
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
# Faker::File.dir #=> "et_error/sint_voluptas/quas_veritatis"
|
18
|
+
# Faker::File.dir(segment_count: 2) #=> "ea-suscipit/ut-deleniti"
|
19
|
+
# Faker::File.dir(segment_count: 3, root: nil, directory_separator: '/') #=> "est_porro/fugit_eveniet/incidunt-autem"
|
20
|
+
# Faker::File.dir(segment_count: 3, root: nil, directory_separator: '\\') #=> "aut-ullam\\quia_quisquam\\ut-eos"
|
21
|
+
#
|
22
|
+
# @faker.version 1.6.4
|
7
23
|
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)
|
8
|
-
# rubocop:enable Metrics/ParameterLists
|
9
24
|
warn_for_deprecated_arguments do |keywords|
|
10
25
|
keywords << :segment_count if legacy_segment_count != NOT_GIVEN
|
11
26
|
keywords << :root if legacy_root != NOT_GIVEN
|
@@ -19,18 +34,53 @@ module Faker
|
|
19
34
|
.join(directory_separator)
|
20
35
|
.squeeze(directory_separator)
|
21
36
|
end
|
37
|
+
# rubocop:enable Metrics/ParameterLists
|
22
38
|
|
39
|
+
##
|
40
|
+
# Produces a random file extension.
|
41
|
+
#
|
42
|
+
# @return [String]
|
43
|
+
#
|
44
|
+
# @example
|
45
|
+
# Faker::File.extension #=> "mp3"
|
46
|
+
#
|
47
|
+
# @faker.version 1.6.4
|
23
48
|
def extension
|
24
49
|
fetch('file.extension')
|
25
50
|
end
|
26
51
|
|
52
|
+
##
|
53
|
+
# Produces a random mime type.
|
54
|
+
#
|
55
|
+
# @return [String]
|
56
|
+
#
|
57
|
+
# @example
|
58
|
+
# Faker::File.mime_type #=> "application/pdf"
|
59
|
+
#
|
60
|
+
# @faker.version 1.6.4
|
27
61
|
def mime_type
|
28
62
|
fetch('file.mime_type')
|
29
63
|
end
|
30
64
|
|
31
65
|
# rubocop:disable Metrics/ParameterLists
|
66
|
+
|
67
|
+
##
|
68
|
+
# Produces a random file name.
|
69
|
+
#
|
70
|
+
# @param dir [String] Specifies the path used for the generated file.
|
71
|
+
# @param name [String] Specifies the filename used for the generated file.
|
72
|
+
# @param ext [String] Specifies the extension used the generated file.
|
73
|
+
# @param directory_separator [String] Specifies the separator between the directory and name elements.
|
74
|
+
# @return [String]
|
75
|
+
#
|
76
|
+
# @example
|
77
|
+
# Faker::File.file_name(dir: 'path/to') #=> "path/to/something_random.jpg"
|
78
|
+
# Faker::File.file_name(dir: 'foo/bar', name: 'baz') #=> "foo/bar/baz.zip"
|
79
|
+
# Faker::File.file_name(dir: 'foo/bar', name: 'baz', ext: 'doc') #=> "foo/bar/baz.doc"
|
80
|
+
# Faker::File.file_name(dir: 'foo/bar', name: 'baz', ext: 'mp3', directory_separator: '\\') #=> "foo/bar\\baz.mp3"
|
81
|
+
#
|
82
|
+
# @faker.version 1.6.4
|
32
83
|
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)
|
33
|
-
# rubocop:enable Metrics/ParameterLists
|
34
84
|
warn_for_deprecated_arguments do |keywords|
|
35
85
|
keywords << :dir if legacy_dir != NOT_GIVEN
|
36
86
|
keywords << :name if legacy_name != NOT_GIVEN
|
@@ -44,6 +94,7 @@ module Faker
|
|
44
94
|
|
45
95
|
[dir, name].join(directory_separator) + ".#{ext}"
|
46
96
|
end
|
97
|
+
# rubocop:enable Metrics/ParameterLists
|
47
98
|
end
|
48
99
|
end
|
49
100
|
end
|
@@ -6,7 +6,21 @@ module Faker
|
|
6
6
|
diners_club jcb switch solo dankort
|
7
7
|
maestro forbrugsforeningen laser].freeze
|
8
8
|
|
9
|
+
MARKET_LIST = %i[nyse nasdaq].freeze
|
10
|
+
|
9
11
|
class << self
|
12
|
+
##
|
13
|
+
# Produces a random credit card number.
|
14
|
+
#
|
15
|
+
# @param types [String] Specific credit card type.
|
16
|
+
# @return [String]
|
17
|
+
#
|
18
|
+
# @example
|
19
|
+
# Faker::Finance.credit_card #=> "3018-348979-1853"
|
20
|
+
# Faker::Finance.credit_card(:mastercard) #=> "6771-8921-2291-6236"
|
21
|
+
# Faker::Finance.credit_card(:mastercard, :visa) #=> "4448-8934-1277-7195"
|
22
|
+
#
|
23
|
+
# @faker.version 1.2.0
|
10
24
|
def credit_card(*types)
|
11
25
|
types = CREDIT_CARD_TYPES if types.empty?
|
12
26
|
type = sample(types)
|
@@ -26,6 +40,18 @@ module Faker
|
|
26
40
|
template.gsub('L', luhn_digit.to_s)
|
27
41
|
end
|
28
42
|
|
43
|
+
##
|
44
|
+
# Produces a random vat number.
|
45
|
+
#
|
46
|
+
# @param country [String] Two capital letter country code to use for the vat number.
|
47
|
+
# @return [String]
|
48
|
+
#
|
49
|
+
# @example
|
50
|
+
# Faker::Finance.vat_number #=> "BR38.395.329/2471-83"
|
51
|
+
# Faker::Finance.vat_number('DE') #=> "DE593306671"
|
52
|
+
# Faker::Finance.vat_number('ZA') #=> "ZA79494416181"
|
53
|
+
#
|
54
|
+
# @faker.version 1.9.2
|
29
55
|
def vat_number(legacy_country = NOT_GIVEN, country: 'BR')
|
30
56
|
warn_for_deprecated_arguments do |keywords|
|
31
57
|
keywords << :country if legacy_country != NOT_GIVEN
|
@@ -39,6 +65,25 @@ module Faker
|
|
39
65
|
def vat_number_keys
|
40
66
|
translate('faker.finance.vat_number').keys
|
41
67
|
end
|
68
|
+
|
69
|
+
##
|
70
|
+
# Returns a randomly-selected stock ticker from a specified market.
|
71
|
+
#
|
72
|
+
# @param markets [String] The name of the market to choose the ticker from (e.g. NYSE, NASDAQ)
|
73
|
+
# @return [String]
|
74
|
+
#
|
75
|
+
# @example
|
76
|
+
# Faker::Finance.ticker #=> 'AMZN'
|
77
|
+
# Faker::Finance.vat_number('NASDAQ') #=> 'GOOG'
|
78
|
+
#
|
79
|
+
# @faker.version next
|
80
|
+
def ticker(*markets)
|
81
|
+
markets = MARKET_LIST if markets.empty?
|
82
|
+
market = sample(markets)
|
83
|
+
fetch("finance.ticker.#{market}")
|
84
|
+
rescue I18n::MissingTranslationData
|
85
|
+
raise ArgumentError, "Could not find market named #{market}"
|
86
|
+
end
|
42
87
|
end
|
43
88
|
end
|
44
89
|
end
|
data/lib/faker/default/food.rb
CHANGED
data/lib/faker/default/gender.rb
CHANGED
@@ -3,14 +3,38 @@
|
|
3
3
|
module Faker
|
4
4
|
class Hipster < Base
|
5
5
|
class << self
|
6
|
+
##
|
7
|
+
# Produces a random hipster word.
|
8
|
+
#
|
9
|
+
# @return [String]
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# Faker::Hipster.word #=> "irony"
|
13
|
+
#
|
14
|
+
# @faker.version 1.6.0
|
6
15
|
def word
|
7
16
|
random_word = sample(translate('faker.hipster.words'))
|
8
17
|
random_word =~ /\s/ ? word : random_word
|
9
18
|
end
|
10
19
|
|
11
20
|
# rubocop:disable Metrics/ParameterLists
|
21
|
+
|
22
|
+
##
|
23
|
+
# Produces a random hipster word.
|
24
|
+
#
|
25
|
+
# @param number [Integer] Specifies the number of words returned
|
26
|
+
# @param supplemental [Boolean] Specifies if the words are supplemental
|
27
|
+
# @param spaces_allowed [Boolean] Specifies if the words may contain spaces
|
28
|
+
# @return [Array<String>]
|
29
|
+
#
|
30
|
+
# @example
|
31
|
+
# Faker::Hipster.words #=> ["pug", "pitchfork", "chia"]
|
32
|
+
# Faker::Hipster.words(number: 4) #=> ["ugh", "cardigan", "poutine", "stumptown"]
|
33
|
+
# Faker::Hipster.words(number: 4, supplemental: true) #=> ["iste", "seitan", "normcore", "provident"]
|
34
|
+
# Faker::Hipster.words(number: 4, supplemental: true, spaces_allowed: true) #=> ["qui", "magni", "craft beer", "est"]
|
35
|
+
#
|
36
|
+
# @faker.version 1.6.0
|
12
37
|
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
38
|
warn_for_deprecated_arguments do |keywords|
|
15
39
|
keywords << :number if legacy_number != NOT_GIVEN
|
16
40
|
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
@@ -30,18 +54,49 @@ module Faker
|
|
30
54
|
words.each_with_index { |w, i| words[i] = word if w =~ /\s/ }
|
31
55
|
end
|
32
56
|
|
33
|
-
|
34
|
-
|
35
|
-
|
57
|
+
##
|
58
|
+
# Produces a random hipster sentence.
|
59
|
+
#
|
60
|
+
# @param word_count [Integer] Specifies the number of words in the sentence
|
61
|
+
# @param supplemental [Boolean] Specifies if the words are supplemental
|
62
|
+
# @param random_words_to_add [Integer] Specifies the number of random words to add
|
63
|
+
# @param open_compounds_allowed [Boolean] Specifies if the generated sentence can contain words having additional spaces
|
64
|
+
# @return [String]
|
65
|
+
#
|
66
|
+
# @example
|
67
|
+
# Faker::Hipster.sentence #=> "Park iphone leggings put a bird on it."
|
68
|
+
# Faker::Hipster.sentence(word_count: 3) #=> "Pour-over swag godard."
|
69
|
+
# Faker::Hipster.sentence(word_count: 3, supplemental: true) #=> "Beard laboriosam sequi celiac."
|
70
|
+
# Faker::Hipster.sentence(word_count: 3, supplemental: false, random_words_to_add: 4) #=> "Bitters retro mustache aesthetic biodiesel 8-bit."
|
71
|
+
# Faker::Hipster.sentence(word_count: 3, supplemental: true, random_words_to_add: 4) #=> "Occaecati deleniti messenger bag meh crucifix autem."
|
72
|
+
# Faker::Hipster.sentence(word_count: 3, supplemental: true, random_words_to_add: 0, open_compounds_allowed: true) #=> "Kale chips nihil eos."
|
73
|
+
# Faker::Hipster.sentence(word_count: 3, supplemental: true, random_words_to_add: 0, open_compounds_allowed: false) #=> "Dreamcatcher umami fixie."
|
74
|
+
#
|
75
|
+
# @faker.version 1.6.0
|
76
|
+
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)
|
36
77
|
warn_for_deprecated_arguments do |keywords|
|
37
78
|
keywords << :word_count if legacy_word_count != NOT_GIVEN
|
38
79
|
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
39
80
|
keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
|
40
81
|
end
|
41
82
|
|
42
|
-
words(number: word_count + rand(random_words_to_add.to_i).to_i, supplemental: supplemental, spaces_allowed:
|
83
|
+
"#{words(number: word_count + rand(random_words_to_add.to_i).to_i, supplemental: supplemental, spaces_allowed: open_compounds_allowed).join(' ').capitalize}."
|
43
84
|
end
|
44
|
-
|
85
|
+
# rubocop:enable Metrics/ParameterLists
|
86
|
+
|
87
|
+
##
|
88
|
+
# Produces random hipster sentences.
|
89
|
+
#
|
90
|
+
# @param number [Integer] Specifies the number of sentences returned
|
91
|
+
# @param supplemental [Boolean] Specifies if the words are supplemental
|
92
|
+
# @return [Array<String>]
|
93
|
+
#
|
94
|
+
# @example
|
95
|
+
# Faker::Hipster.sentences #=> ["Godard pitchfork vinegar chillwave everyday 90's whatever.", "Pour-over artisan distillery street waistcoat.", "Salvia yr leggings franzen blue bottle."]
|
96
|
+
# Faker::Hipster.sentences(number: 1) #=> ["Before they sold out pinterest venmo umami try-hard ugh hoodie artisan."]
|
97
|
+
# Faker::Hipster.sentences(number: 1, supplemental: true) #=> ["Et sustainable optio aesthetic et."]
|
98
|
+
#
|
99
|
+
# @faker.version 1.6.0
|
45
100
|
def sentences(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
|
46
101
|
warn_for_deprecated_arguments do |keywords|
|
47
102
|
keywords << :number if legacy_number != NOT_GIVEN
|
@@ -56,8 +111,24 @@ module Faker
|
|
56
111
|
end
|
57
112
|
|
58
113
|
# rubocop:disable Metrics/ParameterLists
|
114
|
+
|
115
|
+
##
|
116
|
+
# Produces a random hipster paragraph.
|
117
|
+
#
|
118
|
+
# @param sentence_count [Integer] Specifies the number of sentences in the paragraph
|
119
|
+
# @param supplemental [Boolean] Specifies if the words are supplemental
|
120
|
+
# @param random_sentences_to_add [Boolean] Specifies the number of random sentences to add
|
121
|
+
# @return [String]
|
122
|
+
#
|
123
|
+
# @example
|
124
|
+
# Faker::Hipster.paragraph #=> "Migas fingerstache pbr&b tofu. Polaroid distillery typewriter echo tofu actually. Slow-carb fanny pack pickled direct trade scenester mlkshk plaid. Banjo venmo chambray cold-pressed typewriter. Fap skateboard intelligentsia."
|
125
|
+
# Faker::Hipster.paragraph(sentence_count: 2) #=> "Yolo tilde farm-to-table hashtag. Lomo kitsch disrupt forage +1."
|
126
|
+
# Faker::Hipster.paragraph(sentence_count: 2, supplemental: true) #=> "Typewriter iste ut viral kombucha voluptatem. Sint voluptates saepe. Direct trade irony chia excepturi yuccie. Biodiesel esse listicle et quam suscipit."
|
127
|
+
# Faker::Hipster.paragraph(sentence_count: 2, supplemental: false, random_sentences_to_add: 4) #=> "Selvage vhs chartreuse narwhal vinegar. Authentic vinyl truffaut carry vhs pop-up. Hammock everyday iphone locavore thundercats bitters vegan goth. Fashion axe banh mi shoreditch whatever artisan."
|
128
|
+
# 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
|
+
#
|
130
|
+
# @faker.version 1.6.0
|
59
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)
|
60
|
-
# rubocop:enable Metrics/ParameterLists
|
61
132
|
warn_for_deprecated_arguments do |keywords|
|
62
133
|
keywords << :sentence_count if legacy_sentence_count != NOT_GIVEN
|
63
134
|
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
@@ -66,7 +137,21 @@ module Faker
|
|
66
137
|
|
67
138
|
sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i, supplemental: supplemental).join(' ')
|
68
139
|
end
|
69
|
-
|
140
|
+
# rubocop:enable Metrics/ParameterLists
|
141
|
+
|
142
|
+
##
|
143
|
+
# Produces random hipster paragraphs.
|
144
|
+
#
|
145
|
+
# @param number [Integer] Specifies the number of paragraphs
|
146
|
+
# @param supplemental [Boolean] Specifies if the words are supplemental
|
147
|
+
# @return [Array<String>]
|
148
|
+
#
|
149
|
+
# @example
|
150
|
+
# Faker::Hipster.paragraphs #=> ["Tilde microdosing blog cliche meggings. Intelligentsia five dollar toast forage yuccie. Master kitsch knausgaard. Try-hard everyday trust fund mumblecore.", "Normcore viral pickled. Listicle humblebrag swag tote bag. Taxidermy street hammock neutra butcher cred kale chips. Blog portland humblebrag trust fund irony.", "Single-origin coffee fixie cleanse tofu xoxo. Post-ironic tote bag ramps gluten-free locavore mumblecore hammock. Umami loko twee. Ugh kitsch before they sold out."]
|
151
|
+
# Faker::Hipster.paragraphs(number: 1) #=> ["Skateboard cronut synth +1 fashion axe. Pop-up polaroid skateboard asymmetrical. Ennui fingerstache shoreditch before they sold out. Tattooed pitchfork ramps. Photo booth yr messenger bag raw denim bespoke locavore lomo synth."]
|
152
|
+
# 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
|
+
#
|
154
|
+
# @faker.version 1.6.0
|
70
155
|
def paragraphs(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
|
71
156
|
warn_for_deprecated_arguments do |keywords|
|
72
157
|
keywords << :number if legacy_number != NOT_GIVEN
|
@@ -80,6 +165,18 @@ module Faker
|
|
80
165
|
end
|
81
166
|
end
|
82
167
|
|
168
|
+
##
|
169
|
+
# Produces a random hipster paragraph by characters.
|
170
|
+
#
|
171
|
+
# @param characters [Integer] Specifies the number of characters in the paragraph
|
172
|
+
# @param supplemental [Boolean] Specifies if the words are supplemental
|
173
|
+
# @return [String]
|
174
|
+
#
|
175
|
+
# @example
|
176
|
+
# Faker::Hipster.paragraph_by_chars #=> "Truffaut stumptown trust fund 8-bit messenger bag portland. Meh kombucha selvage swag biodiesel. Lomo kinfolk jean shorts asymmetrical diy. Wayfarers portland twee stumptown. Wes anderson biodiesel retro 90's pabst. Diy echo 90's mixtape semiotics. Cornho."
|
177
|
+
# 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
|
+
#
|
179
|
+
# @faker.version 1.6.0
|
83
180
|
def paragraph_by_chars(legacy_characters = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, characters: 256, supplemental: false)
|
84
181
|
warn_for_deprecated_arguments do |keywords|
|
85
182
|
keywords << :characters if legacy_characters != NOT_GIVEN
|
@@ -88,9 +185,9 @@ module Faker
|
|
88
185
|
|
89
186
|
paragraph = paragraph(sentence_count: 3, supplemental: supplemental)
|
90
187
|
|
91
|
-
paragraph +=
|
188
|
+
paragraph += " #{paragraph(sentence_count: 3, supplemental: supplemental)}" while paragraph.length < characters
|
92
189
|
|
93
|
-
paragraph[0...characters - 1]
|
190
|
+
"#{paragraph[0...characters - 1]}."
|
94
191
|
end
|
95
192
|
end
|
96
193
|
end
|
@@ -19,10 +19,28 @@ module Faker
|
|
19
19
|
CHILEAN_MODULO = 11
|
20
20
|
|
21
21
|
class << self
|
22
|
+
##
|
23
|
+
# Produces a random valid US Social Security number.
|
24
|
+
#
|
25
|
+
# @return [String]
|
26
|
+
#
|
27
|
+
# @example
|
28
|
+
# Faker::IDNumber.valid #=> "552-56-3593"
|
29
|
+
#
|
30
|
+
# @faker.version 1.6.0
|
22
31
|
def valid
|
23
32
|
_translate('valid')
|
24
33
|
end
|
25
34
|
|
35
|
+
##
|
36
|
+
# Produces a random invalid US Social Security number.
|
37
|
+
#
|
38
|
+
# @return [String]
|
39
|
+
#
|
40
|
+
# @example
|
41
|
+
# Faker::IDNumber.invalid #=> "311-72-0000"
|
42
|
+
#
|
43
|
+
# @faker.version 1.6.0
|
26
44
|
def invalid
|
27
45
|
_translate('invalid')
|
28
46
|
end
|
@@ -33,6 +51,15 @@ module Faker
|
|
33
51
|
INVALID_SSN.any? { |regex| regex =~ ssn } ? ssn_valid : ssn
|
34
52
|
end
|
35
53
|
|
54
|
+
##
|
55
|
+
# Produces a random Spanish citizen identifier (DNI).
|
56
|
+
#
|
57
|
+
# @return [String]
|
58
|
+
#
|
59
|
+
# @example
|
60
|
+
# Faker::IDNumber.spanish_citizen_number #=> "53290236-H"
|
61
|
+
#
|
62
|
+
# @faker.version 1.9.0
|
36
63
|
def spanish_citizen_number
|
37
64
|
num = Faker::Number.number(digits: 8)
|
38
65
|
mod = num.to_i % 23
|
@@ -40,6 +67,15 @@ module Faker
|
|
40
67
|
"#{num}-#{check}"
|
41
68
|
end
|
42
69
|
|
70
|
+
##
|
71
|
+
# Produces a random Spanish foreign born citizen identifier (NIE).
|
72
|
+
#
|
73
|
+
# @return [String]
|
74
|
+
#
|
75
|
+
# @example
|
76
|
+
# Faker::IDNumber.spanish_foreign_citizen_number #=> "Z-1600870-Y"
|
77
|
+
#
|
78
|
+
# @faker.version 1.9.0
|
43
79
|
def spanish_foreign_citizen_number
|
44
80
|
code = 'XYZ'
|
45
81
|
digits = Faker::Number.number(digits: 7)
|
@@ -50,6 +86,16 @@ module Faker
|
|
50
86
|
"#{prefix}-#{digits}-#{check}"
|
51
87
|
end
|
52
88
|
|
89
|
+
##
|
90
|
+
# Produces a random valid South African ID Number.
|
91
|
+
#
|
92
|
+
# @return [String]
|
93
|
+
#
|
94
|
+
# @example
|
95
|
+
# Faker::IDNumber.south_african_id_number #=> "8105128870184"
|
96
|
+
# Faker::IDNumber.valid_south_african_id_number #=> "8105128870184"
|
97
|
+
#
|
98
|
+
# @faker.version 1.9.2
|
53
99
|
def valid_south_african_id_number
|
54
100
|
id_number = [
|
55
101
|
Faker::Date.birthday.strftime('%y%m%d'),
|
@@ -63,6 +109,15 @@ module Faker
|
|
63
109
|
|
64
110
|
alias south_african_id_number valid_south_african_id_number
|
65
111
|
|
112
|
+
##
|
113
|
+
# Produces a random invalid South African ID Number.
|
114
|
+
#
|
115
|
+
# @return [String]
|
116
|
+
#
|
117
|
+
# @example
|
118
|
+
# Faker::IDNumber.invalid_south_african_id_number #=> "1642972065088"
|
119
|
+
#
|
120
|
+
# @faker.version 1.9.2
|
66
121
|
def invalid_south_african_id_number
|
67
122
|
invalid_date_of_birth = [
|
68
123
|
Faker::Number.number(digits: 2),
|
@@ -80,6 +135,17 @@ module Faker
|
|
80
135
|
[id_number, south_african_id_checksum_digit(id_number)].join
|
81
136
|
end
|
82
137
|
|
138
|
+
##
|
139
|
+
# Produces a random Brazilian Citizen Number (CPF).
|
140
|
+
#
|
141
|
+
# @param formatted [Boolean] Specifies if the number is formatted with dividers.
|
142
|
+
# @return [String]
|
143
|
+
#
|
144
|
+
# @example
|
145
|
+
# Faker::IDNumber.brazilian_citizen_number #=> "53540542221"
|
146
|
+
# Faker::IDNumber.brazilian_citizen_number(formatted: true) #=> "535.405.422-21"
|
147
|
+
#
|
148
|
+
# @faker.version 1.9.2
|
83
149
|
def brazilian_citizen_number(legacy_formatted = NOT_GIVEN, formatted: false)
|
84
150
|
warn_for_deprecated_arguments do |keywords|
|
85
151
|
keywords << :formatted if legacy_formatted != NOT_GIVEN
|
@@ -94,6 +160,17 @@ module Faker
|
|
94
160
|
|
95
161
|
alias brazilian_cpf brazilian_citizen_number
|
96
162
|
|
163
|
+
##
|
164
|
+
# Produces a random Brazilian ID Number (RG).
|
165
|
+
#
|
166
|
+
# @param formatted [Boolean] Specifies if the number is formatted with dividers.
|
167
|
+
# @return [String]
|
168
|
+
#
|
169
|
+
# @example
|
170
|
+
# Faker::IDNumber.brazilian_id #=> "493054029"
|
171
|
+
# Faker::IDNumber.brazilian_id(formatted: true) #=> "49.305.402-9"
|
172
|
+
#
|
173
|
+
# @faker.version 2.1.2
|
97
174
|
def brazilian_id(legacy_formatted = NOT_GIVEN, formatted: false)
|
98
175
|
warn_for_deprecated_arguments do |keywords|
|
99
176
|
keywords << :formatted if legacy_formatted != NOT_GIVEN
|
@@ -107,15 +184,58 @@ module Faker
|
|
107
184
|
|
108
185
|
alias brazilian_rg brazilian_id
|
109
186
|
|
187
|
+
##
|
188
|
+
# Produces a random Chilean ID (Rut with 8 digits).
|
189
|
+
#
|
190
|
+
# @return [String]
|
191
|
+
#
|
192
|
+
# @example
|
193
|
+
# Faker::IDNumber.chilean_id #=> "15620613-K"
|
194
|
+
#
|
195
|
+
# @faker.version 2.1.2
|
110
196
|
def chilean_id
|
111
197
|
digits = Faker::Number.number(digits: 8)
|
112
198
|
verification_code = chilean_verification_code(digits)
|
113
199
|
|
114
|
-
digits
|
200
|
+
"#{digits}-#{verification_code}"
|
201
|
+
end
|
202
|
+
|
203
|
+
##
|
204
|
+
# Produces a random Croatian ID number (OIB).
|
205
|
+
#
|
206
|
+
# @param international [Boolean] Specifies whether to add international prefix.
|
207
|
+
# @return [String]
|
208
|
+
#
|
209
|
+
# @example
|
210
|
+
# Faker::IDNumber.croatian_id #=> "88467617508"
|
211
|
+
# Faker::IDNumber.croatian_id(international: true) #=> "HR88467617508"
|
212
|
+
#
|
213
|
+
# @faker.version next
|
214
|
+
def croatian_id(international: false)
|
215
|
+
prefix = international ? 'HR' : ''
|
216
|
+
digits = Faker::Number.number(digits: 10).to_s
|
217
|
+
checksum_digit = croatian_id_checksum_digit(digits)
|
218
|
+
|
219
|
+
"#{prefix}#{digits}#{checksum_digit}"
|
115
220
|
end
|
116
221
|
|
117
222
|
private
|
118
223
|
|
224
|
+
def croatian_id_checksum_digit(digits)
|
225
|
+
control_sum = 10
|
226
|
+
|
227
|
+
digits.chars.map(&:to_i).each do |digit|
|
228
|
+
control_sum += digit
|
229
|
+
control_sum %= 10
|
230
|
+
control_sum = 10 if control_sum.zero?
|
231
|
+
control_sum *= 2
|
232
|
+
control_sum %= 11
|
233
|
+
end
|
234
|
+
|
235
|
+
control_sum = 11 - control_sum
|
236
|
+
control_sum % 10
|
237
|
+
end
|
238
|
+
|
119
239
|
def chilean_verification_code(digits)
|
120
240
|
# First digit is multiplied by 3, second by 2, and so on
|
121
241
|
multiplication_rule = [3, 2, 7, 6, 5, 4, 3, 2]
|
@@ -170,7 +290,7 @@ module Faker
|
|
170
290
|
end * 10
|
171
291
|
end
|
172
292
|
|
173
|
-
def brazilian_document_digit(checksum, id
|
293
|
+
def brazilian_document_digit(checksum, id: false)
|
174
294
|
remainder = checksum % 11
|
175
295
|
id ? brazilian_id_digit(remainder) : brazilian_citizen_number_digit(remainder)
|
176
296
|
end
|