faker 3.0.0 → 3.5.2

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.
Files changed (161) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +598 -1
  3. data/README.md +203 -107
  4. data/lib/faker/books/lovecraft.rb +2 -3
  5. data/lib/faker/default/address.rb +2 -2
  6. data/lib/faker/default/alphanumeric.rb +1 -1
  7. data/lib/faker/default/chile_rut.rb +23 -17
  8. data/lib/faker/default/code.rb +65 -19
  9. data/lib/faker/default/company.rb +112 -5
  10. data/lib/faker/default/crypto.rb +13 -4
  11. data/lib/faker/default/date.rb +61 -5
  12. data/lib/faker/default/driving_licence.rb +19 -8
  13. data/lib/faker/default/drone.rb +1 -1
  14. data/lib/faker/default/finance.rb +2 -2
  15. data/lib/faker/default/food.rb +14 -1
  16. data/lib/faker/default/hipster.rb +2 -3
  17. data/lib/faker/default/html.rb +230 -0
  18. data/lib/faker/default/id_number.rb +38 -24
  19. data/lib/faker/default/internet.rb +85 -78
  20. data/lib/faker/default/invoice.rb +4 -4
  21. data/lib/faker/default/json.rb +9 -4
  22. data/lib/faker/default/lorem.rb +24 -16
  23. data/lib/faker/default/marketing.rb +1 -1
  24. data/lib/faker/default/measurement.rb +8 -8
  25. data/lib/faker/default/{nhs.rb → national_health_service.rb} +8 -4
  26. data/lib/faker/default/number.rb +1 -1
  27. data/lib/faker/default/omniauth.rb +5 -5
  28. data/lib/faker/default/phone_number.rb +37 -18
  29. data/lib/faker/default/placeholdit.rb +1 -1
  30. data/lib/faker/default/south_africa.rb +3 -3
  31. data/lib/faker/{music/show.rb → default/theater.rb} +8 -8
  32. data/lib/faker/default/twitter.rb +4 -6
  33. data/lib/faker/default/types.rb +5 -6
  34. data/lib/faker/default/vehicle.rb +26 -36
  35. data/lib/faker/games/clash_of_clans.rb +1 -1
  36. data/lib/faker/games/dnd.rb +49 -7
  37. data/lib/faker/games/final_fantasy_xiv.rb +73 -0
  38. data/lib/faker/games/heroes_of_the_storm.rb +0 -11
  39. data/lib/faker/games/minecraft.rb +1 -1
  40. data/lib/faker/games/myst.rb +1 -1
  41. data/lib/faker/japanese_media/cowboy_bebop.rb +61 -0
  42. data/lib/faker/japanese_media/fullmetal_alchemist_brotherhood.rb +10 -10
  43. data/lib/faker/locations/australia.rb +40 -38
  44. data/lib/faker/movies/avatar.rb +49 -0
  45. data/lib/faker/movies/star_wars.rb +1 -1
  46. data/lib/faker/movies/{room.rb → the_room.rb} +4 -4
  47. data/lib/faker/music/smashing_pumpkins.rb +64 -0
  48. data/lib/faker/quotes/quote.rb +13 -0
  49. data/lib/faker/sports/chess.rb +90 -0
  50. data/lib/faker/sports/sport.rb +9 -3
  51. data/lib/faker/travel/airport.rb +43 -0
  52. data/lib/faker/travel/train_station.rb +54 -0
  53. data/lib/faker/tv_shows/archer.rb +51 -0
  54. data/lib/faker/tv_shows/buffy.rb +0 -13
  55. data/lib/faker/tv_shows/dr_who.rb +0 -13
  56. data/lib/faker/tv_shows/south_park.rb +15 -0
  57. data/lib/faker/tv_shows/spongebob.rb +50 -0
  58. data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +0 -13
  59. data/lib/faker/version.rb +1 -1
  60. data/lib/faker.rb +20 -9
  61. data/lib/helpers/deprecator.rb +118 -0
  62. data/lib/helpers/positional_generator.rb +480 -0
  63. data/lib/locales/README.md +18 -2
  64. data/lib/locales/ar.yml +1 -0
  65. data/lib/locales/bg.yml +1 -2
  66. data/lib/locales/da-DK.yml +529 -35
  67. data/lib/locales/de-AT.yml +3487 -27
  68. data/lib/locales/de-CH.yml +4359 -12
  69. data/lib/locales/de.yml +7182 -100
  70. data/lib/locales/ee.yml +0 -1
  71. data/lib/locales/en/address.yml +1826 -561
  72. data/lib/locales/en/airport.yml +381 -0
  73. data/lib/locales/en/archer.yml +75 -0
  74. data/lib/locales/en/australia.yml +106 -105
  75. data/lib/locales/en/avatar.yml +31 -0
  76. data/lib/locales/en/bank.yml +1 -1
  77. data/lib/locales/en/chess.yml +103 -0
  78. data/lib/locales/en/company.yml +1 -0
  79. data/lib/locales/en/cosmere.yml +1 -1
  80. data/lib/locales/en/cowboy_bebop.yml +163 -0
  81. data/lib/locales/en/dnd.yml +186 -1
  82. data/lib/locales/en/dog.yml +262 -7
  83. data/lib/locales/en/dota.yml +120 -67
  84. data/lib/locales/en/final_fantasy_xiv.yml +754 -0
  85. data/lib/locales/en/finance.yml +4 -4
  86. data/lib/locales/en/food.yml +14 -1
  87. data/lib/locales/en/{fma_brotherhood.yml → fullmetal_alchemist_brotherhood.yml} +3 -3
  88. data/lib/locales/en/harry_potter.yml +1 -1
  89. data/lib/locales/en/heroes.yml +0 -0
  90. data/lib/locales/en/id_number.yml +1 -1
  91. data/lib/locales/en/internet.yml +3 -4
  92. data/lib/locales/en/minecraft.yml +4 -4
  93. data/lib/locales/en/mitch_hedberg.yml +46 -0
  94. data/lib/locales/en/music.yml +25 -25
  95. data/lib/locales/en/opera.yml +1 -1
  96. data/lib/locales/en/phone_number.yml +78 -3
  97. data/lib/locales/en/restaurant.yml +1 -1
  98. data/lib/locales/en/smashing_pumpkins.yml +382 -0
  99. data/lib/locales/en/south_park.yml +360 -2
  100. data/lib/locales/en/spongebob.yml +489 -0
  101. data/lib/locales/en/star_wars.yml +1 -1
  102. data/lib/locales/en/{room.yml → the_room.yml} +1 -1
  103. data/lib/locales/en/{show.yml → theater.yml} +1 -1
  104. data/lib/locales/en/train_station.yml +280 -0
  105. data/lib/locales/en/vehicle.yml +1 -1
  106. data/lib/locales/en-AU.yml +718 -47
  107. data/lib/locales/en-CA.yml +373 -19
  108. data/lib/locales/en-GB.yml +116 -8
  109. data/lib/locales/en-IND.yml +1259 -17
  110. data/lib/locales/en-KE.yml +212 -0
  111. data/lib/locales/en-MS.yml +364 -17
  112. data/lib/locales/en-NEP.yml +212 -38
  113. data/lib/locales/en-NG.yml +1 -0
  114. data/lib/locales/en-NZ.yml +1153 -123
  115. data/lib/locales/en-PAK.yml +392 -10
  116. data/lib/locales/en-SG.yml +581 -16
  117. data/lib/locales/en-UG.yml +1 -0
  118. data/lib/locales/en-US.yml +6914 -74
  119. data/lib/locales/en-ZA.yml +1 -1
  120. data/lib/locales/en-au-ocker.yml +266 -22
  121. data/lib/locales/es-AR.yml +4569 -4599
  122. data/lib/locales/es-MX.yml +1 -2
  123. data/lib/locales/es.yml +2 -3
  124. data/lib/locales/fi-FI.yml +1 -0
  125. data/lib/locales/fr/address.yml +761 -9
  126. data/lib/locales/fr/internet.yml +0 -1
  127. data/lib/locales/fr/name.yml +2 -1
  128. data/lib/locales/fr-CA.yml +2733 -44
  129. data/lib/locales/fr-CH.yml +1 -2
  130. data/lib/locales/fr.yml +3 -1
  131. data/lib/locales/hy.yml +3624 -119
  132. data/lib/locales/id.yml +839 -12
  133. data/lib/locales/it.yml +1304 -32
  134. data/lib/locales/ja/book.yml +492 -3
  135. data/lib/locales/ja/football.yml +115 -0
  136. data/lib/locales/ja/lorem.yml +1 -1
  137. data/lib/locales/ja/sport.yml +130 -0
  138. data/lib/locales/ja/super_mario.yml +1 -1
  139. data/lib/locales/ja/touhou.yml +466 -0
  140. data/lib/locales/ko.yml +1361 -20
  141. data/lib/locales/lt.yml +297 -17
  142. data/lib/locales/lv.yml +0 -1
  143. data/lib/locales/mi-NZ.yml +2 -0
  144. data/lib/locales/nb-NO.yml +518 -29
  145. data/lib/locales/nl.yml +10 -2
  146. data/lib/locales/pl.yml +1 -2
  147. data/lib/locales/pt-BR.yml +8205 -664
  148. data/lib/locales/pt.yml +844 -45
  149. data/lib/locales/ru.yml +1353 -69
  150. data/lib/locales/sk.yml +4410 -43
  151. data/lib/locales/sv.yml +100 -0
  152. data/lib/locales/tr.yml +1 -2
  153. data/lib/locales/uk.yml +1808 -44
  154. data/lib/locales/vi.yml +1 -0
  155. data/lib/locales/zh-CN/bank.yml +17 -0
  156. data/lib/locales/zh-CN.yml +1 -0
  157. data/lib/locales/zh-TW.yml +1 -0
  158. metadata +37 -156
  159. data/History.md +0 -176
  160. data/lib/faker/default/fillmurray.rb +0 -36
  161. data/lib/faker/default/lorem_pixel.rb +0 -64
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Faker
2
4
  class Json < Base
3
5
  require 'json'
@@ -71,7 +73,7 @@ module Faker
71
73
  options[:value] = "Faker::#{options[:value]}"
72
74
 
73
75
  hash = JSON.parse(json)
74
- hash.each do |key, _|
76
+ hash.each_key do |key|
75
77
  add_hash_to_bottom(hash, [key], width, options)
76
78
  end
77
79
  JSON.generate(hash)
@@ -93,7 +95,7 @@ module Faker
93
95
  def add_hash_to_bottom(hash, key_array, width, options)
94
96
  key_string = build_keys_from_array(key_array)
95
97
  if eval("hash#{key_string}").is_a?(::Hash)
96
- eval("hash#{key_string}").each do |key, _|
98
+ eval("hash#{key_string}").each_key do |key|
97
99
  key_array << key
98
100
  add_hash_to_bottom(hash, key_array, width, options)
99
101
  end
@@ -104,17 +106,20 @@ module Faker
104
106
  end
105
107
 
106
108
  def add_hash(key_array, hash, width, options)
107
- string_to_eval = 'hash'
109
+ string_to_eval = 'hash'.dup
110
+
108
111
  key_array.length.times do |index|
109
112
  string_to_eval << "['#{key_array[index]}']"
110
113
  end
111
114
  string_to_eval << " = #{build_shallow_hash(width, options)}"
112
115
  eval(string_to_eval)
116
+
113
117
  hash
114
118
  end
115
119
 
116
120
  def build_keys_from_array(key_array)
117
- key_string = ''
121
+ key_string = ''.dup
122
+
118
123
  key_array.each do |value|
119
124
  key_string << "['#{value}']"
120
125
  end
@@ -10,10 +10,13 @@ module Faker
10
10
  #
11
11
  # @example
12
12
  # Faker::Lorem.word #=> "soluto"
13
+ # Faker::Lorem.word(exclude_words: 'error') #=> "nisi"
14
+ # Faker::Lorem.word(exclude_words: 'id, error') #=> "et"
15
+ # Faker::Lorem.word(exclude_words: ['id', 'error']) #=> "consequatur"
13
16
  #
14
17
  # @faker.version 2.1.3
15
- def word
16
- sample(translate('faker.lorem.words'))
18
+ def word(exclude_words: nil)
19
+ words(number: 1, exclude_words: exclude_words).first
17
20
  end
18
21
 
19
22
  ##
@@ -28,16 +31,21 @@ module Faker
28
31
  # Faker::Lorem.words #=> ["hic", "quia", "nihil"]
29
32
  # Faker::Lorem.words(number: 4) #=> ["est", "temporibus", "et", "quaerat"]
30
33
  # Faker::Lorem.words(number: 4, supplemental: true) #=> ["nisi", "sit", "allatus", "consequatur"]
34
+ # Faker::Lorem.words(number: 4, supplemental: true, exclude_words: 'sit') #=> ["nisi", "allatus", "consequatur", "aut"]
31
35
  #
32
36
  # @faker.version 2.1.3
33
- def words(number: 3, supplemental: false)
37
+ def words(number: 3, supplemental: false, exclude_words: nil)
34
38
  resolved_num = resolve(number)
35
39
  word_list = (
36
40
  translate('faker.lorem.words') +
37
41
  (supplemental ? translate('faker.lorem.supplemental') : [])
38
42
  )
43
+ if exclude_words
44
+ exclude_words = exclude_words.split(', ') if exclude_words.instance_of?(::String)
45
+ word_list -= exclude_words
46
+ end
39
47
  word_list *= ((resolved_num / word_list.length) + 1)
40
- shuffle(word_list)[0, resolved_num]
48
+ sample(word_list, resolved_num)
41
49
  end
42
50
 
43
51
  ##
@@ -103,8 +111,8 @@ module Faker
103
111
  # Faker::Lorem.sentence(word_count: 5, supplemental: true, random_words_to_add:2) #=> "Crinis quo cruentus velit animi vomer."
104
112
  #
105
113
  # @faker.version 2.1.3
106
- def sentence(word_count: 4, supplemental: false, random_words_to_add: 0)
107
- words(number: word_count + rand(random_words_to_add.to_i), supplemental: supplemental).join(locale_space).capitalize + locale_period
114
+ def sentence(word_count: 4, supplemental: false, random_words_to_add: 0, exclude_words: nil)
115
+ words(number: word_count + rand(random_words_to_add.to_i), supplemental: supplemental, exclude_words: exclude_words).join(locale_space).capitalize + locale_period
108
116
  end
109
117
 
110
118
  ##
@@ -121,8 +129,8 @@ module Faker
121
129
  # Faker::Lorem.sentences(number: 2, supplemental: true) #=> ["Cito cena ad.", "Solvo animus allatus."]
122
130
  #
123
131
  # @faker.version 2.1.3
124
- def sentences(number: 3, supplemental: false)
125
- 1.upto(resolve(number)).collect { sentence(word_count: 3, supplemental: supplemental) }
132
+ def sentences(number: 3, supplemental: false, exclude_words: nil)
133
+ 1.upto(resolve(number)).collect { sentence(word_count: 3, supplemental: supplemental, exclude_words: exclude_words) }
126
134
  end
127
135
 
128
136
  ##
@@ -145,8 +153,8 @@ module Faker
145
153
  # #=> "Texo tantillus tamisium. Tribuo amissio tamisium. Facere aut canis."
146
154
  #
147
155
  # @faker.version 2.1.3
148
- def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 0)
149
- sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i), supplemental: supplemental).join(locale_space)
156
+ def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 0, exclude_words: nil)
157
+ sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i), supplemental: supplemental, exclude_words: exclude_words).join(locale_space)
150
158
  end
151
159
 
152
160
  ##
@@ -163,8 +171,8 @@ module Faker
163
171
  # Faker::Lorem.paragraphs(number:2, supplemental: true)
164
172
  #
165
173
  # @faker.version 2.1.3
166
- def paragraphs(number: 3, supplemental: false)
167
- 1.upto(resolve(number)).collect { paragraph(sentence_count: 3, supplemental: supplemental) }
174
+ def paragraphs(number: 3, supplemental: false, exclude_words: nil)
175
+ 1.upto(resolve(number)).collect { paragraph(sentence_count: 3, supplemental: supplemental, exclude_words: exclude_words) }
168
176
  end
169
177
 
170
178
  ##
@@ -205,8 +213,8 @@ module Faker
205
213
  # Faker::Lorem.question(word_count: 2, supplemental: true, random_words_to_add: 2) #=> "Depulso uter ut?"
206
214
  #
207
215
  # @faker.version 2.1.3
208
- def question(word_count: 4, supplemental: false, random_words_to_add: 0)
209
- words(number: word_count + rand(random_words_to_add), supplemental: supplemental).join(' ').capitalize + locale_question_mark
216
+ def question(word_count: 4, supplemental: false, random_words_to_add: 0, exclude_words: nil)
217
+ words(number: word_count + rand(random_words_to_add), supplemental: supplemental, exclude_words: exclude_words).join(' ').capitalize + locale_question_mark
210
218
  end
211
219
 
212
220
  ##
@@ -223,8 +231,8 @@ module Faker
223
231
  # Faker::Lorem.questions(number: 2, supplemental: true) #=> ["Acceptus subito cetera?", "Aro sulum cubicularis?"]
224
232
  #
225
233
  # @faker.version 2.1.3
226
- def questions(number: 3, supplemental: false)
227
- 1.upto(resolve(number)).collect { question(word_count: 3, supplemental: supplemental) }
234
+ def questions(number: 3, supplemental: false, exclude_words: nil)
235
+ 1.upto(resolve(number)).collect { question(word_count: 3, supplemental: supplemental, exclude_words: exclude_words) }
228
236
  end
229
237
 
230
238
  private
@@ -6,7 +6,7 @@ module Faker
6
6
 
7
7
  class << self
8
8
  ##
9
- # Produces the name of a video game console or platform.
9
+ # Produces a few marketing buzzwords.
10
10
  #
11
11
  # @return [String]
12
12
  #
@@ -9,7 +9,7 @@ module Faker
9
9
  ##
10
10
  # Produces a random height measurement.
11
11
  #
12
- # @param amount [Integer] Speficies the random height value.
12
+ # @param amount [Integer] Specifies the random height value.
13
13
  # @return [String]
14
14
  #
15
15
  # @example
@@ -26,7 +26,7 @@ module Faker
26
26
  ##
27
27
  # Produces a random length measurement.
28
28
  #
29
- # @param amount [Integer] Speficies the random length value.
29
+ # @param amount [Integer] Specifies the random length value.
30
30
  # @return [String]
31
31
  #
32
32
  # @example
@@ -41,7 +41,7 @@ module Faker
41
41
  ##
42
42
  # Produces a random volume measurement.
43
43
  #
44
- # @param amount [Integer] Speficies the random volume value.
44
+ # @param amount [Integer] Specifies the random volume value.
45
45
  # @return [String]
46
46
  #
47
47
  # @example
@@ -56,7 +56,7 @@ module Faker
56
56
  ##
57
57
  # Produces a random weight measurement.
58
58
  #
59
- # @param amount [Integer] Speficies the random weight value.
59
+ # @param amount [Integer] Specifies the random weight value.
60
60
  # @return [String]
61
61
  #
62
62
  # @example
@@ -71,7 +71,7 @@ module Faker
71
71
  ##
72
72
  # Produces a random metric height measurement.
73
73
  #
74
- # @param amount [Integer] Speficies the random height value.
74
+ # @param amount [Integer] Specifies the random height value.
75
75
  # @return [String]
76
76
  #
77
77
  # @example
@@ -86,7 +86,7 @@ module Faker
86
86
  ##
87
87
  # Produces a random metric length measurement.
88
88
  #
89
- # @param amount [Integer] Speficies the random length value.
89
+ # @param amount [Integer] Specifies the random length value.
90
90
  # @return [String]
91
91
  #
92
92
  # @example
@@ -101,7 +101,7 @@ module Faker
101
101
  ##
102
102
  # Produces a random metric volume measurement.
103
103
  #
104
- # @param amount [Integer] Speficies the random volume value.
104
+ # @param amount [Integer] Specifies the random volume value.
105
105
  # @return [String]
106
106
  #
107
107
  # @example
@@ -116,7 +116,7 @@ module Faker
116
116
  ##
117
117
  # Produces a random metric weight measurement.
118
118
  #
119
- # @param amount [Integer] Speficies the random weight value.
119
+ # @param amount [Integer] Specifies the random weight value.
120
120
  # @return [String]
121
121
  #
122
122
  # @example
@@ -6,24 +6,28 @@ module Faker
6
6
  ##
7
7
  # Produces a random British NHS number.
8
8
  #
9
+ # The NHS sets aside a range of numbers from 999 000 0000 to 999 999 9999
10
+ # for test purposes.
11
+ #
9
12
  # @return [String]
10
13
  #
11
14
  # @example
12
- # Faker::NationalHealthService.british_number #=> "403 958 5577"
15
+ # Faker::NationalHealthService.british_number #=> "999 464 0232"
13
16
  #
14
17
  # @faker.version 1.9.2
15
18
  def british_number
16
- base_number = rand(400_000_001...499_999_999)
19
+ base_number = rand(999_000_001...999_999_999)
17
20
  # If the check digit is equivalent to 10, the number is invalid.
18
21
  # See https://en.wikipedia.org/wiki/NHS_number
19
22
  base_number -= 1 if check_digit(number: base_number) == 10
20
- "#{base_number}#{check_digit(number: base_number)}".to_s
21
- .chars
23
+ "#{base_number}#{check_digit(number: base_number)}".chars
22
24
  .insert(3, ' ')
23
25
  .insert(7, ' ')
24
26
  .join
25
27
  end
26
28
 
29
+ private
30
+
27
31
  ##
28
32
  # Produces a random British NHS number's check digit.
29
33
  #
@@ -114,7 +114,7 @@ module Faker
114
114
  # @faker.version 1.0.0
115
115
  def hexadecimal(digits: 6)
116
116
  hex = ''
117
- digits.times { hex += rand(15).to_s(16) }
117
+ digits.times { hex += rand(16).to_s(16) }
118
118
  hex
119
119
  end
120
120
 
@@ -12,7 +12,7 @@ module Faker
12
12
  super()
13
13
 
14
14
  @name = name || "#{Name.first_name} #{Name.last_name}"
15
- @email = email || Internet.safe_email(name: self.name)
15
+ @email = email || Internet.email(name: self.name)
16
16
  @first_name, @last_name = self.name.split
17
17
  end
18
18
 
@@ -444,11 +444,11 @@ module Faker
444
444
  private
445
445
 
446
446
  def gender
447
- shuffle(%w[male female]).pop
447
+ sample(%w[male female])
448
448
  end
449
449
 
450
450
  def timezone
451
- shuffle((-12..12).to_a).pop
451
+ sample((-12..12).to_a)
452
452
  end
453
453
 
454
454
  def image
@@ -460,11 +460,11 @@ module Faker
460
460
  end
461
461
 
462
462
  def random_number_from_range(range)
463
- shuffle(range.to_a).pop
463
+ sample(range.to_a)
464
464
  end
465
465
 
466
466
  def random_boolean
467
- shuffle([true, false]).pop
467
+ sample([true, false])
468
468
  end
469
469
  end
470
470
  end
@@ -4,12 +4,14 @@ module Faker
4
4
  class PhoneNumber < Base
5
5
  class << self
6
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).
7
+ # Produces a phone number in a random format without the country code and it can have different dividers.
8
8
  #
9
9
  # @return [String]
10
10
  #
11
11
  # @example
12
- # Faker::PhoneNumber.phone_number #=> "397.693.1309 x4321"
12
+ # Faker::PhoneNumber.phone_number #=> "(504) 113-1705"
13
+ # Faker::PhoneNumber.phone_number #=> "662.291.7201"
14
+ # Faker::PhoneNumber.phone_number #=> "9415283713"
13
15
  #
14
16
  # @faker.version 0.3.0
15
17
  def phone_number
@@ -17,12 +19,14 @@ module Faker
17
19
  end
18
20
 
19
21
  ##
20
- # Produces a random cell phone number in a random format (may or may not have a country code and can have different dividers).
22
+ # Produces a random cell phone number in a random format without the country code and it can have different dividers.
21
23
  #
22
24
  # @return [String]
23
25
  #
24
26
  # @example
25
- # Faker::PhoneNumber.cell_phone #=> "(186)285-7925"
27
+ # Faker::PhoneNumber.cell_phone #=> "(836) 115-8995"
28
+ # Faker::PhoneNumber.cell_phone #=> "382-597-5739"
29
+ # Faker::PhoneNumber.cell_phone #=> "316.828.1822"
26
30
  #
27
31
  # @faker.version 1.0.0
28
32
  def cell_phone
@@ -36,10 +40,12 @@ module Faker
36
40
  #
37
41
  # @example
38
42
  # Faker::PhoneNumber.country_code #=> "+20"
43
+ # Faker::PhoneNumber.country_code #=> "+39"
44
+ # Faker::PhoneNumber.country_code #=> "+852"
39
45
  #
40
46
  # @faker.version 1.9.2
41
47
  def country_code
42
- "+#{fetch('country_code')}"
48
+ "+#{fetch('phone_number.country_code')}"
43
49
  end
44
50
 
45
51
  ##
@@ -48,7 +54,9 @@ module Faker
48
54
  # @return [String]
49
55
  #
50
56
  # @example
51
- # Faker::PhoneNumber.phone_number_with_country_code #=> "+95 1-672-173-8153"
57
+ # Faker::PhoneNumber.phone_number_with_country_code #=> "+55 466-746-6882"
58
+ # Faker::PhoneNumber.phone_number_with_country_code #=> "+81 3718219558"
59
+ # Faker::PhoneNumber.phone_number_with_country_code #=> "+49 140 957 9846"
52
60
  #
53
61
  # @faker.version 1.9.2
54
62
  def phone_number_with_country_code
@@ -61,7 +69,9 @@ module Faker
61
69
  # @return [String]
62
70
  #
63
71
  # @example
64
- # Faker::PhoneNumber.cell_phone_with_country_code #=> "+974 (190) 987-9034"
72
+ # Faker::PhoneNumber.cell_phone_with_country_code #=> "+852 (190) 987-9034"
73
+ # Faker::PhoneNumber.cell_phone_with_country_code #=> "+64 (820) 583-6474"
74
+ # Faker::PhoneNumber.cell_phone_with_country_code #=> "+1 591.871.7985"
65
75
  #
66
76
  # @faker.version 1.9.2
67
77
  def cell_phone_with_country_code
@@ -69,12 +79,14 @@ module Faker
69
79
  end
70
80
 
71
81
  ##
72
- # Produces a random phone number in e164 format.
82
+ # Produces a random phone number in e164 format, i.e., without any dividers.
73
83
  #
74
84
  # @return [String]
75
85
  #
76
86
  # @example
77
- # Faker::PhoneNumber.cell_phone_in_e164 #=> "+944937040625"
87
+ # Faker::PhoneNumber.cell_phone_in_e164 #=> "+542024834991"
88
+ # Faker::PhoneNumber.cell_phone_in_e164 #=> "+8522846847703"
89
+ # Faker::PhoneNumber.cell_phone_in_e164 #=> "+649477546575"
78
90
  #
79
91
  # @faker.version 1.9.2
80
92
  def cell_phone_in_e164
@@ -82,49 +94,56 @@ module Faker
82
94
  end
83
95
 
84
96
  ##
85
- # Produces a random US or Canada-based area code.
97
+ # Produces a random area code.
86
98
  #
87
99
  # @return [String]
88
100
  #
89
101
  # @example
90
102
  # Faker::PhoneNumber.area_code #=> "201"
103
+ # Faker::PhoneNumber.area_code #=> "613"
104
+ # Faker::PhoneNumber.area_code #=> "321"
91
105
  #
92
106
  # @faker.version 1.3.0
93
107
  def area_code
94
108
  fetch('phone_number.area_code')
95
- rescue I18n::MissingTranslationData
96
- nil
97
109
  end
98
110
 
99
111
  ##
100
- # Produces a random US or Canada-based exchange code.
112
+ # Produces a random exchange code.
101
113
  #
102
114
  # @return [String]
103
115
  #
104
116
  # @example
105
117
  # Faker::PhoneNumber.exchange_code #=> "208"
118
+ # Faker::PhoneNumber.exchange_code #=> "415"
119
+ # Faker::PhoneNumber.exchange_code #=> "652"
106
120
  #
107
121
  # @faker.version 1.3.0
108
122
  def exchange_code
109
123
  fetch('phone_number.exchange_code')
110
- rescue I18n::MissingTranslationData
111
- nil
112
124
  end
113
125
 
114
126
  ##
115
- # Produces a random US or Canada-based extension / subscriber number. Can be used for both extensions and last four digits of phone number.
127
+ # Produces a random extension / subscriber number. Can be used for both extensions and last four digits of phone number.
116
128
  #
117
- # @param length [Integer] Speficies the length of the return value.
129
+ # @param length [Integer] Specifies the length of the return value. Defaults to 4.
118
130
  # @return [String]
119
131
  #
120
132
  # @example
121
133
  # Faker::PhoneNumber.subscriber_number #=> "3873"
122
134
  # Faker::PhoneNumber.subscriber_number(length: 2) #=> "39"
123
135
  # Faker::PhoneNumber.extension #=> "3764"
136
+ # Faker::PhoneNumber.extension(length: 2) => "37"
124
137
  #
125
138
  # @faker.version 1.3.0
126
139
  def subscriber_number(length: 4)
127
- rand.to_s[2..(1 + length)]
140
+ if !length.is_a?(Integer) || length > 10
141
+ raise ArgumentError, 'length must be an Integer and be lesser than 10'
142
+ end
143
+
144
+ generate(:string) do |g|
145
+ g.int(length: length)
146
+ end
128
147
  end
129
148
 
130
149
  alias extension subscriber_number
@@ -45,7 +45,7 @@ module Faker
45
45
  private
46
46
 
47
47
  def generate_color
48
- format('%06x', (rand * 0xffffff))
48
+ format('%06x', rand * 0xffffff)
49
49
  end
50
50
  end
51
51
  end
@@ -13,7 +13,7 @@ module Faker
13
13
  #
14
14
  # @faker.version 1.9.2
15
15
  def id_number
16
- Faker::IDNumber.south_african_id_number
16
+ Faker::IdNumber.south_african_id_number
17
17
  end
18
18
 
19
19
  ##
@@ -26,7 +26,7 @@ module Faker
26
26
  #
27
27
  # @faker.version 1.9.2
28
28
  def valid_id_number
29
- Faker::IDNumber.valid_south_african_id_number
29
+ Faker::IdNumber.valid_south_african_id_number
30
30
  end
31
31
 
32
32
  ##
@@ -39,7 +39,7 @@ module Faker
39
39
  #
40
40
  # @faker.version 1.9.2
41
41
  def invalid_id_number
42
- Faker::IDNumber.invalid_south_african_id_number
42
+ Faker::IdNumber.invalid_south_african_id_number
43
43
  end
44
44
 
45
45
  ##
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Faker
4
- class Show < Base
4
+ class Theater < Base
5
5
  class << self
6
6
  ##
7
7
  # Produces the name of a musical for an older audience
@@ -9,12 +9,12 @@ module Faker
9
9
  # @return [String]
10
10
  #
11
11
  # @example
12
- # Faker::Alphanumeric.alpha
13
- # #=> "West Side Story"
12
+ # Faker::Theater.adult_musical
13
+ # #=> "Mamma Mia!"
14
14
  #
15
15
  # @faker.version 2.13.0
16
16
  def adult_musical
17
- fetch('show.adult_musical')
17
+ fetch('theater.adult_musical')
18
18
  end
19
19
 
20
20
  ##
@@ -23,12 +23,12 @@ module Faker
23
23
  # @return [String]
24
24
  #
25
25
  # @example
26
- # Faker::Alphanumeric.alpha
26
+ # Faker::Theater.kids_musical
27
27
  # #=> "Into the Woods JR."
28
28
  #
29
29
  # @faker.version 2.13.0
30
30
  def kids_musical
31
- fetch('show.kids_musical')
31
+ fetch('theater.kids_musical')
32
32
  end
33
33
 
34
34
  ##
@@ -37,12 +37,12 @@ module Faker
37
37
  # @return [String]
38
38
  #
39
39
  # @example
40
- # Faker::Alphanumeric.alpha
40
+ # Faker::Theater.play
41
41
  # #=> "Death of a Salesman"
42
42
  #
43
43
  # @faker.version 2.13.0
44
44
  def play
45
- fetch('show.play')
45
+ fetch('theater.play')
46
46
  end
47
47
  end
48
48
  end
@@ -18,7 +18,7 @@ module Faker
18
18
  # @faker.version 1.7.3
19
19
  def user(include_status: true, include_email: false)
20
20
  user_id = id
21
- background_image_url = Faker::LoremPixel.image(size: '600x400') # TODO: Make the dimensions change
21
+ background_image_url = Faker::LoremFlickr.image(size: '600x400')
22
22
  profile_image_url = Faker::Avatar.image(slug: user_id, size: '48x48')
23
23
  user = {
24
24
  id: user_id,
@@ -46,7 +46,7 @@ module Faker
46
46
  profile_background_image_url_https: background_image_url,
47
47
  profile_background_image_url: background_image_url.sub('https://', 'http://'),
48
48
  profile_background_tile: Faker::Boolean.boolean(true_ratio: 0.1),
49
- profile_banner_url: Faker::LoremPixel.image(size: '1500x500'),
49
+ profile_banner_url: Faker::LoremFlickr.image(size: '1500x500'),
50
50
  profile_image_url_https: profile_image_url,
51
51
  profile_image_url: profile_image_url.sub('https://', 'http://'),
52
52
  profile_link_color: Faker::Color.hex_color,
@@ -63,7 +63,7 @@ module Faker
63
63
  verified: Faker::Boolean.boolean(true_ratio: 0.1)
64
64
  }
65
65
  user[:status] = Faker::Twitter.status(include_user: false) if include_status
66
- user[:email] = Faker::Internet.safe_email if include_email
66
+ user[:email] = Faker::Internet.email if include_email
67
67
  user
68
68
  end
69
69
 
@@ -163,9 +163,7 @@ module Faker
163
163
  end
164
164
 
165
165
  def photo_entity
166
- # TODO: Dynamic image sizes
167
- # TODO: Return accurate indices
168
- media_url = Faker::LoremPixel.image(size: '1064x600')
166
+ media_url = Faker::LoremFlickr.image(size: '1064x600')
169
167
  media_id = id
170
168
  {
171
169
  id: media_id,
@@ -18,11 +18,9 @@ module Faker
18
18
  # @faker.version 1.8.6
19
19
  def rb_string(words: 1)
20
20
  resolved_num = resolve(words)
21
- word_list =
22
- translate('faker.lorem.words')
23
-
21
+ word_list = translate('faker.lorem.words')
24
22
  word_list *= ((resolved_num / word_list.length) + 1)
25
- shuffle(word_list)[0, resolved_num].join(' ')
23
+ sample(word_list, resolved_num).join(' ')
26
24
  end
27
25
 
28
26
  ##
@@ -97,12 +95,13 @@ module Faker
97
95
  # @example
98
96
  # Faker::Types.rb_array #=> ["a"]
99
97
  # Faker::Types.rb_array(len: 4) #=> ["a", 1, 2, "bob"]
98
+ # Faker::Types.rb_array(len: 2, type: -> { Faker::Types.rb_string }) #=> ["cat", "foo"]
100
99
  #
101
100
  # @faker.version 1.8.6
102
- def rb_array(len: 1)
101
+ def rb_array(len: 1, type: -> { random_type })
103
102
  [].tap do |ar|
104
103
  len.times do
105
- ar.push random_type
104
+ ar.push type.is_a?(Proc) ? type.call : type
106
105
  end
107
106
  end
108
107
  end