faker 2.11.0 → 2.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +421 -13
- data/History.md +4 -4
- data/README.md +33 -3
- data/lib/faker.rb +28 -23
- data/lib/faker/blockchain/aeternity.rb +4 -4
- data/lib/faker/blockchain/bitcoin.rb +2 -2
- data/lib/faker/blockchain/tezos.rb +30 -2
- data/lib/faker/books/dune.rb +15 -2
- data/lib/faker/books/lovecraft.rb +8 -4
- data/lib/faker/creature/bird.rb +203 -0
- data/lib/faker/default/address.rb +35 -5
- data/lib/faker/default/app.rb +1 -1
- data/lib/faker/default/avatar.rb +1 -1
- data/lib/faker/default/bank.rb +96 -3
- data/lib/faker/default/barcode.rb +165 -0
- data/lib/faker/default/beer.rb +3 -3
- data/lib/faker/default/blood.rb +48 -0
- data/lib/faker/default/business.rb +1 -1
- data/lib/faker/default/camera.rb +46 -0
- data/lib/faker/default/cannabis.rb +10 -0
- data/lib/faker/default/chile_rut.rb +47 -3
- data/lib/faker/default/chuck_norris.rb +1 -0
- data/lib/faker/default/code.rb +98 -17
- data/lib/faker/default/commerce.rb +74 -11
- data/lib/faker/default/company.rb +96 -11
- data/lib/faker/default/compass.rb +135 -0
- data/lib/faker/default/computer.rb +63 -0
- data/lib/faker/default/construction.rb +54 -0
- data/lib/faker/default/cosmere.rb +90 -0
- data/lib/faker/default/crypto.rb +17 -4
- data/lib/faker/default/crypto_coin.rb +45 -0
- data/lib/faker/default/date.rb +16 -12
- data/lib/faker/default/driving_licence.rb +67 -1
- data/lib/faker/default/drone.rb +332 -0
- data/lib/faker/default/educator.rb +13 -0
- data/lib/faker/default/faker_adjective.rb +35 -0
- data/lib/faker/default/file.rb +53 -2
- data/lib/faker/default/finance.rb +45 -0
- data/lib/faker/default/food.rb +1 -1
- data/lib/faker/default/gender.rb +1 -1
- data/lib/faker/default/hipster.rb +107 -10
- data/lib/faker/default/id_number.rb +122 -2
- data/lib/faker/default/internet.rb +266 -12
- data/lib/faker/default/internet_http.rb +48 -0
- data/lib/faker/default/invoice.rb +33 -6
- data/lib/faker/default/json.rb +61 -5
- data/lib/faker/default/lorem.rb +160 -5
- data/lib/faker/default/lorem_flickr.rb +67 -7
- data/lib/faker/default/lorem_pixel.rb +23 -0
- data/lib/faker/default/markdown.rb +91 -0
- data/lib/faker/default/measurement.rb +93 -2
- data/lib/faker/default/military.rb +26 -0
- data/lib/faker/default/mountain.rb +33 -0
- data/lib/faker/default/name.rb +98 -0
- data/lib/faker/default/nhs.rb +19 -0
- data/lib/faker/default/number.rb +28 -13
- data/lib/faker/default/omniauth.rb +62 -14
- data/lib/faker/default/phone_number.rb +88 -5
- data/lib/faker/default/placeholdit.rb +23 -1
- data/lib/faker/default/relationship.rb +1 -1
- data/lib/faker/default/science.rb +26 -0
- data/lib/faker/default/slack_emoji.rb +81 -0
- data/lib/faker/default/south_africa.rb +90 -0
- data/lib/faker/default/space.rb +1 -1
- data/lib/faker/default/string.rb +20 -3
- data/lib/faker/default/stripe.rb +64 -3
- data/lib/faker/default/tea.rb +41 -0
- data/lib/faker/default/twitter.rb +35 -0
- data/lib/faker/default/types.rb +84 -3
- data/lib/faker/default/university.rb +45 -0
- data/lib/faker/default/vehicle.rb +184 -4
- data/lib/faker/default/verb.rb +45 -0
- data/lib/faker/default/world_cup.rb +4 -4
- data/lib/faker/fantasy/tolkien.rb +67 -0
- data/lib/faker/games/clash_of_clans.rb +48 -0
- data/lib/faker/games/control.rb +113 -0
- data/lib/faker/games/dnd.rb +136 -0
- data/lib/faker/games/elder_scrolls.rb +26 -0
- data/lib/faker/games/heroes.rb +13 -0
- data/lib/faker/games/heroes_of_the_storm.rb +16 -5
- data/lib/faker/games/minecraft.rb +113 -0
- data/lib/faker/games/street_fighter.rb +61 -0
- data/lib/faker/games/super_mario.rb +48 -0
- data/lib/faker/games/touhou.rb +75 -0
- data/lib/faker/games/warhammer_fantasy.rb +74 -0
- data/lib/faker/games/witcher.rb +39 -0
- data/lib/faker/games/world_of_warcraft.rb +26 -1
- data/lib/faker/japanese_media/conan.rb +48 -0
- data/lib/faker/japanese_media/doraemon.rb +48 -0
- data/lib/faker/japanese_media/dragon_ball.rb +26 -0
- data/lib/faker/japanese_media/naruto.rb +61 -0
- data/lib/faker/japanese_media/studio_ghibli.rb +48 -0
- data/lib/faker/movies/departed.rb +49 -0
- data/lib/faker/movies/hobbit.rb +4 -4
- data/lib/faker/movies/how_to_train_your_dragon.rb +48 -0
- data/lib/faker/movies/lord_of_the_rings.rb +3 -3
- data/lib/faker/movies/movie.rb +13 -0
- data/lib/faker/movies/room.rb +63 -0
- data/lib/faker/movies/star_wars.rb +74 -2
- data/lib/faker/music/hiphop.rb +48 -0
- data/lib/faker/music/music.rb +12 -0
- data/lib/faker/music/opera.rb +237 -1
- data/lib/faker/music/pearl_jam.rb +50 -0
- data/lib/faker/music/phish.rb +27 -1
- data/lib/faker/music/prince.rb +64 -0
- data/lib/faker/music/rock_band.rb +12 -0
- data/lib/faker/music/rush.rb +37 -0
- data/lib/faker/music/show.rb +49 -0
- data/lib/faker/quotes/quote.rb +80 -1
- data/lib/faker/quotes/rajnikanth.rb +1 -0
- data/lib/faker/quotes/shakespeare.rb +70 -0
- data/lib/faker/sports/volleyball.rb +74 -0
- data/lib/faker/tv_shows/aqua_teen_hunger_force.rb +13 -0
- data/lib/faker/tv_shows/big_bang_theory.rb +37 -0
- data/lib/faker/tv_shows/buffy.rb +17 -4
- data/lib/faker/tv_shows/dr_who.rb +1 -1
- data/lib/faker/tv_shows/final_space.rb +51 -0
- data/lib/faker/tv_shows/futurama.rb +65 -0
- data/lib/faker/tv_shows/simpsons.rb +14 -0
- data/lib/faker/tv_shows/suits.rb +37 -0
- data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +17 -4
- data/lib/faker/version.rb +1 -1
- data/lib/helpers/base58.rb +1 -1
- data/lib/helpers/char.rb +22 -27
- data/lib/helpers/unique_generator.rb +0 -2
- data/lib/locales/de-AT.yml +4 -2
- data/lib/locales/de-CH.yml +1696 -1
- data/lib/locales/de.yml +4 -2
- data/lib/locales/en-AU.yml +50 -10
- data/lib/locales/en-CA.yml +2 -0
- data/lib/locales/en-GB.yml +1 -1
- data/lib/locales/en-IND.yml +2 -1
- data/lib/locales/en-MS.yml +2 -1
- data/lib/locales/en-NEP.yml +4 -1
- data/lib/locales/en-NZ.yml +3 -1
- data/lib/locales/en-PAK.yml +2 -1
- data/lib/locales/en-SG.yml +2 -1
- data/lib/locales/en-US.yml +37 -11
- data/lib/locales/en-au-ocker.yml +2 -1
- data/lib/locales/en.yml +0 -3
- data/lib/locales/en/address.yml +2 -0
- data/lib/locales/en/adjective.yml +179 -0
- data/lib/locales/en/animal.yml +1 -1
- data/lib/locales/en/aqua_teen_hunger_force.yml +33 -1
- data/lib/locales/en/bank.yml +1 -1
- data/lib/locales/en/barcode.yml +24 -0
- data/lib/locales/en/big_bang_theory.yml +38 -0
- data/lib/locales/en/bird.yml +1281 -0
- data/lib/locales/en/blood.yml +13 -0
- data/lib/locales/en/book.yml +487 -3
- data/lib/locales/en/buffy.yml +1 -1
- data/lib/locales/en/camera.yml +611 -0
- data/lib/locales/en/clash_of_clan.yml +101 -0
- data/lib/locales/en/company.yml +2 -2
- data/lib/locales/en/computer.yml +36 -0
- data/lib/locales/en/conan.yml +171 -0
- data/lib/locales/en/control.yml +247 -0
- data/lib/locales/en/demographic.yml +218 -5
- data/lib/locales/en/departed.yml +50 -0
- data/lib/locales/en/device.yml +112 -4
- data/lib/locales/en/dnd.yml +451 -0
- data/lib/locales/en/doraemon.yml +286 -0
- data/lib/locales/en/dota.yml +531 -63
- data/lib/locales/en/dragon_ball.yml +243 -1
- data/lib/locales/en/driving_license.yml +181 -0
- data/lib/locales/en/drone.yml +95 -0
- data/lib/locales/en/dune.yml +270 -131
- data/lib/locales/en/educator.yml +6 -0
- data/lib/locales/en/elder_scrolls.yml +583 -9
- data/lib/locales/en/fallout.yml +311 -133
- data/lib/locales/en/final_space.yml +37 -0
- data/lib/locales/en/finance.yml +53 -0
- data/lib/locales/en/football.yml +3 -3
- data/lib/locales/en/fresh_prince_of_bel_air.yml +1 -1
- data/lib/locales/en/futurama.yml +344 -0
- data/lib/locales/en/half_life.yml +84 -3
- data/lib/locales/en/heroes.yml +408 -3
- data/lib/locales/en/heroes_of_the_storm.yml +131 -4
- data/lib/locales/en/house.yml +1 -1
- data/lib/locales/en/how_to_train_your_dragon.yml +174 -0
- data/lib/locales/en/jack_handey.yml +54 -0
- data/lib/locales/en/league_of_legends.yml +285 -6
- data/lib/locales/en/lebowski.yml +1 -1
- data/lib/locales/en/lovecraft.yml +76 -6
- data/lib/locales/en/military.yml +179 -5
- data/lib/locales/en/minecraft.yml +663 -0
- data/lib/locales/en/mountain.yml +158 -0
- data/lib/locales/en/movie.yml +192 -1
- data/lib/locales/en/music.yml +461 -29
- data/lib/locales/en/myst.yml +87 -31
- data/lib/locales/en/name.yml +5 -4
- data/lib/locales/en/naruto.yml +231 -0
- data/lib/locales/en/one_piece.yml +2 -2
- data/lib/locales/en/opera.yml +168 -0
- data/lib/locales/en/overwatch.yml +2650 -2622
- data/lib/locales/en/pearl_jam.yml +213 -0
- data/lib/locales/en/phish.yml +392 -1
- data/lib/locales/en/pokemon.yml +417 -4
- data/lib/locales/en/prince.yml +227 -0
- data/lib/locales/en/quote.yml +692 -163
- data/lib/locales/en/rock_band.yml +1 -0
- data/lib/locales/en/room.yml +68 -0
- data/lib/locales/en/rush.yml +32 -0
- data/lib/locales/en/science.yml +355 -3
- data/lib/locales/en/shakespeare.yml +21 -24
- data/lib/locales/en/show.yml +597 -0
- data/lib/locales/en/simpsons.yml +668 -0
- data/lib/locales/en/source.yml +30 -0
- data/lib/locales/en/space.yml +1 -1
- data/lib/locales/en/star_trek.yml +1 -1
- data/lib/locales/en/star_wars.yml +568 -220
- data/lib/locales/en/street_fighter.yml +1524 -0
- data/lib/locales/en/studio_ghibli.yml +107 -0
- data/lib/locales/en/suits.yml +45 -0
- data/lib/locales/en/super_mario.yml +58 -0
- data/lib/locales/en/super_smash_bros.yml +18 -4
- data/lib/locales/en/tea.yml +172 -0
- data/lib/locales/en/tolkien.yml +2453 -0
- data/lib/locales/en/touhou.yml +839 -0
- data/lib/locales/en/volleyball.yml +501 -0
- data/lib/locales/en/warhammer_fantasy.yml +582 -0
- data/lib/locales/en/witcher.yml +426 -7
- data/lib/locales/en/world_of_warcraft.yml +122 -4
- data/lib/locales/en/zelda.yml +962 -4
- data/lib/locales/es-AR.yml +4603 -0
- data/lib/locales/es.yml +56 -0
- data/lib/locales/fi-FI.yml +1 -1
- data/lib/locales/fr-CA.yml +21 -5
- data/lib/locales/fr-CH.yml +2 -2
- data/lib/locales/fr.yml +1 -113
- data/lib/locales/fr/address.yml +21 -0
- data/lib/locales/fr/book.yml +7 -0
- data/lib/locales/fr/color.yml +4 -0
- data/lib/locales/fr/company.yml +17 -0
- data/lib/locales/fr/compass.yml +23 -0
- data/lib/locales/fr/demographic.yml +4 -0
- data/lib/locales/fr/gender.yml +6 -0
- data/lib/locales/fr/internet.yml +5 -0
- data/lib/locales/fr/lorem.yml +5 -0
- data/lib/locales/fr/measurement.yml +7 -0
- data/lib/locales/fr/name.yml +21 -0
- data/lib/locales/fr/phone_number.yml +7 -0
- data/lib/locales/fr/pokemon.yml +9 -0
- data/lib/locales/id.yml +3 -1
- data/lib/locales/it.yml +2 -1
- data/lib/locales/ja/README.md +13 -0
- data/lib/locales/ja/address.yml +17 -0
- data/lib/locales/ja/ancient.yml +4 -0
- data/lib/locales/ja/bank.yml +4 -0
- data/lib/locales/ja/book.yml +7 -0
- data/lib/locales/ja/coffee.yml +4 -0
- data/lib/locales/ja/color.yml +4 -0
- data/lib/locales/ja/commerce.yml +11 -0
- data/lib/locales/ja/company.yml +8 -0
- data/lib/locales/ja/creature.yml +9 -0
- data/lib/locales/ja/food.yml +4 -0
- data/lib/locales/ja/games.yml +18 -0
- data/lib/locales/ja/gender.yml +4 -0
- data/lib/locales/ja/lorem.yml +9 -0
- data/lib/locales/ja/name.yml +13 -0
- data/lib/locales/ja/phone_number.yml +7 -0
- data/lib/locales/ja/restaurant.yml +11 -0
- data/lib/locales/ja/space.yml +5 -0
- data/lib/locales/ja/subscription.yml +8 -0
- data/lib/locales/ja/university.yml +9 -0
- data/lib/locales/ko.yml +94 -2
- data/lib/locales/nb-NO.yml +4 -2
- data/lib/locales/pt-BR.yml +3 -1
- data/lib/locales/pt.yml +3 -1
- data/lib/locales/ru.yml +42 -1
- data/lib/locales/sk.yml +4 -2
- data/lib/locales/uk.yml +2 -0
- metadata +133 -24
- data/lib/locales/en/hobbit.yml +0 -19
- data/lib/locales/en/lord_of_the_rings.yml +0 -6
- data/lib/locales/ja.yml +0 -101
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Faker
|
4
|
+
class Mountain < Base
|
5
|
+
class << self
|
6
|
+
##
|
7
|
+
# Produces a name of a mountain
|
8
|
+
#
|
9
|
+
# @return [String]
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# Faker::Mountain.name #=> "Mount Everest"
|
13
|
+
#
|
14
|
+
# @faker.version next
|
15
|
+
def name
|
16
|
+
fetch('mountain.name')
|
17
|
+
end
|
18
|
+
|
19
|
+
##
|
20
|
+
# Produces a name of a range
|
21
|
+
#
|
22
|
+
# @return [String]
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# Faker::Mountain.range #=> "Dhaulagiri Himalaya"
|
26
|
+
#
|
27
|
+
# @faker.version next
|
28
|
+
def range
|
29
|
+
fetch('mountain.range')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/faker/default/name.rb
CHANGED
@@ -5,14 +5,41 @@ module Faker
|
|
5
5
|
flexible :name
|
6
6
|
|
7
7
|
class << self
|
8
|
+
##
|
9
|
+
# Produces a random name.
|
10
|
+
#
|
11
|
+
# @return [String]
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# Faker::Name.name #=> "Tyshawn Johns Sr."
|
15
|
+
#
|
16
|
+
# @faker.version 0.9.0
|
8
17
|
def name
|
9
18
|
parse('name.name')
|
10
19
|
end
|
11
20
|
|
21
|
+
##
|
22
|
+
# Produces a random name with middle name.
|
23
|
+
#
|
24
|
+
# @return [String]
|
25
|
+
#
|
26
|
+
# @example
|
27
|
+
# Faker::Name.name_with_middle #=> "Aditya Elton Douglas"
|
28
|
+
#
|
29
|
+
# @faker.version 1.6.4
|
12
30
|
def name_with_middle
|
13
31
|
parse('name.name_with_middle')
|
14
32
|
end
|
15
33
|
|
34
|
+
##
|
35
|
+
# Produces a random first name.
|
36
|
+
#
|
37
|
+
# @return [String]
|
38
|
+
#
|
39
|
+
# @example
|
40
|
+
# Faker::Name.first_name #=> "Kaci"
|
41
|
+
#
|
42
|
+
# @faker.version 0.9.0
|
16
43
|
def first_name
|
17
44
|
if parse('name.first_name').empty?
|
18
45
|
fetch('name.first_name')
|
@@ -21,31 +48,102 @@ module Faker
|
|
21
48
|
end
|
22
49
|
end
|
23
50
|
|
51
|
+
##
|
52
|
+
# Produces a random male first name.
|
53
|
+
#
|
54
|
+
# @return [String]
|
55
|
+
#
|
56
|
+
# @example
|
57
|
+
# Faker::Name.male_first_name #=> "Edward"
|
58
|
+
#
|
59
|
+
# @faker.version 1.9.1
|
24
60
|
def male_first_name
|
25
61
|
fetch('name.male_first_name')
|
26
62
|
end
|
27
63
|
alias first_name_men male_first_name
|
28
64
|
alias masculine_name male_first_name
|
29
65
|
|
66
|
+
##
|
67
|
+
# Produces a random female first name.
|
68
|
+
#
|
69
|
+
# @return [String]
|
70
|
+
#
|
71
|
+
# @example
|
72
|
+
# Faker::Name.female_first_name #=> "Natasha"
|
73
|
+
#
|
74
|
+
# @faker.version 1.9.1
|
30
75
|
def female_first_name
|
31
76
|
fetch('name.female_first_name')
|
32
77
|
end
|
33
78
|
alias first_name_women female_first_name
|
34
79
|
alias feminine_name female_first_name
|
35
80
|
|
81
|
+
##
|
82
|
+
# Produces a random gender neutral first name.
|
83
|
+
#
|
84
|
+
# @return [String]
|
85
|
+
#
|
86
|
+
# @example
|
87
|
+
# Faker::Name.neutral_first_name #=> "Casey"
|
88
|
+
#
|
89
|
+
# @faker.version 2.13.0
|
90
|
+
def neutral_first_name
|
91
|
+
fetch('name.neutral_first_name')
|
92
|
+
end
|
93
|
+
alias first_name_neutral neutral_first_name
|
94
|
+
alias gender_neutral_first_name neutral_first_name
|
95
|
+
|
96
|
+
##
|
97
|
+
# Produces a random last name.
|
98
|
+
#
|
99
|
+
# @return [String]
|
100
|
+
#
|
101
|
+
# @example
|
102
|
+
# Faker::Name.last_name #=> "Ernser"
|
103
|
+
#
|
104
|
+
# @faker.version 0.9.0
|
36
105
|
def last_name
|
37
106
|
parse('name.last_name')
|
38
107
|
end
|
39
108
|
alias middle_name last_name
|
40
109
|
|
110
|
+
##
|
111
|
+
# Produces a random name prefix.
|
112
|
+
#
|
113
|
+
# @return [String]
|
114
|
+
#
|
115
|
+
# @example
|
116
|
+
# Faker::Name.prefix #=> "Mr."
|
117
|
+
#
|
118
|
+
# @faker.version 0.9.0
|
41
119
|
def prefix
|
42
120
|
fetch('name.prefix')
|
43
121
|
end
|
44
122
|
|
123
|
+
##
|
124
|
+
# Produces a random name suffix.
|
125
|
+
#
|
126
|
+
# @return [String]
|
127
|
+
#
|
128
|
+
# @example
|
129
|
+
# Faker::Name.suffix #=> "IV"
|
130
|
+
#
|
131
|
+
# @faker.version 0.9.0
|
45
132
|
def suffix
|
46
133
|
fetch('name.suffix')
|
47
134
|
end
|
48
135
|
|
136
|
+
##
|
137
|
+
# Produces random initials.
|
138
|
+
#
|
139
|
+
# @param number [Integer] Number of digits that the generated initials should have.
|
140
|
+
# @return [String]
|
141
|
+
#
|
142
|
+
# @example
|
143
|
+
# Faker::Name.initials #=> "NJM"
|
144
|
+
# Faker::Name.initials(number: 2) #=> "NM"
|
145
|
+
#
|
146
|
+
# @faker.version 1.8.5
|
49
147
|
def initials(legacy_number = NOT_GIVEN, number: 3)
|
50
148
|
warn_for_deprecated_arguments do |keywords|
|
51
149
|
keywords << :number if legacy_number != NOT_GIVEN
|
data/lib/faker/default/nhs.rb
CHANGED
@@ -3,6 +3,15 @@
|
|
3
3
|
module Faker
|
4
4
|
class NationalHealthService < Base
|
5
5
|
class << self
|
6
|
+
##
|
7
|
+
# Produces a random British NHS number.
|
8
|
+
#
|
9
|
+
# @return [String]
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# Faker::NationalHealthService.british_number #=> "403 958 5577"
|
13
|
+
#
|
14
|
+
# @faker.version 1.9.2
|
6
15
|
def british_number
|
7
16
|
base_number = rand(400_000_001...499_999_999)
|
8
17
|
# If the check digit is equivalent to 10, the number is invalid.
|
@@ -15,6 +24,16 @@ module Faker
|
|
15
24
|
.join('')
|
16
25
|
end
|
17
26
|
|
27
|
+
##
|
28
|
+
# Produces a random British NHS number's check digit.
|
29
|
+
#
|
30
|
+
# @param number [Integer] Specifies the NHS number the check digit belongs to.
|
31
|
+
# @return [Integer]
|
32
|
+
#
|
33
|
+
# @example
|
34
|
+
# Faker::NationalHealthService.check_digit(number: 400_012_114) #=> 6
|
35
|
+
#
|
36
|
+
# @faker.version 1.9.2
|
18
37
|
def check_digit(legacy_number = NOT_GIVEN, number: 0)
|
19
38
|
warn_for_deprecated_arguments do |keywords|
|
20
39
|
keywords << :number if legacy_number != NOT_GIVEN
|
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
|
##
|
@@ -85,13 +85,11 @@ module Faker
|
|
85
85
|
end
|
86
86
|
|
87
87
|
l_d = number(digits: l_digits)
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
generate(r_digits - 1).join + non_zero_digit.to_s
|
94
|
-
end
|
88
|
+
|
89
|
+
# Ensure the last digit is not zero
|
90
|
+
# so it does not get truncated on converting to float
|
91
|
+
r_d = generate(r_digits - 1).join + non_zero_digit.to_s
|
92
|
+
|
95
93
|
"#{l_d}.#{r_d}".to_f
|
96
94
|
end
|
97
95
|
|
@@ -141,11 +139,26 @@ module Faker
|
|
141
139
|
hex
|
142
140
|
end
|
143
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
|
+
|
144
157
|
##
|
145
158
|
# Produces a float given a mean and standard deviation.
|
146
159
|
#
|
147
160
|
# @param mean [Integer]
|
148
|
-
# @param standard_deviation [
|
161
|
+
# @param standard_deviation [Numeric]
|
149
162
|
# @return [Float]
|
150
163
|
#
|
151
164
|
# @example
|
@@ -167,12 +180,13 @@ module Faker
|
|
167
180
|
##
|
168
181
|
# Produces a number between two provided values. Boundaries are inclusive.
|
169
182
|
#
|
170
|
-
# @param from [
|
171
|
-
# @param to [
|
172
|
-
# @return [
|
183
|
+
# @param from [Numeric] The lowest number to include.
|
184
|
+
# @param to [Numeric] The highest number to include.
|
185
|
+
# @return [Numeric]
|
173
186
|
#
|
174
187
|
# @example
|
175
188
|
# Faker::Number.between(from: 1, to: 10) #=> 7
|
189
|
+
# Faker::Number.between(from: 0.0, to: 1.0) #=> 0.7844640543957383
|
176
190
|
#
|
177
191
|
# @faker.version 1.0.0
|
178
192
|
def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 1.00, to: 5000.00)
|
@@ -188,10 +202,11 @@ module Faker
|
|
188
202
|
# Produces a number within two provided values. Boundaries are inclusive or exclusive depending on the range passed.
|
189
203
|
#
|
190
204
|
# @param range [Range] The range from which to generate a number.
|
191
|
-
# @return [
|
205
|
+
# @return [Numeric]
|
192
206
|
#
|
193
207
|
# @example
|
194
208
|
# Faker::Number.within(range: 1..10) #=> 7
|
209
|
+
# Faker::Number.within(range: 0.0..1.0) #=> 0.7844640543957383
|
195
210
|
#
|
196
211
|
# @faker.version 1.0.0
|
197
212
|
def within(legacy_range = NOT_GIVEN, range: 1.00..5000.00)
|
@@ -9,6 +9,8 @@ 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
|
@@ -16,8 +18,18 @@ module Faker
|
|
16
18
|
|
17
19
|
class << self
|
18
20
|
# rubocop:disable Metrics/ParameterLists
|
21
|
+
|
22
|
+
##
|
23
|
+
# Generate a mock Omniauth response from Google.
|
24
|
+
#
|
25
|
+
# @param name [String] A specific name to return in the response.
|
26
|
+
# @param email [String] A specific email to return in the response.
|
27
|
+
# @param uid [String] A specific UID to return in the response.
|
28
|
+
#
|
29
|
+
# @return [Hash] An auth hash in the format provided by omniauth-google.
|
30
|
+
#
|
31
|
+
# @faker.version 1.8.0
|
19
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)
|
20
|
-
# rubocop:enable Metrics/ParameterLists
|
21
33
|
warn_for_deprecated_arguments do |keywords|
|
22
34
|
keywords << :name if legacy_name != NOT_GIVEN
|
23
35
|
keywords << :email if legacy_email != NOT_GIVEN
|
@@ -72,9 +84,18 @@ module Faker
|
|
72
84
|
}
|
73
85
|
end
|
74
86
|
|
75
|
-
|
87
|
+
##
|
88
|
+
# Generate a mock Omniauth response from Facebook.
|
89
|
+
#
|
90
|
+
# @param name [String] A specific name to return in the response.
|
91
|
+
# @param email [String] A specific email to return in the response.
|
92
|
+
# @param username [String] A specific username to return in the response.
|
93
|
+
# @param uid [String] A specific UID to return in the response.
|
94
|
+
#
|
95
|
+
# @return [Hash] An auth hash in the format provided by omniauth-facebook.
|
96
|
+
#
|
97
|
+
# @faker.version 1.8.0
|
76
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)
|
77
|
-
# rubocop:enable Metrics/ParameterLists
|
78
99
|
warn_for_deprecated_arguments do |keywords|
|
79
100
|
keywords << :name if legacy_name != NOT_GIVEN
|
80
101
|
keywords << :email if legacy_email != NOT_GIVEN
|
@@ -123,9 +144,17 @@ module Faker
|
|
123
144
|
}
|
124
145
|
end
|
125
146
|
|
126
|
-
|
147
|
+
##
|
148
|
+
# Generate a mock Omniauth response from Twitter.
|
149
|
+
#
|
150
|
+
# @param name [String] A specific name to return in the response.
|
151
|
+
# @param nickname [String] A specific nickname to return in the response.
|
152
|
+
# @param uid [String] A specific UID to return in the response.
|
153
|
+
#
|
154
|
+
# @return [Hash] An auth hash in the format provided by omniauth-twitter.
|
155
|
+
#
|
156
|
+
# @faker.version 1.8.0
|
127
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)
|
128
|
-
# rubocop:enable Metrics/ParameterLists
|
129
158
|
warn_for_deprecated_arguments do |keywords|
|
130
159
|
keywords << :name if legacy_name != NOT_GIVEN
|
131
160
|
keywords << :nickname if legacy_nickname != NOT_GIVEN
|
@@ -204,9 +233,17 @@ module Faker
|
|
204
233
|
}
|
205
234
|
end
|
206
235
|
|
207
|
-
|
236
|
+
##
|
237
|
+
# Generate a mock Omniauth response from LinkedIn.
|
238
|
+
#
|
239
|
+
# @param name [String] A specific name to return in the response.
|
240
|
+
# @param email [String] A specific email to return in the response.
|
241
|
+
# @param uid [String] A specific UID to return in the response.
|
242
|
+
#
|
243
|
+
# @return [Hash] An auth hash in the format provided by omniauth-linkedin.
|
244
|
+
#
|
245
|
+
# @faker.version 1.8.0
|
208
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)
|
209
|
-
# rubocop:enable Metrics/ParameterLists
|
210
247
|
warn_for_deprecated_arguments do |keywords|
|
211
248
|
keywords << :name if legacy_name != NOT_GIVEN
|
212
249
|
keywords << :email if legacy_email != NOT_GIVEN
|
@@ -275,9 +312,17 @@ module Faker
|
|
275
312
|
}
|
276
313
|
end
|
277
314
|
|
278
|
-
|
315
|
+
##
|
316
|
+
# Generate a mock Omniauth response from Github.
|
317
|
+
#
|
318
|
+
# @param name [String] A specific name to return in the response.
|
319
|
+
# @param email [String] A specific email to return in the response.
|
320
|
+
# @param uid [String] A specific UID to return in the response.
|
321
|
+
#
|
322
|
+
# @return [Hash] An auth hash in the format provided by omniauth-github.
|
323
|
+
#
|
324
|
+
# @faker.version 1.8.0
|
279
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)
|
280
|
-
# rubocop:enable Metrics/ParameterLists
|
281
326
|
warn_for_deprecated_arguments do |keywords|
|
282
327
|
keywords << :name if legacy_name != NOT_GIVEN
|
283
328
|
keywords << :email if legacy_email != NOT_GIVEN
|
@@ -340,15 +385,18 @@ module Faker
|
|
340
385
|
}
|
341
386
|
}
|
342
387
|
end
|
388
|
+
# rubocop:enable Metrics/ParameterLists
|
343
389
|
|
344
390
|
##
|
345
|
-
# Generate a mock Omniauth response from Apple
|
391
|
+
# Generate a mock Omniauth response from Apple.
|
392
|
+
#
|
393
|
+
# @param name [String] A specific name to return in the response.
|
394
|
+
# @param email [String] A specific email to return in the response.
|
395
|
+
# @param uid [String] A specific UID to return in the response.
|
346
396
|
#
|
347
|
-
# @
|
348
|
-
# @param email [String] A specific email to return in the response
|
349
|
-
# @param uid [String] A specific UID to return in the response
|
397
|
+
# @return [Hash] An auth hash in the format provided by omniauth-apple.
|
350
398
|
#
|
351
|
-
# @
|
399
|
+
# @faker.version 2.3.0
|
352
400
|
def apple(name: nil, email: nil, uid: nil)
|
353
401
|
uid ||= "#{Number.number(digits: 6)}.#{Number.hexadecimal(digits: 32)}.#{Number.number(digits: 4)}"
|
354
402
|
auth = Omniauth.new(name: name, email: email)
|
@@ -3,43 +3,126 @@
|
|
3
3
|
module Faker
|
4
4
|
class PhoneNumber < Base
|
5
5
|
class << self
|
6
|
+
##
|
7
|
+
# Produces a random phone number in a random format (may or may not have a country code, extension and can have different dividers).
|
8
|
+
#
|
9
|
+
# @return [String]
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# Faker::PhoneNumber.phone_number #=> "397.693.1309 x4321"
|
13
|
+
#
|
14
|
+
# @faker.version 0.3.0
|
6
15
|
def phone_number
|
7
16
|
parse('phone_number.formats')
|
8
17
|
end
|
9
18
|
|
19
|
+
##
|
20
|
+
# Produces a random cell phone number in a random format (may or may not have a country code and can have different dividers).
|
21
|
+
#
|
22
|
+
# @return [String]
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# Faker::PhoneNumber.cell_phone #=> "(186)285-7925"
|
26
|
+
#
|
27
|
+
# @faker.version 1.0.0
|
10
28
|
def cell_phone
|
11
29
|
parse('cell_phone.formats')
|
12
30
|
end
|
13
31
|
|
32
|
+
##
|
33
|
+
# Produces a random country code.
|
34
|
+
#
|
35
|
+
# @return [String]
|
36
|
+
#
|
37
|
+
# @example
|
38
|
+
# Faker::PhoneNumber.country_code #=> "+20"
|
39
|
+
#
|
40
|
+
# @faker.version 1.9.2
|
14
41
|
def country_code
|
15
42
|
"+#{fetch('country_code')}"
|
16
43
|
end
|
17
44
|
|
45
|
+
##
|
46
|
+
# Produces a random phone number with country code.
|
47
|
+
#
|
48
|
+
# @return [String]
|
49
|
+
#
|
50
|
+
# @example
|
51
|
+
# Faker::PhoneNumber.phone_number_with_country_code #=> "+95 1-672-173-8153"
|
52
|
+
#
|
53
|
+
# @faker.version 1.9.2
|
18
54
|
def phone_number_with_country_code
|
19
55
|
"#{country_code} #{phone_number}"
|
20
56
|
end
|
21
57
|
|
58
|
+
##
|
59
|
+
# Produces a random cell phone number with country code.
|
60
|
+
#
|
61
|
+
# @return [String]
|
62
|
+
#
|
63
|
+
# @example
|
64
|
+
# Faker::PhoneNumber.cell_phone_with_country_code #=> "+974 (190) 987-9034"
|
65
|
+
#
|
66
|
+
# @faker.version 1.9.2
|
22
67
|
def cell_phone_with_country_code
|
23
68
|
"#{country_code} #{cell_phone}"
|
24
69
|
end
|
25
70
|
|
26
|
-
|
71
|
+
##
|
72
|
+
# Produces a random phone number in e164 format.
|
73
|
+
#
|
74
|
+
# @return [String]
|
75
|
+
#
|
76
|
+
# @example
|
77
|
+
# Faker::PhoneNumber.cell_phone_in_e164 #=> "+944937040625"
|
78
|
+
#
|
79
|
+
# @faker.version 1.9.2
|
80
|
+
def cell_phone_in_e164
|
81
|
+
cell_phone_with_country_code.delete('^+0-9')
|
82
|
+
end
|
83
|
+
|
84
|
+
##
|
85
|
+
# Produces a random US or Canada-based area code.
|
86
|
+
#
|
87
|
+
# @return [String]
|
88
|
+
#
|
89
|
+
# @example
|
90
|
+
# Faker::PhoneNumber.area_code #=> "201"
|
91
|
+
#
|
92
|
+
# @faker.version 1.3.0
|
27
93
|
def area_code
|
28
94
|
fetch('phone_number.area_code')
|
29
95
|
rescue I18n::MissingTranslationData
|
30
96
|
nil
|
31
97
|
end
|
32
98
|
|
33
|
-
|
99
|
+
##
|
100
|
+
# Produces a random US or Canada-based exchange code.
|
101
|
+
#
|
102
|
+
# @return [String]
|
103
|
+
#
|
104
|
+
# @example
|
105
|
+
# Faker::PhoneNumber.exchange_code #=> "208"
|
106
|
+
#
|
107
|
+
# @faker.version 1.3.0
|
34
108
|
def exchange_code
|
35
109
|
fetch('phone_number.exchange_code')
|
36
110
|
rescue I18n::MissingTranslationData
|
37
111
|
nil
|
38
112
|
end
|
39
113
|
|
40
|
-
|
41
|
-
# Can be used for both extensions and last four digits of phone number.
|
42
|
-
#
|
114
|
+
##
|
115
|
+
# Produces a random US or Canada-based extension / subscriber number. Can be used for both extensions and last four digits of phone number.
|
116
|
+
#
|
117
|
+
# @param length [Integer] Speficies the length of the return value.
|
118
|
+
# @return [String]
|
119
|
+
#
|
120
|
+
# @example
|
121
|
+
# Faker::PhoneNumber.subscriber_number #=> "3873"
|
122
|
+
# Faker::PhoneNumber.subscriber_number(length: 2) #=> "39"
|
123
|
+
# Faker::PhoneNumber.extension #=> "3764"
|
124
|
+
#
|
125
|
+
# @faker.version 1.3.0
|
43
126
|
def subscriber_number(legacy_length = NOT_GIVEN, length: 4)
|
44
127
|
warn_for_deprecated_arguments do |keywords|
|
45
128
|
keywords << :length if legacy_length != NOT_GIVEN
|