faker 2.15.1 → 3.4.2
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 +848 -34
- data/README.md +225 -103
- data/lib/faker/blockchain/aeternity.rb +1 -1
- data/lib/faker/blockchain/bitcoin.rb +2 -2
- data/lib/faker/blockchain/ethereum.rb +1 -1
- data/lib/faker/blockchain/tezos.rb +31 -3
- data/lib/faker/books/dune.rb +2 -10
- data/lib/faker/books/lovecraft.rb +9 -41
- data/lib/faker/books/the_kingkiller_chronicle.rb +61 -0
- data/lib/faker/creature/bird.rb +203 -0
- data/lib/faker/default/address.rb +7 -27
- data/lib/faker/default/alphanumeric.rb +2 -8
- data/lib/faker/default/app.rb +1 -10
- data/lib/faker/default/avatar.rb +1 -12
- data/lib/faker/default/bank.rb +25 -17
- data/lib/faker/default/barcode.rb +33 -22
- data/lib/faker/default/boolean.rb +1 -4
- data/lib/faker/default/cannabis.rb +10 -0
- data/lib/faker/default/chile_rut.rb +25 -25
- data/lib/faker/default/chuck_norris.rb +1 -0
- data/lib/faker/default/code.rb +71 -42
- data/lib/faker/default/color.rb +77 -6
- data/lib/faker/default/commerce.rb +31 -17
- data/lib/faker/default/company.rb +137 -22
- data/lib/faker/default/crypto.rb +26 -4
- data/lib/faker/default/crypto_coin.rb +3 -15
- data/lib/faker/default/date.rb +65 -42
- data/lib/faker/default/demographic.rb +1 -5
- data/lib/faker/default/driving_licence.rb +20 -18
- data/lib/faker/default/drone.rb +1 -1
- data/lib/faker/default/educator.rb +13 -0
- data/lib/faker/default/emotion.rb +33 -0
- data/lib/faker/default/file.rb +5 -22
- data/lib/faker/default/finance.rb +30 -7
- data/lib/faker/default/food.rb +27 -1
- data/lib/faker/default/hipster.rb +8 -48
- data/lib/faker/default/hobby.rb +22 -0
- data/lib/faker/default/html.rb +230 -0
- data/lib/faker/default/id_number.rb +175 -27
- data/lib/faker/default/internet.rb +333 -114
- data/lib/faker/default/invoice.rb +4 -17
- data/lib/faker/default/json.rb +4 -21
- data/lib/faker/default/lorem.rb +175 -73
- data/lib/faker/default/lorem_flickr.rb +4 -37
- data/lib/faker/default/markdown.rb +10 -13
- data/lib/faker/default/marketing.rb +1 -1
- data/lib/faker/default/measurement.rb +16 -48
- data/lib/faker/default/name.rb +1 -5
- data/lib/faker/default/nation.rb +0 -3
- data/lib/faker/default/{nhs.rb → national_health_service.rb} +9 -8
- data/lib/faker/default/number.rb +33 -61
- data/lib/faker/default/omniauth.rb +55 -52
- data/lib/faker/default/phone_number.rb +36 -21
- data/lib/faker/default/placeholdit.rb +10 -20
- data/lib/faker/default/relationship.rb +1 -5
- data/lib/faker/default/religion.rb +6 -0
- data/lib/faker/default/science.rb +108 -0
- data/lib/faker/default/source.rb +3 -16
- data/lib/faker/default/south_africa.rb +3 -3
- data/lib/faker/default/string.rb +1 -7
- data/lib/faker/default/stripe.rb +4 -20
- data/lib/faker/default/tea.rb +41 -0
- data/lib/faker/{music/show.rb → default/theater.rb} +11 -8
- data/lib/faker/default/time.rb +4 -34
- data/lib/faker/default/twitter.rb +7 -23
- data/lib/faker/default/types.rb +12 -34
- data/lib/faker/default/vehicle.rb +44 -54
- data/lib/faker/default/vulnerability_identifier.rb +23 -0
- data/lib/faker/default/world_cup.rb +2 -11
- data/lib/faker/games/clash_of_clans.rb +1 -1
- data/lib/faker/games/dnd.rb +49 -7
- data/lib/faker/games/dota.rb +14 -5
- data/lib/faker/games/final_fantasy_xiv.rb +73 -0
- data/lib/faker/games/minecraft.rb +1 -1
- data/lib/faker/games/myst.rb +1 -1
- data/lib/faker/games/tarkov.rb +205 -0
- data/lib/faker/games/touhou.rb +75 -0
- data/lib/faker/games/witcher.rb +39 -0
- data/lib/faker/japanese_media/cowboy_bebop.rb +61 -0
- data/lib/faker/japanese_media/fullmetal_alchemist_brotherhood.rb +51 -0
- data/lib/faker/japanese_media/kamen_rider.rb +102 -0
- data/lib/faker/japanese_media/one_piece.rb +1 -1
- data/lib/faker/locations/australia.rb +52 -0
- data/lib/faker/movies/avatar.rb +49 -0
- data/lib/faker/movies/hackers.rb +48 -0
- data/lib/faker/movies/star_wars.rb +73 -5
- data/lib/faker/movies/{room.rb → the_room.rb} +4 -4
- data/lib/faker/movies/tron.rb +161 -0
- data/lib/faker/music/hiphop.rb +3 -3
- data/lib/faker/music/music.rb +12 -0
- data/lib/faker/music/rock_band.rb +12 -0
- data/lib/faker/music/smashing_pumpkins.rb +64 -0
- data/lib/faker/quotes/quote.rb +13 -0
- data/lib/faker/quotes/rajnikanth.rb +1 -0
- data/lib/faker/quotes/shakespeare.rb +34 -0
- data/lib/faker/religion/bible.rb +50 -0
- data/lib/faker/sports/chess.rb +90 -0
- data/lib/faker/sports/mountaineering.rb +22 -0
- data/lib/faker/sports/sport.rb +116 -0
- data/lib/faker/travel/airport.rb +43 -0
- data/lib/faker/travel/train_station.rb +54 -0
- data/lib/faker/tv_shows/archer.rb +51 -0
- data/lib/faker/tv_shows/big_bang_theory.rb +1 -1
- data/lib/faker/tv_shows/brooklyn_nine_nine.rb +38 -0
- data/lib/faker/tv_shows/michael_scott.rb +0 -3
- data/lib/faker/tv_shows/south_park.rb +15 -0
- data/lib/faker/tv_shows/spongebob.rb +50 -0
- data/lib/faker/tv_shows/suits.rb +1 -1
- data/lib/faker/tv_shows/supernatural.rb +48 -0
- data/lib/faker/tv_shows/the_office.rb +37 -0
- data/lib/faker/version.rb +2 -2
- data/lib/faker.rb +26 -67
- data/lib/helpers/base58.rb +1 -1
- data/lib/helpers/deprecator.rb +53 -0
- data/lib/helpers/positional_generator.rb +480 -0
- data/lib/helpers/unique_generator.rb +13 -14
- data/lib/locales/README.md +18 -2
- data/lib/locales/ar.yml +6 -1
- data/lib/locales/bg.yml +1 -2
- data/lib/locales/da-DK.yml +529 -35
- data/lib/locales/de-AT.yml +3487 -27
- data/lib/locales/de-CH.yml +4328 -12
- data/lib/locales/de.yml +7185 -99
- data/lib/locales/ee.yml +0 -1
- data/lib/locales/en/address.yml +1826 -562
- data/lib/locales/en/airport.yml +381 -0
- data/lib/locales/en/animal.yml +1 -1
- data/lib/locales/en/archer.yml +75 -0
- data/lib/locales/en/australia.yml +108 -0
- data/lib/locales/en/avatar.yml +31 -0
- data/lib/locales/en/bank.yml +1 -1
- data/lib/locales/en/bible.yml +90 -0
- data/lib/locales/en/bird.yml +1281 -0
- data/lib/locales/en/book.yml +487 -3
- data/lib/locales/en/brooklyn_nine_nine.yml +35 -0
- data/lib/locales/en/cat.yml +1 -1
- data/lib/locales/en/chess.yml +103 -0
- data/lib/locales/en/coffee.yml +1 -1
- data/lib/locales/en/commerce.yml +17 -0
- data/lib/locales/en/community.yml +17 -17
- data/lib/locales/en/company.yml +1 -0
- data/lib/locales/en/computer.yml +23 -4
- data/lib/locales/en/cowboy_bebop.yml +163 -0
- data/lib/locales/en/device.yml +112 -4
- data/lib/locales/en/dnd.yml +186 -1
- data/lib/locales/en/dog.yml +262 -7
- data/lib/locales/en/dota.yml +173 -0
- data/lib/locales/en/dune.yml +266 -397
- data/lib/locales/en/educator.yml +6 -0
- data/lib/locales/en/emotion.yml +480 -0
- data/lib/locales/en/file.yml +9 -1
- data/lib/locales/en/final_fantasy_xiv.yml +754 -0
- data/lib/locales/en/finance.yml +27 -4
- data/lib/locales/en/food.yml +1067 -10
- data/lib/locales/en/football.yml +3 -3
- data/lib/locales/en/fullmetal_alchemist_brotherhood.yml +78 -0
- data/lib/locales/en/game.yml +11 -0
- data/lib/locales/en/hackers.yml +53 -0
- data/lib/locales/en/harry_potter.yml +1 -1
- data/lib/locales/en/heroes.yml +2 -2
- data/lib/locales/en/hobby.yml +171 -0
- data/lib/locales/en/horse.yml +2 -2
- data/lib/locales/en/id_number.yml +1 -1
- data/lib/locales/en/internet.yml +136 -3
- data/lib/locales/en/kamen_rider.yml +452 -0
- data/lib/locales/en/kpop.yml +7 -7
- data/lib/locales/en/lebowski.yml +1 -1
- data/lib/locales/en/lovecraft.yml +76 -6
- data/lib/locales/en/minecraft.yml +4 -4
- data/lib/locales/en/mitch_hedberg.yml +46 -0
- data/lib/locales/en/mountain.yml +14 -1
- data/lib/locales/en/mountaineering.yml +14 -0
- data/lib/locales/en/movie.yml +2 -1
- data/lib/locales/en/music.yml +152 -142
- data/lib/locales/en/naruto.yml +2 -3
- data/lib/locales/en/one_piece.yml +1 -1
- data/lib/locales/en/opera.yml +2 -2
- data/lib/locales/en/overwatch.yml +5 -7
- data/lib/locales/en/phone_number.yml +78 -3
- data/lib/locales/en/rock_band.yml +1 -0
- data/lib/locales/en/science.yml +481 -3
- data/lib/locales/en/shakespeare.yml +21 -24
- data/lib/locales/en/smashing_pumpkins.yml +382 -0
- data/lib/locales/en/source.yml +5 -0
- data/lib/locales/en/south_park.yml +360 -2
- data/lib/locales/en/space.yml +1 -1
- data/lib/locales/en/spongebob.yml +489 -0
- data/lib/locales/en/sport.yml +130 -0
- data/lib/locales/en/star_wars.yml +1 -1
- data/lib/locales/en/stranger_thing.yml +1 -1
- data/lib/locales/en/super_smash_bros.yml +7 -2
- data/lib/locales/en/supernatural.yml +141 -0
- data/lib/locales/en/tarkov.yml +593 -0
- data/lib/locales/en/tea.yml +172 -0
- data/lib/locales/en/the_kingkiller_chronicle.yml +56 -0
- data/lib/locales/en/the_office.yml +86 -0
- data/lib/locales/en/{room.yml → the_room.yml} +1 -1
- data/lib/locales/en/{show.yml → theater.yml} +1 -1
- data/lib/locales/en/touhou.yml +839 -0
- data/lib/locales/en/train_station.yml +280 -0
- data/lib/locales/en/tron.yml +227 -0
- data/lib/locales/en/vehicle.yml +2809 -75
- data/lib/locales/en/witcher.yml +37 -0
- data/lib/locales/en-AU.yml +718 -47
- data/lib/locales/en-CA.yml +373 -18
- data/lib/locales/en-GB.yml +116 -8
- data/lib/locales/en-IND.yml +1259 -17
- data/lib/locales/en-KE.yml +212 -0
- data/lib/locales/en-MS.yml +364 -17
- data/lib/locales/en-NEP.yml +212 -38
- data/lib/locales/en-NG.yml +1 -0
- data/lib/locales/en-NZ.yml +1153 -123
- data/lib/locales/en-PAK.yml +369 -10
- data/lib/locales/en-SG.yml +581 -16
- data/lib/locales/en-UG.yml +1 -0
- data/lib/locales/en-US.yml +6914 -74
- data/lib/locales/en-ZA.yml +1 -1
- data/lib/locales/en-au-ocker.yml +266 -22
- data/lib/locales/es-AR.yml +4570 -0
- data/lib/locales/es-MX.yml +1 -2
- data/lib/locales/es.yml +2 -3
- data/lib/locales/fi-FI.yml +3 -1
- data/lib/locales/fr/address.yml +20 -0
- data/lib/locales/fr/adjective.yml +266 -0
- data/lib/locales/fr/ancient.yml +141 -0
- data/lib/locales/fr/animal.yml +5 -0
- data/lib/locales/fr/appliance.yml +4 -0
- data/lib/locales/fr/book.yml +7 -0
- data/lib/locales/fr/color.yml +4 -0
- data/lib/locales/fr/company.yml +17 -0
- data/lib/locales/fr/compass.yml +23 -0
- data/lib/locales/fr/demographic.yml +4 -0
- data/lib/locales/fr/gender.yml +6 -0
- data/lib/locales/fr/internet.yml +4 -0
- data/lib/locales/fr/lorem.yml +5 -0
- data/lib/locales/fr/measurement.yml +7 -0
- data/lib/locales/fr/name.yml +22 -0
- data/lib/locales/fr/phone_number.yml +7 -0
- data/lib/locales/fr/pokemon.yml +7 -0
- data/lib/locales/fr-CA.yml +2733 -44
- data/lib/locales/fr-CH.yml +1 -2
- data/lib/locales/fr.yml +2 -118
- data/lib/locales/hy.yml +3624 -119
- data/lib/locales/id.yml +839 -12
- data/lib/locales/it.yml +1304 -32
- data/lib/locales/ja/README.md +13 -0
- data/lib/locales/ja/address.yml +120539 -0
- data/lib/locales/ja/adjective.yml +148 -0
- data/lib/locales/ja/ancient.yml +4 -0
- data/lib/locales/ja/animal.yml +5 -0
- data/lib/locales/ja/bank.yml +4 -0
- data/lib/locales/ja/book.yml +7 -0
- data/lib/locales/ja/cat.yml +5 -0
- data/lib/locales/ja/coffee.yml +4 -0
- data/lib/locales/ja/color.yml +4 -0
- data/lib/locales/ja/commerce.yml +11 -0
- data/lib/locales/ja/company.yml +8 -0
- data/lib/locales/ja/dog.yml +6 -0
- data/lib/locales/ja/emotion.yml +51 -0
- data/lib/locales/ja/food.yml +4 -0
- data/lib/locales/ja/football.yml +115 -0
- data/lib/locales/ja/gender.yml +4 -0
- data/lib/locales/ja/lorem.yml +9 -0
- data/lib/locales/ja/name.yml +13 -0
- data/lib/locales/ja/naruto.yml +230 -0
- data/lib/locales/ja/overwatch.yml +5 -0
- data/lib/locales/ja/phone_number.yml +7 -0
- data/lib/locales/ja/pokemon.yml +7 -0
- data/lib/locales/ja/relationship.yml +10 -0
- data/lib/locales/ja/restaurant.yml +11 -0
- data/lib/locales/ja/space.yml +5 -0
- data/lib/locales/ja/sport.yml +130 -0
- data/lib/locales/ja/studio_ghibli.yml +112 -0
- data/lib/locales/ja/subscription.yml +8 -0
- data/lib/locales/ja/super_mario.yml +9 -0
- data/lib/locales/ja/super_smash_bros.yml +8 -0
- data/lib/locales/ja/touhou.yml +466 -0
- data/lib/locales/ja/university.yml +9 -0
- data/lib/locales/ja/zelda.yml +5 -0
- data/lib/locales/ko.yml +1361 -20
- data/lib/locales/lt.yml +315 -0
- data/lib/locales/lv.yml +1 -2
- data/lib/locales/mi-NZ.yml +283 -0
- data/lib/locales/nb-NO.yml +518 -29
- data/lib/locales/nl.yml +1 -1
- data/lib/locales/pl.yml +1 -2
- data/lib/locales/pt-BR.yml +8157 -660
- data/lib/locales/pt.yml +844 -45
- data/lib/locales/ru.yml +1355 -32
- data/lib/locales/sk.yml +4410 -43
- data/lib/locales/sv.yml +100 -0
- data/lib/locales/th.yml +76 -76
- data/lib/locales/tr.yml +1 -2
- data/lib/locales/uk.yml +1808 -44
- data/lib/locales/vi.yml +1 -0
- data/lib/locales/zh-CN/bank.yml +17 -0
- data/lib/locales/zh-CN.yml +1 -0
- data/lib/locales/zh-TW.yml +1 -0
- metadata +134 -133
- data/History.md +0 -176
- data/lib/faker/default/fillmurray.rb +0 -45
- data/lib/faker/default/lorem_pixel.rb +0 -69
- data/lib/locales/ja.yml +0 -105
- /data/lib/faker/default/{faker_adjective.rb → adjective.rb} +0 -0
data/lib/faker/default/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/nation.rb
CHANGED
|
@@ -17,8 +17,6 @@ module Faker
|
|
|
17
17
|
fetch('nation.nationality')
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
# rubocop:disable Style/AsciiComments
|
|
21
|
-
|
|
22
20
|
##
|
|
23
21
|
# Produces a random national flag emoji.
|
|
24
22
|
#
|
|
@@ -31,7 +29,6 @@ module Faker
|
|
|
31
29
|
def flag
|
|
32
30
|
sample(translate('faker.nation.flag')).pack('C*').force_encoding('utf-8')
|
|
33
31
|
end
|
|
34
|
-
# rubocop:enable Style/AsciiComments
|
|
35
32
|
|
|
36
33
|
##
|
|
37
34
|
# Produces a random national language.
|
|
@@ -6,14 +6,17 @@ module Faker
|
|
|
6
6
|
##
|
|
7
7
|
# Produces a random British NHS number.
|
|
8
8
|
#
|
|
9
|
+
# The NHS sets aside a range of numbers from 999 000 0000 to 999 999 9999
|
|
10
|
+
# for test purposes.
|
|
11
|
+
#
|
|
9
12
|
# @return [String]
|
|
10
13
|
#
|
|
11
14
|
# @example
|
|
12
|
-
# Faker::NationalHealthService.british_number #=> "
|
|
15
|
+
# Faker::NationalHealthService.british_number #=> "999 464 0232"
|
|
13
16
|
#
|
|
14
17
|
# @faker.version 1.9.2
|
|
15
18
|
def british_number
|
|
16
|
-
base_number = rand(
|
|
19
|
+
base_number = rand(999_000_001...999_999_999)
|
|
17
20
|
# If the check digit is equivalent to 10, the number is invalid.
|
|
18
21
|
# See https://en.wikipedia.org/wiki/NHS_number
|
|
19
22
|
base_number -= 1 if check_digit(number: base_number) == 10
|
|
@@ -21,9 +24,11 @@ module Faker
|
|
|
21
24
|
.chars
|
|
22
25
|
.insert(3, ' ')
|
|
23
26
|
.insert(7, ' ')
|
|
24
|
-
.join
|
|
27
|
+
.join
|
|
25
28
|
end
|
|
26
29
|
|
|
30
|
+
private
|
|
31
|
+
|
|
27
32
|
##
|
|
28
33
|
# Produces a random British NHS number's check digit.
|
|
29
34
|
#
|
|
@@ -34,11 +39,7 @@ module Faker
|
|
|
34
39
|
# Faker::NationalHealthService.check_digit(number: 400_012_114) #=> 6
|
|
35
40
|
#
|
|
36
41
|
# @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
|
-
|
|
42
|
+
def check_digit(number: 0)
|
|
42
43
|
sum = 0
|
|
43
44
|
number.to_s.chars.each_with_index do |digit, idx|
|
|
44
45
|
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,33 +112,39 @@ 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
|
-
digits.times { hex += rand(
|
|
117
|
+
digits.times { hex += rand(16).to_s(16) }
|
|
139
118
|
hex
|
|
140
119
|
end
|
|
141
120
|
|
|
121
|
+
# Produces a number in binary format.
|
|
122
|
+
#
|
|
123
|
+
# @param digits [Integer] Number of digits to generate the binary as string
|
|
124
|
+
# @return [String]
|
|
125
|
+
#
|
|
126
|
+
# @example
|
|
127
|
+
# Faker::Number.binary(digits: 4) #=> "1001"
|
|
128
|
+
#
|
|
129
|
+
# @faker.version next
|
|
130
|
+
def binary(digits: 4)
|
|
131
|
+
bin = ''
|
|
132
|
+
digits.times { bin += rand(2).to_s(2) }
|
|
133
|
+
bin
|
|
134
|
+
end
|
|
135
|
+
|
|
142
136
|
##
|
|
143
137
|
# Produces a float given a mean and standard deviation.
|
|
144
138
|
#
|
|
145
139
|
# @param mean [Integer]
|
|
146
|
-
# @param standard_deviation [
|
|
140
|
+
# @param standard_deviation [Numeric]
|
|
147
141
|
# @return [Float]
|
|
148
142
|
#
|
|
149
143
|
# @example
|
|
150
144
|
# Faker::Number.normal(mean: 50, standard_deviation: 3.5) #=> 47.14669604069156
|
|
151
145
|
#
|
|
152
146
|
# @faker.version 1.0.0
|
|
153
|
-
def normal(
|
|
154
|
-
warn_for_deprecated_arguments do |keywords|
|
|
155
|
-
keywords << :mean if legacy_mean != NOT_GIVEN
|
|
156
|
-
keywords << :standard_deviation if legacy_standard_deviation != NOT_GIVEN
|
|
157
|
-
end
|
|
158
|
-
|
|
147
|
+
def normal(mean: 1, standard_deviation: 1)
|
|
159
148
|
theta = 2 * Math::PI * rand
|
|
160
149
|
rho = Math.sqrt(-2 * Math.log(1 - rand))
|
|
161
150
|
scale = standard_deviation * rho
|
|
@@ -165,20 +154,16 @@ module Faker
|
|
|
165
154
|
##
|
|
166
155
|
# Produces a number between two provided values. Boundaries are inclusive.
|
|
167
156
|
#
|
|
168
|
-
# @param from [
|
|
169
|
-
# @param to [
|
|
170
|
-
# @return [
|
|
157
|
+
# @param from [Numeric] The lowest number to include.
|
|
158
|
+
# @param to [Numeric] The highest number to include.
|
|
159
|
+
# @return [Numeric]
|
|
171
160
|
#
|
|
172
161
|
# @example
|
|
173
162
|
# Faker::Number.between(from: 1, to: 10) #=> 7
|
|
163
|
+
# Faker::Number.between(from: 0.0, to: 1.0) #=> 0.7844640543957383
|
|
174
164
|
#
|
|
175
165
|
# @faker.version 1.0.0
|
|
176
|
-
def between(
|
|
177
|
-
warn_for_deprecated_arguments do |keywords|
|
|
178
|
-
keywords << :from if legacy_from != NOT_GIVEN
|
|
179
|
-
keywords << :to if legacy_to != NOT_GIVEN
|
|
180
|
-
end
|
|
181
|
-
|
|
166
|
+
def between(from: 1.00, to: 5000.00)
|
|
182
167
|
Faker::Base.rand_in_range(from, to)
|
|
183
168
|
end
|
|
184
169
|
|
|
@@ -186,17 +171,14 @@ module Faker
|
|
|
186
171
|
# Produces a number within two provided values. Boundaries are inclusive or exclusive depending on the range passed.
|
|
187
172
|
#
|
|
188
173
|
# @param range [Range] The range from which to generate a number.
|
|
189
|
-
# @return [
|
|
174
|
+
# @return [Numeric]
|
|
190
175
|
#
|
|
191
176
|
# @example
|
|
192
177
|
# Faker::Number.within(range: 1..10) #=> 7
|
|
178
|
+
# Faker::Number.within(range: 0.0..1.0) #=> 0.7844640543957383
|
|
193
179
|
#
|
|
194
180
|
# @faker.version 1.0.0
|
|
195
|
-
def within(
|
|
196
|
-
warn_for_deprecated_arguments do |keywords|
|
|
197
|
-
keywords << :range if legacy_range != NOT_GIVEN
|
|
198
|
-
end
|
|
199
|
-
|
|
181
|
+
def within(range: 1.00..5000.00)
|
|
200
182
|
between(from: range.min, to: range.max)
|
|
201
183
|
end
|
|
202
184
|
|
|
@@ -211,12 +193,7 @@ module Faker
|
|
|
211
193
|
# Faker::Number.positive #=> 235.59238499107653
|
|
212
194
|
#
|
|
213
195
|
# @faker.version 1.0.0
|
|
214
|
-
def positive(
|
|
215
|
-
warn_for_deprecated_arguments do |keywords|
|
|
216
|
-
keywords << :from if legacy_from != NOT_GIVEN
|
|
217
|
-
keywords << :to if legacy_to != NOT_GIVEN
|
|
218
|
-
end
|
|
219
|
-
|
|
196
|
+
def positive(from: 1.00, to: 5000.00)
|
|
220
197
|
random_number = between(from: from, to: to)
|
|
221
198
|
|
|
222
199
|
greater_than_zero(random_number)
|
|
@@ -233,12 +210,7 @@ module Faker
|
|
|
233
210
|
# Faker::Number.negative #=> -4480.042585669558
|
|
234
211
|
#
|
|
235
212
|
# @faker.version 1.0.0
|
|
236
|
-
def negative(
|
|
237
|
-
warn_for_deprecated_arguments do |keywords|
|
|
238
|
-
keywords << :from if legacy_from != NOT_GIVEN
|
|
239
|
-
keywords << :to if legacy_to != NOT_GIVEN
|
|
240
|
-
end
|
|
241
|
-
|
|
213
|
+
def negative(from: -5000.00, to: -1.00)
|
|
242
214
|
random_number = between(from: from, to: to)
|
|
243
215
|
|
|
244
216
|
less_than_zero(random_number)
|
|
@@ -12,7 +12,7 @@ module Faker
|
|
|
12
12
|
super()
|
|
13
13
|
|
|
14
14
|
@name = name || "#{Name.first_name} #{Name.last_name}"
|
|
15
|
-
@email = email || Internet.
|
|
15
|
+
@email = email || Internet.email(name: self.name)
|
|
16
16
|
@first_name, @last_name = self.name.split
|
|
17
17
|
end
|
|
18
18
|
|
|
@@ -27,15 +27,7 @@ module Faker
|
|
|
27
27
|
# @return [Hash] An auth hash in the format provided by omniauth-google.
|
|
28
28
|
#
|
|
29
29
|
# @faker.version 1.8.0
|
|
30
|
-
|
|
31
|
-
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)
|
|
32
|
-
# rubocop:enable Metrics/ParameterLists
|
|
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',
|
|
@@ -65,7 +57,7 @@ module Faker
|
|
|
65
57
|
picture: image,
|
|
66
58
|
gender: gender,
|
|
67
59
|
birthday: Date.backward(days: 36_400).strftime('%Y-%m-%d'),
|
|
68
|
-
|
|
60
|
+
locale: 'en',
|
|
69
61
|
hd: "#{Company.name.downcase}.com"
|
|
70
62
|
},
|
|
71
63
|
id_info: {
|
|
@@ -95,16 +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
|
-
|
|
99
|
-
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)
|
|
100
|
-
# rubocop:enable Metrics/ParameterLists
|
|
101
|
-
warn_for_deprecated_arguments do |keywords|
|
|
102
|
-
keywords << :name if legacy_name != NOT_GIVEN
|
|
103
|
-
keywords << :email if legacy_email != NOT_GIVEN
|
|
104
|
-
keywords << :username if legacy_username != NOT_GIVEN
|
|
105
|
-
keywords << :uid if legacy_uid != NOT_GIVEN
|
|
106
|
-
end
|
|
107
|
-
|
|
90
|
+
def facebook(name: nil, email: nil, username: nil, uid: Number.number(digits: 7).to_s)
|
|
108
91
|
auth = Omniauth.new(name: name, email: email)
|
|
109
92
|
username ||= "#{auth.first_name.downcase[0]}#{auth.last_name.downcase}"
|
|
110
93
|
{
|
|
@@ -156,15 +139,7 @@ module Faker
|
|
|
156
139
|
# @return [Hash] An auth hash in the format provided by omniauth-twitter.
|
|
157
140
|
#
|
|
158
141
|
# @faker.version 1.8.0
|
|
159
|
-
|
|
160
|
-
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)
|
|
161
|
-
# rubocop:enable Metrics/ParameterLists
|
|
162
|
-
warn_for_deprecated_arguments do |keywords|
|
|
163
|
-
keywords << :name if legacy_name != NOT_GIVEN
|
|
164
|
-
keywords << :nickname if legacy_nickname != NOT_GIVEN
|
|
165
|
-
keywords << :uid if legacy_uid != NOT_GIVEN
|
|
166
|
-
end
|
|
167
|
-
|
|
142
|
+
def twitter(name: nil, nickname: nil, uid: Number.number(digits: 6).to_s)
|
|
168
143
|
auth = Omniauth.new(name: name)
|
|
169
144
|
nickname ||= auth.name.downcase.delete(' ')
|
|
170
145
|
location = city_state
|
|
@@ -247,15 +222,7 @@ module Faker
|
|
|
247
222
|
# @return [Hash] An auth hash in the format provided by omniauth-linkedin.
|
|
248
223
|
#
|
|
249
224
|
# @faker.version 1.8.0
|
|
250
|
-
|
|
251
|
-
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)
|
|
252
|
-
# rubocop:enable Metrics/ParameterLists
|
|
253
|
-
warn_for_deprecated_arguments do |keywords|
|
|
254
|
-
keywords << :name if legacy_name != NOT_GIVEN
|
|
255
|
-
keywords << :email if legacy_email != NOT_GIVEN
|
|
256
|
-
keywords << :uid if legacy_uid != NOT_GIVEN
|
|
257
|
-
end
|
|
258
|
-
|
|
225
|
+
def linkedin(name: nil, email: nil, uid: Number.number(digits: 6).to_s)
|
|
259
226
|
auth = Omniauth.new(name: name, email: email)
|
|
260
227
|
first_name = auth.first_name.downcase
|
|
261
228
|
last_name = auth.last_name.downcase
|
|
@@ -328,15 +295,7 @@ module Faker
|
|
|
328
295
|
# @return [Hash] An auth hash in the format provided by omniauth-github.
|
|
329
296
|
#
|
|
330
297
|
# @faker.version 1.8.0
|
|
331
|
-
|
|
332
|
-
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)
|
|
333
|
-
# rubocop:enable Metrics/ParameterLists
|
|
334
|
-
warn_for_deprecated_arguments do |keywords|
|
|
335
|
-
keywords << :name if legacy_name != NOT_GIVEN
|
|
336
|
-
keywords << :email if legacy_email != NOT_GIVEN
|
|
337
|
-
keywords << :uid if legacy_uid != NOT_GIVEN
|
|
338
|
-
end
|
|
339
|
-
|
|
298
|
+
def github(name: nil, email: nil, uid: Number.number(digits: 8).to_s)
|
|
340
299
|
auth = Omniauth.new(name: name, email: email)
|
|
341
300
|
login = auth.name.downcase.tr(' ', '-')
|
|
342
301
|
html_url = "https://github.com/#{login}"
|
|
@@ -438,14 +397,58 @@ module Faker
|
|
|
438
397
|
}
|
|
439
398
|
end
|
|
440
399
|
|
|
400
|
+
##
|
|
401
|
+
# Generate a mock Omniauth response from Auth0.
|
|
402
|
+
#
|
|
403
|
+
# @param name [String] A specific name to return in the response.
|
|
404
|
+
# @param email [String] A specific email to return in the response.
|
|
405
|
+
# @param uid [String] A specific UID to return in the response.
|
|
406
|
+
#
|
|
407
|
+
# @return [Hash] An auth hash in the format provided by omniauth-auth0.
|
|
408
|
+
#
|
|
409
|
+
# @faker.version next
|
|
410
|
+
def auth0(name: nil, email: nil, uid: nil)
|
|
411
|
+
uid ||= "auth0|#{Number.hexadecimal(digits: 24)}"
|
|
412
|
+
auth = Omniauth.new(name: name, email: email)
|
|
413
|
+
{
|
|
414
|
+
provider: 'auth0',
|
|
415
|
+
uid: uid,
|
|
416
|
+
info: {
|
|
417
|
+
name: uid,
|
|
418
|
+
nickname: auth.name,
|
|
419
|
+
email: auth.email,
|
|
420
|
+
image: image
|
|
421
|
+
},
|
|
422
|
+
credentials: {
|
|
423
|
+
expires_at: Time.forward.to_i,
|
|
424
|
+
expires: true,
|
|
425
|
+
token_type: 'Bearer',
|
|
426
|
+
id_token: Crypto.sha256,
|
|
427
|
+
token: Crypto.md5,
|
|
428
|
+
refresh_token: Crypto.md5
|
|
429
|
+
},
|
|
430
|
+
extra: {
|
|
431
|
+
raw_info: {
|
|
432
|
+
email: auth.email,
|
|
433
|
+
email_verified: true,
|
|
434
|
+
iss: 'https://auth0.com/',
|
|
435
|
+
sub: uid,
|
|
436
|
+
aud: 'Auth012345',
|
|
437
|
+
iat: Time.forward.to_i,
|
|
438
|
+
exp: Time.forward.to_i
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
end
|
|
443
|
+
|
|
441
444
|
private
|
|
442
445
|
|
|
443
446
|
def gender
|
|
444
|
-
|
|
447
|
+
sample(%w[male female])
|
|
445
448
|
end
|
|
446
449
|
|
|
447
450
|
def timezone
|
|
448
|
-
|
|
451
|
+
sample((-12..12).to_a)
|
|
449
452
|
end
|
|
450
453
|
|
|
451
454
|
def image
|
|
@@ -457,11 +460,11 @@ module Faker
|
|
|
457
460
|
end
|
|
458
461
|
|
|
459
462
|
def random_number_from_range(range)
|
|
460
|
-
|
|
463
|
+
sample(range.to_a)
|
|
461
464
|
end
|
|
462
465
|
|
|
463
466
|
def random_boolean
|
|
464
|
-
|
|
467
|
+
sample([true, false])
|
|
465
468
|
end
|
|
466
469
|
end
|
|
467
470
|
end
|
|
@@ -4,12 +4,14 @@ module Faker
|
|
|
4
4
|
class PhoneNumber < Base
|
|
5
5
|
class << self
|
|
6
6
|
##
|
|
7
|
-
# Produces a
|
|
7
|
+
# Produces a phone number in a random format without the country code and it can have different dividers.
|
|
8
8
|
#
|
|
9
9
|
# @return [String]
|
|
10
10
|
#
|
|
11
11
|
# @example
|
|
12
|
-
# Faker::PhoneNumber.phone_number #=> "
|
|
12
|
+
# Faker::PhoneNumber.phone_number #=> "(504) 113-1705"
|
|
13
|
+
# Faker::PhoneNumber.phone_number #=> "662.291.7201"
|
|
14
|
+
# Faker::PhoneNumber.phone_number #=> "9415283713"
|
|
13
15
|
#
|
|
14
16
|
# @faker.version 0.3.0
|
|
15
17
|
def phone_number
|
|
@@ -17,12 +19,14 @@ module Faker
|
|
|
17
19
|
end
|
|
18
20
|
|
|
19
21
|
##
|
|
20
|
-
# Produces a random cell phone number in a random format
|
|
22
|
+
# Produces a random cell phone number in a random format without the country code and it can have different dividers.
|
|
21
23
|
#
|
|
22
24
|
# @return [String]
|
|
23
25
|
#
|
|
24
26
|
# @example
|
|
25
|
-
# Faker::PhoneNumber.cell_phone #=> "(
|
|
27
|
+
# Faker::PhoneNumber.cell_phone #=> "(836) 115-8995"
|
|
28
|
+
# Faker::PhoneNumber.cell_phone #=> "382-597-5739"
|
|
29
|
+
# Faker::PhoneNumber.cell_phone #=> "316.828.1822"
|
|
26
30
|
#
|
|
27
31
|
# @faker.version 1.0.0
|
|
28
32
|
def cell_phone
|
|
@@ -36,10 +40,12 @@ module Faker
|
|
|
36
40
|
#
|
|
37
41
|
# @example
|
|
38
42
|
# Faker::PhoneNumber.country_code #=> "+20"
|
|
43
|
+
# Faker::PhoneNumber.country_code #=> "+39"
|
|
44
|
+
# Faker::PhoneNumber.country_code #=> "+852"
|
|
39
45
|
#
|
|
40
46
|
# @faker.version 1.9.2
|
|
41
47
|
def country_code
|
|
42
|
-
"+#{fetch('country_code')}"
|
|
48
|
+
"+#{fetch('phone_number.country_code')}"
|
|
43
49
|
end
|
|
44
50
|
|
|
45
51
|
##
|
|
@@ -48,7 +54,9 @@ module Faker
|
|
|
48
54
|
# @return [String]
|
|
49
55
|
#
|
|
50
56
|
# @example
|
|
51
|
-
# Faker::PhoneNumber.phone_number_with_country_code #=> "+
|
|
57
|
+
# Faker::PhoneNumber.phone_number_with_country_code #=> "+55 466-746-6882"
|
|
58
|
+
# Faker::PhoneNumber.phone_number_with_country_code #=> "+81 3718219558"
|
|
59
|
+
# Faker::PhoneNumber.phone_number_with_country_code #=> "+49 140 957 9846"
|
|
52
60
|
#
|
|
53
61
|
# @faker.version 1.9.2
|
|
54
62
|
def phone_number_with_country_code
|
|
@@ -61,7 +69,9 @@ module Faker
|
|
|
61
69
|
# @return [String]
|
|
62
70
|
#
|
|
63
71
|
# @example
|
|
64
|
-
# Faker::PhoneNumber.cell_phone_with_country_code #=> "+
|
|
72
|
+
# Faker::PhoneNumber.cell_phone_with_country_code #=> "+852 (190) 987-9034"
|
|
73
|
+
# Faker::PhoneNumber.cell_phone_with_country_code #=> "+64 (820) 583-6474"
|
|
74
|
+
# Faker::PhoneNumber.cell_phone_with_country_code #=> "+1 591.871.7985"
|
|
65
75
|
#
|
|
66
76
|
# @faker.version 1.9.2
|
|
67
77
|
def cell_phone_with_country_code
|
|
@@ -69,12 +79,14 @@ module Faker
|
|
|
69
79
|
end
|
|
70
80
|
|
|
71
81
|
##
|
|
72
|
-
# Produces a random phone number in e164 format.
|
|
82
|
+
# Produces a random phone number in e164 format, i.e., without any dividers.
|
|
73
83
|
#
|
|
74
84
|
# @return [String]
|
|
75
85
|
#
|
|
76
86
|
# @example
|
|
77
|
-
# Faker::PhoneNumber.cell_phone_in_e164 #=> "+
|
|
87
|
+
# Faker::PhoneNumber.cell_phone_in_e164 #=> "+542024834991"
|
|
88
|
+
# Faker::PhoneNumber.cell_phone_in_e164 #=> "+8522846847703"
|
|
89
|
+
# Faker::PhoneNumber.cell_phone_in_e164 #=> "+649477546575"
|
|
78
90
|
#
|
|
79
91
|
# @faker.version 1.9.2
|
|
80
92
|
def cell_phone_in_e164
|
|
@@ -82,53 +94,56 @@ module Faker
|
|
|
82
94
|
end
|
|
83
95
|
|
|
84
96
|
##
|
|
85
|
-
# Produces a random
|
|
97
|
+
# Produces a random area code.
|
|
86
98
|
#
|
|
87
99
|
# @return [String]
|
|
88
100
|
#
|
|
89
101
|
# @example
|
|
90
102
|
# Faker::PhoneNumber.area_code #=> "201"
|
|
103
|
+
# Faker::PhoneNumber.area_code #=> "613"
|
|
104
|
+
# Faker::PhoneNumber.area_code #=> "321"
|
|
91
105
|
#
|
|
92
106
|
# @faker.version 1.3.0
|
|
93
107
|
def area_code
|
|
94
108
|
fetch('phone_number.area_code')
|
|
95
|
-
rescue I18n::MissingTranslationData
|
|
96
|
-
nil
|
|
97
109
|
end
|
|
98
110
|
|
|
99
111
|
##
|
|
100
|
-
# Produces a random
|
|
112
|
+
# Produces a random exchange code.
|
|
101
113
|
#
|
|
102
114
|
# @return [String]
|
|
103
115
|
#
|
|
104
116
|
# @example
|
|
105
117
|
# Faker::PhoneNumber.exchange_code #=> "208"
|
|
118
|
+
# Faker::PhoneNumber.exchange_code #=> "415"
|
|
119
|
+
# Faker::PhoneNumber.exchange_code #=> "652"
|
|
106
120
|
#
|
|
107
121
|
# @faker.version 1.3.0
|
|
108
122
|
def exchange_code
|
|
109
123
|
fetch('phone_number.exchange_code')
|
|
110
|
-
rescue I18n::MissingTranslationData
|
|
111
|
-
nil
|
|
112
124
|
end
|
|
113
125
|
|
|
114
126
|
##
|
|
115
|
-
# Produces a random
|
|
127
|
+
# Produces a random extension / subscriber number. Can be used for both extensions and last four digits of phone number.
|
|
116
128
|
#
|
|
117
|
-
# @param length [Integer]
|
|
129
|
+
# @param length [Integer] Specifies the length of the return value. Defaults to 4.
|
|
118
130
|
# @return [String]
|
|
119
131
|
#
|
|
120
132
|
# @example
|
|
121
133
|
# Faker::PhoneNumber.subscriber_number #=> "3873"
|
|
122
134
|
# Faker::PhoneNumber.subscriber_number(length: 2) #=> "39"
|
|
123
135
|
# Faker::PhoneNumber.extension #=> "3764"
|
|
136
|
+
# Faker::PhoneNumber.extension(length: 2) => "37"
|
|
124
137
|
#
|
|
125
138
|
# @faker.version 1.3.0
|
|
126
|
-
def subscriber_number(
|
|
127
|
-
|
|
128
|
-
|
|
139
|
+
def subscriber_number(length: 4)
|
|
140
|
+
if !length.is_a?(Integer) || length > 10
|
|
141
|
+
raise ArgumentError, 'length must be an Integer and be lesser than 10'
|
|
129
142
|
end
|
|
130
143
|
|
|
131
|
-
|
|
144
|
+
generate(:string) do |g|
|
|
145
|
+
g.int(length: length)
|
|
146
|
+
end
|
|
132
147
|
end
|
|
133
148
|
|
|
134
149
|
alias extension subscriber_number
|
|
@@ -6,7 +6,7 @@ module Faker
|
|
|
6
6
|
SUPPORTED_FORMATS = %w[png jpg gif jpeg].freeze
|
|
7
7
|
|
|
8
8
|
##
|
|
9
|
-
# Produces a random placeholder image from https://
|
|
9
|
+
# Produces a random placeholder image from https://via.placeholder.com.
|
|
10
10
|
#
|
|
11
11
|
# @param size [String] Specifies the image's size, dimensions separated by 'x'.
|
|
12
12
|
# @param format [String] Specifies the image's extension.
|
|
@@ -17,26 +17,16 @@ module Faker
|
|
|
17
17
|
#
|
|
18
18
|
# @example
|
|
19
19
|
# # Keyword arguments: size, format, background_color, text_color, text
|
|
20
|
-
# Faker::Placeholdit.image #=> "https://
|
|
21
|
-
# Faker::Placeholdit.image(size: '50x50') #=> "https://
|
|
22
|
-
# Faker::Placeholdit.image(size: '50x50', format: 'jpg') #=> "https://
|
|
23
|
-
# Faker::Placeholdit.image(size: '50x50', format: 'gif', background_color: 'ffffff') #=> "https://
|
|
24
|
-
# Faker::Placeholdit.image(size: '50x50', format: 'jpeg', background_color: :random) #=> "https://
|
|
25
|
-
# Faker::Placeholdit.image(size: '50x50', format: 'jpeg', background_color: 'ffffff', text_color: '000') #=> "https://
|
|
26
|
-
# Faker::Placeholdit.image(size: '50x50', format: 'jpg', background_color: 'ffffff', text_color: '000', text: 'Some Custom Text') #=> "https://
|
|
20
|
+
# Faker::Placeholdit.image #=> "https://via.placeholder.com/300x300.png"
|
|
21
|
+
# Faker::Placeholdit.image(size: '50x50') #=> "https://via.placeholder.com/50x50.png"
|
|
22
|
+
# Faker::Placeholdit.image(size: '50x50', format: 'jpg') #=> "https://via.placeholder.com/50x50.jpg"
|
|
23
|
+
# Faker::Placeholdit.image(size: '50x50', format: 'gif', background_color: 'ffffff') #=> "https://via.placeholder.com/50x50.gif/ffffff"
|
|
24
|
+
# Faker::Placeholdit.image(size: '50x50', format: 'jpeg', background_color: :random) #=> "https://via.placeholder.com/50x50.jpeg/39eba7"
|
|
25
|
+
# Faker::Placeholdit.image(size: '50x50', format: 'jpeg', background_color: 'ffffff', text_color: '000') #=> "https://via.placeholder.com/50x50.jpeg/ffffff/000"
|
|
26
|
+
# Faker::Placeholdit.image(size: '50x50', format: 'jpg', background_color: 'ffffff', text_color: '000', text: 'Some Custom Text') #=> "https://via.placeholder.com/50x50.jpg/ffffff/000?text=Some Custom Text"
|
|
27
27
|
#
|
|
28
28
|
# @faker.version 1.6.0
|
|
29
|
-
|
|
30
|
-
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
|
-
warn_for_deprecated_arguments do |keywords|
|
|
33
|
-
keywords << :size if legacy_size != NOT_GIVEN
|
|
34
|
-
keywords << :format if legacy_format != NOT_GIVEN
|
|
35
|
-
keywords << :background_color if legacy_background_color != NOT_GIVEN
|
|
36
|
-
keywords << :text_color if legacy_text_color != NOT_GIVEN
|
|
37
|
-
keywords << :text if legacy_text != NOT_GIVEN
|
|
38
|
-
end
|
|
39
|
-
|
|
29
|
+
def image(size: '300x300', format: 'png', background_color: nil, text_color: nil, text: nil)
|
|
40
30
|
background_color = generate_color if background_color == :random
|
|
41
31
|
text_color = generate_color if text_color == :random
|
|
42
32
|
|
|
@@ -45,7 +35,7 @@ module Faker
|
|
|
45
35
|
raise ArgumentError, "background_color must be a hex value without '#'" unless background_color.nil? || background_color =~ /((?:^\h{3}$)|(?:^\h{6}$)){1}(?!.*\H)/
|
|
46
36
|
raise ArgumentError, "text_color must be a hex value without '#'" unless text_color.nil? || text_color =~ /((?:^\h{3}$)|(?:^\h{6}$)){1}(?!.*\H)/
|
|
47
37
|
|
|
48
|
-
image_url = "https://
|
|
38
|
+
image_url = "https://via.placeholder.com/#{size}.#{format}"
|
|
49
39
|
image_url += "/#{background_color}" if background_color
|
|
50
40
|
image_url += "/#{text_color}" if text_color
|
|
51
41
|
image_url += "?text=#{text}" if text
|
|
@@ -14,11 +14,7 @@ module Faker
|
|
|
14
14
|
# Faker::Relationship.familial #=> "Grandfather"
|
|
15
15
|
#
|
|
16
16
|
# @faker.version 1.9.2
|
|
17
|
-
def familial(
|
|
18
|
-
warn_for_deprecated_arguments do |keywords|
|
|
19
|
-
keywords << :connection if legacy_connection != NOT_GIVEN
|
|
20
|
-
end
|
|
21
|
-
|
|
17
|
+
def familial(connection: nil)
|
|
22
18
|
familial_connections = translate('faker.relationship.familial').keys
|
|
23
19
|
|
|
24
20
|
if connection.nil?
|