faker 2.15.1 → 2.16.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 +31 -0
- data/History.md +4 -4
- data/README.md +2 -1
- data/lib/faker.rb +1 -1
- data/lib/faker/blockchain/tezos.rb +28 -0
- data/lib/faker/default/app.rb +1 -1
- data/lib/faker/default/avatar.rb +1 -1
- data/lib/faker/default/barcode.rb +33 -22
- data/lib/faker/default/cannabis.rb +10 -0
- data/lib/faker/default/chuck_norris.rb +1 -0
- data/lib/faker/default/code.rb +2 -2
- data/lib/faker/default/company.rb +18 -0
- data/lib/faker/default/driving_licence.rb +3 -2
- data/lib/faker/default/file.rb +6 -4
- data/lib/faker/default/hipster.rb +6 -6
- data/lib/faker/default/internet.rb +227 -2
- data/lib/faker/default/json.rb +3 -2
- data/lib/faker/default/lorem.rb +158 -3
- data/lib/faker/default/lorem_flickr.rb +3 -8
- data/lib/faker/default/lorem_pixel.rb +2 -1
- data/lib/faker/default/markdown.rb +4 -2
- data/lib/faker/default/omniauth.rb +3 -10
- data/lib/faker/default/placeholdit.rb +3 -2
- data/lib/faker/default/string.rb +3 -2
- data/lib/faker/games/touhou.rb +75 -0
- data/lib/faker/movies/star_wars.rb +72 -0
- data/lib/faker/music/rock_band.rb +12 -0
- data/lib/faker/quotes/rajnikanth.rb +1 -0
- data/lib/faker/quotes/shakespeare.rb +34 -0
- data/lib/faker/tv_shows/big_bang_theory.rb +1 -1
- data/lib/faker/tv_shows/suits.rb +1 -1
- data/lib/faker/version.rb +1 -1
- data/lib/locales/en/football.yml +3 -3
- data/lib/locales/en/lebowski.yml +1 -1
- data/lib/locales/en/rock_band.yml +1 -0
- data/lib/locales/en/super_smash_bros.yml +2 -0
- data/lib/locales/en/touhou.yml +839 -0
- data/lib/locales/fr.yml +4 -4
- data/lib/locales/ja.yml +5 -0
- metadata +10 -8
@@ -6,6 +6,8 @@ module Faker
|
|
6
6
|
NI_CHANCE = 0.03 # NI Pop is about 3% of total UK population
|
7
7
|
|
8
8
|
class << self
|
9
|
+
# rubocop:disable Metrics/ParameterLists
|
10
|
+
|
9
11
|
##
|
10
12
|
# Produces a random British driving licence number.
|
11
13
|
#
|
@@ -23,9 +25,7 @@ module Faker
|
|
23
25
|
# date_of_birth: Date.parse("1986-10-24")) #=> "OCARR815246J91HT"
|
24
26
|
#
|
25
27
|
# @faker.version 1.9.2
|
26
|
-
# rubocop:disable Metrics/ParameterLists
|
27
28
|
def british_driving_licence(legacy_last_name = NOT_GIVEN, legacy_initials = NOT_GIVEN, legacy_gender = NOT_GIVEN, legacy_date_of_birth = NOT_GIVEN, last_name: Faker::Name.last_name, initials: Faker::Name.initials, gender: random_gender, date_of_birth: Faker::Date.birthday(min_age: 18, max_age: 65))
|
28
|
-
# rubocop:enable Metrics/ParameterLists
|
29
29
|
warn_for_deprecated_arguments do |keywords|
|
30
30
|
keywords << :last_name if legacy_last_name != NOT_GIVEN
|
31
31
|
keywords << :initials if legacy_initials != NOT_GIVEN
|
@@ -40,6 +40,7 @@ module Faker
|
|
40
40
|
gb_licence_checksum
|
41
41
|
].join
|
42
42
|
end
|
43
|
+
# rubocop:enable Metrics/ParameterLists
|
43
44
|
|
44
45
|
##
|
45
46
|
# Produces a random Northern Irish licence number.
|
data/lib/faker/default/file.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
module Faker
|
4
4
|
class File < Base
|
5
5
|
class << self
|
6
|
+
# rubocop:disable Metrics/ParameterLists
|
7
|
+
|
6
8
|
##
|
7
9
|
# Produces a random directory name.
|
8
10
|
#
|
@@ -18,9 +20,7 @@ module Faker
|
|
18
20
|
# Faker::File.dir(segment_count: 3, root: nil, directory_separator: '\\') #=> "aut-ullam\\quia_quisquam\\ut-eos"
|
19
21
|
#
|
20
22
|
# @faker.version 1.6.4
|
21
|
-
# rubocop:disable Metrics/ParameterLists
|
22
23
|
def dir(legacy_segment_count = NOT_GIVEN, legacy_root = NOT_GIVEN, legacy_directory_separator = NOT_GIVEN, segment_count: 3, root: nil, directory_separator: ::File::Separator)
|
23
|
-
# rubocop:enable Metrics/ParameterLists
|
24
24
|
warn_for_deprecated_arguments do |keywords|
|
25
25
|
keywords << :segment_count if legacy_segment_count != NOT_GIVEN
|
26
26
|
keywords << :root if legacy_root != NOT_GIVEN
|
@@ -34,6 +34,7 @@ module Faker
|
|
34
34
|
.join(directory_separator)
|
35
35
|
.squeeze(directory_separator)
|
36
36
|
end
|
37
|
+
# rubocop:enable Metrics/ParameterLists
|
37
38
|
|
38
39
|
##
|
39
40
|
# Produces a random file extension.
|
@@ -61,6 +62,8 @@ module Faker
|
|
61
62
|
fetch('file.mime_type')
|
62
63
|
end
|
63
64
|
|
65
|
+
# rubocop:disable Metrics/ParameterLists
|
66
|
+
|
64
67
|
##
|
65
68
|
# Produces a random file name.
|
66
69
|
#
|
@@ -77,9 +80,7 @@ module Faker
|
|
77
80
|
# Faker::File.file_name(dir: 'foo/bar', name: 'baz', ext: 'mp3', directory_separator: '\\') #=> "foo/bar\\baz.mp3"
|
78
81
|
#
|
79
82
|
# @faker.version 1.6.4
|
80
|
-
# rubocop:disable Metrics/ParameterLists
|
81
83
|
def file_name(legacy_dir = NOT_GIVEN, legacy_name = NOT_GIVEN, legacy_ext = NOT_GIVEN, legacy_directory_separator = NOT_GIVEN, dir: nil, name: nil, ext: nil, directory_separator: ::File::Separator)
|
82
|
-
# rubocop:enable Metrics/ParameterLists
|
83
84
|
warn_for_deprecated_arguments do |keywords|
|
84
85
|
keywords << :dir if legacy_dir != NOT_GIVEN
|
85
86
|
keywords << :name if legacy_name != NOT_GIVEN
|
@@ -93,6 +94,7 @@ module Faker
|
|
93
94
|
|
94
95
|
[dir, name].join(directory_separator) + ".#{ext}"
|
95
96
|
end
|
97
|
+
# rubocop:enable Metrics/ParameterLists
|
96
98
|
end
|
97
99
|
end
|
98
100
|
end
|
@@ -17,6 +17,8 @@ module Faker
|
|
17
17
|
random_word =~ /\s/ ? word : random_word
|
18
18
|
end
|
19
19
|
|
20
|
+
# rubocop:disable Metrics/ParameterLists
|
21
|
+
|
20
22
|
##
|
21
23
|
# Produces a random hipster word.
|
22
24
|
#
|
@@ -32,9 +34,7 @@ module Faker
|
|
32
34
|
# Faker::Hipster.words(number: 4, supplemental: true, spaces_allowed: true) #=> ["qui", "magni", "craft beer", "est"]
|
33
35
|
#
|
34
36
|
# @faker.version 1.6.0
|
35
|
-
# rubocop:disable Metrics/ParameterLists
|
36
37
|
def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_spaces_allowed = NOT_GIVEN, number: 3, supplemental: false, spaces_allowed: false)
|
37
|
-
# rubocop:enable Metrics/ParameterLists
|
38
38
|
warn_for_deprecated_arguments do |keywords|
|
39
39
|
keywords << :number if legacy_number != NOT_GIVEN
|
40
40
|
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
@@ -73,9 +73,7 @@ module Faker
|
|
73
73
|
# Faker::Hipster.sentence(word_count: 3, supplemental: true, random_words_to_add: 0, open_compounds_allowed: false) #=> "Dreamcatcher umami fixie."
|
74
74
|
#
|
75
75
|
# @faker.version 1.6.0
|
76
|
-
# rubocop:disable Metrics/ParameterLists
|
77
76
|
def sentence(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, supplemental: false, random_words_to_add: 6, open_compounds_allowed: true)
|
78
|
-
# rubocop:enable Metrics/ParameterLists
|
79
77
|
warn_for_deprecated_arguments do |keywords|
|
80
78
|
keywords << :word_count if legacy_word_count != NOT_GIVEN
|
81
79
|
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
@@ -84,6 +82,7 @@ module Faker
|
|
84
82
|
|
85
83
|
"#{words(number: word_count + rand(random_words_to_add.to_i).to_i, supplemental: supplemental, spaces_allowed: open_compounds_allowed).join(' ').capitalize}."
|
86
84
|
end
|
85
|
+
# rubocop:enable Metrics/ParameterLists
|
87
86
|
|
88
87
|
##
|
89
88
|
# Produces random hipster sentences.
|
@@ -111,6 +110,8 @@ module Faker
|
|
111
110
|
end
|
112
111
|
end
|
113
112
|
|
113
|
+
# rubocop:disable Metrics/ParameterLists
|
114
|
+
|
114
115
|
##
|
115
116
|
# Produces a random hipster paragraph.
|
116
117
|
#
|
@@ -127,9 +128,7 @@ module Faker
|
|
127
128
|
# Faker::Hipster.paragraph(sentence_count: 2, supplemental: true, random_sentences_to_add: 4) #=> "Deep v gluten-free unde waistcoat aperiam migas voluptas dolorum. Aut drinking illo sustainable sapiente. Direct trade fanny pack kale chips ennui semiotics."
|
128
129
|
#
|
129
130
|
# @faker.version 1.6.0
|
130
|
-
# rubocop:disable Metrics/ParameterLists
|
131
131
|
def paragraph(legacy_sentence_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_sentences_to_add = NOT_GIVEN, sentence_count: 3, supplemental: false, random_sentences_to_add: 3)
|
132
|
-
# rubocop:enable Metrics/ParameterLists
|
133
132
|
warn_for_deprecated_arguments do |keywords|
|
134
133
|
keywords << :sentence_count if legacy_sentence_count != NOT_GIVEN
|
135
134
|
keywords << :supplemental if legacy_supplemental != NOT_GIVEN
|
@@ -138,6 +137,7 @@ module Faker
|
|
138
137
|
|
139
138
|
sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i, supplemental: supplemental).join(' ')
|
140
139
|
end
|
140
|
+
# rubocop:enable Metrics/ParameterLists
|
141
141
|
|
142
142
|
##
|
143
143
|
# Produces random hipster paragraphs.
|
@@ -3,6 +3,20 @@
|
|
3
3
|
module Faker
|
4
4
|
class Internet < Base
|
5
5
|
class << self
|
6
|
+
##
|
7
|
+
# Returns the email address
|
8
|
+
#
|
9
|
+
# @return [String]
|
10
|
+
#
|
11
|
+
# @param name [String]
|
12
|
+
# @param separators [Array]
|
13
|
+
# @param domain [String]
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# Faker::Internet.email #=> "samsmith@faker.com"
|
17
|
+
# Faker::Internet.email(name: 'smith') #=> "smith@faker.com"
|
18
|
+
# Faker::Internet.email(name: 'sam smith', separators: ['-']) #=> "sam-smith@faker.com"
|
19
|
+
# Faker::Internet.email(name: 'sam smith', separators: ['-'], domain: 'gmail') #=> "sam-smith@gmail.com"
|
6
20
|
def email(legacy_name = NOT_GIVEN, legacy_separators = NOT_GIVEN, name: nil, separators: nil, domain: nil)
|
7
21
|
warn_for_deprecated_arguments do |keywords|
|
8
22
|
keywords << :name if legacy_name != NOT_GIVEN
|
@@ -19,6 +33,16 @@ module Faker
|
|
19
33
|
construct_email(sanitized_local_part, domain_name(domain: domain))
|
20
34
|
end
|
21
35
|
|
36
|
+
##
|
37
|
+
# Returns the email address with doamin either gmail.com, yahoo.com or hotmail.com
|
38
|
+
#
|
39
|
+
# @return [String]
|
40
|
+
#
|
41
|
+
# @param name [String]
|
42
|
+
#
|
43
|
+
# @example
|
44
|
+
# Faker::Internet.free_email #=> "samsmith@gmail.com"
|
45
|
+
# Faker::Internet.free_email(name: 'smith') #=> "smith@yahoo.com"
|
22
46
|
def free_email(legacy_name = NOT_GIVEN, name: nil)
|
23
47
|
warn_for_deprecated_arguments do |keywords|
|
24
48
|
keywords << :name if legacy_name != NOT_GIVEN
|
@@ -30,6 +54,16 @@ module Faker
|
|
30
54
|
)
|
31
55
|
end
|
32
56
|
|
57
|
+
##
|
58
|
+
# Returns the email address with fixed domain name as 'example'
|
59
|
+
#
|
60
|
+
# @return [String]
|
61
|
+
#
|
62
|
+
# @param name [String]
|
63
|
+
#
|
64
|
+
# @example
|
65
|
+
# Faker::Internet.safe_email #=> "samsmith@example.com"
|
66
|
+
# Faker::Internet.safe_email(name: 'smith') #=> "smith@example.net"
|
33
67
|
def safe_email(legacy_name = NOT_GIVEN, name: nil)
|
34
68
|
warn_for_deprecated_arguments do |keywords|
|
35
69
|
keywords << :name if legacy_name != NOT_GIVEN
|
@@ -41,6 +75,19 @@ module Faker
|
|
41
75
|
)
|
42
76
|
end
|
43
77
|
|
78
|
+
##
|
79
|
+
# Returns the username
|
80
|
+
#
|
81
|
+
# @return [String]
|
82
|
+
#
|
83
|
+
# @param specifier [Integer, Range] When int value passed it returns the username longer than specifier. Max value can be 10^6
|
84
|
+
# @param separator [Array]
|
85
|
+
#
|
86
|
+
# @wxample
|
87
|
+
# Faker::Internet.username(specifier: 10) #=> "lulu.goodwin"
|
88
|
+
# Faker::Internet.username(specifier: 5..10) #=> "morris"
|
89
|
+
# Faker::Internet.username(specifier: 5..10) #=> "berryberry"
|
90
|
+
# Faker::Internet.username(specifier: 20, separators: ['-']) #=> "nikki_sawaynnikki_saway"
|
44
91
|
def username(legacy_specifier = NOT_GIVEN, legacy_separators = NOT_GIVEN, specifier: nil, separators: %w[. _])
|
45
92
|
warn_for_deprecated_arguments do |keywords|
|
46
93
|
keywords << :specifier if legacy_specifier != NOT_GIVEN
|
@@ -108,7 +155,6 @@ module Faker
|
|
108
155
|
#
|
109
156
|
# @faker.version 2.1.3
|
110
157
|
def password(legacy_min_length = NOT_GIVEN, legacy_max_length = NOT_GIVEN, legacy_mix_case = NOT_GIVEN, legacy_special_characters = NOT_GIVEN, min_length: 8, max_length: 16, mix_case: true, special_characters: false)
|
111
|
-
# rubocop:enable Metrics/ParameterLists
|
112
158
|
warn_for_deprecated_arguments do |keywords|
|
113
159
|
keywords << :min_length if legacy_min_length != NOT_GIVEN
|
114
160
|
keywords << :max_length if legacy_max_length != NOT_GIVEN
|
@@ -144,7 +190,21 @@ module Faker
|
|
144
190
|
|
145
191
|
temp
|
146
192
|
end
|
193
|
+
# rubocop:enable Metrics/ParameterLists
|
147
194
|
|
195
|
+
##
|
196
|
+
# Returns the domain name
|
197
|
+
#
|
198
|
+
# @return [String]
|
199
|
+
#
|
200
|
+
# @param subdomain [Bool] If true passed adds a subdomain in response
|
201
|
+
# @param domain [String]
|
202
|
+
#
|
203
|
+
# @example
|
204
|
+
# Faker::Internet.domain_name #=> "test.net"
|
205
|
+
# Faker::Internet.domain_name(subdomain: true) #=> "test.faker.io"
|
206
|
+
# Faker::Internet.domain_name(subdomain: true, domain: 'example') #=> "faker.example.com"
|
207
|
+
# Faker::Internet.domain_name(domain: 'faker') #=> "faker.org"
|
148
208
|
def domain_name(legacy_subdomain = NOT_GIVEN, subdomain: false, domain: nil)
|
149
209
|
warn_for_deprecated_arguments do |keywords|
|
150
210
|
keywords << :subdomain if legacy_subdomain != NOT_GIVEN
|
@@ -167,6 +227,19 @@ module Faker
|
|
167
227
|
end
|
168
228
|
end
|
169
229
|
|
230
|
+
# rubocop:disable Style/AsciiComments
|
231
|
+
|
232
|
+
##
|
233
|
+
# Fixes ä, ö, ü, ß characters in string passed with ae, oe, ue, ss resp.
|
234
|
+
#
|
235
|
+
# @return [String]
|
236
|
+
#
|
237
|
+
# @param string [String]
|
238
|
+
#
|
239
|
+
# @example
|
240
|
+
# Faker::Internet.fix_umlauts #=> ""
|
241
|
+
# Faker::Internet.fix_umlauts(string: 'faker') #=> "faker"
|
242
|
+
# Faker::Internet.fix_umlauts(string: 'faküer') #=> "fakueer"
|
170
243
|
def fix_umlauts(legacy_string = NOT_GIVEN, string: '')
|
171
244
|
warn_for_deprecated_arguments do |keywords|
|
172
245
|
keywords << :string if legacy_string != NOT_GIVEN
|
@@ -174,15 +247,40 @@ module Faker
|
|
174
247
|
|
175
248
|
Char.fix_umlauts(string)
|
176
249
|
end
|
250
|
+
# rubocop:enable Style/AsciiComments
|
177
251
|
|
252
|
+
##
|
253
|
+
# Returns the domain word for internet
|
254
|
+
#
|
255
|
+
# @return [String]
|
256
|
+
#
|
257
|
+
# @example
|
258
|
+
# Faker::Internet.domain_word #=> "senger"
|
178
259
|
def domain_word
|
179
260
|
with_locale(:en) { Char.prepare(Company.name.split(' ').first) }
|
180
261
|
end
|
181
262
|
|
263
|
+
## Returns the domain suffix e.g. com, org, co, biz, info etc.
|
264
|
+
#
|
265
|
+
# @return [String]
|
266
|
+
#
|
267
|
+
# @wxample
|
268
|
+
# Faker::Internet.domain_suffix #=> "com"
|
269
|
+
# Faker::Internet.domain_suffix #=> "biz"
|
182
270
|
def domain_suffix
|
183
271
|
fetch('internet.domain_suffix')
|
184
272
|
end
|
185
273
|
|
274
|
+
##
|
275
|
+
# Returns the MAC address
|
276
|
+
#
|
277
|
+
# @return [String]
|
278
|
+
#
|
279
|
+
# @example
|
280
|
+
# Faker::Internet.mac_address #=> "74:d0:c9:22:95:12"
|
281
|
+
# Faker::Internet.mac_address(prefix: 'a') #=> "0a:91:ce:24:89:3b"
|
282
|
+
# Faker::Internet.mac_address(prefix: 'aa') #=> "aa:38:a0:3e:e8:41"
|
283
|
+
# Faker::Internet.mac_address(prefix: 'aa:44') #=> "aa:44:30:88:6e:95"
|
186
284
|
def mac_address(legacy_prefix = NOT_GIVEN, prefix: '')
|
187
285
|
warn_for_deprecated_arguments do |keywords|
|
188
286
|
keywords << :prefix if legacy_prefix != NOT_GIVEN
|
@@ -193,11 +291,25 @@ module Faker
|
|
193
291
|
(prefix_digits + address_digits).map { |d| format('%02x', d) }.join(':')
|
194
292
|
end
|
195
293
|
|
294
|
+
##
|
295
|
+
# Returns the IPv4 address
|
296
|
+
#
|
297
|
+
# @return [String]
|
298
|
+
#
|
299
|
+
# @example
|
300
|
+
# Faker::Internet.ip_v4_address #=> "97.117.128.93"
|
196
301
|
def ip_v4_address
|
197
302
|
[rand_in_range(0, 255), rand_in_range(0, 255),
|
198
303
|
rand_in_range(0, 255), rand_in_range(0, 255)].join('.')
|
199
304
|
end
|
200
305
|
|
306
|
+
##
|
307
|
+
# Returns the private IPv4 address
|
308
|
+
#
|
309
|
+
# @return [String]
|
310
|
+
#
|
311
|
+
# @example
|
312
|
+
# Faker::Internet.private_ip_v4_address #=> "127.120.80.42"
|
201
313
|
def private_ip_v4_address
|
202
314
|
addr = nil
|
203
315
|
loop do
|
@@ -207,6 +319,13 @@ module Faker
|
|
207
319
|
addr
|
208
320
|
end
|
209
321
|
|
322
|
+
##
|
323
|
+
# Returns the public IPv4 address
|
324
|
+
#
|
325
|
+
# @return [String]
|
326
|
+
#
|
327
|
+
# @example
|
328
|
+
# Faker::Internet.public_ip_v4_address #=> "127.120.80.42"
|
210
329
|
def public_ip_v4_address
|
211
330
|
addr = nil
|
212
331
|
loop do
|
@@ -216,6 +335,13 @@ module Faker
|
|
216
335
|
addr
|
217
336
|
end
|
218
337
|
|
338
|
+
##
|
339
|
+
# Returns the private network regular expressions
|
340
|
+
#
|
341
|
+
# @return [Array]
|
342
|
+
#
|
343
|
+
# @example
|
344
|
+
# Faker::Internet.private_nets_regex #=> [/^10\./, /^100\.(6[4-9]|[7-9]\d|1[0-1]\d|12[0-7])\./, /^127\./, /^169\.254\./, /^172\.(1[6-9]|2\d|3[0-1])\./, /^192\.0\.0\./, /^192\.168\./, /^198\.(1[8-9])\./]
|
219
345
|
def private_nets_regex
|
220
346
|
[
|
221
347
|
/^10\./, # 10.0.0.0 - 10.255.255.255
|
@@ -229,10 +355,25 @@ module Faker
|
|
229
355
|
]
|
230
356
|
end
|
231
357
|
|
358
|
+
##
|
359
|
+
# Returns lambda to check if address passed is private or not
|
360
|
+
#
|
361
|
+
# @return [Lambda]
|
362
|
+
#
|
363
|
+
# @example
|
364
|
+
# Faker::Internet.private_net_checker.call("127.120.80.42") #=> true
|
365
|
+
# Faker::Internet.private_net_checker.call("148.120.80.42") #=> false
|
232
366
|
def private_net_checker
|
233
367
|
->(addr) { private_nets_regex.any? { |net| net =~ addr } }
|
234
368
|
end
|
235
369
|
|
370
|
+
##
|
371
|
+
# Returns the reserved network regular expressions
|
372
|
+
#
|
373
|
+
# @return [Array]
|
374
|
+
#
|
375
|
+
# @example
|
376
|
+
# Faker::Internet.reserved_nets_regex #=> [/^0\./, /^192\.0\.2\./, /^192\.88\.99\./, /^198\.51\.100\./, /^203\.0\.113\./, /^(22[4-9]|23\d)\./, /^(24\d|25[0-5])\./]
|
236
377
|
def reserved_nets_regex
|
237
378
|
[
|
238
379
|
/^0\./, # 0.0.0.0 - 0.255.255.255
|
@@ -245,25 +386,69 @@ module Faker
|
|
245
386
|
]
|
246
387
|
end
|
247
388
|
|
389
|
+
##
|
390
|
+
# Returns lambda function to check address passed is reserverd or not
|
391
|
+
#
|
392
|
+
# @return [Lambda]
|
393
|
+
#
|
394
|
+
# @example
|
395
|
+
# Faker::Internet.reserved_net_checker.call('192.88.99.255') #=> true
|
396
|
+
# Faker::Internet.reserved_net_checker.call('192.88.199.255') #=> false
|
248
397
|
def reserved_net_checker
|
249
398
|
->(addr) { (private_nets_regex + reserved_nets_regex).any? { |net| net =~ addr } }
|
250
399
|
end
|
251
400
|
|
401
|
+
##
|
402
|
+
# Returns Ipv4 address with CIDR, range from 1 to 31
|
403
|
+
#
|
404
|
+
# @return [String]
|
405
|
+
#
|
406
|
+
# @example
|
407
|
+
# Faker::Internet.ip_v4_cidr #=> "129.162.99.74/16"
|
408
|
+
# Faker::Internet.ip_v4_cidr #=> "129.162.99.74/24"
|
252
409
|
def ip_v4_cidr
|
253
410
|
"#{ip_v4_address}/#{rand(1..31)}"
|
254
411
|
end
|
255
412
|
|
413
|
+
##
|
414
|
+
# Returns Ipv6 address
|
415
|
+
#
|
416
|
+
# @return [String]
|
417
|
+
#
|
418
|
+
# @example
|
419
|
+
# Faker::Internet.ip_v6_address #=> "7754:76d4:c7aa:7646:ea68:1abb:4055:4343"
|
256
420
|
def ip_v6_address
|
257
421
|
(1..8).map { rand(65_536).to_s(16) }.join(':')
|
258
422
|
end
|
259
423
|
|
424
|
+
##
|
425
|
+
# Returns Ipv6 address with CIDR, range between 1 to 127
|
426
|
+
#
|
427
|
+
# @return [String]
|
428
|
+
#
|
429
|
+
# @example
|
430
|
+
# Faker::Internet.ip_v6_cidr #=> "beca:9b99:4bb6:9712:af2f:516f:8507:96e1/99"
|
260
431
|
def ip_v6_cidr
|
261
432
|
"#{ip_v6_address}/#{rand(1..127)}"
|
262
433
|
end
|
263
434
|
|
264
435
|
# rubocop:disable Metrics/ParameterLists
|
436
|
+
|
437
|
+
##
|
438
|
+
# Returns URL
|
439
|
+
#
|
440
|
+
# @return [String]
|
441
|
+
#
|
442
|
+
# @param host [String]
|
443
|
+
# @param path [String]
|
444
|
+
# @param scheme [String]
|
445
|
+
#
|
446
|
+
# @example
|
447
|
+
# Faker::Internet.url #=> "http://sipes-okon.com/hung.macejkovic"
|
448
|
+
# Faker::Internet.url(host: 'faker') #=> "http://faker/shad"
|
449
|
+
# Faker::Internet.url(host: 'faker', path: '/fake_test_path') #=> "http://faker/fake_test_path"
|
450
|
+
# Faker::Internet.url(host: 'faker', path: '/fake_test_path', scheme: 'https') #=> "https://faker/fake_test_path"
|
265
451
|
def url(legacy_host = NOT_GIVEN, legacy_path = NOT_GIVEN, legacy_scheme = NOT_GIVEN, host: domain_name, path: "/#{username}", scheme: 'http')
|
266
|
-
# rubocop:enable Metrics/ParameterLists
|
267
452
|
warn_for_deprecated_arguments do |keywords|
|
268
453
|
keywords << :host if legacy_host != NOT_GIVEN
|
269
454
|
keywords << :path if legacy_path != NOT_GIVEN
|
@@ -272,7 +457,21 @@ module Faker
|
|
272
457
|
|
273
458
|
"#{scheme}://#{host}#{path}"
|
274
459
|
end
|
460
|
+
# rubocop:enable Metrics/ParameterLists
|
275
461
|
|
462
|
+
##
|
463
|
+
# Returns unique string in URL
|
464
|
+
#
|
465
|
+
# @return [String]
|
466
|
+
#
|
467
|
+
# @param words [String] Comma or period separated words list
|
468
|
+
# @param glue [String] Separator to add between words passed, default used are '-' or '_'
|
469
|
+
#
|
470
|
+
# @example
|
471
|
+
# Faker::Internet.slug #=> "repudiandae-sed"
|
472
|
+
# Faker::Internet.slug(words: 'test, faker') #=> "test-faker"
|
473
|
+
# Faker::Internet.slug(words: 'test. faker') #=> "test-faker"
|
474
|
+
# Faker::Internet.slug(words: 'test. faker', glue: '$') #=> "test$faker"
|
276
475
|
def slug(legacy_words = NOT_GIVEN, legacy_glue = NOT_GIVEN, words: nil, glue: nil)
|
277
476
|
warn_for_deprecated_arguments do |keywords|
|
278
477
|
keywords << :words if legacy_words != NOT_GIVEN
|
@@ -283,10 +482,29 @@ module Faker
|
|
283
482
|
(words || Faker::Lorem.words(number: 2).join(' ')).delete(',.').gsub(' ', glue).downcase
|
284
483
|
end
|
285
484
|
|
485
|
+
##
|
486
|
+
# Generates random token
|
487
|
+
#
|
488
|
+
# @return[String]
|
489
|
+
#
|
490
|
+
# @example
|
491
|
+
# Faker::Internet.device_token #=> "749f535671cf6b34d8e794d212d00c703b96274e07161b18b082d0d70ef1052f"
|
286
492
|
def device_token
|
287
493
|
shuffle(rand(16**64).to_s(16).rjust(64, '0').chars.to_a).join
|
288
494
|
end
|
289
495
|
|
496
|
+
##
|
497
|
+
# Generates the random browser identifier
|
498
|
+
#
|
499
|
+
# @return [String]
|
500
|
+
#
|
501
|
+
# @param vendor [String] Name of vendor, supported vendors are aol, chrome, firefox, internet_explorer, netscape, opera, safari
|
502
|
+
#
|
503
|
+
# @example
|
504
|
+
# Faker::Internet.user_agent #=> "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"
|
505
|
+
# Faker::Internet.user_agent(vendor: 'chrome') #=> "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"
|
506
|
+
# Faker::Internet.user_agent(vendor: 'safari') #=> "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A"
|
507
|
+
# Faker::Internet.user_agent(vendor: 'faker') #=> "Mozilla/5.0 (Windows; U; Win 9x 4.90; SG; rv:1.9.2.4) Gecko/20101104 Netscape/9.1.0285"
|
290
508
|
def user_agent(legacy_vendor = NOT_GIVEN, vendor: nil)
|
291
509
|
warn_for_deprecated_arguments do |keywords|
|
292
510
|
keywords << :vendor if legacy_vendor != NOT_GIVEN
|
@@ -297,6 +515,13 @@ module Faker
|
|
297
515
|
sample(agents)
|
298
516
|
end
|
299
517
|
|
518
|
+
##
|
519
|
+
# Generated universally unique identifier
|
520
|
+
#
|
521
|
+
# @return [String]
|
522
|
+
#
|
523
|
+
# @example
|
524
|
+
# Faker::Internet.uuid #=> "8a6cdd40-6d78-4fdb-912b-190e3057197f"
|
300
525
|
def uuid
|
301
526
|
# borrowed from: https://github.com/ruby/ruby/blob/d48783bb0236db505fe1205d1d9822309de53a36/lib/securerandom.rb#L250
|
302
527
|
ary = Faker::Config.random.bytes(16).unpack('NnnnnN')
|