faker 2.11.0 → 2.13.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 +160 -0
- data/README.md +11 -2
- data/lib/faker.rb +16 -10
- data/lib/faker/default/address.rb +31 -1
- data/lib/faker/default/bank.rb +79 -0
- data/lib/faker/default/blood.rb +48 -0
- data/lib/faker/default/business.rb +1 -1
- data/lib/faker/default/chile_rut.rb +44 -1
- data/lib/faker/default/commerce.rb +73 -10
- data/lib/faker/default/company.rb +40 -3
- data/lib/faker/default/compass.rb +135 -0
- data/lib/faker/default/computer.rb +63 -0
- data/lib/faker/default/construction.rb +54 -0
- data/lib/faker/default/cosmere.rb +90 -0
- data/lib/faker/default/crypto_coin.rb +45 -0
- data/lib/faker/default/date.rb +16 -12
- data/lib/faker/default/driving_licence.rb +42 -0
- data/lib/faker/default/file.rb +49 -0
- data/lib/faker/default/finance.rb +24 -0
- data/lib/faker/default/gender.rb +1 -1
- data/lib/faker/default/hipster.rb +94 -0
- data/lib/faker/default/id_number.rb +86 -0
- data/lib/faker/default/internet.rb +35 -7
- data/lib/faker/default/internet_http.rb +48 -0
- data/lib/faker/default/invoice.rb +32 -5
- data/lib/faker/default/json.rb +55 -0
- data/lib/faker/default/lorem_flickr.rb +65 -0
- data/lib/faker/default/lorem_pixel.rb +22 -0
- data/lib/faker/default/markdown.rb +89 -0
- data/lib/faker/default/measurement.rb +90 -0
- data/lib/faker/default/name.rb +98 -0
- data/lib/faker/default/nhs.rb +19 -0
- data/lib/faker/default/number.rb +5 -7
- data/lib/faker/default/omniauth.rb +58 -5
- data/lib/faker/default/phone_number.rb +88 -5
- data/lib/faker/default/placeholdit.rb +21 -0
- data/lib/faker/default/slack_emoji.rb +81 -0
- data/lib/faker/default/south_africa.rb +90 -0
- data/lib/faker/default/string.rb +19 -3
- data/lib/faker/default/stripe.rb +61 -0
- data/lib/faker/default/twitter.rb +35 -0
- data/lib/faker/default/types.rb +80 -0
- data/lib/faker/default/university.rb +45 -0
- data/lib/faker/default/vehicle.rb +184 -4
- data/lib/faker/default/verb.rb +45 -0
- data/lib/faker/default/world_cup.rb +4 -4
- data/lib/faker/games/control.rb +113 -0
- data/lib/faker/games/dnd.rb +61 -0
- data/lib/faker/games/heroes_of_the_storm.rb +16 -5
- data/lib/faker/games/minecraft.rb +48 -0
- data/lib/faker/games/warhammer_fantasy.rb +74 -0
- data/lib/faker/movies/departed.rb +49 -0
- data/lib/faker/movies/movie.rb +13 -0
- 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/rush.rb +37 -0
- data/lib/faker/music/show.rb +49 -0
- data/lib/faker/quotes/quote.rb +54 -1
- data/lib/faker/quotes/shakespeare.rb +36 -0
- data/lib/faker/tv_shows/aqua_teen_hunger_force.rb +13 -0
- data/lib/faker/tv_shows/big_bang_theory.rb +37 -0
- data/lib/faker/tv_shows/dr_who.rb +1 -1
- 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/version.rb +1 -1
- data/lib/helpers/base58.rb +1 -1
- data/lib/helpers/char.rb +22 -27
- data/lib/locales/de-CH.yml +1693 -0
- data/lib/locales/en-AU.yml +44 -10
- data/lib/locales/en-CA.yml +2 -0
- data/lib/locales/en-US.yml +29 -3
- data/lib/locales/en/address.yml +2 -0
- data/lib/locales/en/aqua_teen_hunger_force.yml +33 -1
- data/lib/locales/en/bank.yml +1 -1
- data/lib/locales/en/big_bang_theory.yml +38 -0
- data/lib/locales/en/blood.yml +13 -0
- data/lib/locales/en/computer.yml +36 -0
- data/lib/locales/en/control.yml +247 -0
- data/lib/locales/en/departed.yml +50 -0
- data/lib/locales/en/dnd.yml +54 -0
- data/lib/locales/en/futurama.yml +344 -0
- data/lib/locales/en/heroes_of_the_storm.yml +2 -2
- data/lib/locales/en/house.yml +1 -1
- data/lib/locales/en/minecraft.yml +390 -0
- data/lib/locales/en/movie.yml +192 -1
- data/lib/locales/en/name.yml +3 -2
- data/lib/locales/en/one_piece.yml +2 -2
- data/lib/locales/en/pearl_jam.yml +213 -0
- data/lib/locales/en/phish.yml +392 -1
- data/lib/locales/en/prince.yml +227 -0
- data/lib/locales/en/rush.yml +32 -0
- data/lib/locales/en/show.yml +597 -0
- data/lib/locales/en/simpsons.yml +668 -0
- data/lib/locales/en/star_wars.yml +568 -220
- data/lib/locales/en/suits.yml +45 -0
- data/lib/locales/en/warhammer_fantasy.yml +582 -0
- data/lib/locales/fr-CA.yml +2 -0
- data/lib/locales/ko.yml +82 -0
- data/lib/locales/pt-BR.yml +1 -0
- metadata +46 -17
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
|
@@ -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
|
|
|
@@ -15,6 +15,16 @@ module Faker
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
class << self
|
|
18
|
+
##
|
|
19
|
+
# Generate a mock Omniauth response from Google.
|
|
20
|
+
#
|
|
21
|
+
# @param name [String] A specific name to return in the response.
|
|
22
|
+
# @param email [String] A specific email to return in the response.
|
|
23
|
+
# @param uid [String] A specific UID to return in the response.
|
|
24
|
+
#
|
|
25
|
+
# @return [Hash] An auth hash in the format provided by omniauth-google.
|
|
26
|
+
#
|
|
27
|
+
# @faker.version 1.8.0
|
|
18
28
|
# rubocop:disable Metrics/ParameterLists
|
|
19
29
|
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
30
|
# rubocop:enable Metrics/ParameterLists
|
|
@@ -72,6 +82,17 @@ module Faker
|
|
|
72
82
|
}
|
|
73
83
|
end
|
|
74
84
|
|
|
85
|
+
##
|
|
86
|
+
# Generate a mock Omniauth response from Facebook.
|
|
87
|
+
#
|
|
88
|
+
# @param name [String] A specific name to return in the response.
|
|
89
|
+
# @param email [String] A specific email to return in the response.
|
|
90
|
+
# @param username [String] A specific username to return in the response.
|
|
91
|
+
# @param uid [String] A specific UID to return in the response.
|
|
92
|
+
#
|
|
93
|
+
# @return [Hash] An auth hash in the format provided by omniauth-facebook.
|
|
94
|
+
#
|
|
95
|
+
# @faker.version 1.8.0
|
|
75
96
|
# rubocop:disable Metrics/ParameterLists
|
|
76
97
|
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
98
|
# rubocop:enable Metrics/ParameterLists
|
|
@@ -123,6 +144,16 @@ module Faker
|
|
|
123
144
|
}
|
|
124
145
|
end
|
|
125
146
|
|
|
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
|
|
126
157
|
# rubocop:disable Metrics/ParameterLists
|
|
127
158
|
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
159
|
# rubocop:enable Metrics/ParameterLists
|
|
@@ -204,6 +235,16 @@ module Faker
|
|
|
204
235
|
}
|
|
205
236
|
end
|
|
206
237
|
|
|
238
|
+
##
|
|
239
|
+
# Generate a mock Omniauth response from LinkedIn.
|
|
240
|
+
#
|
|
241
|
+
# @param name [String] A specific name to return in the response.
|
|
242
|
+
# @param email [String] A specific email to return in the response.
|
|
243
|
+
# @param uid [String] A specific UID to return in the response.
|
|
244
|
+
#
|
|
245
|
+
# @return [Hash] An auth hash in the format provided by omniauth-linkedin.
|
|
246
|
+
#
|
|
247
|
+
# @faker.version 1.8.0
|
|
207
248
|
# rubocop:disable Metrics/ParameterLists
|
|
208
249
|
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
250
|
# rubocop:enable Metrics/ParameterLists
|
|
@@ -275,6 +316,16 @@ module Faker
|
|
|
275
316
|
}
|
|
276
317
|
end
|
|
277
318
|
|
|
319
|
+
##
|
|
320
|
+
# Generate a mock Omniauth response from Github.
|
|
321
|
+
#
|
|
322
|
+
# @param name [String] A specific name to return in the response.
|
|
323
|
+
# @param email [String] A specific email to return in the response.
|
|
324
|
+
# @param uid [String] A specific UID to return in the response.
|
|
325
|
+
#
|
|
326
|
+
# @return [Hash] An auth hash in the format provided by omniauth-github.
|
|
327
|
+
#
|
|
328
|
+
# @faker.version 1.8.0
|
|
278
329
|
# rubocop:disable Metrics/ParameterLists
|
|
279
330
|
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
331
|
# rubocop:enable Metrics/ParameterLists
|
|
@@ -342,13 +393,15 @@ module Faker
|
|
|
342
393
|
end
|
|
343
394
|
|
|
344
395
|
##
|
|
345
|
-
# Generate a mock Omniauth response from Apple
|
|
396
|
+
# Generate a mock Omniauth response from Apple.
|
|
397
|
+
#
|
|
398
|
+
# @param name [String] A specific name to return in the response.
|
|
399
|
+
# @param email [String] A specific email to return in the response.
|
|
400
|
+
# @param uid [String] A specific UID to return in the response.
|
|
346
401
|
#
|
|
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
|
|
402
|
+
# @return [Hash] An auth hash in the format provided by omniauth-apple.
|
|
350
403
|
#
|
|
351
|
-
# @
|
|
404
|
+
# @faker.version 2.3.0
|
|
352
405
|
def apple(name: nil, email: nil, uid: nil)
|
|
353
406
|
uid ||= "#{Number.number(digits: 6)}.#{Number.hexadecimal(digits: 32)}.#{Number.number(digits: 4)}"
|
|
354
407
|
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
|
|
@@ -5,6 +5,27 @@ module Faker
|
|
|
5
5
|
class << self
|
|
6
6
|
SUPPORTED_FORMATS = %w[png jpg gif jpeg].freeze
|
|
7
7
|
|
|
8
|
+
##
|
|
9
|
+
# Produces a random placeholder image from https://placehold.it.
|
|
10
|
+
#
|
|
11
|
+
# @param size [String] Specifies the image's size, dimensions separated by 'x'.
|
|
12
|
+
# @param format [String] Specifies the image's extension.
|
|
13
|
+
# @param background_color [String, Symbol] Specifies the background color, either in hexadecimal format (without #) or as :random.
|
|
14
|
+
# @param text_color [String, Symbol] Specifies the text color, either in hexadecimal format (without #) or as :random.
|
|
15
|
+
# @param text [String] Specifies a custom text to be used.
|
|
16
|
+
# @return [String]
|
|
17
|
+
#
|
|
18
|
+
# @example
|
|
19
|
+
# # Keyword arguments: size, format, background_color, text_color, text
|
|
20
|
+
# Faker::Placeholdit.image #=> "https://placehold.it/300x300.png"
|
|
21
|
+
# Faker::Placeholdit.image(size: '50x50') #=> "https://placehold.it/50x50.png"
|
|
22
|
+
# Faker::Placeholdit.image(size: '50x50', format: 'jpg') #=> "https://placehold.it/50x50.jpg"
|
|
23
|
+
# Faker::Placeholdit.image(size: '50x50', format: 'gif', background_color: 'ffffff') #=> "https://placehold.it/50x50.gif/ffffff"
|
|
24
|
+
# Faker::Placeholdit.image(size: '50x50', format: 'jpeg', background_color: :random) #=> "https://placehold.it/50x50.jpeg/39eba7"
|
|
25
|
+
# Faker::Placeholdit.image(size: '50x50', format: 'jpeg', background_color: 'ffffff', text_color: '000') #=> "https://placehold.it/50x50.jpeg/ffffff/000"
|
|
26
|
+
# 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
|
+
#
|
|
28
|
+
# @faker.version 1.6.0
|
|
8
29
|
# rubocop:disable Metrics/ParameterLists
|
|
9
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)
|
|
10
31
|
# rubocop:enable Metrics/ParameterLists
|