faker 3.5.1 → 3.8.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.
Files changed (288) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +251 -7
  3. data/README.md +78 -393
  4. data/lib/faker/blockchain/bitcoin.rb +0 -1
  5. data/lib/faker/blockchain/tezos.rb +0 -1
  6. data/lib/faker/blockchain.rb +9 -0
  7. data/lib/faker/books/lovecraft.rb +1 -1
  8. data/lib/faker/books.rb +9 -0
  9. data/lib/faker/creature.rb +9 -0
  10. data/lib/faker/default/avatar.rb +1 -1
  11. data/lib/faker/default/bank.rb +1 -5
  12. data/lib/faker/default/boolean.rb +2 -1
  13. data/lib/faker/default/code.rb +4 -0
  14. data/lib/faker/default/company.rb +2 -2
  15. data/lib/faker/default/crypto.rb +0 -2
  16. data/lib/faker/default/driving_licence.rb +3 -3
  17. data/lib/faker/default/finance.rb +2 -2
  18. data/lib/faker/default/hipster.rb +1 -1
  19. data/lib/faker/default/html.rb +4 -4
  20. data/lib/faker/default/id_number.rb +1 -1
  21. data/lib/faker/default/invoice.rb +2 -2
  22. data/lib/faker/default/json.rb +7 -2
  23. data/lib/faker/default/lorem.rb +3 -3
  24. data/lib/faker/default/lorem_flickr.rb +1 -1
  25. data/lib/faker/default/markdown.rb +5 -5
  26. data/lib/faker/default/national_health_service.rb +1 -2
  27. data/lib/faker/default/omniauth.rb +58 -58
  28. data/lib/faker/default/placeholdit.rb +2 -2
  29. data/lib/faker/default/string.rb +1 -1
  30. data/lib/faker/default/types.rb +2 -2
  31. data/lib/faker/default/x.rb +189 -0
  32. data/lib/faker/default.rb +9 -0
  33. data/lib/faker/fantasy.rb +9 -0
  34. data/lib/faker/games.rb +9 -0
  35. data/lib/faker/{default/internet.rb → internet.rb} +8 -4
  36. data/lib/faker/japanese_media.rb +9 -0
  37. data/lib/faker/locations.rb +9 -0
  38. data/lib/faker/movies.rb +9 -0
  39. data/lib/faker/music/bossa_nova.rb +35 -0
  40. data/lib/faker/music/grateful_dead.rb +0 -2
  41. data/lib/faker/music/pearl_jam.rb +0 -2
  42. data/lib/faker/music/rush.rb +0 -2
  43. data/lib/faker/music/smashing_pumpkins.rb +0 -2
  44. data/lib/faker/{music/music.rb → music.rb} +4 -0
  45. data/lib/faker/quotes.rb +9 -0
  46. data/lib/faker/religion/bible.rb +1 -1
  47. data/lib/faker/religion.rb +9 -0
  48. data/lib/faker/sports.rb +9 -0
  49. data/lib/faker/travel.rb +9 -0
  50. data/lib/faker/tv_shows.rb +9 -0
  51. data/lib/faker/version.rb +1 -1
  52. data/lib/faker.rb +67 -12
  53. data/lib/helpers/deprecator.rb +1 -1
  54. data/lib/helpers/positional_generator.rb +0 -2
  55. data/lib/helpers/unique_generator.rb +1 -1
  56. data/lib/locales/README.md +2 -2
  57. data/lib/locales/ar.yml +1606 -49
  58. data/lib/locales/bg.yml +935 -18
  59. data/lib/locales/ca-CAT.yml +347 -12
  60. data/lib/locales/ca.yml +580 -7
  61. data/lib/locales/de-CH.yml +31 -0
  62. data/lib/locales/ee.yml +1185 -26
  63. data/lib/locales/en/adjective.yml +174 -174
  64. data/lib/locales/en/airport.yml +374 -374
  65. data/lib/locales/en/ancient.yml +128 -4
  66. data/lib/locales/en/animal.yml +141 -2
  67. data/lib/locales/en/app.yml +89 -2
  68. data/lib/locales/en/appliance.yml +81 -2
  69. data/lib/locales/en/aqua_teen_hunger_force.yml +31 -31
  70. data/lib/locales/en/artist.yml +43 -1
  71. data/lib/locales/en/avatar.yml +54 -28
  72. data/lib/locales/en/back_to_the_future.yml +145 -117
  73. data/lib/locales/en/bank.yml +91 -2
  74. data/lib/locales/en/beer.yml +232 -6
  75. data/lib/locales/en/bible.yml +3 -6
  76. data/lib/locales/en/big_bang_theory.yml +34 -35
  77. data/lib/locales/en/bird.yml +1225 -1226
  78. data/lib/locales/en/bojack_horseman.yml +63 -3
  79. data/lib/locales/en/book.yml +0 -1
  80. data/lib/locales/en/bossa_nova.yml +110 -3
  81. data/lib/locales/en/breaking_bad.yml +110 -25
  82. data/lib/locales/en/brooklyn_nine_nine.yml +0 -1
  83. data/lib/locales/en/buffy.yml +239 -257
  84. data/lib/locales/en/business.yml +18 -2
  85. data/lib/locales/en/cannabis.yml +344 -10
  86. data/lib/locales/en/cat.yml +155 -3
  87. data/lib/locales/en/chess.yml +2 -3
  88. data/lib/locales/en/chiquito.yml +60 -61
  89. data/lib/locales/en/chuck_norris.yml +78 -79
  90. data/lib/locales/en/clash_of_clan.yml +0 -2
  91. data/lib/locales/en/code.yml +501 -1
  92. data/lib/locales/en/coffee.yml +450 -25
  93. data/lib/locales/en/color.yml +73 -1
  94. data/lib/locales/en/commerce.yml +117 -23
  95. data/lib/locales/en/community.yml +55 -30
  96. data/lib/locales/en/company.yml +1756 -14
  97. data/lib/locales/en/compass.yml +108 -12
  98. data/lib/locales/en/conan.yml +0 -2
  99. data/lib/locales/en/construction.yml +416 -422
  100. data/lib/locales/en/cosmere.yml +219 -54
  101. data/lib/locales/en/cowboy_bebop.yml +56 -59
  102. data/lib/locales/en/culture_series.yml +298 -298
  103. data/lib/locales/en/currency.yml +358 -3
  104. data/lib/locales/en/dc_comics.yml +178 -49
  105. data/lib/locales/en/demographic.yml +215 -215
  106. data/lib/locales/en/departed.yml +40 -44
  107. data/lib/locales/en/dessert.yml +78 -3
  108. data/lib/locales/en/doraemon.yml +278 -280
  109. data/lib/locales/en/dr_who.yml +468 -93
  110. data/lib/locales/en/dragon_ball.yml +240 -240
  111. data/lib/locales/en/dumb_and_dumber.yml +72 -56
  112. data/lib/locales/en/elder_scrolls.yml +52 -53
  113. data/lib/locales/en/electrical_components.yml +49 -3
  114. data/lib/locales/en/esport.yml +58 -5
  115. data/lib/locales/en/family_guy.yml +54 -4
  116. data/lib/locales/en/file.yml +108 -9
  117. data/lib/locales/en/final_space.yml +1 -3
  118. data/lib/locales/en/finance.yml +1 -1
  119. data/lib/locales/en/food.yml +1 -1
  120. data/lib/locales/en/football.yml +121 -5
  121. data/lib/locales/en/fresh_prince_of_bel_air.yml +119 -70
  122. data/lib/locales/en/friends.yml +162 -3
  123. data/lib/locales/en/funny_name.yml +752 -1
  124. data/lib/locales/en/futurama.yml +7 -15
  125. data/lib/locales/en/game_of_thrones.yml +2487 -5
  126. data/lib/locales/en/gender.yml +15 -3
  127. data/lib/locales/en/ghostbusters.yml +101 -88
  128. data/lib/locales/en/grateful_dead.yml +47 -45
  129. data/lib/locales/en/greek_philosophers.yml +44 -23
  130. data/lib/locales/en/hacker.yml +110 -5
  131. data/lib/locales/en/hackers.yml +1 -1
  132. data/lib/locales/en/harry_potter.yml +323 -6
  133. data/lib/locales/en/hey_arnold.yml +104 -21
  134. data/lib/locales/en/hipster.yml +203 -1
  135. data/lib/locales/en/hitchhikers_guide_to_the_galaxy.yml +243 -42
  136. data/lib/locales/en/hobby.yml +0 -1
  137. data/lib/locales/en/horse.yml +446 -2
  138. data/lib/locales/en/house.yml +34 -2
  139. data/lib/locales/en/how_i_met_your_mother.yml +97 -25
  140. data/lib/locales/en/how_to_train_your_dragon.yml +0 -1
  141. data/lib/locales/en/id_number.yml +6 -1
  142. data/lib/locales/en/industry_segments.yml +188 -4
  143. data/lib/locales/en/job.yml +98 -7
  144. data/lib/locales/en/kamen_rider.yml +272 -6
  145. data/lib/locales/en/kpop.yml +954 -80
  146. data/lib/locales/en/lebowski.yml +58 -40
  147. data/lib/locales/en/lorem.yml +1095 -6
  148. data/lib/locales/en/markdown.yml +12 -2
  149. data/lib/locales/en/marketing.yml +54 -1
  150. data/lib/locales/en/measurement.yml +42 -8
  151. data/lib/locales/en/michael_scott.yml +41 -42
  152. data/lib/locales/en/movie.yml +188 -176
  153. data/lib/locales/en/name.yml +6068 -6
  154. data/lib/locales/en/nato_phonetic_alphabet.yml +27 -1
  155. data/lib/locales/en/new_girl.yml +35 -37
  156. data/lib/locales/en/one_piece.yml +359 -6
  157. data/lib/locales/en/opera.yml +1 -1
  158. data/lib/locales/en/overwatch.yml +1 -1
  159. data/lib/locales/en/parks_and_rec.yml +33 -4
  160. data/lib/locales/en/pearl_jam.yml +207 -207
  161. data/lib/locales/en/phish.yml +388 -389
  162. data/lib/locales/en/prince.yml +219 -219
  163. data/lib/locales/en/princess_bride.yml +48 -2
  164. data/lib/locales/en/programming_language.yml +753 -3
  165. data/lib/locales/en/quote.yml +599 -685
  166. data/lib/locales/en/rajnikanth.yml +74 -74
  167. data/lib/locales/en/relationship.yml +29 -6
  168. data/lib/locales/en/restaurant.yml +31 -31
  169. data/lib/locales/en/rick_and_morty.yml +116 -3
  170. data/lib/locales/en/rock_band.yml +228 -2
  171. data/lib/locales/en/rupaul.yml +120 -122
  172. data/lib/locales/en/seinfeld.yml +110 -3
  173. data/lib/locales/en/shakespeare.yml +46 -50
  174. data/lib/locales/en/silicon_valley.yml +122 -50
  175. data/lib/locales/en/simpsons.yml +897 -691
  176. data/lib/locales/en/slack_emoji.yml +874 -8
  177. data/lib/locales/en/space.yml +373 -14
  178. data/lib/locales/en/star_trek.yml +105 -4
  179. data/lib/locales/en/star_wars.yml +525 -528
  180. data/lib/locales/en/stargate.yml +65 -18
  181. data/lib/locales/en/stranger_thing.yml +31 -33
  182. data/lib/locales/en/street_fighter.yml +1 -1
  183. data/lib/locales/en/subscription.yml +47 -5
  184. data/lib/locales/en/superhero.yml +574 -4
  185. data/lib/locales/en/sword_art_online.yml +327 -331
  186. data/lib/locales/en/team.yml +125 -3
  187. data/lib/locales/en/the_expanse.yml +92 -4
  188. data/lib/locales/en/the_it_crowd.yml +148 -152
  189. data/lib/locales/en/the_office.yml +77 -81
  190. data/lib/locales/en/the_room.yml +35 -35
  191. data/lib/locales/en/the_thick_of_it.yml +83 -3
  192. data/lib/locales/en/theater.yml +593 -593
  193. data/lib/locales/en/tolkien.yml +2 -2
  194. data/lib/locales/en/touhou.yml +54 -54
  195. data/lib/locales/en/tron.yml +191 -191
  196. data/lib/locales/en/twin_peaks.yml +130 -3
  197. data/lib/locales/en/umphreys_mcgee.yml +266 -1
  198. data/lib/locales/en/university.yml +15 -2
  199. data/lib/locales/en/v_for_vendetta.yml +157 -160
  200. data/lib/locales/en/venture_bros.yml +225 -4
  201. data/lib/locales/en/verbs.yml +3785 -5
  202. data/lib/locales/en/volleyball.yml +493 -493
  203. data/lib/locales/en/warhammer_fantasy.yml +540 -573
  204. data/lib/locales/en/world_cup.yml +1132 -235
  205. data/lib/locales/en/yoda.yml +38 -1
  206. data/lib/locales/en-BORK.yml +104 -1
  207. data/lib/locales/en-GB.yml +9 -7
  208. data/lib/locales/en-NG.yml +737 -66
  209. data/lib/locales/en-PAK.yml +24 -1
  210. data/lib/locales/en-TH.yml +1 -1
  211. data/lib/locales/en-UG.yml +374 -76
  212. data/lib/locales/en-ZA.yml +1394 -13
  213. data/lib/locales/es-AR.yml +1 -1
  214. data/lib/locales/es-MX.yml +1907 -40
  215. data/lib/locales/es.yml +2117 -52
  216. data/lib/locales/fa.yml +1624 -5
  217. data/lib/locales/fi-FI.yml +315 -17
  218. data/lib/locales/fr/address.yml +761 -8
  219. data/lib/locales/fr/adjective.yml +261 -261
  220. data/lib/locales/fr/ancient.yml +134 -134
  221. data/lib/locales/fr/animal.yml +118 -1
  222. data/lib/locales/fr/appliance.yml +66 -1
  223. data/lib/locales/fr/book.yml +27 -3
  224. data/lib/locales/fr/color.yml +31 -1
  225. data/lib/locales/fr/company.yml +490 -10
  226. data/lib/locales/fr/compass.yml +58 -10
  227. data/lib/locales/fr/demographic.yml +3 -1
  228. data/lib/locales/fr/gender.yml +18 -3
  229. data/lib/locales/fr/internet.yml +12 -1
  230. data/lib/locales/fr/lorem.yml +1091 -2
  231. data/lib/locales/fr/measurement.yml +31 -4
  232. data/lib/locales/fr/name.yml +1176 -5
  233. data/lib/locales/fr/phone_number.yml +34 -3
  234. data/lib/locales/fr/pokemon.yml +417 -3
  235. data/lib/locales/fr-CA.yml +12 -6
  236. data/lib/locales/fr-CH.yml +2455 -41
  237. data/lib/locales/he.yml +255 -9
  238. data/lib/locales/hy.yml +12 -6
  239. data/lib/locales/it.yml +12 -6
  240. data/lib/locales/ja/address.yml +350 -120526
  241. data/lib/locales/ja/ancient.yml +15 -1
  242. data/lib/locales/ja/animal.yml +83 -1
  243. data/lib/locales/ja/artist.yml +46 -0
  244. data/lib/locales/ja/bank.yml +136 -1
  245. data/lib/locales/ja/book.yml +492 -3
  246. data/lib/locales/ja/cat.yml +75 -1
  247. data/lib/locales/ja/coffee.yml +19 -1
  248. data/lib/locales/ja/color.yml +32 -1
  249. data/lib/locales/ja/commerce.yml +98 -6
  250. data/lib/locales/ja/company.yml +20 -2
  251. data/lib/locales/ja/dog.yml +335 -2
  252. data/lib/locales/ja/emotion.yml +1 -3
  253. data/lib/locales/ja/food.yml +38 -1
  254. data/lib/locales/ja/gender.yml +3 -1
  255. data/lib/locales/ja/lorem.yml +1014 -3
  256. data/lib/locales/ja/name.yml +203 -3
  257. data/lib/locales/ja/overwatch.yml +33 -1
  258. data/lib/locales/ja/phone_number.yml +9 -3
  259. data/lib/locales/ja/pokemon.yml +437 -3
  260. data/lib/locales/ja/relationship.yml +29 -6
  261. data/lib/locales/ja/restaurant.yml +74 -3
  262. data/lib/locales/ja/space.yml +20 -2
  263. data/lib/locales/ja/subscription.yml +47 -5
  264. data/lib/locales/ja/super_mario.yml +68 -4
  265. data/lib/locales/ja/university.yml +15 -2
  266. data/lib/locales/ja/zelda.yml +15 -1
  267. data/lib/locales/ko.yml +1 -1
  268. data/lib/locales/lv.yml +1221 -26
  269. data/lib/locales/nl.yml +33514 -55
  270. data/lib/locales/pl.yml +4008 -37
  271. data/lib/locales/sk.yml +12 -6
  272. data/lib/locales/sv.yml +639 -49
  273. data/lib/locales/th.yml +375 -375
  274. data/lib/locales/tr.yml +77 -18
  275. data/lib/locales/uk.yml +7 -7
  276. data/lib/locales/vi.yml +392 -49
  277. data/lib/locales/zh-CN.yml +540 -19
  278. data/lib/locales/zh-TW.yml +1030 -15
  279. metadata +29 -18
  280. data/lib/faker/default/bossa_nova.rb +0 -33
  281. data/lib/faker/default/religion.rb +0 -6
  282. data/lib/faker/default/twitter.rb +0 -207
  283. /data/lib/faker/{books → default}/book.rb +0 -0
  284. /data/lib/faker/{games → default}/game.rb +0 -0
  285. /data/lib/faker/{movies → default}/movie.rb +0 -0
  286. /data/lib/faker/{quotes → default}/quote.rb +0 -0
  287. /data/lib/faker/{sports → default}/sport.rb +0 -0
  288. /data/lib/faker/{default/internet_http.rb → internet/http.rb} +0 -0
@@ -494,7 +494,7 @@ module Faker
494
494
  # Construct taxpayer number
495
495
  gen.group(name: :taxpayer_number) do |g_|
496
496
  g_.letter(length: 3, ranges: ['A'..'Z'])
497
- g_.letter(length: 1, ranges: [%w[A B C F G H L J P T K]].to_a)
497
+ g_.letter(length: 1, ranges: [%w[A B C F G H L J P T K]])
498
498
  g_.letter(length: 1, ranges: ['A'..'Z'])
499
499
  g_.int(length: 4, ranges: [0..9999])
500
500
  g_.letter(length: 1, ranges: ['A'..'Z'])
@@ -591,7 +591,7 @@ module Faker
591
591
 
592
592
  def weight_sum(array, weights)
593
593
  sum = 0
594
- (0..weights.size - 1).each do |index|
594
+ (0..(weights.size - 1)).each do |index|
595
595
  sum += (array[index] * weights[index])
596
596
  end
597
597
  sum
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'openssl'
4
-
5
3
  module Faker
6
4
  class Crypto < Base
7
5
  class << self
@@ -61,11 +61,11 @@ module Faker
61
61
  # Faker::DrivingLicence.uk_driving_licence #=> "70702548"
62
62
  #
63
63
  # @faker.version 1.9.2
64
- def uk_driving_licence(*args)
64
+ def uk_driving_licence(*)
65
65
  if Faker::Config.random.rand < NI_CHANCE
66
66
  northern_irish_driving_licence
67
67
  else
68
- british_driving_licence(*args)
68
+ british_driving_licence(*)
69
69
  end
70
70
  end
71
71
 
@@ -104,7 +104,7 @@ module Faker
104
104
  end
105
105
  g.computed do
106
106
  gender_marker = gender == :female ? 50 : 0
107
- format('%02d', (dob.month + gender_marker))
107
+ format('%02d', dob.month + gender_marker)
108
108
  end
109
109
  g.computed do
110
110
  format('%02d', dob.day)
@@ -97,11 +97,11 @@ module Faker
97
97
  ##
98
98
  # Returns a random condominium fiscal code.
99
99
  #
100
- # @param country [String] Two capital letter country code to use for the vat number.
100
+ # @param country [String] Two capital letter country code to use for the condominium fiscal code number.
101
101
  # @return [String]
102
102
  #
103
103
  # @example
104
- # Faker::Finance.condominium_fiscal_code #=> "012345678"
104
+ # Faker::Finance.condominium_fiscal_code #=> "01234567890"
105
105
  #
106
106
  # @faker.version next
107
107
  def condominium_fiscal_code(country: 'IT')
@@ -147,7 +147,7 @@ module Faker
147
147
 
148
148
  paragraph += " #{paragraph(sentence_count: 3, supplemental: supplemental)}" while paragraph.length < characters
149
149
 
150
- "#{paragraph[0...characters - 1]}."
150
+ "#{paragraph[0...(characters - 1)]}."
151
151
  end
152
152
  end
153
153
  end
@@ -14,7 +14,7 @@ module Faker
14
14
  # @faker.version 3.2.1
15
15
  def heading
16
16
  level = rand(1..6)
17
- "<h#{level}>#{Lorem.word.capitalize}</h#{level}>"
17
+ "<h#{level}>#{Faker::Lorem.word.capitalize}</h#{level}>"
18
18
  end
19
19
 
20
20
  ##
@@ -97,7 +97,7 @@ module Faker
97
97
  #
98
98
  # @faker.version 3.2.1
99
99
  def code
100
- "<code>#{Lorem.sentence(word_count: 1)}</code>"
100
+ "<code>#{Faker::Lorem.sentence(word_count: 1)}</code>"
101
101
  end
102
102
 
103
103
  ##
@@ -165,7 +165,7 @@ module Faker
165
165
  # Faker::HTML.element(tag: 'div', content: "This is a div with XSS attributes.", attributes: {class: 'xss', onclick: "alert('XSS')"}) #=> "<div class=\"xss\" onclick=\"alert('XSS')\">This is a div with XSS attributes.</div>"
166
166
  #
167
167
  # @faker.version 3.2.1
168
- def element(tag: 'div', content: Lorem.sentence(word_count: 3), attributes: { class: Lorem.word, onclick: "#{Lorem.word}()" })
168
+ def element(tag: 'div', content: Faker::Lorem.sentence(word_count: 3), attributes: { class: Faker::Lorem.word, onclick: "#{Faker::Lorem.word}()" })
169
169
  attribute_string = attributes.map { |key, value| "#{key}=\"#{value}\"" }.join(' ')
170
170
  "<#{tag} #{attribute_string}>#{content}</#{tag}>"
171
171
  end
@@ -187,7 +187,7 @@ module Faker
187
187
  def random(exclude: [])
188
188
  method_list = available_methods
189
189
  exclude.each { |ex| method_list.delete_if { |meth| meth == ex.to_sym } }
190
- send(method_list[Faker::Config.random.rand(0..method_list.length - 1)])
190
+ send(method_list[Faker::Config.random.rand(0..(method_list.length - 1))])
191
191
  end
192
192
 
193
193
  ##
@@ -137,7 +137,7 @@ module Faker
137
137
  Faker::Number.number(digits: 2),
138
138
  Faker::Number.between(from: 13, to: 99),
139
139
  Faker::Number.between(from: 32, to: 99)
140
- ].map(&:to_s).join
140
+ ].join
141
141
 
142
142
  id_number = [
143
143
  invalid_date_of_birth,
@@ -13,8 +13,8 @@ module Faker
13
13
  # @return [Integer]
14
14
  #
15
15
  # @example
16
- # Faker::Finance.amount_between #=> 0
17
- # Faker::Finance.amount_between(0, 10) #=> 4.33
16
+ # Faker::Invoice.amount_between #=> 0
17
+ # Faker::Invoice.amount_between(from: 0, to: 10) #=> 4.33
18
18
  #
19
19
  # @faker.version 1.9.0
20
20
  def amount_between(from: 0, to: 0)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Faker
2
4
  class Json < Base
3
5
  require 'json'
@@ -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
@@ -58,7 +58,7 @@ module Faker
58
58
  #
59
59
  # @faker.version 2.1.3
60
60
  def character
61
- sample(Types::CHARACTERS)
61
+ sample(Faker::Types::CHARACTERS)
62
62
  end
63
63
 
64
64
  ##
@@ -78,7 +78,7 @@ module Faker
78
78
  #
79
79
  # @faker.version 2.1.3
80
80
  def characters(number: 255, min_alpha: 0, min_numeric: 0)
81
- Alphanumeric.alphanumeric(number: number, min_alpha: min_alpha, min_numeric: min_numeric)
81
+ Faker::Alphanumeric.alphanumeric(number: number, min_alpha: min_alpha, min_numeric: min_numeric)
82
82
  end
83
83
 
84
84
  ##
@@ -194,7 +194,7 @@ module Faker
194
194
 
195
195
  paragraph += " #{paragraph(sentence_count: 3, supplemental: supplemental)}" while paragraph.length < number
196
196
 
197
- "#{paragraph[0...number - 1]}."
197
+ "#{paragraph[0...(number - 1)]}."
198
198
  end
199
199
 
200
200
  ##
@@ -96,7 +96,7 @@ module Faker
96
96
  private
97
97
 
98
98
  def build_url(size, format, search_terms, match_all)
99
- raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /^[0-9]+x[0-9]+$/
99
+ raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /\A[0-9]+x[0-9]+\z/
100
100
 
101
101
  url_parts = ['https://loremflickr.com']
102
102
  url_parts << format
@@ -13,7 +13,7 @@ module Faker
13
13
  #
14
14
  # @faker.version 1.8.0
15
15
  def headers
16
- "#{fetch('markdown.headers')} #{Lorem.word.capitalize}"
16
+ "#{fetch('markdown.headers')} #{Faker::Lorem.word.capitalize}"
17
17
  end
18
18
 
19
19
  ##
@@ -28,7 +28,7 @@ module Faker
28
28
  def emphasis
29
29
  paragraph = Faker::Lorem.paragraph(sentence_count: 3)
30
30
  words = paragraph.split
31
- position = rand(0..words.length - 1)
31
+ position = rand(0..(words.length - 1))
32
32
  formatting = fetch('markdown.emphasis')
33
33
  words[position] = "#{formatting}#{words[position]}#{formatting}"
34
34
  words.join(' ')
@@ -95,7 +95,7 @@ module Faker
95
95
  #
96
96
  # @faker.version 1.8.0
97
97
  def block_code
98
- "```ruby\n#{Lorem.sentence(word_count: 1)}\n```"
98
+ "```ruby\n#{Faker::Lorem.sentence(word_count: 1)}\n```"
99
99
  end
100
100
 
101
101
  ##
@@ -110,7 +110,7 @@ module Faker
110
110
  def table
111
111
  table = []
112
112
  3.times do
113
- table << "#{Lorem.word} | #{Lorem.word} | #{Lorem.word}"
113
+ table << "#{Faker::Lorem.word} | #{Faker::Lorem.word} | #{Faker::Lorem.word}"
114
114
  end
115
115
  table.insert(1, '---- | ---- | ----')
116
116
  table.join("\n")
@@ -133,7 +133,7 @@ module Faker
133
133
  def random(*args)
134
134
  method_list = available_methods
135
135
  args&.each { |ex| method_list.delete_if { |meth| meth == ex.to_sym } }
136
- send(method_list[Faker::Config.random.rand(0..method_list.length - 1)])
136
+ send(method_list[Faker::Config.random.rand(0..(method_list.length - 1))])
137
137
  end
138
138
 
139
139
  ##
@@ -20,8 +20,7 @@ module Faker
20
20
  # If the check digit is equivalent to 10, the number is invalid.
21
21
  # See https://en.wikipedia.org/wiki/NHS_number
22
22
  base_number -= 1 if check_digit(number: base_number) == 10
23
- "#{base_number}#{check_digit(number: base_number)}".to_s
24
- .chars
23
+ "#{base_number}#{check_digit(number: base_number)}".chars
25
24
  .insert(3, ' ')
26
25
  .insert(7, ' ')
27
26
  .join
@@ -11,8 +11,8 @@ module Faker
11
11
  def initialize(name: nil, email: nil)
12
12
  super()
13
13
 
14
- @name = name || "#{Name.first_name} #{Name.last_name}"
15
- @email = email || Internet.email(name: self.name)
14
+ @name = name || "#{Faker::Name.first_name} #{Faker::Name.last_name}"
15
+ @email = email || Faker::Internet.email(name: self.name)
16
16
  @first_name, @last_name = self.name.split
17
17
  end
18
18
 
@@ -27,8 +27,8 @@ module Faker
27
27
  # @return [Hash] An auth hash in the format provided by omniauth-google.
28
28
  #
29
29
  # @faker.version 1.8.0
30
- def google(name: nil, email: nil, uid: Number.number(digits: 9).to_s)
31
- auth = Omniauth.new(name: name, email: email)
30
+ def google(name: nil, email: nil, uid: Faker::Number.number(digits: 9).to_s)
31
+ auth = new(name: name, email: email)
32
32
  {
33
33
  provider: 'google_oauth2',
34
34
  uid: uid,
@@ -40,9 +40,9 @@ module Faker
40
40
  image: image
41
41
  },
42
42
  credentials: {
43
- token: Crypto.md5,
44
- refresh_token: Crypto.md5,
45
- expires_at: Time.forward.to_i,
43
+ token: Faker::Crypto.md5,
44
+ refresh_token: Faker::Crypto.md5,
45
+ expires_at: Faker::Time.forward.to_i,
46
46
  expires: true
47
47
  },
48
48
  extra: {
@@ -56,20 +56,20 @@ module Faker
56
56
  profile: "https://plus.google.com/#{uid}",
57
57
  picture: image,
58
58
  gender: gender,
59
- birthday: Date.backward(days: 36_400).strftime('%Y-%m-%d'),
59
+ birthday: Faker::Date.backward(days: 36_400).strftime('%Y-%m-%d'),
60
60
  locale: 'en',
61
- hd: "#{Company.name.downcase}.com"
61
+ hd: "#{Faker::Company.name.downcase}.com"
62
62
  },
63
63
  id_info: {
64
64
  iss: 'accounts.google.com',
65
- at_hash: Crypto.md5,
65
+ at_hash: Faker::Crypto.md5,
66
66
  email_verified: true,
67
- sub: Number.number(digits: 28).to_s,
67
+ sub: Faker::Number.number(digits: 28).to_s,
68
68
  azp: 'APP_ID',
69
69
  email: auth.email,
70
70
  aud: 'APP_ID',
71
- iat: Time.forward.to_i,
72
- exp: Time.forward.to_i,
71
+ iat: Faker::Time.forward.to_i,
72
+ exp: Faker::Time.forward.to_i,
73
73
  openid_id: "https://www.google.com/accounts/o8/id?id=#{uid}"
74
74
  }
75
75
  }
@@ -87,8 +87,8 @@ module Faker
87
87
  # @return [Hash] An auth hash in the format provided by omniauth-facebook.
88
88
  #
89
89
  # @faker.version 1.8.0
90
- def facebook(name: nil, email: nil, username: nil, uid: Number.number(digits: 7).to_s)
91
- auth = Omniauth.new(name: name, email: email)
90
+ def facebook(name: nil, email: nil, username: nil, uid: Faker::Number.number(digits: 7).to_s)
91
+ auth = new(name: name, email: email)
92
92
  username ||= "#{auth.first_name.downcase[0]}#{auth.last_name.downcase}"
93
93
  {
94
94
  provider: 'facebook',
@@ -102,7 +102,7 @@ module Faker
102
102
  verified: random_boolean
103
103
  },
104
104
  credentials: {
105
- token: Crypto.md5,
105
+ token: Faker::Crypto.md5,
106
106
  expires_at: Time.forward.to_i,
107
107
  expires: true
108
108
  },
@@ -115,7 +115,7 @@ module Faker
115
115
  link: "http://www.facebook.com/#{username}",
116
116
  username: username,
117
117
  location: {
118
- id: Number.number(digits: 9).to_s,
118
+ id: Faker::Number.number(digits: 9).to_s,
119
119
  name: city_state
120
120
  },
121
121
  gender: gender,
@@ -123,7 +123,7 @@ module Faker
123
123
  timezone: timezone,
124
124
  locale: 'en_US',
125
125
  verified: random_boolean,
126
- updated_time: Time.backward.iso8601
126
+ updated_time: Faker::Time.backward.iso8601
127
127
  }
128
128
  }
129
129
  }
@@ -139,11 +139,11 @@ module Faker
139
139
  # @return [Hash] An auth hash in the format provided by omniauth-twitter.
140
140
  #
141
141
  # @faker.version 1.8.0
142
- def twitter(name: nil, nickname: nil, uid: Number.number(digits: 6).to_s)
143
- auth = Omniauth.new(name: name)
142
+ def twitter(name: nil, nickname: nil, uid: Faker::Number.number(digits: 6).to_s)
143
+ auth = new(name: name)
144
144
  nickname ||= auth.name.downcase.delete(' ')
145
145
  location = city_state
146
- description = Lorem.sentence
146
+ description = Faker::Lorem.sentence
147
147
  {
148
148
  provider: 'twitter',
149
149
  uid: uid,
@@ -159,26 +159,26 @@ module Faker
159
159
  }
160
160
  },
161
161
  credentials: {
162
- token: Crypto.md5,
163
- secret: Crypto.md5
162
+ token: Faker::Crypto.md5,
163
+ secret: Faker::Crypto.md5
164
164
  },
165
165
  extra: {
166
166
  access_token: '',
167
167
  raw_info: {
168
168
  name: auth.name,
169
169
  listed_count: random_number_from_range(1..10),
170
- profile_sidebar_border_color: Color.hex_color,
170
+ profile_sidebar_border_color: Faker::Color.hex_color,
171
171
  url: nil,
172
172
  lang: 'en',
173
173
  statuses_count: random_number_from_range(1..1000),
174
174
  profile_image_url: image,
175
175
  profile_background_image_url_https: image,
176
176
  location: location,
177
- time_zone: Address.city,
177
+ time_zone: Faker::Address.city,
178
178
  follow_request_sent: random_boolean,
179
179
  id: uid,
180
180
  profile_background_tile: random_boolean,
181
- profile_sidebar_fill_color: Color.hex_color,
181
+ profile_sidebar_fill_color: Faker::Color.hex_color,
182
182
  followers_count: random_number_from_range(1..10_000),
183
183
  default_profile_image: random_boolean,
184
184
  screen_name: '',
@@ -186,7 +186,7 @@ module Faker
186
186
  utc_offset: timezone,
187
187
  verified: random_boolean,
188
188
  favourites_count: random_number_from_range(1..10),
189
- profile_background_color: Color.hex_color,
189
+ profile_background_color: Faker::Color.hex_color,
190
190
  is_translator: random_boolean,
191
191
  friends_count: random_number_from_range(1..10_000),
192
192
  notifications: random_boolean,
@@ -194,8 +194,8 @@ module Faker
194
194
  profile_background_image_url: image,
195
195
  protected: random_boolean,
196
196
  description: description,
197
- profile_link_color: Color.hex_color,
198
- created_at: Time.backward.strftime('%a %b %d %H:%M:%S %z %Y'),
197
+ profile_link_color: Faker::Color.hex_color,
198
+ created_at: Faker::Time.backward.strftime('%a %b %d %H:%M:%S %z %Y'),
199
199
  id_str: uid,
200
200
  profile_image_url_https: image,
201
201
  default_profile: random_boolean,
@@ -222,15 +222,15 @@ module Faker
222
222
  # @return [Hash] An auth hash in the format provided by omniauth-linkedin.
223
223
  #
224
224
  # @faker.version 1.8.0
225
- def linkedin(name: nil, email: nil, uid: Number.number(digits: 6).to_s)
225
+ def linkedin(name: nil, email: nil, uid: Faker::Number.number(digits: 6).to_s)
226
226
  auth = Omniauth.new(name: name, email: email)
227
227
  first_name = auth.first_name.downcase
228
228
  last_name = auth.last_name.downcase
229
229
  location = city_state
230
- description = Lorem.sentence
231
- token = Crypto.md5
232
- secret = Crypto.md5
233
- industry = Commerce.department
230
+ description = Faker::Lorem.sentence
231
+ token = Faker::Crypto.md5
232
+ secret = Faker::Crypto.md5
233
+ industry = Faker::Commerce.department
234
234
  url = "http://www.linkedin.com/in/#{first_name}#{last_name}"
235
235
  {
236
236
  provider: 'linkedin',
@@ -244,7 +244,7 @@ module Faker
244
244
  location: location,
245
245
  description: description,
246
246
  image: image,
247
- phone: PhoneNumber.phone_number,
247
+ phone: Faker::PhoneNumber.phone_number,
248
248
  headline: description,
249
249
  industry: industry,
250
250
  urls: {
@@ -275,7 +275,7 @@ module Faker
275
275
  industry: industry,
276
276
  lastName: auth.last_name,
277
277
  location: {
278
- country: { code: Address.country_code.downcase },
278
+ country: { code: Faker::Address.country_code.downcase },
279
279
  name: city_state.split(', ').first
280
280
  },
281
281
  pictureUrl: image,
@@ -295,8 +295,8 @@ module Faker
295
295
  # @return [Hash] An auth hash in the format provided by omniauth-github.
296
296
  #
297
297
  # @faker.version 1.8.0
298
- def github(name: nil, email: nil, uid: Number.number(digits: 8).to_s)
299
- auth = Omniauth.new(name: name, email: email)
298
+ def github(name: nil, email: nil, uid: Faker::Number.number(digits: 8).to_s)
299
+ auth = new(name: name, email: email)
300
300
  login = auth.name.downcase.tr(' ', '-')
301
301
  html_url = "https://github.com/#{login}"
302
302
  api_url = "https://api.github.com/users/#{login}"
@@ -346,8 +346,8 @@ module Faker
346
346
  public_gists: random_number_from_range(1..1000),
347
347
  followers: random_number_from_range(1..1000),
348
348
  following: random_number_from_range(1..1000),
349
- created_at: Time.backward(days: 36_400).iso8601,
350
- updated_at: Time.backward(days: 2).iso8601
349
+ created_at: Faker::Time.backward(days: 36_400).iso8601,
350
+ updated_at: Faker::Time.backward(days: 2).iso8601
351
351
  }
352
352
  }
353
353
  }
@@ -364,8 +364,8 @@ module Faker
364
364
  #
365
365
  # @faker.version 2.3.0
366
366
  def apple(name: nil, email: nil, uid: nil)
367
- uid ||= "#{Number.number(digits: 6)}.#{Number.hexadecimal(digits: 32)}.#{Number.number(digits: 4)}"
368
- auth = Omniauth.new(name: name, email: email)
367
+ uid ||= "#{Faker::Number.number(digits: 6)}.#{Faker::Number.hexadecimal(digits: 32)}.#{Faker::Number.number(digits: 4)}"
368
+ auth = new(name: name, email: email)
369
369
  {
370
370
  provider: 'apple',
371
371
  uid: uid,
@@ -376,20 +376,20 @@ module Faker
376
376
  last_name: auth.last_name
377
377
  },
378
378
  credentials: {
379
- token: Crypto.md5,
380
- refresh_token: Crypto.md5,
381
- expires_at: Time.forward.to_i,
379
+ token: Faker::Crypto.md5,
380
+ refresh_token: Faker::Crypto.md5,
381
+ expires_at: Faker::Time.forward.to_i,
382
382
  expires: true
383
383
  },
384
384
  extra: {
385
385
  raw_info: {
386
386
  iss: 'https://appleid.apple.com',
387
387
  aud: 'CLIENT_ID',
388
- exp: Time.forward.to_i,
389
- iat: Time.forward.to_i,
388
+ exp: Faker::Time.forward.to_i,
389
+ iat: Faker::Time.forward.to_i,
390
390
  sub: uid,
391
- at_hash: Crypto.md5,
392
- auth_time: Time.forward.to_i,
391
+ at_hash: Faker::Crypto.md5,
392
+ auth_time: Faker::Time.forward.to_i,
393
393
  email: auth.email,
394
394
  email_verified: true
395
395
  }
@@ -408,8 +408,8 @@ module Faker
408
408
  #
409
409
  # @faker.version next
410
410
  def auth0(name: nil, email: nil, uid: nil)
411
- uid ||= "auth0|#{Number.hexadecimal(digits: 24)}"
412
- auth = Omniauth.new(name: name, email: email)
411
+ uid ||= "auth0|#{Faker::Number.hexadecimal(digits: 24)}"
412
+ auth = new(name: name, email: email)
413
413
  {
414
414
  provider: 'auth0',
415
415
  uid: uid,
@@ -423,9 +423,9 @@ module Faker
423
423
  expires_at: Time.forward.to_i,
424
424
  expires: true,
425
425
  token_type: 'Bearer',
426
- id_token: Crypto.sha256,
427
- token: Crypto.md5,
428
- refresh_token: Crypto.md5
426
+ id_token: Faker::Crypto.sha256,
427
+ token: Faker::Crypto.md5,
428
+ refresh_token: Faker::Crypto.md5
429
429
  },
430
430
  extra: {
431
431
  raw_info: {
@@ -434,8 +434,8 @@ module Faker
434
434
  iss: 'https://auth0.com/',
435
435
  sub: uid,
436
436
  aud: 'Auth012345',
437
- iat: Time.forward.to_i,
438
- exp: Time.forward.to_i
437
+ iat: Faker::Time.forward.to_i,
438
+ exp: Faker::Time.forward.to_i
439
439
  }
440
440
  }
441
441
  }
@@ -452,11 +452,11 @@ module Faker
452
452
  end
453
453
 
454
454
  def image
455
- Placeholdit.image
455
+ Faker::Placeholdit.image
456
456
  end
457
457
 
458
458
  def city_state
459
- "#{Address.city}, #{Address.state}"
459
+ "#{Faker::Address.city}, #{Faker::Address.state}"
460
460
  end
461
461
 
462
462
  def random_number_from_range(range)
@@ -30,7 +30,7 @@ module Faker
30
30
  background_color = generate_color if background_color == :random
31
31
  text_color = generate_color if text_color == :random
32
32
 
33
- raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /^[0-9]+x[0-9]+$/
33
+ raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /\A[0-9]+x[0-9]+\z$/
34
34
  raise ArgumentError, "Supported formats are #{SUPPORTED_FORMATS.join(', ')}" unless SUPPORTED_FORMATS.include?(format)
35
35
  raise ArgumentError, "background_color must be a hex value without '#'" unless background_color.nil? || background_color =~ /((?:^\h{3}$)|(?:^\h{6}$)){1}(?!.*\H)/
36
36
  raise ArgumentError, "text_color must be a hex value without '#'" unless text_color.nil? || text_color =~ /((?:^\h{3}$)|(?:^\h{6}$)){1}(?!.*\H)/
@@ -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
@@ -24,7 +24,7 @@ module Faker
24
24
  private
25
25
 
26
26
  def select_a(length)
27
- if length.class.included_modules.include? Enumerable
27
+ if length.class.include?(Enumerable)
28
28
  select_a sample(length.to_enum.to_a)
29
29
  else
30
30
  length # recursive base case
@@ -116,7 +116,7 @@ module Faker
116
116
  #
117
117
  # @faker.version 1.8.6
118
118
  def random_type
119
- type_to_use = SIMPLE_TYPES[rand(0..SIMPLE_TYPES.length - 1)]
119
+ type_to_use = SIMPLE_TYPES[rand(0..(SIMPLE_TYPES.length - 1))]
120
120
  case type_to_use
121
121
  when :string
122
122
  rb_string
@@ -136,7 +136,7 @@ module Faker
136
136
  # @faker.version 1.8.6
137
137
  def random_complex_type
138
138
  types = SIMPLE_TYPES + COMPLEX_TYPES
139
- type_to_use = types[rand(0..types.length - 1)]
139
+ type_to_use = types[rand(0..(types.length - 1))]
140
140
  case type_to_use
141
141
  when :string
142
142
  rb_string