faker 2.14.0 → 2.18.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 +218 -19
- data/History.md +4 -4
- data/README.md +18 -1
- data/lib/faker.rb +12 -13
- 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 +4 -4
- data/lib/faker/default/app.rb +1 -1
- data/lib/faker/default/avatar.rb +1 -1
- data/lib/faker/default/bank.rb +20 -6
- data/lib/faker/default/barcode.rb +44 -33
- data/lib/faker/default/beer.rb +3 -3
- data/lib/faker/default/camera.rb +46 -0
- data/lib/faker/default/cannabis.rb +10 -0
- data/lib/faker/default/chile_rut.rb +3 -2
- data/lib/faker/default/chuck_norris.rb +1 -0
- data/lib/faker/default/code.rb +5 -5
- data/lib/faker/default/commerce.rb +1 -1
- data/lib/faker/default/company.rb +58 -10
- data/lib/faker/default/crypto.rb +17 -4
- data/lib/faker/default/driving_licence.rb +4 -3
- data/lib/faker/default/drone.rb +25 -25
- data/lib/faker/default/educator.rb +13 -0
- data/lib/faker/default/faker_adjective.rb +35 -0
- data/lib/faker/default/file.rb +6 -4
- data/lib/faker/default/finance.rb +21 -0
- data/lib/faker/default/food.rb +1 -1
- data/lib/faker/default/hipster.rb +14 -11
- data/lib/faker/default/id_number.rb +36 -2
- data/lib/faker/default/internet.rb +232 -6
- data/lib/faker/default/invoice.rb +1 -1
- data/lib/faker/default/json.rb +7 -6
- data/lib/faker/default/lorem.rb +160 -5
- data/lib/faker/default/lorem_flickr.rb +3 -8
- data/lib/faker/default/lorem_pixel.rb +2 -1
- data/lib/faker/default/markdown.rb +4 -2
- data/lib/faker/default/measurement.rb +3 -2
- data/lib/faker/default/military.rb +26 -0
- data/lib/faker/default/mountain.rb +33 -0
- data/lib/faker/default/number.rb +23 -6
- data/lib/faker/default/omniauth.rb +5 -10
- data/lib/faker/default/placeholdit.rb +3 -2
- data/lib/faker/default/relationship.rb +1 -1
- data/lib/faker/default/science.rb +26 -0
- data/lib/faker/default/space.rb +1 -1
- data/lib/faker/default/string.rb +3 -2
- data/lib/faker/default/stripe.rb +3 -3
- data/lib/faker/default/tea.rb +41 -0
- data/lib/faker/default/types.rb +4 -3
- data/lib/faker/default/vehicle.rb +1 -1
- data/lib/faker/fantasy/tolkien.rb +67 -0
- data/lib/faker/games/clash_of_clans.rb +48 -0
- data/lib/faker/games/control.rb +1 -1
- data/lib/faker/games/dnd.rb +6 -6
- data/lib/faker/games/elder_scrolls.rb +26 -0
- data/lib/faker/games/heroes.rb +13 -0
- data/lib/faker/games/minecraft.rb +65 -0
- data/lib/faker/games/street_fighter.rb +4 -4
- data/lib/faker/games/super_mario.rb +48 -0
- data/lib/faker/games/touhou.rb +75 -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/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/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/rock_band.rb +12 -0
- data/lib/faker/quotes/quote.rb +26 -0
- data/lib/faker/quotes/rajnikanth.rb +1 -0
- data/lib/faker/quotes/shakespeare.rb +34 -0
- data/lib/faker/sports/volleyball.rb +74 -0
- data/lib/faker/tv_shows/big_bang_theory.rb +1 -1
- data/lib/faker/tv_shows/buffy.rb +17 -4
- data/lib/faker/tv_shows/final_space.rb +51 -0
- data/lib/faker/tv_shows/suits.rb +1 -1
- data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +17 -4
- data/lib/faker/version.rb +1 -1
- data/lib/locales/en-US.yml +1 -1
- data/lib/locales/en/adjective.yml +179 -0
- data/lib/locales/en/bird.yml +1281 -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/conan.yml +171 -0
- data/lib/locales/en/demographic.yml +218 -5
- data/lib/locales/en/device.yml +112 -4
- 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 +3 -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/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/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 +273 -0
- data/lib/locales/en/mountain.yml +158 -0
- data/lib/locales/en/music.yml +461 -29
- data/lib/locales/en/myst.yml +87 -31
- data/lib/locales/en/naruto.yml +231 -0
- data/lib/locales/en/opera.yml +168 -0
- data/lib/locales/en/overwatch.yml +2650 -2622
- data/lib/locales/en/pokemon.yml +417 -4
- 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/science.yml +355 -3
- data/lib/locales/en/shakespeare.yml +21 -24
- 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/street_fighter.yml +4 -4
- data/lib/locales/en/studio_ghibli.yml +107 -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/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/fr.yml +0 -118
- 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 +1 -0
- 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/pt-BR.yml +2 -1
- data/lib/locales/ru.yml +39 -0
- data/lib/locales/uk.yml +2 -0
- metadata +92 -19
- 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
data/lib/faker/default/number.rb
CHANGED
|
@@ -40,7 +40,7 @@ module Faker
|
|
|
40
40
|
keywords << :digits if legacy_digits != NOT_GIVEN
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
"0#{(2..digits).collect { digit }.join}"
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
##
|
|
@@ -139,11 +139,26 @@ module Faker
|
|
|
139
139
|
hex
|
|
140
140
|
end
|
|
141
141
|
|
|
142
|
+
# Produces a number in binary format.
|
|
143
|
+
#
|
|
144
|
+
# @param digits [Integer] Number of digits to generate the binary as string
|
|
145
|
+
# @return [String]
|
|
146
|
+
#
|
|
147
|
+
# @example
|
|
148
|
+
# Faker::Number.binary(digits: 4) #=> "1001"
|
|
149
|
+
#
|
|
150
|
+
# @faker.version next
|
|
151
|
+
def binary(digits: 4)
|
|
152
|
+
bin = ''
|
|
153
|
+
digits.times { bin += rand(2).to_s(2) }
|
|
154
|
+
bin
|
|
155
|
+
end
|
|
156
|
+
|
|
142
157
|
##
|
|
143
158
|
# Produces a float given a mean and standard deviation.
|
|
144
159
|
#
|
|
145
160
|
# @param mean [Integer]
|
|
146
|
-
# @param standard_deviation [
|
|
161
|
+
# @param standard_deviation [Numeric]
|
|
147
162
|
# @return [Float]
|
|
148
163
|
#
|
|
149
164
|
# @example
|
|
@@ -165,12 +180,13 @@ module Faker
|
|
|
165
180
|
##
|
|
166
181
|
# Produces a number between two provided values. Boundaries are inclusive.
|
|
167
182
|
#
|
|
168
|
-
# @param from [
|
|
169
|
-
# @param to [
|
|
170
|
-
# @return [
|
|
183
|
+
# @param from [Numeric] The lowest number to include.
|
|
184
|
+
# @param to [Numeric] The highest number to include.
|
|
185
|
+
# @return [Numeric]
|
|
171
186
|
#
|
|
172
187
|
# @example
|
|
173
188
|
# Faker::Number.between(from: 1, to: 10) #=> 7
|
|
189
|
+
# Faker::Number.between(from: 0.0, to: 1.0) #=> 0.7844640543957383
|
|
174
190
|
#
|
|
175
191
|
# @faker.version 1.0.0
|
|
176
192
|
def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 1.00, to: 5000.00)
|
|
@@ -186,10 +202,11 @@ module Faker
|
|
|
186
202
|
# Produces a number within two provided values. Boundaries are inclusive or exclusive depending on the range passed.
|
|
187
203
|
#
|
|
188
204
|
# @param range [Range] The range from which to generate a number.
|
|
189
|
-
# @return [
|
|
205
|
+
# @return [Numeric]
|
|
190
206
|
#
|
|
191
207
|
# @example
|
|
192
208
|
# Faker::Number.within(range: 1..10) #=> 7
|
|
209
|
+
# Faker::Number.within(range: 0.0..1.0) #=> 0.7844640543957383
|
|
193
210
|
#
|
|
194
211
|
# @faker.version 1.0.0
|
|
195
212
|
def within(legacy_range = NOT_GIVEN, range: 1.00..5000.00)
|
|
@@ -9,12 +9,16 @@ module Faker
|
|
|
9
9
|
:email
|
|
10
10
|
|
|
11
11
|
def initialize(name: nil, email: nil)
|
|
12
|
+
super()
|
|
13
|
+
|
|
12
14
|
@name = name || "#{Name.first_name} #{Name.last_name}"
|
|
13
15
|
@email = email || Internet.safe_email(name: self.name)
|
|
14
16
|
@first_name, @last_name = self.name.split
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
class << self
|
|
20
|
+
# rubocop:disable Metrics/ParameterLists
|
|
21
|
+
|
|
18
22
|
##
|
|
19
23
|
# Generate a mock Omniauth response from Google.
|
|
20
24
|
#
|
|
@@ -25,9 +29,7 @@ module Faker
|
|
|
25
29
|
# @return [Hash] An auth hash in the format provided by omniauth-google.
|
|
26
30
|
#
|
|
27
31
|
# @faker.version 1.8.0
|
|
28
|
-
# rubocop:disable Metrics/ParameterLists
|
|
29
32
|
def google(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, uid: Number.number(digits: 9).to_s)
|
|
30
|
-
# rubocop:enable Metrics/ParameterLists
|
|
31
33
|
warn_for_deprecated_arguments do |keywords|
|
|
32
34
|
keywords << :name if legacy_name != NOT_GIVEN
|
|
33
35
|
keywords << :email if legacy_email != NOT_GIVEN
|
|
@@ -93,9 +95,7 @@ module Faker
|
|
|
93
95
|
# @return [Hash] An auth hash in the format provided by omniauth-facebook.
|
|
94
96
|
#
|
|
95
97
|
# @faker.version 1.8.0
|
|
96
|
-
# rubocop:disable Metrics/ParameterLists
|
|
97
98
|
def facebook(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_username = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, username: nil, uid: Number.number(digits: 7).to_s)
|
|
98
|
-
# rubocop:enable Metrics/ParameterLists
|
|
99
99
|
warn_for_deprecated_arguments do |keywords|
|
|
100
100
|
keywords << :name if legacy_name != NOT_GIVEN
|
|
101
101
|
keywords << :email if legacy_email != NOT_GIVEN
|
|
@@ -154,9 +154,7 @@ module Faker
|
|
|
154
154
|
# @return [Hash] An auth hash in the format provided by omniauth-twitter.
|
|
155
155
|
#
|
|
156
156
|
# @faker.version 1.8.0
|
|
157
|
-
# rubocop:disable Metrics/ParameterLists
|
|
158
157
|
def twitter(legacy_name = NOT_GIVEN, legacy_nickname = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, nickname: nil, uid: Number.number(digits: 6).to_s)
|
|
159
|
-
# rubocop:enable Metrics/ParameterLists
|
|
160
158
|
warn_for_deprecated_arguments do |keywords|
|
|
161
159
|
keywords << :name if legacy_name != NOT_GIVEN
|
|
162
160
|
keywords << :nickname if legacy_nickname != NOT_GIVEN
|
|
@@ -245,9 +243,7 @@ module Faker
|
|
|
245
243
|
# @return [Hash] An auth hash in the format provided by omniauth-linkedin.
|
|
246
244
|
#
|
|
247
245
|
# @faker.version 1.8.0
|
|
248
|
-
# rubocop:disable Metrics/ParameterLists
|
|
249
246
|
def linkedin(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, uid: Number.number(digits: 6).to_s)
|
|
250
|
-
# rubocop:enable Metrics/ParameterLists
|
|
251
247
|
warn_for_deprecated_arguments do |keywords|
|
|
252
248
|
keywords << :name if legacy_name != NOT_GIVEN
|
|
253
249
|
keywords << :email if legacy_email != NOT_GIVEN
|
|
@@ -326,9 +322,7 @@ module Faker
|
|
|
326
322
|
# @return [Hash] An auth hash in the format provided by omniauth-github.
|
|
327
323
|
#
|
|
328
324
|
# @faker.version 1.8.0
|
|
329
|
-
# rubocop:disable Metrics/ParameterLists
|
|
330
325
|
def github(legacy_name = NOT_GIVEN, legacy_email = NOT_GIVEN, legacy_uid = NOT_GIVEN, name: nil, email: nil, uid: Number.number(digits: 8).to_s)
|
|
331
|
-
# rubocop:enable Metrics/ParameterLists
|
|
332
326
|
warn_for_deprecated_arguments do |keywords|
|
|
333
327
|
keywords << :name if legacy_name != NOT_GIVEN
|
|
334
328
|
keywords << :email if legacy_email != NOT_GIVEN
|
|
@@ -391,6 +385,7 @@ module Faker
|
|
|
391
385
|
}
|
|
392
386
|
}
|
|
393
387
|
end
|
|
388
|
+
# rubocop:enable Metrics/ParameterLists
|
|
394
389
|
|
|
395
390
|
##
|
|
396
391
|
# Generate a mock Omniauth response from Apple.
|
|
@@ -5,6 +5,8 @@ module Faker
|
|
|
5
5
|
class << self
|
|
6
6
|
SUPPORTED_FORMATS = %w[png jpg gif jpeg].freeze
|
|
7
7
|
|
|
8
|
+
# rubocop:disable Metrics/ParameterLists
|
|
9
|
+
|
|
8
10
|
##
|
|
9
11
|
# Produces a random placeholder image from https://placehold.it.
|
|
10
12
|
#
|
|
@@ -26,9 +28,7 @@ module Faker
|
|
|
26
28
|
# Faker::Placeholdit.image(size: '50x50', format: 'jpg', background_color: 'ffffff', text_color: '000', text: 'Some Custom Text') #=> "https://placehold.it/50x50.jpg/ffffff/000?text=Some Custom Text"
|
|
27
29
|
#
|
|
28
30
|
# @faker.version 1.6.0
|
|
29
|
-
# rubocop:disable Metrics/ParameterLists
|
|
30
31
|
def image(legacy_size = NOT_GIVEN, legacy_format = NOT_GIVEN, legacy_background_color = NOT_GIVEN, legacy_text_color = NOT_GIVEN, legacy_text = NOT_GIVEN, size: '300x300', format: 'png', background_color: nil, text_color: nil, text: nil)
|
|
31
|
-
# rubocop:enable Metrics/ParameterLists
|
|
32
32
|
warn_for_deprecated_arguments do |keywords|
|
|
33
33
|
keywords << :size if legacy_size != NOT_GIVEN
|
|
34
34
|
keywords << :format if legacy_format != NOT_GIVEN
|
|
@@ -51,6 +51,7 @@ module Faker
|
|
|
51
51
|
image_url += "?text=#{text}" if text
|
|
52
52
|
image_url
|
|
53
53
|
end
|
|
54
|
+
# rubocop:enable Metrics/ParameterLists
|
|
54
55
|
|
|
55
56
|
private
|
|
56
57
|
|
|
@@ -29,6 +29,32 @@ module Faker
|
|
|
29
29
|
fetch('science.element_symbol')
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
+
##
|
|
33
|
+
# Produces the state of an element.
|
|
34
|
+
#
|
|
35
|
+
# @return [String]
|
|
36
|
+
#
|
|
37
|
+
# @example
|
|
38
|
+
# Faker::Science.element_state #=> "Liquid"
|
|
39
|
+
#
|
|
40
|
+
# @faker.version next
|
|
41
|
+
def element_state
|
|
42
|
+
fetch('science.element_state')
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
##
|
|
46
|
+
# Produces the subcategory of an element.
|
|
47
|
+
#
|
|
48
|
+
# @return [String]
|
|
49
|
+
#
|
|
50
|
+
# @example
|
|
51
|
+
# Faker::Science.element_subcategory #=> "Reactive nonmetal"
|
|
52
|
+
#
|
|
53
|
+
# @faker.version next
|
|
54
|
+
def element_subcategory
|
|
55
|
+
fetch('science.element_subcategory')
|
|
56
|
+
end
|
|
57
|
+
|
|
32
58
|
##
|
|
33
59
|
# Produces the name of a scientist.
|
|
34
60
|
#
|
data/lib/faker/default/space.rb
CHANGED
data/lib/faker/default/string.rb
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
module Faker
|
|
4
4
|
class String < Base
|
|
5
5
|
class << self
|
|
6
|
+
# rubocop:disable Style/AsciiComments
|
|
7
|
+
|
|
6
8
|
##
|
|
7
9
|
# Produces a random UTF-8 string with optional nested length selectors.
|
|
8
10
|
#
|
|
@@ -10,13 +12,11 @@ module Faker
|
|
|
10
12
|
# @return [String]
|
|
11
13
|
#
|
|
12
14
|
# @example
|
|
13
|
-
# rubocop:disable Style/AsciiComments
|
|
14
15
|
# Faker::String.random #=> "3 뇦\u0017&y\u{3A109}$8^4* 녹豿4좘툢ꔾ쉙6ɉ\uA6 8TN畀챵|\"3쇤Ŵ"
|
|
15
16
|
# Faker::String.random(length: 4) #=> "⼨%0*"
|
|
16
17
|
# Faker::String.random(length: 3..12) #=> "\u{69FDC};秨툫"
|
|
17
18
|
# Faker::String.random(length: [0, 6]) #=> "I轤𣴒P溟L"
|
|
18
19
|
# Faker::String.random(length: [1, (2..5), [3, 6], nil]) #=> "葓L#ћ"
|
|
19
|
-
# rubocop:enable Style/AsciiComments
|
|
20
20
|
#
|
|
21
21
|
# @faker.version 1.9.0
|
|
22
22
|
def random(legacy_length = NOT_GIVEN, length: 32)
|
|
@@ -26,6 +26,7 @@ module Faker
|
|
|
26
26
|
|
|
27
27
|
utf8string select_a length
|
|
28
28
|
end
|
|
29
|
+
# rubocop:enable Style/AsciiComments
|
|
29
30
|
|
|
30
31
|
private
|
|
31
32
|
|
data/lib/faker/default/stripe.rb
CHANGED
|
@@ -30,7 +30,7 @@ module Faker
|
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
fetch(
|
|
33
|
+
fetch("stripe.valid_cards.#{card_type}")
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
##
|
|
@@ -60,7 +60,7 @@ module Faker
|
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
fetch(
|
|
63
|
+
fetch("stripe.valid_tokens.#{card_type}")
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
##
|
|
@@ -89,7 +89,7 @@ module Faker
|
|
|
89
89
|
end
|
|
90
90
|
end
|
|
91
91
|
|
|
92
|
-
fetch(
|
|
92
|
+
fetch("stripe.invalid_cards.#{card_error}")
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
##
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Faker
|
|
4
|
+
class Tea < Base
|
|
5
|
+
flexible :tea
|
|
6
|
+
|
|
7
|
+
class << self
|
|
8
|
+
##
|
|
9
|
+
# Produces a random variety or blend of tea.
|
|
10
|
+
#
|
|
11
|
+
# @param type [String, nil] the type of tea to query for (valid types: 'Black', 'Green', 'Oolong', 'White', and 'Herbal')
|
|
12
|
+
# @return [String] a variety of tea
|
|
13
|
+
#
|
|
14
|
+
# @example
|
|
15
|
+
# Faker::Tea.variety
|
|
16
|
+
# #=> "Earl Grey"
|
|
17
|
+
#
|
|
18
|
+
# @example
|
|
19
|
+
# Faker::Tea.variety(type: 'Green')
|
|
20
|
+
# #=> "Jasmine"
|
|
21
|
+
# @faker.version next
|
|
22
|
+
def variety(type: nil)
|
|
23
|
+
type ||= fetch('tea.type')
|
|
24
|
+
fetch "tea.variety.#{type.downcase}"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
##
|
|
28
|
+
# Produces a random type of tea.
|
|
29
|
+
#
|
|
30
|
+
# @return [String] a type of tea
|
|
31
|
+
#
|
|
32
|
+
# @example
|
|
33
|
+
# Faker::Tea.type
|
|
34
|
+
# #=> "Green"
|
|
35
|
+
# @faker.version next
|
|
36
|
+
def type
|
|
37
|
+
fetch 'tea.type'
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
data/lib/faker/default/types.rb
CHANGED
|
@@ -72,7 +72,7 @@ module Faker
|
|
|
72
72
|
# Faker::Types.rb_hash(number: 2) #=> {name: "bob", last: "marley"}
|
|
73
73
|
#
|
|
74
74
|
# @faker.version 1.8.6
|
|
75
|
-
def rb_hash(legacy_number = NOT_GIVEN, legacy_type = NOT_GIVEN, number: 1, type: random_type)
|
|
75
|
+
def rb_hash(legacy_number = NOT_GIVEN, legacy_type = NOT_GIVEN, number: 1, type: -> { random_type })
|
|
76
76
|
warn_for_deprecated_arguments do |keywords|
|
|
77
77
|
keywords << :number if legacy_number != NOT_GIVEN
|
|
78
78
|
keywords << :type if legacy_type != NOT_GIVEN
|
|
@@ -80,7 +80,8 @@ module Faker
|
|
|
80
80
|
|
|
81
81
|
{}.tap do |hsh|
|
|
82
82
|
Lorem.words(number: number * 2).uniq.first(number).each do |s|
|
|
83
|
-
|
|
83
|
+
value = type.is_a?(Proc) ? type.call : type
|
|
84
|
+
hsh.merge!(s.to_sym => value)
|
|
84
85
|
end
|
|
85
86
|
end
|
|
86
87
|
end
|
|
@@ -102,7 +103,7 @@ module Faker
|
|
|
102
103
|
keywords << :number if legacy_number != NOT_GIVEN
|
|
103
104
|
end
|
|
104
105
|
|
|
105
|
-
rb_hash(number: number, type: random_complex_type)
|
|
106
|
+
rb_hash(number: number, type: -> { random_complex_type })
|
|
106
107
|
end
|
|
107
108
|
|
|
108
109
|
##
|
|
@@ -278,7 +278,7 @@ module Faker
|
|
|
278
278
|
|
|
279
279
|
return regexify(bothify(fetch('vehicle.license_plate'))) if state_abbreviation.empty?
|
|
280
280
|
|
|
281
|
-
key =
|
|
281
|
+
key = "vehicle.license_plate_by_state.#{state_abbreviation}"
|
|
282
282
|
regexify(bothify(fetch(key)))
|
|
283
283
|
end
|
|
284
284
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Faker
|
|
4
|
+
class Fantasy
|
|
5
|
+
class Tolkien < Base
|
|
6
|
+
flexible :tolkien
|
|
7
|
+
|
|
8
|
+
class << self
|
|
9
|
+
##
|
|
10
|
+
# Produces a character from Tolkien's legendarium
|
|
11
|
+
#
|
|
12
|
+
# @return [String]
|
|
13
|
+
#
|
|
14
|
+
# @example
|
|
15
|
+
# Faker::Fantasy::Tolkien.character
|
|
16
|
+
# #=> "Goldberry"
|
|
17
|
+
#
|
|
18
|
+
# @faker.version next
|
|
19
|
+
def character
|
|
20
|
+
fetch('tolkien.characters')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
##
|
|
24
|
+
# Produces a location from Tolkien's legendarium
|
|
25
|
+
#
|
|
26
|
+
# @return [String]
|
|
27
|
+
#
|
|
28
|
+
# @example
|
|
29
|
+
# Faker::Fantasy::Tolkien.location
|
|
30
|
+
# #=> "Helm's Deep"
|
|
31
|
+
#
|
|
32
|
+
# @faker.version next
|
|
33
|
+
def location
|
|
34
|
+
fetch('tolkien.locations')
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
##
|
|
38
|
+
# Produces a race from Tolkien's legendarium
|
|
39
|
+
#
|
|
40
|
+
# @return [String]
|
|
41
|
+
#
|
|
42
|
+
# @example
|
|
43
|
+
# Faker::Fantasy::Tolkien.race
|
|
44
|
+
# #=> "Uruk-hai"
|
|
45
|
+
#
|
|
46
|
+
# @faker.version next
|
|
47
|
+
def race
|
|
48
|
+
fetch('tolkien.races')
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
##
|
|
52
|
+
# Produces the name of a poem from Tolkien's legendarium
|
|
53
|
+
#
|
|
54
|
+
# @return [String]
|
|
55
|
+
#
|
|
56
|
+
# @example
|
|
57
|
+
# Faker::Fantasy::Tolkien.poem
|
|
58
|
+
# #=> "Chip the glasses and crack the plates"
|
|
59
|
+
#
|
|
60
|
+
# @faker.version next
|
|
61
|
+
def poem
|
|
62
|
+
fetch('tolkien.poems')
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Faker
|
|
4
|
+
class Games
|
|
5
|
+
class ClashOfClans < Base
|
|
6
|
+
class << self
|
|
7
|
+
##
|
|
8
|
+
# Produces the name of a troop from Clash of Clans.
|
|
9
|
+
#
|
|
10
|
+
# @return [String]
|
|
11
|
+
#
|
|
12
|
+
# @example
|
|
13
|
+
# Faker::Games::ClashOfClans.troop #=> "Barbarian"
|
|
14
|
+
#
|
|
15
|
+
# @faker.version next
|
|
16
|
+
def troop
|
|
17
|
+
fetch('games.clash_of_clans.troops')
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
##
|
|
21
|
+
# Produces the name of a rank from Clash Of Clans.
|
|
22
|
+
#
|
|
23
|
+
# @return [String]
|
|
24
|
+
#
|
|
25
|
+
# @example
|
|
26
|
+
# Faker::Games::ClashOfClans.rank #=> "Legend"
|
|
27
|
+
#
|
|
28
|
+
# @faker.version next
|
|
29
|
+
def rank
|
|
30
|
+
fetch('games.clash_of_clans.ranks')
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
##
|
|
34
|
+
# Produces the name of a defensive buiding from Clash Of Clans.
|
|
35
|
+
#
|
|
36
|
+
# @return [String]
|
|
37
|
+
#
|
|
38
|
+
# @example
|
|
39
|
+
# Faker::Games::ClashOfClans.defensive_building #=> "Cannon"
|
|
40
|
+
#
|
|
41
|
+
# @faker.version next
|
|
42
|
+
def defensive_building
|
|
43
|
+
fetch('games.clash_of_clans.defensive_buildings')
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|