faker 2.11.0 → 2.12.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 +89 -0
- data/README.md +8 -2
- data/lib/faker.rb +14 -9
- data/lib/faker/default/address.rb +1 -1
- data/lib/faker/default/bank.rb +79 -0
- data/lib/faker/default/blood.rb +48 -0
- data/lib/faker/default/business.rb +1 -1
- data/lib/faker/default/commerce.rb +73 -10
- data/lib/faker/default/company.rb +39 -0
- 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_coin.rb +45 -0
- data/lib/faker/default/driving_licence.rb +42 -0
- data/lib/faker/default/file.rb +49 -0
- data/lib/faker/default/finance.rb +24 -0
- data/lib/faker/default/hipster.rb +94 -0
- data/lib/faker/default/invoice.rb +32 -5
- data/lib/faker/default/json.rb +55 -0
- data/lib/faker/default/measurement.rb +90 -0
- data/lib/faker/default/name.rb +83 -0
- data/lib/faker/default/phone_number.rb +88 -5
- data/lib/faker/default/placeholdit.rb +21 -0
- data/lib/faker/default/slack_emoji.rb +81 -0
- data/lib/faker/default/south_africa.rb +90 -0
- data/lib/faker/default/string.rb +19 -3
- data/lib/faker/default/stripe.rb +61 -0
- data/lib/faker/default/twitter.rb +35 -0
- data/lib/faker/default/types.rb +80 -0
- 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/games/control.rb +113 -0
- data/lib/faker/games/dnd.rb +61 -0
- data/lib/faker/games/warhammer_fantasy.rb +74 -0
- data/lib/faker/movies/departed.rb +49 -0
- data/lib/faker/music/pearl_jam.rb +50 -0
- data/lib/faker/music/phish.rb +27 -1
- data/lib/faker/music/show.rb +49 -0
- data/lib/faker/quotes/quote.rb +54 -1
- data/lib/faker/quotes/shakespeare.rb +36 -0
- data/lib/faker/tv_shows/suits.rb +37 -0
- data/lib/faker/version.rb +1 -1
- data/lib/helpers/char.rb +2 -1
- data/lib/locales/de-CH.yml +1693 -0
- data/lib/locales/en-AU.yml +44 -10
- data/lib/locales/en-CA.yml +2 -0
- data/lib/locales/en-US.yml +29 -3
- data/lib/locales/en/address.yml +2 -0
- data/lib/locales/en/blood.yml +13 -0
- data/lib/locales/en/computer.yml +36 -0
- data/lib/locales/en/control.yml +247 -0
- data/lib/locales/en/departed.yml +50 -0
- data/lib/locales/en/dnd.yml +54 -0
- data/lib/locales/en/heroes_of_the_storm.yml +1 -1
- data/lib/locales/en/house.yml +1 -1
- data/lib/locales/en/one_piece.yml +2 -2
- data/lib/locales/en/pearl_jam.yml +213 -0
- data/lib/locales/en/phish.yml +392 -1
- data/lib/locales/en/show.yml +597 -0
- data/lib/locales/en/star_wars.yml +568 -221
- data/lib/locales/en/suits.yml +45 -0
- data/lib/locales/en/warhammer_fantasy.yml +582 -0
- data/lib/locales/fr-CA.yml +2 -0
- data/lib/locales/ko.yml +82 -0
- data/lib/locales/pt-BR.yml +1 -0
- metadata +29 -11
@@ -7,6 +7,15 @@ module Faker
|
|
7
7
|
ACRONYM = 1
|
8
8
|
URL_LOGO = 2
|
9
9
|
|
10
|
+
##
|
11
|
+
# Produces a random crypto coin name.
|
12
|
+
#
|
13
|
+
# @return [String]
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# Faker::CryptoCoin.coin_name #=> "Bitcoin"
|
17
|
+
#
|
18
|
+
# @faker.version 1.9.2
|
10
19
|
def coin_name(legacy_coin = NOT_GIVEN, coin: coin_array)
|
11
20
|
warn_for_deprecated_arguments do |keywords|
|
12
21
|
keywords << :coin if legacy_coin != NOT_GIVEN
|
@@ -15,6 +24,15 @@ module Faker
|
|
15
24
|
coin[COIN_NAME]
|
16
25
|
end
|
17
26
|
|
27
|
+
##
|
28
|
+
# Produces a random crypto coin acronym.
|
29
|
+
#
|
30
|
+
# @return [String]
|
31
|
+
#
|
32
|
+
# @example
|
33
|
+
# Faker::CryptoCoin.acronym #=> "BTC"
|
34
|
+
#
|
35
|
+
# @faker.version 1.9.2
|
18
36
|
def acronym(legacy_coin = NOT_GIVEN, coin: coin_array)
|
19
37
|
warn_for_deprecated_arguments do |keywords|
|
20
38
|
keywords << :coin if legacy_coin != NOT_GIVEN
|
@@ -23,6 +41,15 @@ module Faker
|
|
23
41
|
coin[ACRONYM]
|
24
42
|
end
|
25
43
|
|
44
|
+
##
|
45
|
+
# Produces a random crypto coin logo url.
|
46
|
+
#
|
47
|
+
# @return [String]
|
48
|
+
#
|
49
|
+
# @example
|
50
|
+
# Faker::CryptoCoin.url_logo #=> "https://i.imgur.com/EFz61Ei.png"
|
51
|
+
#
|
52
|
+
# @faker.version 1.9.2
|
26
53
|
def url_logo(legacy_coin = NOT_GIVEN, coin: coin_array)
|
27
54
|
warn_for_deprecated_arguments do |keywords|
|
28
55
|
keywords << :coin if legacy_coin != NOT_GIVEN
|
@@ -31,10 +58,28 @@ module Faker
|
|
31
58
|
coin[URL_LOGO]
|
32
59
|
end
|
33
60
|
|
61
|
+
##
|
62
|
+
# Produces a random crypto coin's name, acronym and logo in an array.
|
63
|
+
#
|
64
|
+
# @return [Array<String>]
|
65
|
+
#
|
66
|
+
# @example
|
67
|
+
# Faker::CryptoCoin.coin_array #=> ["Dash", "DASH", "https://i.imgur.com/2uX91cb.png"]
|
68
|
+
#
|
69
|
+
# @faker.version 1.9.2
|
34
70
|
def coin_array
|
35
71
|
fetch('crypto_coin.coin').split(',').map(&:strip)
|
36
72
|
end
|
37
73
|
|
74
|
+
##
|
75
|
+
# Produces a random crypto coin's name, acronym and logo in a hash.
|
76
|
+
#
|
77
|
+
# @return [Hash]
|
78
|
+
#
|
79
|
+
# @example
|
80
|
+
# Faker::CryptoCoin.coin_hash {:name=>"Ethereum", :acronym=>"ETH", :url_logo=>"https://i.imgur.com/uOPFCXj.png"}
|
81
|
+
#
|
82
|
+
# @faker.version 1.9.2
|
38
83
|
def coin_hash
|
39
84
|
coin = coin_array
|
40
85
|
|
@@ -6,6 +6,23 @@ module Faker
|
|
6
6
|
NI_CHANCE = 0.03 # NI Pop is about 3% of total UK population
|
7
7
|
|
8
8
|
class << self
|
9
|
+
##
|
10
|
+
# Produces a random British driving licence number.
|
11
|
+
#
|
12
|
+
# @param last_name [String] The last name of the driving licence's owner.
|
13
|
+
# @param initials [String] The initials of the driving licence's owner.
|
14
|
+
# @param gender [String] The gender of the driving licence's owner.
|
15
|
+
# @param date_of_birth [String] The date of birth of the driving licence's owner.
|
16
|
+
# @return [String]
|
17
|
+
#
|
18
|
+
# @example
|
19
|
+
# Faker::DrivingLicence.british_driving_licence #=> "MCDER712081VF7EK"
|
20
|
+
# Faker::DrivingLicence.british_driving_licence(last_name: "O'Carroll",
|
21
|
+
# initials: "J",
|
22
|
+
# gender: :female,
|
23
|
+
# date_of_birth: Date.parse("1986-10-24")) #=> "OCARR815246J91HT"
|
24
|
+
#
|
25
|
+
# @faker.version 1.9.2
|
9
26
|
# rubocop:disable Metrics/ParameterLists
|
10
27
|
def british_driving_licence(legacy_last_name = NOT_GIVEN, legacy_initials = NOT_GIVEN, legacy_gender = NOT_GIVEN, legacy_date_of_birth = NOT_GIVEN, last_name: Faker::Name.last_name, initials: Faker::Name.initials, gender: random_gender, date_of_birth: Faker::Date.birthday(min_age: 18, max_age: 65))
|
11
28
|
# rubocop:enable Metrics/ParameterLists
|
@@ -24,10 +41,35 @@ module Faker
|
|
24
41
|
].join
|
25
42
|
end
|
26
43
|
|
44
|
+
##
|
45
|
+
# Produces a random Northern Irish licence number.
|
46
|
+
#
|
47
|
+
# @return [String]
|
48
|
+
#
|
49
|
+
# @example
|
50
|
+
# Faker::DrivingLicence.northern_irish_driving_licence #=> "70702548"
|
51
|
+
#
|
52
|
+
# @faker.version 1.9.2
|
27
53
|
def northern_irish_driving_licence
|
28
54
|
Faker::Number.number(digits: 8).to_s
|
29
55
|
end
|
30
56
|
|
57
|
+
##
|
58
|
+
# Produces a random UK driving licence number in either GB or NI format, at a rate consistent with their relative populations
|
59
|
+
#
|
60
|
+
# @overload uk_driving_licence(last_name, initials, gender, date_of_birth)
|
61
|
+
# @param last_name [String] The last name of the driving licence's owner.
|
62
|
+
# @param initials [String] The initials of the driving licence's owner.
|
63
|
+
# @param gender [String] The gender of the driving licence's owner.
|
64
|
+
# @param date_of_birth [String] The date of birth of the driving licence's owner.
|
65
|
+
# @overload uk_driving_licence()
|
66
|
+
# @return [String]
|
67
|
+
#
|
68
|
+
# @example
|
69
|
+
# Faker::DrivingLicence.uk_driving_licence #=> "OCARR815246J91HT"
|
70
|
+
# Faker::DrivingLicence.uk_driving_licence #=> "70702548"
|
71
|
+
#
|
72
|
+
# @faker.version 1.9.2
|
31
73
|
def uk_driving_licence(*args)
|
32
74
|
if Faker::Config.random.rand < NI_CHANCE
|
33
75
|
northern_irish_driving_licence
|
data/lib/faker/default/file.rb
CHANGED
@@ -3,6 +3,21 @@
|
|
3
3
|
module Faker
|
4
4
|
class File < Base
|
5
5
|
class << self
|
6
|
+
##
|
7
|
+
# Produces a random directory name.
|
8
|
+
#
|
9
|
+
# @param segment_count [Integer] Specifies the number of nested folders in the generated string.
|
10
|
+
# @param root [String] Specifies the root of the generated string.
|
11
|
+
# @param directory_separator [String] Specifies the separator between the segments.
|
12
|
+
# @return [String]
|
13
|
+
#
|
14
|
+
# @example
|
15
|
+
# Faker::File.dir #=> "et_error/sint_voluptas/quas_veritatis"
|
16
|
+
# Faker::File.dir(segment_count: 2) #=> "ea-suscipit/ut-deleniti"
|
17
|
+
# Faker::File.dir(segment_count: 3, root: nil, directory_separator: '/') #=> "est_porro/fugit_eveniet/incidunt-autem"
|
18
|
+
# Faker::File.dir(segment_count: 3, root: nil, directory_separator: '\\') #=> "aut-ullam\\quia_quisquam\\ut-eos"
|
19
|
+
#
|
20
|
+
# @faker.version 1.6.4
|
6
21
|
# rubocop:disable Metrics/ParameterLists
|
7
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)
|
8
23
|
# rubocop:enable Metrics/ParameterLists
|
@@ -20,14 +35,48 @@ module Faker
|
|
20
35
|
.squeeze(directory_separator)
|
21
36
|
end
|
22
37
|
|
38
|
+
##
|
39
|
+
# Produces a random file extension.
|
40
|
+
#
|
41
|
+
# @return [String]
|
42
|
+
#
|
43
|
+
# @example
|
44
|
+
# Faker::File.extension #=> "mp3"
|
45
|
+
#
|
46
|
+
# @faker.version 1.6.4
|
23
47
|
def extension
|
24
48
|
fetch('file.extension')
|
25
49
|
end
|
26
50
|
|
51
|
+
##
|
52
|
+
# Produces a random mime type.
|
53
|
+
#
|
54
|
+
# @return [String]
|
55
|
+
#
|
56
|
+
# @example
|
57
|
+
# Faker::File.mime_type #=> "application/pdf"
|
58
|
+
#
|
59
|
+
# @faker.version 1.6.4
|
27
60
|
def mime_type
|
28
61
|
fetch('file.mime_type')
|
29
62
|
end
|
30
63
|
|
64
|
+
##
|
65
|
+
# Produces a random file name.
|
66
|
+
#
|
67
|
+
# @param dir [String] Specifies the path used for the generated file.
|
68
|
+
# @param name [String] Specifies the filename used for the generated file.
|
69
|
+
# @param ext [String] Specifies the extension used the generated file.
|
70
|
+
# @param directory_separator [String] Specifies the separator between the directory and name elements.
|
71
|
+
# @return [String]
|
72
|
+
#
|
73
|
+
# @example
|
74
|
+
# Faker::File.file_name(dir: 'path/to') #=> "path/to/something_random.jpg"
|
75
|
+
# Faker::File.file_name(dir: 'foo/bar', name: 'baz') #=> "foo/bar/baz.zip"
|
76
|
+
# Faker::File.file_name(dir: 'foo/bar', name: 'baz', ext: 'doc') #=> "foo/bar/baz.doc"
|
77
|
+
# Faker::File.file_name(dir: 'foo/bar', name: 'baz', ext: 'mp3', directory_separator: '\\') #=> "foo/bar\\baz.mp3"
|
78
|
+
#
|
79
|
+
# @faker.version 1.6.4
|
31
80
|
# rubocop:disable Metrics/ParameterLists
|
32
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)
|
33
82
|
# rubocop:enable Metrics/ParameterLists
|
@@ -7,6 +7,18 @@ module Faker
|
|
7
7
|
maestro forbrugsforeningen laser].freeze
|
8
8
|
|
9
9
|
class << self
|
10
|
+
##
|
11
|
+
# Produces a random credit card number.
|
12
|
+
#
|
13
|
+
# @param types [String] Specific credit card type.
|
14
|
+
# @return [String]
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
# Faker::Finance.credit_card #=> "3018-348979-1853"
|
18
|
+
# Faker::Finance.credit_card(:mastercard) #=> "6771-8921-2291-6236"
|
19
|
+
# Faker::Finance.credit_card(:mastercard, :visa) #=> "4448-8934-1277-7195"
|
20
|
+
#
|
21
|
+
# @faker.version 1.2.0
|
10
22
|
def credit_card(*types)
|
11
23
|
types = CREDIT_CARD_TYPES if types.empty?
|
12
24
|
type = sample(types)
|
@@ -26,6 +38,18 @@ module Faker
|
|
26
38
|
template.gsub('L', luhn_digit.to_s)
|
27
39
|
end
|
28
40
|
|
41
|
+
##
|
42
|
+
# Produces a random vat number.
|
43
|
+
#
|
44
|
+
# @param country [String] Two capital letter country code to use for the vat number.
|
45
|
+
# @return [String]
|
46
|
+
#
|
47
|
+
# @example
|
48
|
+
# Faker::Finance.vat_number #=> "BR38.395.329/2471-83"
|
49
|
+
# Faker::Finance.vat_number('DE') #=> "DE593306671"
|
50
|
+
# Faker::Finance.vat_number('ZA') #=> "ZA79494416181"
|
51
|
+
#
|
52
|
+
# @faker.version 1.9.2
|
29
53
|
def vat_number(legacy_country = NOT_GIVEN, country: 'BR')
|
30
54
|
warn_for_deprecated_arguments do |keywords|
|
31
55
|
keywords << :country if legacy_country != NOT_GIVEN
|
@@ -3,11 +3,35 @@
|
|
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
|
|
20
|
+
##
|
21
|
+
# Produces a random hipster word.
|
22
|
+
#
|
23
|
+
# @param number [Integer] Specifies the number of words returned
|
24
|
+
# @param supplemental [Boolean] Specifies if the words are supplemental
|
25
|
+
# @param spaces_allowed [Boolean] Specifies if the words may contain spaces
|
26
|
+
# @return [Array<String>]
|
27
|
+
#
|
28
|
+
# @example
|
29
|
+
# Faker::Hipster.words #=> ["pug", "pitchfork", "chia"]
|
30
|
+
# Faker::Hipster.words(number: 4) #=> ["ugh", "cardigan", "poutine", "stumptown"]
|
31
|
+
# Faker::Hipster.words(number: 4, supplemental: true) #=> ["iste", "seitan", "normcore", "provident"]
|
32
|
+
# Faker::Hipster.words(number: 4, supplemental: true, spaces_allowed: true) #=> ["qui", "magni", "craft beer", "est"]
|
33
|
+
#
|
34
|
+
# @faker.version 1.6.0
|
11
35
|
# rubocop:disable Metrics/ParameterLists
|
12
36
|
def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_spaces_allowed = NOT_GIVEN, number: 3, supplemental: false, spaces_allowed: false)
|
13
37
|
# rubocop:enable Metrics/ParameterLists
|
@@ -30,6 +54,22 @@ module Faker
|
|
30
54
|
words.each_with_index { |w, i| words[i] = word if w =~ /\s/ }
|
31
55
|
end
|
32
56
|
|
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 [Boolean] Specifies the number of random words to add
|
63
|
+
# @return [String]
|
64
|
+
#
|
65
|
+
# @example
|
66
|
+
# Faker::Hipster.sentence #=> "Park iphone leggings put a bird on it."
|
67
|
+
# Faker::Hipster.sentence(word_count: 3) #=> "Pour-over swag godard."
|
68
|
+
# Faker::Hipster.sentence(word_count: 3, supplemental: true) #=> "Beard laboriosam sequi celiac."
|
69
|
+
# Faker::Hipster.sentence(word_count: 3, supplemental: false, random_words_to_add: 4) #=> "Bitters retro mustache aesthetic biodiesel 8-bit."
|
70
|
+
# Faker::Hipster.sentence(word_count: 3, supplemental: true, random_words_to_add: 4) #=> "Occaecati deleniti messenger bag meh crucifix autem."
|
71
|
+
#
|
72
|
+
# @faker.version 1.6.0
|
33
73
|
# rubocop:disable Metrics/ParameterLists
|
34
74
|
def sentence(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, supplemental: false, random_words_to_add: 6)
|
35
75
|
# rubocop:enable Metrics/ParameterLists
|
@@ -42,6 +82,19 @@ module Faker
|
|
42
82
|
words(number: word_count + rand(random_words_to_add.to_i).to_i, supplemental: supplemental, spaces_allowed: true).join(' ').capitalize + '.'
|
43
83
|
end
|
44
84
|
|
85
|
+
##
|
86
|
+
# Produces random hipster sentences.
|
87
|
+
#
|
88
|
+
# @param number [Integer] Specifies the number of sentences returned
|
89
|
+
# @param supplemental [Boolean] Specifies if the words are supplemental
|
90
|
+
# @return [Array<String>]
|
91
|
+
#
|
92
|
+
# @example
|
93
|
+
# Faker::Hipster.sentences #=> ["Godard pitchfork vinegar chillwave everyday 90's whatever.", "Pour-over artisan distillery street waistcoat.", "Salvia yr leggings franzen blue bottle."]
|
94
|
+
# Faker::Hipster.sentences(number: 1) #=> ["Before they sold out pinterest venmo umami try-hard ugh hoodie artisan."]
|
95
|
+
# Faker::Hipster.sentences(number: 1, supplemental: true) #=> ["Et sustainable optio aesthetic et."]
|
96
|
+
#
|
97
|
+
# @faker.version 1.6.0
|
45
98
|
def sentences(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
|
46
99
|
warn_for_deprecated_arguments do |keywords|
|
47
100
|
keywords << :number if legacy_number != NOT_GIVEN
|
@@ -55,6 +108,22 @@ module Faker
|
|
55
108
|
end
|
56
109
|
end
|
57
110
|
|
111
|
+
##
|
112
|
+
# Produces a random hipster paragraph.
|
113
|
+
#
|
114
|
+
# @param sentence_count [Integer] Specifies the number of sentences in the paragraph
|
115
|
+
# @param supplemental [Boolean] Specifies if the words are supplemental
|
116
|
+
# @param random_sentences_to_add [Boolean] Specifies the number of random sentences to add
|
117
|
+
# @return [String]
|
118
|
+
#
|
119
|
+
# @example
|
120
|
+
# 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."
|
121
|
+
# Faker::Hipster.paragraph(sentence_count: 2) #=> "Yolo tilde farm-to-table hashtag. Lomo kitsch disrupt forage +1."
|
122
|
+
# 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."
|
123
|
+
# 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."
|
124
|
+
# 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."
|
125
|
+
#
|
126
|
+
# @faker.version 1.6.0
|
58
127
|
# rubocop:disable Metrics/ParameterLists
|
59
128
|
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
129
|
# rubocop:enable Metrics/ParameterLists
|
@@ -67,6 +136,19 @@ module Faker
|
|
67
136
|
sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i, supplemental: supplemental).join(' ')
|
68
137
|
end
|
69
138
|
|
139
|
+
##
|
140
|
+
# Produces random hipster paragraphs.
|
141
|
+
#
|
142
|
+
# @param number [Integer] Specifies the number of paragraphs
|
143
|
+
# @param supplemental [Boolean] Specifies if the words are supplemental
|
144
|
+
# @return [Array<String>]
|
145
|
+
#
|
146
|
+
# @example
|
147
|
+
# 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."]
|
148
|
+
# 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."]
|
149
|
+
# 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."]
|
150
|
+
#
|
151
|
+
# @faker.version 1.6.0
|
70
152
|
def paragraphs(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
|
71
153
|
warn_for_deprecated_arguments do |keywords|
|
72
154
|
keywords << :number if legacy_number != NOT_GIVEN
|
@@ -80,6 +162,18 @@ module Faker
|
|
80
162
|
end
|
81
163
|
end
|
82
164
|
|
165
|
+
##
|
166
|
+
# Produces a random hipster paragraph by characters.
|
167
|
+
#
|
168
|
+
# @param characters [Integer] Specifies the number of characters in the paragraph
|
169
|
+
# @param supplemental [Boolean] Specifies if the words are supplemental
|
170
|
+
# @return [String]
|
171
|
+
#
|
172
|
+
# @example
|
173
|
+
# 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."
|
174
|
+
# 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."
|
175
|
+
#
|
176
|
+
# @faker.version 1.6.0
|
83
177
|
def paragraph_by_chars(legacy_characters = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, characters: 256, supplemental: false)
|
84
178
|
warn_for_deprecated_arguments do |keywords|
|
85
179
|
keywords << :characters if legacy_characters != NOT_GIVEN
|
@@ -5,7 +5,18 @@ module Faker
|
|
5
5
|
flexible :invoice
|
6
6
|
|
7
7
|
class << self
|
8
|
-
|
8
|
+
##
|
9
|
+
# Produces a random amount between values with 2 decimals
|
10
|
+
#
|
11
|
+
# @param from [Integer] Specifies lower limit.
|
12
|
+
# @param to [Integer] Specifies upper limit.
|
13
|
+
# @return [Integer]
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# Faker::Finance.amount_between #=> 0
|
17
|
+
# Faker::Finance.amount_between(0, 10) #=> 4.33
|
18
|
+
#
|
19
|
+
# @faker.version 1.9.0
|
9
20
|
def amount_between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 0, to: 0)
|
10
21
|
warn_for_deprecated_arguments do |keywords|
|
11
22
|
keywords << :from if legacy_from != NOT_GIVEN
|
@@ -15,8 +26,16 @@ module Faker
|
|
15
26
|
Faker::Base.rand_in_range(from, to).round(2)
|
16
27
|
end
|
17
28
|
|
18
|
-
|
19
|
-
#
|
29
|
+
##
|
30
|
+
# Produces a random valid reference accoring to the International bank slip reference https://en.wikipedia.org/wiki/Creditor_Reference
|
31
|
+
#
|
32
|
+
# @param ref [String] Specifies reference base.
|
33
|
+
# @return [String]
|
34
|
+
#
|
35
|
+
# @example
|
36
|
+
# Faker::Invoice.creditor_reference #=> "RF34118592570724925498"
|
37
|
+
#
|
38
|
+
# @faker.version 1.9.0
|
20
39
|
def creditor_reference(legacy_ref = NOT_GIVEN, ref: '')
|
21
40
|
warn_for_deprecated_arguments do |keywords|
|
22
41
|
keywords << :ref if legacy_ref != NOT_GIVEN
|
@@ -27,8 +46,16 @@ module Faker
|
|
27
46
|
'RF' + iban_checksum('RF', ref) + ref
|
28
47
|
end
|
29
48
|
|
30
|
-
|
31
|
-
#
|
49
|
+
##
|
50
|
+
# Produces a random valid reference.
|
51
|
+
#
|
52
|
+
# @param ref [String] Specifies reference base.
|
53
|
+
# @return [String]
|
54
|
+
#
|
55
|
+
# @example
|
56
|
+
# Faker::Invoice.reference #=> "45656646957845"
|
57
|
+
#
|
58
|
+
# @faker.version 1.9.0
|
32
59
|
def reference(legacy_ref = NOT_GIVEN, ref: '')
|
33
60
|
warn_for_deprecated_arguments do |keywords|
|
34
61
|
keywords << :ref if legacy_ref != NOT_GIVEN
|
data/lib/faker/default/json.rb
CHANGED
@@ -3,6 +3,23 @@ module Faker
|
|
3
3
|
require 'json'
|
4
4
|
|
5
5
|
class << self
|
6
|
+
##
|
7
|
+
# Produces a random simple JSON formatted string.
|
8
|
+
#
|
9
|
+
# @param width [Integer] Specifies the number of key-value pairs.
|
10
|
+
# @param options [Hash] Specifies a Faker gem class to use for keys and for values, respectably. options_hash = {key: Class.method, value: Class.method}
|
11
|
+
# @return [Hash{String => String}]
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# Faker::Json.shallow_json(width: 3, options: { key: 'RockBand.name', value: 'Seinfeld.quote' }) # =>
|
15
|
+
# {"Parliament Funkadelic":"They're real, and they're spectacular.",
|
16
|
+
# "Fleetwood Mac":"I'm not a lesbian. I hate men, but I'm not a lesbian.",
|
17
|
+
# "The Roots":"It became very clear to me sitting out there today that every decision
|
18
|
+
# I've made in my entire life has been wrong. My life is the complete opposite of everything
|
19
|
+
# I want it to be. Every instinct I have, in every aspect of life, be it something to wear,
|
20
|
+
# something to eat - it's all been wrong."}
|
21
|
+
#
|
22
|
+
# @faker.version 1.9.2
|
6
23
|
def shallow_json(legacy_width = NOT_GIVEN, legacy_options = NOT_GIVEN, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' })
|
7
24
|
warn_for_deprecated_arguments do |keywords|
|
8
25
|
keywords << :width if legacy_width != NOT_GIVEN
|
@@ -16,6 +33,44 @@ module Faker
|
|
16
33
|
JSON.generate(hash)
|
17
34
|
end
|
18
35
|
|
36
|
+
##
|
37
|
+
# Produces a random nested JSON formatted string that can take JSON as an additional argument.
|
38
|
+
#
|
39
|
+
# @param json [Hash{String => String}] Specifies a Json.shallow_json and uses its keys as keys of the nested JSON.
|
40
|
+
# @param width [Integer] Specifies the number of nested key-value pairs.
|
41
|
+
# @param options [Hash] Specifies a Faker gem class to use for nested keys and for values, respectably. options_hash = {key: Class.method, value: Class.method}
|
42
|
+
# @return [Hash{String => String}]
|
43
|
+
#
|
44
|
+
# @example
|
45
|
+
# json = Faker::Json.shallow_json(width: 3, options: { key: 'Name.first_name', value: 'Name.last_name' })
|
46
|
+
# puts json # =>
|
47
|
+
# {"Alisha":"Olson","Everardo":"DuBuque","Bridgette":"Turner"}
|
48
|
+
#
|
49
|
+
# json2 = Faker::Json.add_depth_to_json(json: json, width: 2, options: { key: 'Name.first_name', value: 'Name.last_name' })
|
50
|
+
# puts json2 # =>
|
51
|
+
# {"Alisha":{"Daisy":"Trantow","Oda":"Haag"},
|
52
|
+
# "Everardo":{"Javier":"Marvin","Eliseo":"Schuppe"},
|
53
|
+
# "Bridgette":{"Jorge":"Kertzmann","Lelah":"MacGyver"}}
|
54
|
+
#
|
55
|
+
# json3 = Faker::Json.add_depth_to_json(json: json2, width: 4, options: { key: 'Name.first_name', value: 'Name.last_name' })
|
56
|
+
# puts json3 # =>
|
57
|
+
# {"Alisha":
|
58
|
+
# {"Daisy":
|
59
|
+
# {"Bulah":"Wunsch","Cristian":"Champlin","Lester":"Bartoletti","Greg":"Jacobson"},
|
60
|
+
# "Oda":
|
61
|
+
# {"Salvatore":"Kuhlman","Aubree":"Okuneva","Larry":"Schmitt","Velva":"Gibson"}},
|
62
|
+
# "Everardo":
|
63
|
+
# {"Javier":
|
64
|
+
# {"Eduardo":"Orn","Laila":"Kub","Thad":"Legros","Dion":"Wilderman"},
|
65
|
+
# "Eliseo":
|
66
|
+
# {"Olin":"Hilpert","Marisa":"Greenfelder","Karlee":"Schmitt","Judd":"Larkin"}},
|
67
|
+
# "Bridgette":
|
68
|
+
# {"Jorge":
|
69
|
+
# {"Eloy":"Pfeffer","Kody":"Hansen","Paxton":"Lubowitz","Abe":"Lesch"},
|
70
|
+
# "Lelah":
|
71
|
+
# {"Rick":"Wiza","Bonita":"Bayer","Gardner":"Auer","Felicity":"Abbott"}}}
|
72
|
+
#
|
73
|
+
# @faker.version 1.9.2
|
19
74
|
# rubocop:disable Metrics/ParameterLists
|
20
75
|
def add_depth_to_json(legacy_json = NOT_GIVEN, legacy_width = NOT_GIVEN, legacy_options = NOT_GIVEN, json: shallow_json, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' })
|
21
76
|
# rubocop:enable Metrics/ParameterLists
|