faker 2.22.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +88 -7
- data/History.md +1 -1
- data/README.md +11 -5
- data/lib/faker/blockchain/aeternity.rb +1 -1
- data/lib/faker/blockchain/ethereum.rb +1 -1
- data/lib/faker/blockchain/tezos.rb +1 -1
- data/lib/faker/books/dune.rb +2 -10
- data/lib/faker/books/lovecraft.rb +7 -38
- data/lib/faker/default/address.rb +5 -25
- data/lib/faker/default/alphanumeric.rb +2 -8
- data/lib/faker/default/app.rb +1 -10
- data/lib/faker/default/avatar.rb +1 -12
- data/lib/faker/default/bank.rb +9 -17
- data/lib/faker/default/boolean.rb +1 -4
- data/lib/faker/default/chile_rut.rb +8 -14
- data/lib/faker/default/code.rb +10 -23
- data/lib/faker/default/color.rb +77 -6
- data/lib/faker/default/commerce.rb +3 -17
- data/lib/faker/default/company.rb +6 -14
- data/lib/faker/default/crypto_coin.rb +3 -15
- data/lib/faker/default/date.rb +5 -38
- data/lib/faker/default/demographic.rb +1 -5
- data/lib/faker/default/driving_licence.rb +1 -11
- data/lib/faker/default/file.rb +5 -24
- data/lib/faker/default/fillmurray.rb +1 -10
- data/lib/faker/default/finance.rb +17 -7
- data/lib/faker/default/hipster.rb +6 -45
- data/lib/faker/default/id_number.rb +108 -11
- data/lib/faker/default/internet.rb +17 -71
- data/lib/faker/default/invoice.rb +3 -16
- data/lib/faker/default/json.rb +2 -20
- data/lib/faker/default/lorem.rb +9 -66
- data/lib/faker/default/lorem_flickr.rb +4 -32
- data/lib/faker/default/lorem_pixel.rb +4 -10
- data/lib/faker/default/markdown.rb +4 -9
- data/lib/faker/default/measurement.rb +8 -40
- data/lib/faker/default/name.rb +1 -5
- data/lib/faker/default/nhs.rb +2 -6
- data/lib/faker/default/number.rb +10 -55
- data/lib/faker/default/omniauth.rb +5 -39
- data/lib/faker/default/phone_number.rb +1 -5
- data/lib/faker/default/placeholdit.rb +1 -12
- data/lib/faker/default/relationship.rb +1 -5
- data/lib/faker/default/source.rb +3 -16
- data/lib/faker/default/string.rb +1 -5
- data/lib/faker/default/stripe.rb +4 -20
- data/lib/faker/default/time.rb +4 -32
- data/lib/faker/default/twitter.rb +3 -17
- data/lib/faker/default/types.rb +5 -27
- data/lib/faker/default/vehicle.rb +21 -21
- data/lib/faker/default/vulnerability_identifier.rb +23 -0
- data/lib/faker/default/world_cup.rb +2 -11
- data/lib/faker/games/dota.rb +1 -5
- data/lib/faker/games/tarkov.rb +205 -0
- data/lib/faker/japanese_media/kamen_rider.rb +2 -2
- data/lib/faker/japanese_media/one_piece.rb +1 -1
- data/lib/faker/movies/hackers.rb +48 -0
- data/lib/faker/movies/star_wars.rb +1 -5
- data/lib/faker/sports/sport.rb +110 -0
- data/lib/faker/version.rb +1 -1
- data/lib/faker.rb +15 -63
- data/lib/helpers/base58.rb +1 -1
- data/lib/helpers/unique_generator.rb +13 -11
- data/lib/locales/en/computer.yml +23 -4
- data/lib/locales/en/file.yml +9 -1
- data/lib/locales/en/finance.yml +3 -1
- data/lib/locales/en/hackers.yml +53 -0
- data/lib/locales/en/heroes.yml +2 -2
- data/lib/locales/en/one_piece.yml +1 -1
- data/lib/locales/en/opera.yml +1 -1
- data/lib/locales/en/overwatch.yml +5 -7
- data/lib/locales/en/source.yml +5 -0
- data/lib/locales/en/sport.yml +130 -0
- data/lib/locales/en/tarkov.yml +593 -0
- data/lib/locales/en/vehicle.yml +2809 -75
- data/lib/locales/en-CA.yml +1 -0
- data/lib/locales/es-AR.yml +2 -2
- data/lib/locales/fi-FI.yml +2 -1
- data/lib/locales/fr/ancient.yml +141 -0
- data/lib/locales/hy.yml +1 -1
- data/lib/locales/th.yml +76 -76
- metadata +50 -19
data/lib/faker/default/lorem.rb
CHANGED
@@ -30,12 +30,7 @@ module Faker
|
|
30
30
|
# Faker::Lorem.words(number: 4, supplemental: true) #=> ["nisi", "sit", "allatus", "consequatur"]
|
31
31
|
#
|
32
32
|
# @faker.version 2.1.3
|
33
|
-
def words(
|
34
|
-
warn_for_deprecated_arguments do |keywords|
|
35
|
-
keywords << :number if legacy_number != NOT_GIVEN
|
36
|
-
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
37
|
-
end
|
38
|
-
|
33
|
+
def words(number: 3, supplemental: false)
|
39
34
|
resolved_num = resolve(number)
|
40
35
|
word_list = (
|
41
36
|
translate('faker.lorem.words') +
|
@@ -74,11 +69,7 @@ module Faker
|
|
74
69
|
# Faker::Lorem.characters(number: 10, min_alpha: 4, min_numeric: 1) #=> "ang9cbhoa8"
|
75
70
|
#
|
76
71
|
# @faker.version 2.1.3
|
77
|
-
def characters(
|
78
|
-
warn_for_deprecated_arguments do |keywords|
|
79
|
-
keywords << :number if legacy_number != NOT_GIVEN
|
80
|
-
end
|
81
|
-
|
72
|
+
def characters(number: 255, min_alpha: 0, min_numeric: 0)
|
82
73
|
Alphanumeric.alphanumeric(number: number, min_alpha: min_alpha, min_numeric: min_numeric)
|
83
74
|
end
|
84
75
|
|
@@ -95,7 +86,6 @@ module Faker
|
|
95
86
|
def multibyte
|
96
87
|
sample(translate('faker.lorem.multibyte')).pack('C*').force_encoding('utf-8')
|
97
88
|
end
|
98
|
-
# rubocop:disable Metrics/ParameterLists
|
99
89
|
|
100
90
|
##
|
101
91
|
# Generates sentence
|
@@ -113,16 +103,9 @@ module Faker
|
|
113
103
|
# Faker::Lorem.sentence(word_count: 5, supplemental: true, random_words_to_add:2) #=> "Crinis quo cruentus velit animi vomer."
|
114
104
|
#
|
115
105
|
# @faker.version 2.1.3
|
116
|
-
def sentence(
|
117
|
-
warn_for_deprecated_arguments do |keywords|
|
118
|
-
keywords << :word_count if legacy_word_count != NOT_GIVEN
|
119
|
-
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
120
|
-
keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
|
121
|
-
end
|
122
|
-
|
106
|
+
def sentence(word_count: 4, supplemental: false, random_words_to_add: 0)
|
123
107
|
words(number: word_count + rand(random_words_to_add.to_i), supplemental: supplemental).join(locale_space).capitalize + locale_period
|
124
108
|
end
|
125
|
-
# rubocop:enable Metrics/ParameterLists
|
126
109
|
|
127
110
|
##
|
128
111
|
# Generates three sentences
|
@@ -138,17 +121,10 @@ module Faker
|
|
138
121
|
# Faker::Lorem.sentences(number: 2, supplemental: true) #=> ["Cito cena ad.", "Solvo animus allatus."]
|
139
122
|
#
|
140
123
|
# @faker.version 2.1.3
|
141
|
-
def sentences(
|
142
|
-
warn_for_deprecated_arguments do |keywords|
|
143
|
-
keywords << :number if legacy_number != NOT_GIVEN
|
144
|
-
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
145
|
-
end
|
146
|
-
|
124
|
+
def sentences(number: 3, supplemental: false)
|
147
125
|
1.upto(resolve(number)).collect { sentence(word_count: 3, supplemental: supplemental) }
|
148
126
|
end
|
149
127
|
|
150
|
-
# rubocop:disable Metrics/ParameterLists
|
151
|
-
|
152
128
|
##
|
153
129
|
# Generates three sentence paragraph
|
154
130
|
#
|
@@ -169,16 +145,9 @@ module Faker
|
|
169
145
|
# #=> "Texo tantillus tamisium. Tribuo amissio tamisium. Facere aut canis."
|
170
146
|
#
|
171
147
|
# @faker.version 2.1.3
|
172
|
-
def paragraph(
|
173
|
-
warn_for_deprecated_arguments do |keywords|
|
174
|
-
keywords << :sentence_count if legacy_sentence_count != NOT_GIVEN
|
175
|
-
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
176
|
-
keywords << :random_sentences_to_add if legacy_random_sentences_to_add != NOT_GIVEN
|
177
|
-
end
|
178
|
-
|
148
|
+
def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 0)
|
179
149
|
sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i), supplemental: supplemental).join(locale_space)
|
180
150
|
end
|
181
|
-
# rubocop:enable Metrics/ParameterLists
|
182
151
|
|
183
152
|
##
|
184
153
|
# Generates three paragraphs
|
@@ -194,14 +163,7 @@ module Faker
|
|
194
163
|
# Faker::Lorem.paragraphs(number:2, supplemental: true)
|
195
164
|
#
|
196
165
|
# @faker.version 2.1.3
|
197
|
-
def paragraphs(
|
198
|
-
warn_for_deprecated_arguments do |keywords|
|
199
|
-
keywords << :number if legacy_number != NOT_GIVEN
|
200
|
-
end
|
201
|
-
warn_for_deprecated_arguments do |keywords|
|
202
|
-
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
203
|
-
end
|
204
|
-
|
166
|
+
def paragraphs(number: 3, supplemental: false)
|
205
167
|
1.upto(resolve(number)).collect { paragraph(sentence_count: 3, supplemental: supplemental) }
|
206
168
|
end
|
207
169
|
|
@@ -219,12 +181,7 @@ module Faker
|
|
219
181
|
# Faker::Lorem.paragraph_by_chars(number: 20, supplemental: true) #=> "Certus aveho admove."
|
220
182
|
#
|
221
183
|
# @faker.version 2.1.3
|
222
|
-
def paragraph_by_chars(
|
223
|
-
warn_for_deprecated_arguments do |keywords|
|
224
|
-
keywords << :number if legacy_number != NOT_GIVEN
|
225
|
-
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
226
|
-
end
|
227
|
-
|
184
|
+
def paragraph_by_chars(number: 256, supplemental: false)
|
228
185
|
paragraph = paragraph(sentence_count: 3, supplemental: supplemental)
|
229
186
|
|
230
187
|
paragraph += " #{paragraph(sentence_count: 3, supplemental: supplemental)}" while paragraph.length < number
|
@@ -232,8 +189,6 @@ module Faker
|
|
232
189
|
"#{paragraph[0...number - 1]}."
|
233
190
|
end
|
234
191
|
|
235
|
-
# rubocop:disable Metrics/ParameterLists
|
236
|
-
|
237
192
|
##
|
238
193
|
# Returns the question with 4 words
|
239
194
|
#
|
@@ -250,16 +205,9 @@ module Faker
|
|
250
205
|
# Faker::Lorem.question(word_count: 2, supplemental: true, random_words_to_add: 2) #=> "Depulso uter ut?"
|
251
206
|
#
|
252
207
|
# @faker.version 2.1.3
|
253
|
-
def question(
|
254
|
-
warn_for_deprecated_arguments do |keywords|
|
255
|
-
keywords << :word_count if legacy_word_count != NOT_GIVEN
|
256
|
-
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
257
|
-
keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
|
258
|
-
end
|
259
|
-
|
208
|
+
def question(word_count: 4, supplemental: false, random_words_to_add: 0)
|
260
209
|
words(number: word_count + rand(random_words_to_add), supplemental: supplemental).join(' ').capitalize + locale_question_mark
|
261
210
|
end
|
262
|
-
# rubocop:enable Metrics/ParameterLists
|
263
211
|
|
264
212
|
##
|
265
213
|
# Generates array of three questions
|
@@ -275,12 +223,7 @@ module Faker
|
|
275
223
|
# Faker::Lorem.questions(number: 2, supplemental: true) #=> ["Acceptus subito cetera?", "Aro sulum cubicularis?"]
|
276
224
|
#
|
277
225
|
# @faker.version 2.1.3
|
278
|
-
def questions(
|
279
|
-
warn_for_deprecated_arguments do |keywords|
|
280
|
-
keywords << :number if legacy_number != NOT_GIVEN
|
281
|
-
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
282
|
-
end
|
283
|
-
|
226
|
+
def questions(number: 3, supplemental: false)
|
284
227
|
1.upto(resolve(number)).collect { question(word_count: 3, supplemental: supplemental) }
|
285
228
|
end
|
286
229
|
|
@@ -5,8 +5,6 @@ module Faker
|
|
5
5
|
class << self
|
6
6
|
SUPPORTED_COLORIZATIONS = %w[red green blue].freeze
|
7
7
|
|
8
|
-
# rubocop:disable Metrics/ParameterLists
|
9
|
-
|
10
8
|
##
|
11
9
|
# Produces a random image URL from loremflickr.com.
|
12
10
|
#
|
@@ -23,13 +21,7 @@ module Faker
|
|
23
21
|
# Faker::LoremFlickr.image(size: "50x60", search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/50/60/sports,fitness/all"
|
24
22
|
#
|
25
23
|
# @faker.version 1.9.0
|
26
|
-
def image(
|
27
|
-
warn_for_deprecated_arguments do |keywords|
|
28
|
-
keywords << :size if legacy_size != NOT_GIVEN
|
29
|
-
keywords << :search_terms if legacy_search_terms != NOT_GIVEN
|
30
|
-
keywords << :match_all if legacy_match_all != NOT_GIVEN
|
31
|
-
end
|
32
|
-
|
24
|
+
def image(size: '300x300', search_terms: [], match_all: false)
|
33
25
|
build_url(size, nil, search_terms, match_all)
|
34
26
|
end
|
35
27
|
|
@@ -49,13 +41,7 @@ module Faker
|
|
49
41
|
# Faker::LoremFlickr.grayscale_image(size: "50x60", search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/g/50/60/sports,fitness/all"
|
50
42
|
#
|
51
43
|
# @faker.version 1.9.0
|
52
|
-
def grayscale_image(
|
53
|
-
warn_for_deprecated_arguments do |keywords|
|
54
|
-
keywords << :size if legacy_size != NOT_GIVEN
|
55
|
-
keywords << :search_terms if legacy_search_terms != NOT_GIVEN
|
56
|
-
keywords << :match_all if legacy_match_all != NOT_GIVEN
|
57
|
-
end
|
58
|
-
|
44
|
+
def grayscale_image(size: '300x300', search_terms: ['all'], match_all: false)
|
59
45
|
raise ArgumentError, 'Search terms must be specified for grayscale images' unless search_terms.any?
|
60
46
|
|
61
47
|
build_url(size, 'g', search_terms, match_all)
|
@@ -77,13 +63,7 @@ module Faker
|
|
77
63
|
# Faker::LoremFlickr.pixelated_image(size: "50x60", search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/p/50/60/sports,fitness/all"
|
78
64
|
#
|
79
65
|
# @faker.version 1.9.0
|
80
|
-
def pixelated_image(
|
81
|
-
warn_for_deprecated_arguments do |keywords|
|
82
|
-
keywords << :size if legacy_size != NOT_GIVEN
|
83
|
-
keywords << :search_terms if legacy_search_terms != NOT_GIVEN
|
84
|
-
keywords << :match_all if legacy_match_all != NOT_GIVEN
|
85
|
-
end
|
86
|
-
|
66
|
+
def pixelated_image(size: '300x300', search_terms: ['all'], match_all: false)
|
87
67
|
raise ArgumentError, 'Search terms must be specified for pixelated images' unless search_terms.any?
|
88
68
|
|
89
69
|
build_url(size, 'p', search_terms, match_all)
|
@@ -106,20 +86,12 @@ module Faker
|
|
106
86
|
# Faker::LoremFlickr.image(size: "50x60", color: 'blue', search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/blue/50/60/sports,fitness/all"
|
107
87
|
#
|
108
88
|
# @faker.version 1.9.0
|
109
|
-
def colorized_image(
|
110
|
-
warn_for_deprecated_arguments do |keywords|
|
111
|
-
keywords << :size if legacy_size != NOT_GIVEN
|
112
|
-
keywords << :color if legacy_color != NOT_GIVEN
|
113
|
-
keywords << :search_terms if legacy_search_terms != NOT_GIVEN
|
114
|
-
keywords << :match_all if legacy_match_all != NOT_GIVEN
|
115
|
-
end
|
116
|
-
|
89
|
+
def colorized_image(size: '300x300', color: 'red', search_terms: ['all'], match_all: false)
|
117
90
|
raise ArgumentError, 'Search terms must be specified for colorized images' unless search_terms.any?
|
118
91
|
raise ArgumentError, "Supported colorizations are #{SUPPORTED_COLORIZATIONS.join(', ')}" unless SUPPORTED_COLORIZATIONS.include?(color)
|
119
92
|
|
120
93
|
build_url(size, color, search_terms, match_all)
|
121
94
|
end
|
122
|
-
# rubocop:enable Metrics/ParameterLists
|
123
95
|
|
124
96
|
private
|
125
97
|
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module Faker
|
4
4
|
class LoremPixel < Base
|
5
5
|
class << self
|
6
|
+
extend Gem::Deprecate
|
7
|
+
|
6
8
|
SUPPORTED_CATEGORIES = %w[abstract
|
7
9
|
animals
|
8
10
|
business
|
@@ -41,16 +43,7 @@ module Faker
|
|
41
43
|
# Faker::LoremPixel.image(secure: false) #=> "http://lorempixel.com/300/300"
|
42
44
|
#
|
43
45
|
# @faker.version 1.7.0
|
44
|
-
def image(
|
45
|
-
warn_for_deprecated_arguments do |keywords|
|
46
|
-
keywords << :size if legacy_size != NOT_GIVEN
|
47
|
-
keywords << :is_gray if legacy_is_gray != NOT_GIVEN
|
48
|
-
keywords << :category if legacy_category != NOT_GIVEN
|
49
|
-
keywords << :number if legacy_number != NOT_GIVEN
|
50
|
-
keywords << :text if legacy_text != NOT_GIVEN
|
51
|
-
keywords << :secure if legacy_secure != NOT_GIVEN
|
52
|
-
end
|
53
|
-
|
46
|
+
def image(size: '300x300', is_gray: false, category: nil, number: nil, text: nil, secure: true)
|
54
47
|
raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /^[0-9]+x[0-9]+$/
|
55
48
|
raise ArgumentError, "Supported categories are #{SUPPORTED_CATEGORIES.join(', ')}" unless category.nil? || SUPPORTED_CATEGORIES.include?(category)
|
56
49
|
raise ArgumentError, 'Category required when number is passed' if !number.nil? && category.nil?
|
@@ -64,6 +57,7 @@ module Faker
|
|
64
57
|
url_parts += [category, number, text].compact
|
65
58
|
url_parts.join('/')
|
66
59
|
end
|
60
|
+
deprecate :image, 'Faker::LoremFlickr.image', 2022, 12
|
67
61
|
# rubocop:enable Metrics/ParameterLists
|
68
62
|
end
|
69
63
|
end
|
@@ -27,7 +27,7 @@ module Faker
|
|
27
27
|
# @faker.version 1.8.0
|
28
28
|
def emphasis
|
29
29
|
paragraph = Faker::Lorem.paragraph(sentence_count: 3)
|
30
|
-
words = paragraph.split
|
30
|
+
words = paragraph.split
|
31
31
|
position = rand(0..words.length - 1)
|
32
32
|
formatting = fetch('markdown.emphasis')
|
33
33
|
words[position] = "#{formatting}#{words[position]}#{formatting}"
|
@@ -50,7 +50,7 @@ module Faker
|
|
50
50
|
number.times do |i|
|
51
51
|
result << "#{i}. #{Faker::Lorem.sentence(word_count: 1)} \n"
|
52
52
|
end
|
53
|
-
result.join
|
53
|
+
result.join
|
54
54
|
end
|
55
55
|
|
56
56
|
##
|
@@ -69,7 +69,7 @@ module Faker
|
|
69
69
|
number.times do |_i|
|
70
70
|
result << "* #{Faker::Lorem.sentence(word_count: 1)} \n"
|
71
71
|
end
|
72
|
-
result.join
|
72
|
+
result.join
|
73
73
|
end
|
74
74
|
|
75
75
|
##
|
@@ -150,12 +150,7 @@ module Faker
|
|
150
150
|
# Faker::Markdown.sandwich(sentences: 6, repeat: 3) #=> returns newline separated content of 1 header, and then 3 sections consisting of, here, 1 6-sentence lorem paragraph and 1 random markdown element. The random markdown element is chosen at random in each iteration of the paragraph-markdown pairing.
|
151
151
|
#
|
152
152
|
# @faker.version 1.8.0
|
153
|
-
def sandwich(
|
154
|
-
warn_for_deprecated_arguments do |keywords|
|
155
|
-
keywords << :sentences if legacy_sentences != NOT_GIVEN
|
156
|
-
keywords << :repeat if legacy_repeat != NOT_GIVEN
|
157
|
-
end
|
158
|
-
|
153
|
+
def sandwich(sentences: 3, repeat: 1)
|
159
154
|
text_block = []
|
160
155
|
text_block << headers
|
161
156
|
repeat.times do
|
@@ -19,11 +19,7 @@ module Faker
|
|
19
19
|
# Faker::Measurement.height(amount: "all") #=> "inches"
|
20
20
|
#
|
21
21
|
# @faker.version 1.7.3
|
22
|
-
def height(
|
23
|
-
warn_for_deprecated_arguments do |keywords|
|
24
|
-
keywords << :amount if legacy_amount != NOT_GIVEN
|
25
|
-
end
|
26
|
-
|
22
|
+
def height(amount: rand(10))
|
27
23
|
define_measurement_locale(amount, 'height')
|
28
24
|
end
|
29
25
|
|
@@ -38,11 +34,7 @@ module Faker
|
|
38
34
|
# Faker::Measurement.length(amount: 1.4) #=> "1.4 yards"
|
39
35
|
#
|
40
36
|
# @faker.version 1.7.3
|
41
|
-
def length(
|
42
|
-
warn_for_deprecated_arguments do |keywords|
|
43
|
-
keywords << :amount if legacy_amount != NOT_GIVEN
|
44
|
-
end
|
45
|
-
|
37
|
+
def length(amount: rand(10))
|
46
38
|
define_measurement_locale(amount, 'length')
|
47
39
|
end
|
48
40
|
|
@@ -57,11 +49,7 @@ module Faker
|
|
57
49
|
# Faker::Measurement.volume(amount: 1.4) #=> "1.4 cups"
|
58
50
|
#
|
59
51
|
# @faker.version 1.7.3
|
60
|
-
def volume(
|
61
|
-
warn_for_deprecated_arguments do |keywords|
|
62
|
-
keywords << :amount if legacy_amount != NOT_GIVEN
|
63
|
-
end
|
64
|
-
|
52
|
+
def volume(amount: rand(10))
|
65
53
|
define_measurement_locale(amount, 'volume')
|
66
54
|
end
|
67
55
|
|
@@ -76,11 +64,7 @@ module Faker
|
|
76
64
|
# Faker::Measurement.weight(amount: 1.4) #=> "1.4 pounds"
|
77
65
|
#
|
78
66
|
# @faker.version 1.7.3
|
79
|
-
def weight(
|
80
|
-
warn_for_deprecated_arguments do |keywords|
|
81
|
-
keywords << :amount if legacy_amount != NOT_GIVEN
|
82
|
-
end
|
83
|
-
|
67
|
+
def weight(amount: rand(10))
|
84
68
|
define_measurement_locale(amount, 'weight')
|
85
69
|
end
|
86
70
|
|
@@ -95,11 +79,7 @@ module Faker
|
|
95
79
|
# Faker::Measurement.metric_height(amount: 1.4) #=> "1.4 meters"
|
96
80
|
#
|
97
81
|
# @faker.version 1.7.3
|
98
|
-
def metric_height(
|
99
|
-
warn_for_deprecated_arguments do |keywords|
|
100
|
-
keywords << :amount if legacy_amount != NOT_GIVEN
|
101
|
-
end
|
102
|
-
|
82
|
+
def metric_height(amount: rand(10))
|
103
83
|
define_measurement_locale(amount, 'metric_height')
|
104
84
|
end
|
105
85
|
|
@@ -114,11 +94,7 @@ module Faker
|
|
114
94
|
# Faker::Measurement.metric_length(amount: 1.4) #=> "1.4 decimeters"
|
115
95
|
#
|
116
96
|
# @faker.version 1.7.3
|
117
|
-
def metric_length(
|
118
|
-
warn_for_deprecated_arguments do |keywords|
|
119
|
-
keywords << :amount if legacy_amount != NOT_GIVEN
|
120
|
-
end
|
121
|
-
|
97
|
+
def metric_length(amount: rand(10))
|
122
98
|
define_measurement_locale(amount, 'metric_length')
|
123
99
|
end
|
124
100
|
|
@@ -133,11 +109,7 @@ module Faker
|
|
133
109
|
# Faker::Measurement.metric_volume(amount: 1.4) #=> "1.4 liters"
|
134
110
|
#
|
135
111
|
# @faker.version 1.7.3
|
136
|
-
def metric_volume(
|
137
|
-
warn_for_deprecated_arguments do |keywords|
|
138
|
-
keywords << :amount if legacy_amount != NOT_GIVEN
|
139
|
-
end
|
140
|
-
|
112
|
+
def metric_volume(amount: rand(10))
|
141
113
|
define_measurement_locale(amount, 'metric_volume')
|
142
114
|
end
|
143
115
|
|
@@ -152,11 +124,7 @@ module Faker
|
|
152
124
|
# Faker::Measurement.metric_weight(amount: 1.4) #=> "1.4 grams"
|
153
125
|
#
|
154
126
|
# @faker.version 1.7.3
|
155
|
-
def metric_weight(
|
156
|
-
warn_for_deprecated_arguments do |keywords|
|
157
|
-
keywords << :amount if legacy_amount != NOT_GIVEN
|
158
|
-
end
|
159
|
-
|
127
|
+
def metric_weight(amount: rand(10))
|
160
128
|
define_measurement_locale(amount, 'metric_weight')
|
161
129
|
end
|
162
130
|
|
data/lib/faker/default/name.rb
CHANGED
@@ -144,11 +144,7 @@ module Faker
|
|
144
144
|
# Faker::Name.initials(number: 2) #=> "NM"
|
145
145
|
#
|
146
146
|
# @faker.version 1.8.5
|
147
|
-
def initials(
|
148
|
-
warn_for_deprecated_arguments do |keywords|
|
149
|
-
keywords << :number if legacy_number != NOT_GIVEN
|
150
|
-
end
|
151
|
-
|
147
|
+
def initials(number: 3)
|
152
148
|
(0...number).map { rand(65..90).chr }.join
|
153
149
|
end
|
154
150
|
end
|
data/lib/faker/default/nhs.rb
CHANGED
@@ -21,7 +21,7 @@ module Faker
|
|
21
21
|
.chars
|
22
22
|
.insert(3, ' ')
|
23
23
|
.insert(7, ' ')
|
24
|
-
.join
|
24
|
+
.join
|
25
25
|
end
|
26
26
|
|
27
27
|
##
|
@@ -34,11 +34,7 @@ module Faker
|
|
34
34
|
# Faker::NationalHealthService.check_digit(number: 400_012_114) #=> 6
|
35
35
|
#
|
36
36
|
# @faker.version 1.9.2
|
37
|
-
def check_digit(
|
38
|
-
warn_for_deprecated_arguments do |keywords|
|
39
|
-
keywords << :number if legacy_number != NOT_GIVEN
|
40
|
-
end
|
41
|
-
|
37
|
+
def check_digit(number: 0)
|
42
38
|
sum = 0
|
43
39
|
number.to_s.chars.each_with_index do |digit, idx|
|
44
40
|
position = idx + 1
|
data/lib/faker/default/number.rb
CHANGED
@@ -13,11 +13,7 @@ module Faker
|
|
13
13
|
# Faker::Number.number(digits: 10) #=> 1968353479
|
14
14
|
#
|
15
15
|
# @faker.version 1.0.0
|
16
|
-
def number(
|
17
|
-
warn_for_deprecated_arguments do |keywords|
|
18
|
-
keywords << :digits if legacy_digits != NOT_GIVEN
|
19
|
-
end
|
20
|
-
|
16
|
+
def number(digits: 10)
|
21
17
|
return if digits < 1
|
22
18
|
return rand(0..9).round if digits == 1
|
23
19
|
|
@@ -35,11 +31,7 @@ module Faker
|
|
35
31
|
# Faker::Number.leading_zero_number(digits: 10) #=> "0669336915"
|
36
32
|
#
|
37
33
|
# @faker.version 1.0.0
|
38
|
-
def leading_zero_number(
|
39
|
-
warn_for_deprecated_arguments do |keywords|
|
40
|
-
keywords << :digits if legacy_digits != NOT_GIVEN
|
41
|
-
end
|
42
|
-
|
34
|
+
def leading_zero_number(digits: 10)
|
43
35
|
"0#{(2..digits).collect { digit }.join}"
|
44
36
|
end
|
45
37
|
|
@@ -53,11 +45,7 @@ module Faker
|
|
53
45
|
# Faker::Number.decimal_part(digits: 2) #=> "09"
|
54
46
|
#
|
55
47
|
# @faker.version 1.0.0
|
56
|
-
def decimal_part(
|
57
|
-
warn_for_deprecated_arguments do |keywords|
|
58
|
-
keywords << :digits if legacy_digits != NOT_GIVEN
|
59
|
-
end
|
60
|
-
|
48
|
+
def decimal_part(digits: 10)
|
61
49
|
num = ''
|
62
50
|
if digits > 1
|
63
51
|
num = non_zero_digit
|
@@ -78,12 +66,7 @@ module Faker
|
|
78
66
|
# Faker::Number.decimal(l_digits: 3, r_digits: 3) #=> 181.843
|
79
67
|
#
|
80
68
|
# @faker.version 1.0.0
|
81
|
-
def decimal(
|
82
|
-
warn_for_deprecated_arguments do |keywords|
|
83
|
-
keywords << :l_digits if legacy_l_digits != NOT_GIVEN
|
84
|
-
keywords << :r_digits if legacy_r_digits != NOT_GIVEN
|
85
|
-
end
|
86
|
-
|
69
|
+
def decimal(l_digits: 5, r_digits: 2)
|
87
70
|
l_d = number(digits: l_digits)
|
88
71
|
|
89
72
|
# Ensure the last digit is not zero
|
@@ -129,11 +112,7 @@ module Faker
|
|
129
112
|
# Faker::Number.hexadecimal(digits: 3) #=> "e74"
|
130
113
|
#
|
131
114
|
# @faker.version 1.0.0
|
132
|
-
def hexadecimal(
|
133
|
-
warn_for_deprecated_arguments do |keywords|
|
134
|
-
keywords << :digits if legacy_digits != NOT_GIVEN
|
135
|
-
end
|
136
|
-
|
115
|
+
def hexadecimal(digits: 6)
|
137
116
|
hex = ''
|
138
117
|
digits.times { hex += rand(15).to_s(16) }
|
139
118
|
hex
|
@@ -165,12 +144,7 @@ module Faker
|
|
165
144
|
# Faker::Number.normal(mean: 50, standard_deviation: 3.5) #=> 47.14669604069156
|
166
145
|
#
|
167
146
|
# @faker.version 1.0.0
|
168
|
-
def normal(
|
169
|
-
warn_for_deprecated_arguments do |keywords|
|
170
|
-
keywords << :mean if legacy_mean != NOT_GIVEN
|
171
|
-
keywords << :standard_deviation if legacy_standard_deviation != NOT_GIVEN
|
172
|
-
end
|
173
|
-
|
147
|
+
def normal(mean: 1, standard_deviation: 1)
|
174
148
|
theta = 2 * Math::PI * rand
|
175
149
|
rho = Math.sqrt(-2 * Math.log(1 - rand))
|
176
150
|
scale = standard_deviation * rho
|
@@ -189,12 +163,7 @@ module Faker
|
|
189
163
|
# Faker::Number.between(from: 0.0, to: 1.0) #=> 0.7844640543957383
|
190
164
|
#
|
191
165
|
# @faker.version 1.0.0
|
192
|
-
def between(
|
193
|
-
warn_for_deprecated_arguments do |keywords|
|
194
|
-
keywords << :from if legacy_from != NOT_GIVEN
|
195
|
-
keywords << :to if legacy_to != NOT_GIVEN
|
196
|
-
end
|
197
|
-
|
166
|
+
def between(from: 1.00, to: 5000.00)
|
198
167
|
Faker::Base.rand_in_range(from, to)
|
199
168
|
end
|
200
169
|
|
@@ -209,11 +178,7 @@ module Faker
|
|
209
178
|
# Faker::Number.within(range: 0.0..1.0) #=> 0.7844640543957383
|
210
179
|
#
|
211
180
|
# @faker.version 1.0.0
|
212
|
-
def within(
|
213
|
-
warn_for_deprecated_arguments do |keywords|
|
214
|
-
keywords << :range if legacy_range != NOT_GIVEN
|
215
|
-
end
|
216
|
-
|
181
|
+
def within(range: 1.00..5000.00)
|
217
182
|
between(from: range.min, to: range.max)
|
218
183
|
end
|
219
184
|
|
@@ -228,12 +193,7 @@ module Faker
|
|
228
193
|
# Faker::Number.positive #=> 235.59238499107653
|
229
194
|
#
|
230
195
|
# @faker.version 1.0.0
|
231
|
-
def positive(
|
232
|
-
warn_for_deprecated_arguments do |keywords|
|
233
|
-
keywords << :from if legacy_from != NOT_GIVEN
|
234
|
-
keywords << :to if legacy_to != NOT_GIVEN
|
235
|
-
end
|
236
|
-
|
196
|
+
def positive(from: 1.00, to: 5000.00)
|
237
197
|
random_number = between(from: from, to: to)
|
238
198
|
|
239
199
|
greater_than_zero(random_number)
|
@@ -250,12 +210,7 @@ module Faker
|
|
250
210
|
# Faker::Number.negative #=> -4480.042585669558
|
251
211
|
#
|
252
212
|
# @faker.version 1.0.0
|
253
|
-
def negative(
|
254
|
-
warn_for_deprecated_arguments do |keywords|
|
255
|
-
keywords << :from if legacy_from != NOT_GIVEN
|
256
|
-
keywords << :to if legacy_to != NOT_GIVEN
|
257
|
-
end
|
258
|
-
|
213
|
+
def negative(from: -5000.00, to: -1.00)
|
259
214
|
random_number = between(from: from, to: to)
|
260
215
|
|
261
216
|
less_than_zero(random_number)
|
@@ -17,8 +17,6 @@ module Faker
|
|
17
17
|
end
|
18
18
|
|
19
19
|
class << self
|
20
|
-
# rubocop:disable Metrics/ParameterLists
|
21
|
-
|
22
20
|
##
|
23
21
|
# Generate a mock Omniauth response from Google.
|
24
22
|
#
|
@@ -29,13 +27,7 @@ module Faker
|
|
29
27
|
# @return [Hash] An auth hash in the format provided by omniauth-google.
|
30
28
|
#
|
31
29
|
# @faker.version 1.8.0
|
32
|
-
def google(
|
33
|
-
warn_for_deprecated_arguments do |keywords|
|
34
|
-
keywords << :name if legacy_name != NOT_GIVEN
|
35
|
-
keywords << :email if legacy_email != NOT_GIVEN
|
36
|
-
keywords << :uid if legacy_uid != NOT_GIVEN
|
37
|
-
end
|
38
|
-
|
30
|
+
def google(name: nil, email: nil, uid: Number.number(digits: 9).to_s)
|
39
31
|
auth = Omniauth.new(name: name, email: email)
|
40
32
|
{
|
41
33
|
provider: 'google_oauth2',
|
@@ -95,14 +87,7 @@ module Faker
|
|
95
87
|
# @return [Hash] An auth hash in the format provided by omniauth-facebook.
|
96
88
|
#
|
97
89
|
# @faker.version 1.8.0
|
98
|
-
def facebook(
|
99
|
-
warn_for_deprecated_arguments do |keywords|
|
100
|
-
keywords << :name if legacy_name != NOT_GIVEN
|
101
|
-
keywords << :email if legacy_email != NOT_GIVEN
|
102
|
-
keywords << :username if legacy_username != NOT_GIVEN
|
103
|
-
keywords << :uid if legacy_uid != NOT_GIVEN
|
104
|
-
end
|
105
|
-
|
90
|
+
def facebook(name: nil, email: nil, username: nil, uid: Number.number(digits: 7).to_s)
|
106
91
|
auth = Omniauth.new(name: name, email: email)
|
107
92
|
username ||= "#{auth.first_name.downcase[0]}#{auth.last_name.downcase}"
|
108
93
|
{
|
@@ -154,13 +139,7 @@ module Faker
|
|
154
139
|
# @return [Hash] An auth hash in the format provided by omniauth-twitter.
|
155
140
|
#
|
156
141
|
# @faker.version 1.8.0
|
157
|
-
def twitter(
|
158
|
-
warn_for_deprecated_arguments do |keywords|
|
159
|
-
keywords << :name if legacy_name != NOT_GIVEN
|
160
|
-
keywords << :nickname if legacy_nickname != NOT_GIVEN
|
161
|
-
keywords << :uid if legacy_uid != NOT_GIVEN
|
162
|
-
end
|
163
|
-
|
142
|
+
def twitter(name: nil, nickname: nil, uid: Number.number(digits: 6).to_s)
|
164
143
|
auth = Omniauth.new(name: name)
|
165
144
|
nickname ||= auth.name.downcase.delete(' ')
|
166
145
|
location = city_state
|
@@ -243,13 +222,7 @@ module Faker
|
|
243
222
|
# @return [Hash] An auth hash in the format provided by omniauth-linkedin.
|
244
223
|
#
|
245
224
|
# @faker.version 1.8.0
|
246
|
-
def linkedin(
|
247
|
-
warn_for_deprecated_arguments do |keywords|
|
248
|
-
keywords << :name if legacy_name != NOT_GIVEN
|
249
|
-
keywords << :email if legacy_email != NOT_GIVEN
|
250
|
-
keywords << :uid if legacy_uid != NOT_GIVEN
|
251
|
-
end
|
252
|
-
|
225
|
+
def linkedin(name: nil, email: nil, uid: Number.number(digits: 6).to_s)
|
253
226
|
auth = Omniauth.new(name: name, email: email)
|
254
227
|
first_name = auth.first_name.downcase
|
255
228
|
last_name = auth.last_name.downcase
|
@@ -322,13 +295,7 @@ module Faker
|
|
322
295
|
# @return [Hash] An auth hash in the format provided by omniauth-github.
|
323
296
|
#
|
324
297
|
# @faker.version 1.8.0
|
325
|
-
def github(
|
326
|
-
warn_for_deprecated_arguments do |keywords|
|
327
|
-
keywords << :name if legacy_name != NOT_GIVEN
|
328
|
-
keywords << :email if legacy_email != NOT_GIVEN
|
329
|
-
keywords << :uid if legacy_uid != NOT_GIVEN
|
330
|
-
end
|
331
|
-
|
298
|
+
def github(name: nil, email: nil, uid: Number.number(digits: 8).to_s)
|
332
299
|
auth = Omniauth.new(name: name, email: email)
|
333
300
|
login = auth.name.downcase.tr(' ', '-')
|
334
301
|
html_url = "https://github.com/#{login}"
|
@@ -385,7 +352,6 @@ module Faker
|
|
385
352
|
}
|
386
353
|
}
|
387
354
|
end
|
388
|
-
# rubocop:enable Metrics/ParameterLists
|
389
355
|
|
390
356
|
##
|
391
357
|
# Generate a mock Omniauth response from Apple.
|