faker 2.9.0 → 2.12.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 +231 -0
- data/README.md +12 -3
- data/lib/faker.rb +21 -14
- data/lib/faker/default/address.rb +13 -0
- data/lib/faker/default/bank.rb +80 -1
- data/lib/faker/default/blood.rb +48 -0
- data/lib/faker/default/business.rb +1 -1
- data/lib/faker/default/cannabis.rb +80 -0
- data/lib/faker/default/commerce.rb +73 -10
- data/lib/faker/default/company.rb +275 -4
- 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/dc_comics.rb +45 -0
- data/lib/faker/default/driving_licence.rb +42 -0
- data/lib/faker/default/file.rb +51 -2
- data/lib/faker/default/finance.rb +24 -0
- data/lib/faker/default/funny_name.rb +45 -0
- data/lib/faker/default/hipster.rb +94 -0
- data/lib/faker/default/internet.rb +29 -0
- data/lib/faker/default/invoice.rb +32 -5
- data/lib/faker/default/json.rb +55 -0
- data/lib/faker/default/lorem.rb +1 -1
- data/lib/faker/default/measurement.rb +90 -0
- data/lib/faker/default/name.rb +83 -0
- data/lib/faker/default/omniauth.rb +47 -47
- 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/games/control.rb +113 -0
- data/lib/faker/games/dnd.rb +61 -0
- data/lib/faker/games/warhammer_fantasy.rb +74 -0
- data/lib/faker/movies/departed.rb +49 -0
- data/lib/faker/music/music.rb +90 -4
- data/lib/faker/music/opera.rb +36 -0
- data/lib/faker/music/pearl_jam.rb +50 -0
- data/lib/faker/music/phish.rb +27 -1
- data/lib/faker/music/show.rb +49 -0
- data/lib/faker/quotes/chiquito.rb +80 -0
- data/lib/faker/quotes/quote.rb +54 -1
- data/lib/faker/quotes/rajnikanth.rb +26 -0
- data/lib/faker/quotes/shakespeare.rb +36 -0
- data/lib/faker/tv_shows/suits.rb +37 -0
- data/lib/faker/version.rb +1 -1
- data/lib/helpers/char.rb +2 -1
- data/lib/helpers/unique_generator.rb +4 -0
- data/lib/locales/bg.yml +2 -2
- data/lib/locales/ca.yml +0 -8
- data/lib/locales/da-DK.yml +3 -3
- 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-GB.yml +1 -1
- data/lib/locales/en-NEP.yml +1 -1
- data/lib/locales/en-NZ.yml +132 -8
- data/lib/locales/en-US.yml +29 -3
- data/lib/locales/en-ZA.yml +1 -1
- data/lib/locales/en/address.yml +6 -0
- data/lib/locales/en/blood.yml +13 -0
- data/lib/locales/en/chiquito.yml +64 -0
- data/lib/locales/en/color.yml +1 -1
- 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/heroes_of_the_storm.yml +1 -1
- data/lib/locales/en/house.yml +1 -1
- data/lib/locales/en/name.yml +1 -1
- 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/phone_number.yml +1 -1
- data/lib/locales/en/rajnikanth.yml +77 -0
- data/lib/locales/en/shakespeare.yml +3 -3
- data/lib/locales/en/show.yml +597 -0
- data/lib/locales/en/star_wars.yml +568 -221
- data/lib/locales/en/stripe.yml +3 -3
- data/lib/locales/en/suits.yml +45 -0
- data/lib/locales/en/warhammer_fantasy.yml +582 -0
- data/lib/locales/es-MX.yml +3 -0
- data/lib/locales/fr-CA.yml +7 -4
- data/lib/locales/fr-CH.yml +1 -1
- data/lib/locales/fr.yml +5 -4
- data/lib/locales/hy.yml +1 -6
- data/lib/locales/id.yml +2 -1
- data/lib/locales/ja.yml +1 -1
- data/lib/locales/ko.yml +82 -0
- data/lib/locales/pt-BR.yml +1 -0
- data/lib/locales/pt.yml +2 -2
- data/lib/locales/uk.yml +5 -5
- data/lib/locales/zh-CN.yml +1 -1
- data/lib/locales/zh-TW.yml +1 -1
- metadata +37 -16
|
@@ -295,6 +295,35 @@ module Faker
|
|
|
295
295
|
'%08x-%04x-%04x-%04x-%04x%08x' % ary # rubocop:disable Style/FormatString
|
|
296
296
|
end
|
|
297
297
|
|
|
298
|
+
##
|
|
299
|
+
# Produces a random string of alphabetic characters, (no digits)
|
|
300
|
+
#
|
|
301
|
+
# @param length [Integer] The length of the string to generate
|
|
302
|
+
# @param padding [Boolean] Toggles if a final equal '=' will be added.
|
|
303
|
+
# @param urlsafe [Boolean] Toggles charset to '-' and '_' instead of '+' and '/'.
|
|
304
|
+
#
|
|
305
|
+
# @return [String]
|
|
306
|
+
#
|
|
307
|
+
# @example
|
|
308
|
+
# Faker::Internet.base64
|
|
309
|
+
# #=> "r_hbZ2DSD-ZACzZT"
|
|
310
|
+
# @example
|
|
311
|
+
# Faker::Internet.base64(length: 4, padding: true, urlsafe: false)
|
|
312
|
+
# #=> "x1/R="
|
|
313
|
+
#
|
|
314
|
+
# @faker.version 2.11.0
|
|
315
|
+
def base64(length: 16, padding: false, urlsafe: true)
|
|
316
|
+
char_range = [
|
|
317
|
+
Array('0'..'9'),
|
|
318
|
+
Array('A'..'Z'),
|
|
319
|
+
Array('a'..'z'),
|
|
320
|
+
urlsafe ? %w[- _] : %w[+ /]
|
|
321
|
+
].flatten
|
|
322
|
+
s = Array.new(length) { sample(char_range) }.join
|
|
323
|
+
s += '=' if padding
|
|
324
|
+
s
|
|
325
|
+
end
|
|
326
|
+
|
|
298
327
|
alias user_name username
|
|
299
328
|
end
|
|
300
329
|
end
|
|
@@ -5,7 +5,18 @@ module Faker
|
|
|
5
5
|
flexible :invoice
|
|
6
6
|
|
|
7
7
|
class << self
|
|
8
|
-
|
|
8
|
+
##
|
|
9
|
+
# Produces a random amount between values with 2 decimals
|
|
10
|
+
#
|
|
11
|
+
# @param from [Integer] Specifies lower limit.
|
|
12
|
+
# @param to [Integer] Specifies upper limit.
|
|
13
|
+
# @return [Integer]
|
|
14
|
+
#
|
|
15
|
+
# @example
|
|
16
|
+
# Faker::Finance.amount_between #=> 0
|
|
17
|
+
# Faker::Finance.amount_between(0, 10) #=> 4.33
|
|
18
|
+
#
|
|
19
|
+
# @faker.version 1.9.0
|
|
9
20
|
def amount_between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 0, to: 0)
|
|
10
21
|
warn_for_deprecated_arguments do |keywords|
|
|
11
22
|
keywords << :from if legacy_from != NOT_GIVEN
|
|
@@ -15,8 +26,16 @@ module Faker
|
|
|
15
26
|
Faker::Base.rand_in_range(from, to).round(2)
|
|
16
27
|
end
|
|
17
28
|
|
|
18
|
-
|
|
19
|
-
#
|
|
29
|
+
##
|
|
30
|
+
# Produces a random valid reference accoring to the International bank slip reference https://en.wikipedia.org/wiki/Creditor_Reference
|
|
31
|
+
#
|
|
32
|
+
# @param ref [String] Specifies reference base.
|
|
33
|
+
# @return [String]
|
|
34
|
+
#
|
|
35
|
+
# @example
|
|
36
|
+
# Faker::Invoice.creditor_reference #=> "RF34118592570724925498"
|
|
37
|
+
#
|
|
38
|
+
# @faker.version 1.9.0
|
|
20
39
|
def creditor_reference(legacy_ref = NOT_GIVEN, ref: '')
|
|
21
40
|
warn_for_deprecated_arguments do |keywords|
|
|
22
41
|
keywords << :ref if legacy_ref != NOT_GIVEN
|
|
@@ -27,8 +46,16 @@ module Faker
|
|
|
27
46
|
'RF' + iban_checksum('RF', ref) + ref
|
|
28
47
|
end
|
|
29
48
|
|
|
30
|
-
|
|
31
|
-
#
|
|
49
|
+
##
|
|
50
|
+
# Produces a random valid reference.
|
|
51
|
+
#
|
|
52
|
+
# @param ref [String] Specifies reference base.
|
|
53
|
+
# @return [String]
|
|
54
|
+
#
|
|
55
|
+
# @example
|
|
56
|
+
# Faker::Invoice.reference #=> "45656646957845"
|
|
57
|
+
#
|
|
58
|
+
# @faker.version 1.9.0
|
|
32
59
|
def reference(legacy_ref = NOT_GIVEN, ref: '')
|
|
33
60
|
warn_for_deprecated_arguments do |keywords|
|
|
34
61
|
keywords << :ref if legacy_ref != NOT_GIVEN
|
data/lib/faker/default/json.rb
CHANGED
|
@@ -3,6 +3,23 @@ module Faker
|
|
|
3
3
|
require 'json'
|
|
4
4
|
|
|
5
5
|
class << self
|
|
6
|
+
##
|
|
7
|
+
# Produces a random simple JSON formatted string.
|
|
8
|
+
#
|
|
9
|
+
# @param width [Integer] Specifies the number of key-value pairs.
|
|
10
|
+
# @param options [Hash] Specifies a Faker gem class to use for keys and for values, respectably. options_hash = {key: Class.method, value: Class.method}
|
|
11
|
+
# @return [Hash{String => String}]
|
|
12
|
+
#
|
|
13
|
+
# @example
|
|
14
|
+
# Faker::Json.shallow_json(width: 3, options: { key: 'RockBand.name', value: 'Seinfeld.quote' }) # =>
|
|
15
|
+
# {"Parliament Funkadelic":"They're real, and they're spectacular.",
|
|
16
|
+
# "Fleetwood Mac":"I'm not a lesbian. I hate men, but I'm not a lesbian.",
|
|
17
|
+
# "The Roots":"It became very clear to me sitting out there today that every decision
|
|
18
|
+
# I've made in my entire life has been wrong. My life is the complete opposite of everything
|
|
19
|
+
# I want it to be. Every instinct I have, in every aspect of life, be it something to wear,
|
|
20
|
+
# something to eat - it's all been wrong."}
|
|
21
|
+
#
|
|
22
|
+
# @faker.version 1.9.2
|
|
6
23
|
def shallow_json(legacy_width = NOT_GIVEN, legacy_options = NOT_GIVEN, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' })
|
|
7
24
|
warn_for_deprecated_arguments do |keywords|
|
|
8
25
|
keywords << :width if legacy_width != NOT_GIVEN
|
|
@@ -16,6 +33,44 @@ module Faker
|
|
|
16
33
|
JSON.generate(hash)
|
|
17
34
|
end
|
|
18
35
|
|
|
36
|
+
##
|
|
37
|
+
# Produces a random nested JSON formatted string that can take JSON as an additional argument.
|
|
38
|
+
#
|
|
39
|
+
# @param json [Hash{String => String}] Specifies a Json.shallow_json and uses its keys as keys of the nested JSON.
|
|
40
|
+
# @param width [Integer] Specifies the number of nested key-value pairs.
|
|
41
|
+
# @param options [Hash] Specifies a Faker gem class to use for nested keys and for values, respectably. options_hash = {key: Class.method, value: Class.method}
|
|
42
|
+
# @return [Hash{String => String}]
|
|
43
|
+
#
|
|
44
|
+
# @example
|
|
45
|
+
# json = Faker::Json.shallow_json(width: 3, options: { key: 'Name.first_name', value: 'Name.last_name' })
|
|
46
|
+
# puts json # =>
|
|
47
|
+
# {"Alisha":"Olson","Everardo":"DuBuque","Bridgette":"Turner"}
|
|
48
|
+
#
|
|
49
|
+
# json2 = Faker::Json.add_depth_to_json(json: json, width: 2, options: { key: 'Name.first_name', value: 'Name.last_name' })
|
|
50
|
+
# puts json2 # =>
|
|
51
|
+
# {"Alisha":{"Daisy":"Trantow","Oda":"Haag"},
|
|
52
|
+
# "Everardo":{"Javier":"Marvin","Eliseo":"Schuppe"},
|
|
53
|
+
# "Bridgette":{"Jorge":"Kertzmann","Lelah":"MacGyver"}}
|
|
54
|
+
#
|
|
55
|
+
# json3 = Faker::Json.add_depth_to_json(json: json2, width: 4, options: { key: 'Name.first_name', value: 'Name.last_name' })
|
|
56
|
+
# puts json3 # =>
|
|
57
|
+
# {"Alisha":
|
|
58
|
+
# {"Daisy":
|
|
59
|
+
# {"Bulah":"Wunsch","Cristian":"Champlin","Lester":"Bartoletti","Greg":"Jacobson"},
|
|
60
|
+
# "Oda":
|
|
61
|
+
# {"Salvatore":"Kuhlman","Aubree":"Okuneva","Larry":"Schmitt","Velva":"Gibson"}},
|
|
62
|
+
# "Everardo":
|
|
63
|
+
# {"Javier":
|
|
64
|
+
# {"Eduardo":"Orn","Laila":"Kub","Thad":"Legros","Dion":"Wilderman"},
|
|
65
|
+
# "Eliseo":
|
|
66
|
+
# {"Olin":"Hilpert","Marisa":"Greenfelder","Karlee":"Schmitt","Judd":"Larkin"}},
|
|
67
|
+
# "Bridgette":
|
|
68
|
+
# {"Jorge":
|
|
69
|
+
# {"Eloy":"Pfeffer","Kody":"Hansen","Paxton":"Lubowitz","Abe":"Lesch"},
|
|
70
|
+
# "Lelah":
|
|
71
|
+
# {"Rick":"Wiza","Bonita":"Bayer","Gardner":"Auer","Felicity":"Abbott"}}}
|
|
72
|
+
#
|
|
73
|
+
# @faker.version 1.9.2
|
|
19
74
|
# rubocop:disable Metrics/ParameterLists
|
|
20
75
|
def add_depth_to_json(legacy_json = NOT_GIVEN, legacy_width = NOT_GIVEN, legacy_options = NOT_GIVEN, json: shallow_json, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' })
|
|
21
76
|
# rubocop:enable Metrics/ParameterLists
|
data/lib/faker/default/lorem.rb
CHANGED
|
@@ -64,7 +64,7 @@ module Faker
|
|
|
64
64
|
keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
words(number: word_count + rand(random_words_to_add.to_i), supplemental: supplemental).join(
|
|
67
|
+
words(number: word_count + rand(random_words_to_add.to_i), supplemental: supplemental).join(locale_space).capitalize + locale_period
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
def sentences(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
|
|
@@ -6,6 +6,19 @@ module Faker
|
|
|
6
6
|
ALL = 'all'
|
|
7
7
|
NONE = 'none'
|
|
8
8
|
|
|
9
|
+
##
|
|
10
|
+
# Produces a random height measurement.
|
|
11
|
+
#
|
|
12
|
+
# @param amount [Integer] Speficies the random height value.
|
|
13
|
+
# @return [String]
|
|
14
|
+
#
|
|
15
|
+
# @example
|
|
16
|
+
# Faker::Measurement.height #=> "6 inches"
|
|
17
|
+
# Faker::Measurement.height(amount: 1.4) #=> "1.4 inches"
|
|
18
|
+
# Faker::Measurement.height(amount: "none") #=> "inch"
|
|
19
|
+
# Faker::Measurement.height(amount: "all") #=> "inches"
|
|
20
|
+
#
|
|
21
|
+
# @faker.version 1.7.3
|
|
9
22
|
def height(legacy_amount = NOT_GIVEN, amount: rand(10))
|
|
10
23
|
warn_for_deprecated_arguments do |keywords|
|
|
11
24
|
keywords << :amount if legacy_amount != NOT_GIVEN
|
|
@@ -14,6 +27,17 @@ module Faker
|
|
|
14
27
|
define_measurement_locale(amount, 'height')
|
|
15
28
|
end
|
|
16
29
|
|
|
30
|
+
##
|
|
31
|
+
# Produces a random length measurement.
|
|
32
|
+
#
|
|
33
|
+
# @param amount [Integer] Speficies the random length value.
|
|
34
|
+
# @return [String]
|
|
35
|
+
#
|
|
36
|
+
# @example
|
|
37
|
+
# Faker::Measurement.length #=> "1 yard"
|
|
38
|
+
# Faker::Measurement.length(amount: 1.4) #=> "1.4 yards"
|
|
39
|
+
#
|
|
40
|
+
# @faker.version 1.7.3
|
|
17
41
|
def length(legacy_amount = NOT_GIVEN, amount: rand(10))
|
|
18
42
|
warn_for_deprecated_arguments do |keywords|
|
|
19
43
|
keywords << :amount if legacy_amount != NOT_GIVEN
|
|
@@ -22,6 +46,17 @@ module Faker
|
|
|
22
46
|
define_measurement_locale(amount, 'length')
|
|
23
47
|
end
|
|
24
48
|
|
|
49
|
+
##
|
|
50
|
+
# Produces a random volume measurement.
|
|
51
|
+
#
|
|
52
|
+
# @param amount [Integer] Speficies the random volume value.
|
|
53
|
+
# @return [String]
|
|
54
|
+
#
|
|
55
|
+
# @example
|
|
56
|
+
# Faker::Measurement.volume #=> "10 cups"
|
|
57
|
+
# Faker::Measurement.volume(amount: 1.4) #=> "1.4 cups"
|
|
58
|
+
#
|
|
59
|
+
# @faker.version 1.7.3
|
|
25
60
|
def volume(legacy_amount = NOT_GIVEN, amount: rand(10))
|
|
26
61
|
warn_for_deprecated_arguments do |keywords|
|
|
27
62
|
keywords << :amount if legacy_amount != NOT_GIVEN
|
|
@@ -30,6 +65,17 @@ module Faker
|
|
|
30
65
|
define_measurement_locale(amount, 'volume')
|
|
31
66
|
end
|
|
32
67
|
|
|
68
|
+
##
|
|
69
|
+
# Produces a random weight measurement.
|
|
70
|
+
#
|
|
71
|
+
# @param amount [Integer] Speficies the random weight value.
|
|
72
|
+
# @return [String]
|
|
73
|
+
#
|
|
74
|
+
# @example
|
|
75
|
+
# Faker::Measurement.weight #=> "3 pounds"
|
|
76
|
+
# Faker::Measurement.weight(amount: 1.4) #=> "1.4 pounds"
|
|
77
|
+
#
|
|
78
|
+
# @faker.version 1.7.3
|
|
33
79
|
def weight(legacy_amount = NOT_GIVEN, amount: rand(10))
|
|
34
80
|
warn_for_deprecated_arguments do |keywords|
|
|
35
81
|
keywords << :amount if legacy_amount != NOT_GIVEN
|
|
@@ -38,6 +84,17 @@ module Faker
|
|
|
38
84
|
define_measurement_locale(amount, 'weight')
|
|
39
85
|
end
|
|
40
86
|
|
|
87
|
+
##
|
|
88
|
+
# Produces a random metric height measurement.
|
|
89
|
+
#
|
|
90
|
+
# @param amount [Integer] Speficies the random height value.
|
|
91
|
+
# @return [String]
|
|
92
|
+
#
|
|
93
|
+
# @example
|
|
94
|
+
# Faker::Measurement.metric_height #=> "2 meters"
|
|
95
|
+
# Faker::Measurement.metric_height(amount: 1.4) #=> "1.4 meters"
|
|
96
|
+
#
|
|
97
|
+
# @faker.version 1.7.3
|
|
41
98
|
def metric_height(legacy_amount = NOT_GIVEN, amount: rand(10))
|
|
42
99
|
warn_for_deprecated_arguments do |keywords|
|
|
43
100
|
keywords << :amount if legacy_amount != NOT_GIVEN
|
|
@@ -46,6 +103,17 @@ module Faker
|
|
|
46
103
|
define_measurement_locale(amount, 'metric_height')
|
|
47
104
|
end
|
|
48
105
|
|
|
106
|
+
##
|
|
107
|
+
# Produces a random metric length measurement.
|
|
108
|
+
#
|
|
109
|
+
# @param amount [Integer] Speficies the random length value.
|
|
110
|
+
# @return [String]
|
|
111
|
+
#
|
|
112
|
+
# @example
|
|
113
|
+
# Faker::Measurement.metric_length #=> "0 decimeters"
|
|
114
|
+
# Faker::Measurement.metric_length(amount: 1.4) #=> "1.4 decimeters"
|
|
115
|
+
#
|
|
116
|
+
# @faker.version 1.7.3
|
|
49
117
|
def metric_length(legacy_amount = NOT_GIVEN, amount: rand(10))
|
|
50
118
|
warn_for_deprecated_arguments do |keywords|
|
|
51
119
|
keywords << :amount if legacy_amount != NOT_GIVEN
|
|
@@ -54,6 +122,17 @@ module Faker
|
|
|
54
122
|
define_measurement_locale(amount, 'metric_length')
|
|
55
123
|
end
|
|
56
124
|
|
|
125
|
+
##
|
|
126
|
+
# Produces a random metric volume measurement.
|
|
127
|
+
#
|
|
128
|
+
# @param amount [Integer] Speficies the random volume value.
|
|
129
|
+
# @return [String]
|
|
130
|
+
#
|
|
131
|
+
# @example
|
|
132
|
+
# Faker::Measurement.metric_volume #=> "1 liter"
|
|
133
|
+
# Faker::Measurement.metric_volume(amount: 1.4) #=> "1.4 liters"
|
|
134
|
+
#
|
|
135
|
+
# @faker.version 1.7.3
|
|
57
136
|
def metric_volume(legacy_amount = NOT_GIVEN, amount: rand(10))
|
|
58
137
|
warn_for_deprecated_arguments do |keywords|
|
|
59
138
|
keywords << :amount if legacy_amount != NOT_GIVEN
|
|
@@ -62,6 +141,17 @@ module Faker
|
|
|
62
141
|
define_measurement_locale(amount, 'metric_volume')
|
|
63
142
|
end
|
|
64
143
|
|
|
144
|
+
##
|
|
145
|
+
# Produces a random metric weight measurement.
|
|
146
|
+
#
|
|
147
|
+
# @param amount [Integer] Speficies the random weight value.
|
|
148
|
+
# @return [String]
|
|
149
|
+
#
|
|
150
|
+
# @example
|
|
151
|
+
# Faker::Measurement.metric_weight #=> "8 grams"
|
|
152
|
+
# Faker::Measurement.metric_weight(amount: 1.4) #=> "1.4 grams"
|
|
153
|
+
#
|
|
154
|
+
# @faker.version 1.7.3
|
|
65
155
|
def metric_weight(legacy_amount = NOT_GIVEN, amount: rand(10))
|
|
66
156
|
warn_for_deprecated_arguments do |keywords|
|
|
67
157
|
keywords << :amount if legacy_amount != NOT_GIVEN
|
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,87 @@ 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 last name.
|
|
83
|
+
#
|
|
84
|
+
# @return [String]
|
|
85
|
+
#
|
|
86
|
+
# @example
|
|
87
|
+
# Faker::Name.last_name #=> "Ernser"
|
|
88
|
+
#
|
|
89
|
+
# @faker.version 0.9.0
|
|
36
90
|
def last_name
|
|
37
91
|
parse('name.last_name')
|
|
38
92
|
end
|
|
39
93
|
alias middle_name last_name
|
|
40
94
|
|
|
95
|
+
##
|
|
96
|
+
# Produces a random name prefix.
|
|
97
|
+
#
|
|
98
|
+
# @return [String]
|
|
99
|
+
#
|
|
100
|
+
# @example
|
|
101
|
+
# Faker::Name.prefix #=> "Mr."
|
|
102
|
+
#
|
|
103
|
+
# @faker.version 0.9.0
|
|
41
104
|
def prefix
|
|
42
105
|
fetch('name.prefix')
|
|
43
106
|
end
|
|
44
107
|
|
|
108
|
+
##
|
|
109
|
+
# Produces a random name suffix.
|
|
110
|
+
#
|
|
111
|
+
# @return [String]
|
|
112
|
+
#
|
|
113
|
+
# @example
|
|
114
|
+
# Faker::Name.suffix #=> "IV"
|
|
115
|
+
#
|
|
116
|
+
# @faker.version 0.9.0
|
|
45
117
|
def suffix
|
|
46
118
|
fetch('name.suffix')
|
|
47
119
|
end
|
|
48
120
|
|
|
121
|
+
##
|
|
122
|
+
# Produces random initials.
|
|
123
|
+
#
|
|
124
|
+
# @param number [Integer] Number of digits that the generated initials should have.
|
|
125
|
+
# @return [String]
|
|
126
|
+
#
|
|
127
|
+
# @example
|
|
128
|
+
# Faker::Name.initials #=> "NJM"
|
|
129
|
+
# Faker::Name.initials(number: 2) #=> "NM"
|
|
130
|
+
#
|
|
131
|
+
# @faker.version 1.8.5
|
|
49
132
|
def initials(legacy_number = NOT_GIVEN, number: 3)
|
|
50
133
|
warn_for_deprecated_arguments do |keywords|
|
|
51
134
|
keywords << :number if legacy_number != NOT_GIVEN
|
|
@@ -57,16 +57,16 @@ module Faker
|
|
|
57
57
|
hd: "#{Company.name.downcase}.com"
|
|
58
58
|
},
|
|
59
59
|
id_info: {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
60
|
+
iss: 'accounts.google.com',
|
|
61
|
+
at_hash: Crypto.md5,
|
|
62
|
+
email_verified: true,
|
|
63
|
+
sub: Number.number(digits: 28).to_s,
|
|
64
|
+
azp: 'APP_ID',
|
|
65
|
+
email: auth.email,
|
|
66
|
+
aud: 'APP_ID',
|
|
67
|
+
iat: Time.forward.to_i,
|
|
68
|
+
exp: Time.forward.to_i,
|
|
69
|
+
openid_id: "https://www.google.com/accounts/o8/id?id=#{uid}"
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
}
|
|
@@ -223,53 +223,53 @@ module Faker
|
|
|
223
223
|
industry = Commerce.department
|
|
224
224
|
url = "http://www.linkedin.com/in/#{first_name}#{last_name}"
|
|
225
225
|
{
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
226
|
+
provider: 'linkedin',
|
|
227
|
+
uid: uid,
|
|
228
|
+
info: {
|
|
229
|
+
name: auth.name,
|
|
230
|
+
email: auth.email,
|
|
231
|
+
nickname: auth.name,
|
|
232
|
+
first_name: auth.first_name,
|
|
233
|
+
last_name: auth.last_name,
|
|
234
|
+
location: location,
|
|
235
|
+
description: description,
|
|
236
|
+
image: image,
|
|
237
|
+
phone: PhoneNumber.phone_number,
|
|
238
|
+
headline: description,
|
|
239
|
+
industry: industry,
|
|
240
|
+
urls: {
|
|
241
|
+
public_profile: url
|
|
242
242
|
}
|
|
243
243
|
},
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
244
|
+
credentials: {
|
|
245
|
+
token: token,
|
|
246
|
+
secret: secret
|
|
247
247
|
},
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
248
|
+
extra: {
|
|
249
|
+
access_token: {
|
|
250
|
+
token: token,
|
|
251
|
+
secret: secret,
|
|
252
|
+
consumer: nil,
|
|
253
|
+
params: {
|
|
254
254
|
oauth_token: token,
|
|
255
255
|
oauth_token_secret: secret,
|
|
256
256
|
oauth_expires_in: Time.forward.to_i,
|
|
257
257
|
oauth_authorization_expires_in: Time.forward.to_i
|
|
258
258
|
},
|
|
259
|
-
|
|
259
|
+
response: nil
|
|
260
260
|
},
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
261
|
+
raw_info: {
|
|
262
|
+
firstName: auth.first_name,
|
|
263
|
+
headline: description,
|
|
264
|
+
id: uid,
|
|
265
|
+
industry: industry,
|
|
266
|
+
lastName: auth.last_name,
|
|
267
|
+
location: {
|
|
268
|
+
country: { code: Address.country_code.downcase },
|
|
269
|
+
name: city_state.split(', ').first
|
|
270
270
|
},
|
|
271
|
-
|
|
272
|
-
|
|
271
|
+
pictureUrl: image,
|
|
272
|
+
publicProfileUrl: url
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
}
|