faker 2.11.0 → 2.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +89 -0
  3. data/README.md +8 -2
  4. data/lib/faker.rb +14 -9
  5. data/lib/faker/default/address.rb +1 -1
  6. data/lib/faker/default/bank.rb +79 -0
  7. data/lib/faker/default/blood.rb +48 -0
  8. data/lib/faker/default/business.rb +1 -1
  9. data/lib/faker/default/commerce.rb +73 -10
  10. data/lib/faker/default/company.rb +39 -0
  11. data/lib/faker/default/compass.rb +135 -0
  12. data/lib/faker/default/computer.rb +63 -0
  13. data/lib/faker/default/construction.rb +54 -0
  14. data/lib/faker/default/cosmere.rb +90 -0
  15. data/lib/faker/default/crypto_coin.rb +45 -0
  16. data/lib/faker/default/driving_licence.rb +42 -0
  17. data/lib/faker/default/file.rb +49 -0
  18. data/lib/faker/default/finance.rb +24 -0
  19. data/lib/faker/default/hipster.rb +94 -0
  20. data/lib/faker/default/invoice.rb +32 -5
  21. data/lib/faker/default/json.rb +55 -0
  22. data/lib/faker/default/measurement.rb +90 -0
  23. data/lib/faker/default/name.rb +83 -0
  24. data/lib/faker/default/phone_number.rb +88 -5
  25. data/lib/faker/default/placeholdit.rb +21 -0
  26. data/lib/faker/default/slack_emoji.rb +81 -0
  27. data/lib/faker/default/south_africa.rb +90 -0
  28. data/lib/faker/default/string.rb +19 -3
  29. data/lib/faker/default/stripe.rb +61 -0
  30. data/lib/faker/default/twitter.rb +35 -0
  31. data/lib/faker/default/types.rb +80 -0
  32. data/lib/faker/default/university.rb +45 -0
  33. data/lib/faker/default/vehicle.rb +184 -4
  34. data/lib/faker/default/verb.rb +45 -0
  35. data/lib/faker/games/control.rb +113 -0
  36. data/lib/faker/games/dnd.rb +61 -0
  37. data/lib/faker/games/warhammer_fantasy.rb +74 -0
  38. data/lib/faker/movies/departed.rb +49 -0
  39. data/lib/faker/music/pearl_jam.rb +50 -0
  40. data/lib/faker/music/phish.rb +27 -1
  41. data/lib/faker/music/show.rb +49 -0
  42. data/lib/faker/quotes/quote.rb +54 -1
  43. data/lib/faker/quotes/shakespeare.rb +36 -0
  44. data/lib/faker/tv_shows/suits.rb +37 -0
  45. data/lib/faker/version.rb +1 -1
  46. data/lib/helpers/char.rb +2 -1
  47. data/lib/locales/de-CH.yml +1693 -0
  48. data/lib/locales/en-AU.yml +44 -10
  49. data/lib/locales/en-CA.yml +2 -0
  50. data/lib/locales/en-US.yml +29 -3
  51. data/lib/locales/en/address.yml +2 -0
  52. data/lib/locales/en/blood.yml +13 -0
  53. data/lib/locales/en/computer.yml +36 -0
  54. data/lib/locales/en/control.yml +247 -0
  55. data/lib/locales/en/departed.yml +50 -0
  56. data/lib/locales/en/dnd.yml +54 -0
  57. data/lib/locales/en/heroes_of_the_storm.yml +1 -1
  58. data/lib/locales/en/house.yml +1 -1
  59. data/lib/locales/en/one_piece.yml +2 -2
  60. data/lib/locales/en/pearl_jam.yml +213 -0
  61. data/lib/locales/en/phish.yml +392 -1
  62. data/lib/locales/en/show.yml +597 -0
  63. data/lib/locales/en/star_wars.yml +568 -221
  64. data/lib/locales/en/suits.yml +45 -0
  65. data/lib/locales/en/warhammer_fantasy.yml +582 -0
  66. data/lib/locales/fr-CA.yml +2 -0
  67. data/lib/locales/ko.yml +82 -0
  68. data/lib/locales/pt-BR.yml +1 -0
  69. metadata +29 -11
@@ -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
@@ -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
@@ -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
- # US and Canada only
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
- # US and Canada only
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
- # US and Canada only
41
- # Can be used for both extensions and last four digits of phone number.
42
- # Since extensions can be of variable length, this method taks a length parameter
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
@@ -3,38 +3,119 @@
3
3
  module Faker
4
4
  class SlackEmoji < Base
5
5
  class << self
6
+ ##
7
+ # Produces a random slack emoji from people category.
8
+ #
9
+ # @return [String]
10
+ #
11
+ # @example
12
+ # Faker::SlackEmoji.people #=> ":sleepy:"
13
+ #
14
+ # @faker.version 1.5.0
6
15
  def people
7
16
  fetch('slack_emoji.people')
8
17
  end
9
18
 
19
+ ##
20
+ # Produces a random slack emoji from nature category.
21
+ #
22
+ # @return [String]
23
+ #
24
+ # @example
25
+ # Faker::SlackEmoji.nature #=> ":mount_fuji:"
26
+ #
27
+ # @faker.version 1.5.0
10
28
  def nature
11
29
  fetch('slack_emoji.nature')
12
30
  end
13
31
 
32
+ ##
33
+ # Produces a random slack emoji from food and drink category.
34
+ #
35
+ # @return [String]
36
+ #
37
+ # @example
38
+ # Faker::SlackEmoji.food_and_drink #=> ":beers:"
39
+ #
40
+ # @faker.version 1.5.0
14
41
  def food_and_drink
15
42
  fetch('slack_emoji.food_and_drink')
16
43
  end
17
44
 
45
+ ##
46
+ # Produces a random slack emoji from celebration category.
47
+ #
48
+ # @return [String]
49
+ #
50
+ # @example
51
+ # Faker::SlackEmoji.celebration #=> ":tada:"
52
+ #
53
+ # @faker.version 1.5.0
18
54
  def celebration
19
55
  fetch('slack_emoji.celebration')
20
56
  end
21
57
 
58
+ ##
59
+ # Produces a random slack emoji from activity category.
60
+ #
61
+ # @return [String]
62
+ #
63
+ # @example
64
+ # Faker::SlackEmoji.activity #=> ":soccer:"
65
+ #
66
+ # @faker.version 1.5.0
22
67
  def activity
23
68
  fetch('slack_emoji.activity')
24
69
  end
25
70
 
71
+ ##
72
+ # Produces a random slack emoji from travel and places category.
73
+ #
74
+ # @return [String]
75
+ #
76
+ # @example
77
+ # Faker::SlackEmoji.travel_and_places #=> ":metro:"
78
+ #
79
+ # @faker.version 1.5.0
26
80
  def travel_and_places
27
81
  fetch('slack_emoji.travel_and_places')
28
82
  end
29
83
 
84
+ ##
85
+ # Produces a random slack emoji from objects and symbols category.
86
+ #
87
+ # @return [String]
88
+ #
89
+ # @example
90
+ # Faker::SlackEmoji.objects_and_symbols #=> ":id:"
91
+ #
92
+ # @faker.version 1.5.0
30
93
  def objects_and_symbols
31
94
  fetch('slack_emoji.objects_and_symbols')
32
95
  end
33
96
 
97
+ ##
98
+ # Produces a random slack emoji from custom category.
99
+ #
100
+ # @return [String]
101
+ #
102
+ # @example
103
+ # Faker::SlackEmoji.custom #=> ":slack:"
104
+ #
105
+ # @faker.version 1.5.0
34
106
  def custom
35
107
  fetch('slack_emoji.custom')
36
108
  end
37
109
 
110
+ ##
111
+ # Produces a random slack emoji from any category.
112
+ #
113
+ # @return [String]
114
+ #
115
+ # @example
116
+ # Faker::SlackEmoji.emoji #=> ":pizza:"
117
+ #
118
+ # @faker.version 1.5.0
38
119
  def emoji
39
120
  parse('slack_emoji.emoji')
40
121
  end