faker 2.14.0 → 2.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +83 -0
  3. data/README.md +9 -0
  4. data/lib/faker.rb +37 -15
  5. data/lib/faker/blockchain/aeternity.rb +4 -4
  6. data/lib/faker/books/dune.rb +15 -2
  7. data/lib/faker/books/lovecraft.rb +8 -4
  8. data/lib/faker/default/address.rb +4 -4
  9. data/lib/faker/default/bank.rb +3 -5
  10. data/lib/faker/default/barcode.rb +11 -11
  11. data/lib/faker/default/beer.rb +3 -3
  12. data/lib/faker/default/camera.rb +46 -0
  13. data/lib/faker/default/chile_rut.rb +3 -2
  14. data/lib/faker/default/code.rb +2 -2
  15. data/lib/faker/default/commerce.rb +1 -1
  16. data/lib/faker/default/company.rb +40 -10
  17. data/lib/faker/default/driving_licence.rb +1 -1
  18. data/lib/faker/default/drone.rb +25 -25
  19. data/lib/faker/default/faker_adjective.rb +35 -0
  20. data/lib/faker/default/finance.rb +21 -0
  21. data/lib/faker/default/food.rb +1 -1
  22. data/lib/faker/default/hipster.rb +8 -5
  23. data/lib/faker/default/id_number.rb +2 -2
  24. data/lib/faker/default/internet.rb +5 -4
  25. data/lib/faker/default/invoice.rb +1 -1
  26. data/lib/faker/default/json.rb +4 -4
  27. data/lib/faker/default/lorem.rb +2 -2
  28. data/lib/faker/default/measurement.rb +3 -2
  29. data/lib/faker/default/military.rb +26 -0
  30. data/lib/faker/default/mountain.rb +33 -0
  31. data/lib/faker/default/number.rb +1 -1
  32. data/lib/faker/default/omniauth.rb +2 -0
  33. data/lib/faker/default/relationship.rb +1 -1
  34. data/lib/faker/default/space.rb +1 -1
  35. data/lib/faker/default/stripe.rb +3 -3
  36. data/lib/faker/default/vehicle.rb +1 -1
  37. data/lib/faker/fantasy/tolkien.rb +67 -0
  38. data/lib/faker/games/clash_of_clans.rb +48 -0
  39. data/lib/faker/games/control.rb +1 -1
  40. data/lib/faker/games/dnd.rb +6 -6
  41. data/lib/faker/games/elder_scrolls.rb +26 -0
  42. data/lib/faker/games/heroes.rb +13 -0
  43. data/lib/faker/games/minecraft.rb +65 -0
  44. data/lib/faker/games/street_fighter.rb +4 -4
  45. data/lib/faker/games/super_mario.rb +48 -0
  46. data/lib/faker/games/world_of_warcraft.rb +26 -1
  47. data/lib/faker/japanese_media/conan.rb +48 -0
  48. data/lib/faker/japanese_media/doraemon.rb +48 -0
  49. data/lib/faker/japanese_media/dragon_ball.rb +26 -0
  50. data/lib/faker/japanese_media/naruto.rb +61 -0
  51. data/lib/faker/japanese_media/studio_ghibli.rb +48 -0
  52. data/lib/faker/movies/hobbit.rb +4 -4
  53. data/lib/faker/movies/how_to_train_your_dragon.rb +48 -0
  54. data/lib/faker/movies/lord_of_the_rings.rb +3 -3
  55. data/lib/faker/movies/room.rb +63 -0
  56. data/lib/faker/movies/star_wars.rb +2 -2
  57. data/lib/faker/music/hiphop.rb +48 -0
  58. data/lib/faker/music/opera.rb +237 -1
  59. data/lib/faker/quotes/quote.rb +26 -0
  60. data/lib/faker/sports/volleyball.rb +74 -0
  61. data/lib/faker/tv_shows/buffy.rb +17 -4
  62. data/lib/faker/tv_shows/final_space.rb +51 -0
  63. data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +17 -4
  64. data/lib/faker/version.rb +1 -1
  65. data/lib/helpers/unique_generator.rb +3 -0
  66. data/lib/locales/en/adjective.yml +179 -0
  67. data/lib/locales/en/buffy.yml +1 -1
  68. data/lib/locales/en/camera.yml +611 -0
  69. data/lib/locales/en/clash_of_clan.yml +101 -0
  70. data/lib/locales/en/company.yml +2 -2
  71. data/lib/locales/en/conan.yml +171 -0
  72. data/lib/locales/en/demographic.yml +218 -5
  73. data/lib/locales/en/doraemon.yml +286 -0
  74. data/lib/locales/en/dota.yml +531 -63
  75. data/lib/locales/en/dragon_ball.yml +243 -1
  76. data/lib/locales/en/driving_license.yml +3 -0
  77. data/lib/locales/en/dune.yml +401 -131
  78. data/lib/locales/en/elder_scrolls.yml +583 -9
  79. data/lib/locales/en/fallout.yml +311 -133
  80. data/lib/locales/en/final_space.yml +37 -0
  81. data/lib/locales/en/finance.yml +53 -0
  82. data/lib/locales/en/fresh_prince_of_bel_air.yml +1 -1
  83. data/lib/locales/en/half_life.yml +84 -3
  84. data/lib/locales/en/heroes.yml +408 -3
  85. data/lib/locales/en/heroes_of_the_storm.yml +131 -4
  86. data/lib/locales/en/how_to_train_your_dragon.yml +174 -0
  87. data/lib/locales/en/jack_handey.yml +54 -0
  88. data/lib/locales/en/league_of_legends.yml +285 -6
  89. data/lib/locales/en/military.yml +179 -5
  90. data/lib/locales/en/minecraft.yml +273 -0
  91. data/lib/locales/en/mountain.yml +158 -0
  92. data/lib/locales/en/music.yml +451 -29
  93. data/lib/locales/en/myst.yml +87 -31
  94. data/lib/locales/en/naruto.yml +231 -0
  95. data/lib/locales/en/opera.yml +168 -0
  96. data/lib/locales/en/overwatch.yml +2650 -2622
  97. data/lib/locales/en/pokemon.yml +417 -4
  98. data/lib/locales/en/quote.yml +692 -163
  99. data/lib/locales/en/room.yml +68 -0
  100. data/lib/locales/en/source.yml +30 -0
  101. data/lib/locales/en/star_trek.yml +1 -1
  102. data/lib/locales/en/street_fighter.yml +4 -4
  103. data/lib/locales/en/studio_ghibli.yml +107 -0
  104. data/lib/locales/en/super_mario.yml +58 -0
  105. data/lib/locales/en/super_smash_bros.yml +16 -4
  106. data/lib/locales/en/tolkien.yml +2453 -0
  107. data/lib/locales/en/volleyball.yml +501 -0
  108. data/lib/locales/en/witcher.yml +389 -7
  109. data/lib/locales/en/world_of_warcraft.yml +122 -4
  110. data/lib/locales/en/zelda.yml +962 -4
  111. data/lib/locales/es.yml +56 -0
  112. data/lib/locales/ja.yml +5 -1
  113. data/lib/locales/pt-BR.yml +1 -1
  114. data/lib/locales/uk.yml +2 -0
  115. metadata +38 -10
  116. data/lib/locales/en/hobbit.yml +0 -19
  117. data/lib/locales/en/lord_of_the_rings.yml +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c20404a4d9474978940db437ddac9984deddd352fdf7cf9313d038a7e9c0ce54
4
- data.tar.gz: d52491d45e9dbc7525cf078789e84c10219d2c8e428de4541a1e73dfa6246569
3
+ metadata.gz: a6312a74dbe40f19bd57cda93e7b0d6b01ee227591e84d1acea6723ff86d4c98
4
+ data.tar.gz: a64be3fe39785f420fd0004a4909149d588629d005d4081467d5959cb05d6e8d
5
5
  SHA512:
6
- metadata.gz: ee17e0c0333a8e5456d167ed3f7ccc26be29c5f95efdcf6aa866cc2b80789afb95a910922af3405f9d3484b0c266c5217fa40fb593c08eefcc8aab0159b83f91
7
- data.tar.gz: 66fa28264c8fbe299c025e6bd566a55870fd9059bda1863dfbe3d03c7fe56a176f04432c784f3d1a079429bb375cc18c56da6d38341b2167edce1f3abbae9074
6
+ metadata.gz: f1845f8d60cfd9b219535979d879ba40065f8330bad9db0411c9a404de780b20d614d1a8f7f421cbb7e56d2a9f28bd7bfcb202349b76a93e33681c69a4b78d3b
7
+ data.tar.gz: 8a0ccf115f416f64d3d093b367f36e4659f4f010d97e2ebf596b2e41dc9e62574de51545bd6e0e39ba2af18a9bf06a8d91ab5e173f7f6e9ced017bc0d918bc32
@@ -1,5 +1,88 @@
1
1
  # Change Log
2
2
 
3
+ ## [v2.15.0](https://github.com/faker-ruby/faker/tree/v2.15.0) (2020-11-24)
4
+
5
+ ## Bug/Fixes
6
+
7
+ - Rubocop 1.0 fixes [#2182](https://github.com/faker-ruby/faker/pull/2182) @amatsuda
8
+ - Get rid of broken I18n locales configuration for the tests [#2168](https://github.com/faker-ruby/faker/pull/2168) @amatsuda
9
+ - Fixes a bug when generating a password with min_length eq 1 [#2138](https://github.com/faker-ruby/faker/pull/2138) @adrian-rivera @Zeragamba
10
+ - Improve Faker::Company.spanish_organisation_number [#2106](https://github.com/faker-ruby/faker/pull/2106)
11
+
12
+ ## Chores
13
+
14
+ - Reformat demographic yaml [#2189](https://github.com/faker-ruby/faker/pull/2189) @fiteclub
15
+ - An attempt to load only necessary locales on the fly [#2169](https://github.com/faker-ruby/faker/pull/2169) @amatsuda
16
+ - Faker::Config can be a Module rather than a Class [#2167](https://github.com/faker-ruby/faker/pull/2167) @amatsuda
17
+ - Cleanup games [#2155](https://github.com/faker-ruby/faker/pull/2155) @mathisto
18
+ - Deprecate `celebrity` methods in favor of `actor` [#2133](https://github.com/faker-ruby/faker/pull/2133) @vraravam
19
+
20
+ ## Documentation
21
+
22
+ - Fix class name in volleyball.md [#2198](https://github.com/faker-ruby/faker/pull/2198) @connorshea
23
+ - Fix typo in doc/games/heroes.md [#2145](https://github.com/faker-ruby/faker/pull/2145) @Crysicia
24
+ - fix typo [#2141](https://github.com/faker-ruby/faker/pull/2141) @Zeragamba
25
+ - Updated versions in doc for methods. [#2123](https://github.com/faker-ruby/faker/pull/2123) @sudeeptarlekar
26
+
27
+ ## Feature Request
28
+
29
+ - Add `Faker::Mountain` [#2196](https://github.com/faker-ruby/faker/pull/2196) @bipashant
30
+ - Add Faker::Volleyball [#2178](https://github.com/faker-ruby/faker/pull/2178) @RubyHuntsman
31
+ - Add artifact generator to Faker::Game::Heroes [#2177](https://github.com/faker-ruby/faker/pull/2177) @droznyk
32
+ - Add generator to Faker::Games:ElderScrolls [#2171](https://github.com/faker-ruby/faker/pull/2171) @RubyHuntsman
33
+ - Augment opera [#2170](https://github.com/faker-ruby/faker/pull/2170) @Gaitorius
34
+ - Add generator to Faker::Games::ElderScrolls [#2164](https://github.com/faker-ruby/faker/pull/2164) @RubyHuntsman
35
+ - Add more generators to Faker::Minecraft [#2162](https://github.com/faker-ruby/faker/pull/2162) @RubyHuntsman
36
+ - I added more programming languages to the source [#2161](https://github.com/faker-ruby/faker/pull/2161) @JoaoHenriqueVale
37
+ - Add Faker:Camera [#2159](https://github.com/faker-ruby/faker/pull/2159) @RubyHuntsman
38
+ - Add how to train your dragon [#2158](https://github.com/faker-ruby/faker/pull/2158) @archbloom
39
+ - Add Faker::Fantasy::Tolkien [#2152](https://github.com/faker-ruby/faker/pull/2152) @mathisto
40
+ - Feature: Add north dakota driving licence [#2149](https://github.com/faker-ruby/faker/pull/2149) @martinjaimem
41
+ - Add Final Space to TvShows category [#2147](https://github.com/faker-ruby/faker/pull/2147)
42
+ - Add finance/stock generators [#2146](https://github.com/faker-ruby/faker/pull/2146) @johnpitchko
43
+ - Add Clash Of Clans to the Game category [#2143](https://github.com/faker-ruby/faker/pull/2143) @jamesmai0512
44
+ - Add Conan to the JapaneseMedia category [#2142](https://github.com/faker-ruby/faker/pull/2142) @jamesmai0512
45
+ - Add Naruto to the JapaneseMedia category [#2139](https://github.com/faker-ruby/faker/pull/2139) @jamesmai0512
46
+ - Add Doraemon to the JapaneseMedia category [#2137](https://github.com/faker-ruby/faker/pull/2137) @jamesmai0512
47
+ - Add space force and coast guard to military [#2136](https://github.com/faker-ruby/faker/pull/2136) @mathisto
48
+ - Add Super Mario [#2135](https://github.com/faker-ruby/faker/pull/2135) @fblupi
49
+ - Add The Room (2003) to Movies [#2134](https://github.com/faker-ruby/faker/pull/2134) @fiteclub
50
+ - Faker adjectives [#2130](https://github.com/faker-ruby/faker/pull/2130) @loicboset
51
+ - Add Studio Ghibli to the JapaneseMedia category [#2124](https://github.com/faker-ruby/faker/pull/2124) @Kadaaran
52
+ - Created New Method Faker::Quote.fortune_cookie [#2112](https://github.com/faker-ruby/faker/pull/2112) @catonmat
53
+ - Allow disabling the usage of open compounds in sentences [#2109](https://github.com/faker-ruby/faker/pull/2109) @tjozwik
54
+ - Add faker for hiphop artist [#1923](https://github.com/faker-ruby/faker/pull/1923) @Josiassejod1
55
+ - Add races and class names to WorldOfWarcraft [#1787](https://github.com/faker-ruby/faker/pull/1787) @mathisto
56
+ - Add planets and races to DragonBall [#1786](https://github.com/faker-ruby/faker/pull/1786) @mathisto
57
+ - Add planets, cities, and quotes to Dune [#1784](https://github.com/faker-ruby/faker/pull/1784) @mathisto
58
+
59
+ ## Update locales
60
+
61
+ - add japanese gender first name [#2191](https://github.com/faker-ruby/faker/pull/2191) @issei126
62
+ - Add full_address to Ukrainian locale [#2176](https://github.com/faker-ruby/faker/pull/2176) @Ptico
63
+ - Fixed some spelling issues in company.yml [#2173](https://github.com/faker-ruby/faker/pull/2173) @coreymaher
64
+ - Update Faker::Games::SuperSmashBros [#2164](https://github.com/faker-ruby/faker/pull/2164) @boardfish
65
+ - Add more quotes to Faker::Games::Witcher [#2163](https://github.com/faker-ruby/faker/pull/2163) @RubyHuntsman
66
+ - Add Jack Handey's Deep Thoughts to quotes [#2150](https://github.com/faker-ruby/faker/pull/2150) @fiteclub
67
+ - add brazil license plate from mercosul rules [#2144](https://github.com/faker-ruby/faker/pull/2144) @gabrielbaldao
68
+ - Add additional quotes to Studio Ghibli [#2132](https://github.com/faker-ruby/faker/pull/2132) @lambda2
69
+ - Change 'Nyota Uhuru' to 'Nyota Uhura' [#2121](https://github.com/faker-ruby/faker/pull/2121) @TrevorA-TrevorA
70
+ - Add spanish license plates [#2103](https://github.com/faker-ruby/faker/pull/2103)
71
+
72
+ ## Update local dependencies
73
+
74
+ - Update rubocop requirement from = 1.0.0 to = 1.1.0 [#2185](https://github.com/faker-ruby/faker/pull/2185)
75
+ - Update rubocop requirement from = 0.93.1 to = 1.0.0 [#2172](https://github.com/faker-ruby/faker/pull/2172)
76
+ - Update rubocop requirement from = 0.93.0 to = 0.93.1 [#2156](https://github.com/faker-ruby/faker/pull/2156)
77
+ - Update rubocop requirement from = 0.92.0 to = 0.93.0 [#2151](https://github.com/faker-ruby/faker/pull/2151)
78
+ - Update rubocop requirement from = 0.91.1 to = 0.92.0 [#2129](https://github.com/faker-ruby/faker/pull/2129)
79
+ - Update rubocop requirement from = 0.91.0 to = 0.91.1 [#2126](https://github.com/faker-ruby/faker/pull/2126)
80
+ - Update rubocop requirement from = 0.90.0 to = 0.91.0 [#2122](https://github.com/faker-ruby/faker/pull/2122)
81
+ - Update test-unit requirement from = 3.3.6 to = 3.3.7 [#2195](https://github.com/faker-ruby/faker/pull/2195)
82
+ - Update timecop requirement from = 0.9.1 to = 0.9.2 [#2160](https://github.com/faker-ruby/faker/pull/2160)
83
+
84
+ ------------------------------------------------------------------------------
85
+
3
86
  ## [v2.14.0](https://github.com/faker-ruby/faker/tree/v2.14.0) (2020-09-15)
4
87
 
5
88
  ## Bug/Fixes
data/README.md CHANGED
@@ -235,6 +235,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'mast
235
235
 
236
236
  ### Games
237
237
  - [Faker::Game](doc/games/game.md)
238
+ - [Faker::Games::ClashOfClans](doc/games/clash_of_clans.md)
238
239
  - [Faker::Games::DnD](doc/games/dnd.md)
239
240
  - [Faker::Games::Dota](doc/games/dota.md)
240
241
  - [Faker::Games::ElderScrolls](doc/games/elder_scrolls.md)
@@ -243,11 +244,13 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'mast
243
244
  - [Faker::Games::Heroes](doc/games/heroes.md)
244
245
  - [Faker::Games::HeroesOfTheStorm](doc/games/heroes_of_the_storm.md)
245
246
  - [Faker::Games::LeagueOfLegends](doc/games/league_of_legends.md)
247
+ - [Faker::Games::Minecraft](doc/games/minecraft.md)
246
248
  - [Faker::Games::Myst](doc/games/myst.md)
247
249
  - [Faker::Games::Overwatch](doc/games/overwatch.md)
248
250
  - [Faker::Games::Pokemon](doc/games/pokemon.md)
249
251
  - [Faker::Games::SonicTheHedgehog](doc/games/sonic_the_hedgehog.md)
250
252
  - [Faker::Games::StreetFighter](doc/games/street_fighter.md)
253
+ - [Faker::Games::SuperMario](doc/games/super_mario.md)
251
254
  - [Faker::Games::SuperSmashBros](doc/games/super_smash_bros.md)
252
255
  - [Faker::Games::WarhammerFantasy](doc/games/warhammer_fantasy.md)
253
256
  - [Faker::Games::Witcher](doc/games/witcher.md)
@@ -257,7 +260,11 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'mast
257
260
  ### Japanese Media
258
261
  - [Faker::JapaneseMedia::DragonBall](doc/japanese_media/dragon_ball.md)
259
262
  - [Faker::JapaneseMedia::OnePiece](doc/japanese_media/one_piece.md)
263
+ - [Faker::JapaneseMedia::StudioGhibli](doc/japanese_media/studio_ghibli.md)
260
264
  - [Faker::JapaneseMedia::SwordArtOnline](doc/japanese_media/sword_art_online.md)
265
+ - [Faker::JapaneseMedia::Naruto](doc/japanese_media/naruto.md)
266
+ - [Faker::JapaneseMedia::Doraemon](doc/japanese_media/doraemon.md)
267
+ - [Faker::JapaneseMedia::Conan](doc/japanese_media/conan.md)
261
268
 
262
269
  ### Movies
263
270
  - [Faker::Movie](doc/movies/movie.md)
@@ -267,6 +274,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'mast
267
274
  - [Faker::Movies::HarryPotter](doc/movies/harry_potter.md)
268
275
  - [Faker::Movies::HitchhikersGuideToTheGalaxy](doc/movies/hitchhikers_guide_to_the_galaxy.md)
269
276
  - [Faker::Movies::Hobbit](doc/movies/hobbit.md)
277
+ - [Faker::Movies::HowToTrainYourDragon](doc/movies/how_to_train_your_dragon.md)
270
278
  - [Faker::Movies::Lebowski](doc/movies/lebowski.md)
271
279
  - [Faker::Movies::LordOfTheRings](doc/movies/lord_of_the_rings.md)
272
280
  - [Faker::Movies::PrincessBride](doc/movies/princess_bride.md)
@@ -305,6 +313,7 @@ gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'mast
305
313
  - [Faker::TvShows::DrWho](doc/tv_shows/dr_who.md)
306
314
  - [Faker::TvShows::DumbAndDumber](doc/tv_shows/dumb_and_dumber.md)
307
315
  - [Faker::TvShows::FamilyGuy](doc/tv_shows/family_guy.md)
316
+ - [Faker::TvShows::FinalSpace](doc/tv_shows/final_space.md)
308
317
  - [Faker::TvShows::Friends](doc/tv_shows/friends.md)
309
318
  - [Faker::TvShows::GameOfThrones](doc/tv_shows/game_of_thrones.md)
310
319
  - [Faker::TvShows::HeyArnold](doc/tv_shows/hey_arnold.md)
@@ -8,19 +8,37 @@ require 'set' # Fixes a bug in i18n 0.6.11
8
8
 
9
9
  Dir.glob(File.join(mydir, 'helpers', '*.rb')).sort.each { |file| require file }
10
10
 
11
- I18n.load_path += Dir[File.join(mydir, 'locales', '**/*.yml')]
12
- I18n.reload! if I18n.backend.initialized?
13
-
14
11
  module Faker
15
- class Config
12
+ @i18n_loaded = nil
13
+
14
+ class << self
15
+ def load_i18n
16
+ return if @i18n_loaded
17
+
18
+ if I18n.available_locales&.any?
19
+ # We expect all locale .yml files to have the locale name in its filename
20
+ I18n.load_path += ::Dir[::File.join(__dir__, 'locales', "{#{I18n.available_locales.join(',')}}.yml")]
21
+ # Or to be located in a directory with the locale name
22
+ I18n.load_path += ::Dir[::File.join(__dir__, 'locales', "{#{I18n.available_locales.join(',')}}/*.yml")]
23
+ else
24
+ I18n.load_path += ::Dir[::File.join(__dir__, 'locales', '**/*.yml')]
25
+ end
26
+
27
+ I18n.reload! if I18n.backend.initialized?
28
+ @i18n_loaded = true
29
+ end
30
+ end
31
+
32
+ module Config
16
33
  @locale = nil
17
34
  @random = nil
18
35
 
19
36
  class << self
20
- attr_writer :locale
21
- attr_writer :random
37
+ attr_writer :locale, :random
22
38
 
23
39
  def locale
40
+ Faker.load_i18n
41
+
24
42
  # Because I18n.locale defaults to :en, if we don't have :en in our available_locales, errors will happen
25
43
  @locale || (I18n.available_locales.include?(I18n.locale) ? I18n.locale : I18n.available_locales.first)
26
44
  end
@@ -81,13 +99,13 @@ module Faker
81
99
  def regexify(reg)
82
100
  reg = reg.source if reg.respond_to?(:source) # Handle either a Regexp or a String that looks like a Regexp
83
101
  reg
84
- .gsub(%r{^\/?\^?}, '').gsub(%r{\$?\/?$}, '') # Ditch the anchors
102
+ .gsub(%r{^/?\^?}, '').gsub(%r{\$?/?$}, '') # Ditch the anchors
85
103
  .gsub(/\{(\d+)\}/, '{\1,\1}').gsub(/\?/, '{0,1}') # All {2} become {2,2} and ? become {0,1}
86
104
  .gsub(/(\[[^\]]+\])\{(\d+),(\d+)\}/) { |_match| Regexp.last_match(1) * sample(Array(Range.new(Regexp.last_match(2).to_i, Regexp.last_match(3).to_i))) } # [12]{1,2} becomes [12] or [12][12]
87
- .gsub(/(\([^\)]+\))\{(\d+),(\d+)\}/) { |_match| Regexp.last_match(1) * sample(Array(Range.new(Regexp.last_match(2).to_i, Regexp.last_match(3).to_i))) } # (12|34){1,2} becomes (12|34) or (12|34)(12|34)
105
+ .gsub(/(\([^)]+\))\{(\d+),(\d+)\}/) { |_match| Regexp.last_match(1) * sample(Array(Range.new(Regexp.last_match(2).to_i, Regexp.last_match(3).to_i))) } # (12|34){1,2} becomes (12|34) or (12|34)(12|34)
88
106
  .gsub(/(\\?.)\{(\d+),(\d+)\}/) { |_match| Regexp.last_match(1) * sample(Array(Range.new(Regexp.last_match(2).to_i, Regexp.last_match(3).to_i))) } # A{1,2} becomes A or AA or \d{3} becomes \d\d\d
89
- .gsub(/\((.*?)\)/) { |match| sample(match.gsub(/[\(\)]/, '').split('|')) } # (this|that) becomes 'this' or 'that'
90
- .gsub(/\[([^\]]+)\]/) { |match| match.gsub(/(\w\-\w)/) { |range| sample(Array(Range.new(*range.split('-')))) } } # All A-Z inside of [] become C (or X, or whatever)
107
+ .gsub(/\((.*?)\)/) { |match| sample(match.gsub(/[()]/, '').split('|')) } # (this|that) becomes 'this' or 'that'
108
+ .gsub(/\[([^\]]+)\]/) { |match| match.gsub(/(\w-\w)/) { |range| sample(Array(Range.new(*range.split('-')))) } } # All A-Z inside of [] become C (or X, or whatever)
91
109
  .gsub(/\[([^\]]+)\]/) { |_match| sample(Regexp.last_match(1).split('')) } # All [ABC] become B (or A or C)
92
110
  .gsub('\d') { |_match| sample(Numbers) }
93
111
  .gsub('\w') { |_match| sample(Letters) }
@@ -97,7 +115,7 @@ module Faker
97
115
  # with an array of values and selecting one of them.
98
116
  def fetch(key)
99
117
  fetched = sample(translate("faker.#{key}"))
100
- if fetched&.match(%r{^\/}) && fetched&.match(%r{\/$}) # A regex
118
+ if fetched&.match(%r{^/}) && fetched&.match(%r{/$}) # A regex
101
119
  regexify(fetched)
102
120
  else
103
121
  fetched
@@ -109,7 +127,7 @@ module Faker
109
127
  def fetch_all(key)
110
128
  fetched = translate("faker.#{key}")
111
129
  fetched = fetched.last if fetched.size <= 1
112
- if !fetched.respond_to?(:sample) && fetched.match(%r{^\/}) && fetched.match(%r{\/$}) # A regex
130
+ if !fetched.respond_to?(:sample) && fetched.match(%r{^/}) && fetched.match(%r{/$}) # A regex
113
131
  regexify(fetched)
114
132
  else
115
133
  fetched
@@ -121,7 +139,7 @@ module Faker
121
139
  # formatted translation: e.g., "#{first_name} #{last_name}".
122
140
  def parse(key)
123
141
  fetched = fetch(key)
124
- parts = fetched.scan(/(\(?)#\{([A-Za-z]+\.)?([^\}]+)\}([^#]+)?/).map do |prefix, kls, meth, etc|
142
+ parts = fetched.scan(/(\(?)#\{([A-Za-z]+\.)?([^}]+)\}([^#]+)?/).map do |prefix, kls, meth, etc|
125
143
  # If the token had a class Prefix (e.g., Name.first_name)
126
144
  # grab the constant, otherwise use self
127
145
  cls = kls ? Faker.const_get(kls.chop) : self
@@ -150,6 +168,8 @@ module Faker
150
168
  # Call I18n.translate with our configured locale if no
151
169
  # locale is specified
152
170
  def translate(*args, **opts)
171
+ Faker.load_i18n
172
+
153
173
  opts[:locale] ||= Faker::Config.locale
154
174
  opts[:raise] = true
155
175
  I18n.translate(*args, **opts)
@@ -165,12 +185,14 @@ module Faker
165
185
  end
166
186
 
167
187
  # Executes block with given locale set.
168
- def with_locale(tmp_locale = nil)
188
+ def with_locale(tmp_locale = nil, &block)
189
+ Faker.load_i18n
190
+
169
191
  current_locale = Faker::Config.own_locale
170
192
  Faker::Config.locale = tmp_locale
171
193
 
172
194
  disable_enforce_available_locales do
173
- I18n.with_locale(tmp_locale) { yield }
195
+ I18n.with_locale(tmp_locale, &block)
174
196
  end
175
197
  ensure
176
198
  Faker::Config.locale = current_locale
@@ -14,7 +14,7 @@ module Faker
14
14
  # #=> "ak_zvU8YQLagjcfng7Tg8yCdiZ1rpiWNp1PBn3vtUs44utSvbJVR"
15
15
  #
16
16
  def address
17
- 'ak_' + rand_strings
17
+ "ak_#{rand_strings}"
18
18
  end
19
19
 
20
20
  ##
@@ -27,7 +27,7 @@ module Faker
27
27
  # #=> "th_147nDP22h3pHrLt2qykTH4txUwQh1ccaXp"
28
28
  #
29
29
  def transaction
30
- 'th_' + rand_strings(51)
30
+ "th_#{rand_strings(51)}"
31
31
  end
32
32
 
33
33
  ##
@@ -40,7 +40,7 @@ module Faker
40
40
  # #=> "ct_Hk2JsNeWGEYQEHHQCfcBeGrwbhtYSwFTPdDhW2SvjFYVojyhW"
41
41
  #
42
42
  def contract
43
- 'ct_' + rand_strings
43
+ "ct_#{rand_strings}"
44
44
  end
45
45
 
46
46
  ##
@@ -53,7 +53,7 @@ module Faker
53
53
  # #=> "ok_28QDg7fkF5qiKueSdUvUBtCYPJdmMEoS73CztzXCRAwMGKHKZh"
54
54
  #
55
55
  def oracle
56
- 'ok_' + rand_strings(51)
56
+ "ok_#{rand_strings(51)}"
57
57
  end
58
58
 
59
59
  protected
@@ -30,6 +30,19 @@ module Faker
30
30
  fetch('dune.titles')
31
31
  end
32
32
 
33
+ ##
34
+ # Produces the name of a city from Dune
35
+ #
36
+ # @return [String]
37
+ #
38
+ # @example
39
+ # Faker::Books::Dune.city #=> "Arrakeen"
40
+ #
41
+ # @faker.version next
42
+ def city
43
+ fetch('dune.cities')
44
+ end
45
+
33
46
  ##
34
47
  # Produces the name of a planet from Dune
35
48
  #
@@ -76,7 +89,7 @@ module Faker
76
89
  end
77
90
  end
78
91
 
79
- fetch('dune.quotes.' + character)
92
+ fetch("dune.quotes.#{character}")
80
93
  end
81
94
 
82
95
  ##
@@ -111,7 +124,7 @@ module Faker
111
124
  end
112
125
  end
113
126
 
114
- fetch('dune.sayings.' + source)
127
+ fetch("dune.sayings.#{source}")
115
128
  end
116
129
  end
117
130
  end
@@ -68,6 +68,7 @@ module Faker
68
68
  #
69
69
  # @param word_count [Integer] The number of words to have in the sentence
70
70
  # @param random_words_to_add [Integer]
71
+ # @param open_compounds_allowed [Boolean] If true, generated sentence can contain words having additional spaces
71
72
  #
72
73
  # @return [String]
73
74
  #
@@ -80,15 +81,18 @@ module Faker
80
81
  # @example
81
82
  # Faker::Books::Lovecraft.sentence(word_count: 3, random_words_to_add: 1)
82
83
  # #=> "Amorphous indescribable tenebrous."
84
+ # @example
85
+ # Faker::Books::Lovecraft.sentence(word_count: 3, random_words_to_add: 0, open_compounds_allowed: true)
86
+ # #=> "Effulgence unmentionable gambrel."
83
87
  #
84
88
  # @faker.version 1.9.3
85
- def sentence(legacy_word_count = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, random_words_to_add: 6)
89
+ def sentence(legacy_word_count = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, random_words_to_add: 6, open_compounds_allowed: true)
86
90
  warn_for_deprecated_arguments do |keywords|
87
91
  keywords << :word_count if legacy_word_count != NOT_GIVEN
88
92
  keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
89
93
  end
90
94
 
91
- words(number: word_count + rand(random_words_to_add.to_i).to_i, spaces_allowed: true).join(' ').capitalize + '.'
95
+ "#{words(number: word_count + rand(random_words_to_add.to_i).to_i, spaces_allowed: open_compounds_allowed).join(' ').capitalize}."
92
96
  end
93
97
 
94
98
  ##
@@ -266,9 +270,9 @@ module Faker
266
270
 
267
271
  paragraph = paragraph(sentence_count: 3)
268
272
 
269
- paragraph += ' ' + paragraph(sentence_count: 3) while paragraph.length < characters
273
+ paragraph += " #{paragraph(sentence_count: 3)}" while paragraph.length < characters
270
274
 
271
- paragraph[0...characters - 1] + '.'
275
+ "#{paragraph[0...characters - 1]}."
272
276
  end
273
277
  end
274
278
  end
@@ -54,7 +54,7 @@ module Faker
54
54
  keywords << :include_secondary if legacy_include_secondary != NOT_GIVEN
55
55
  end
56
56
 
57
- numerify(parse('address.street_address') + (include_secondary ? ' ' + secondary_address : ''))
57
+ numerify(parse('address.street_address') + (include_secondary ? " #{secondary_address}" : ''))
58
58
  end
59
59
 
60
60
  ##
@@ -133,7 +133,7 @@ module Faker
133
133
 
134
134
  # provide a zip code that is valid for the state provided
135
135
  # see http://www.fincen.gov/forms/files/us_state_territory_zip_codes.pdf
136
- bothify(fetch('address.postcode_by_state.' + state_abbreviation))
136
+ bothify(fetch("address.postcode_by_state.#{state_abbreviation}"))
137
137
  end
138
138
 
139
139
  ##
@@ -247,7 +247,7 @@ module Faker
247
247
  keywords << :code if legacy_code != NOT_GIVEN
248
248
  end
249
249
 
250
- fetch('address.country_by_code.' + code)
250
+ fetch("address.country_by_code.#{code}")
251
251
  end
252
252
 
253
253
  ##
@@ -265,7 +265,7 @@ module Faker
265
265
  keywords << :name if legacy_name != NOT_GIVEN
266
266
  end
267
267
 
268
- fetch('address.country_by_name.' + name)
268
+ fetch("address.country_by_name.#{name}")
269
269
  end
270
270
 
271
271
  ##
@@ -140,15 +140,13 @@ module Faker
140
140
  def compile_routing_number
141
141
  digit_one_two = %w[00 01 02 03 04 05 06 07 08 09 10 11 12]
142
142
  ((21..32).to_a + (61..72).to_a + [80]).each { |x| digit_one_two << x.to_s }
143
- routing_num = digit_one_two.sample + rand_numstring + rand_numstring + rand_numstring + rand_numstring + rand_numstring + rand_numstring + rand_numstring
144
- routing_num
143
+ digit_one_two.sample + rand_numstring + rand_numstring + rand_numstring + rand_numstring + rand_numstring + rand_numstring + rand_numstring
145
144
  end
146
145
 
147
146
  def compile_bsb_number
148
147
  digit_one_two = %w[01 03 06 08 11 12 73 76 78 30]
149
148
  state = (2..7).to_a.map(&:to_s).sample
150
- bsb_num = digit_one_two.sample + state + rand_numstring + rand_numstring + rand_numstring
151
- bsb_num
149
+ digit_one_two.sample + state + rand_numstring + rand_numstring + rand_numstring
152
150
  end
153
151
 
154
152
  # Calculates the mandatory checksum in 3rd and 4th characters in IBAN format
@@ -182,7 +180,7 @@ module Faker
182
180
  prefix = (1..50).to_a.map(&:to_s).sample
183
181
  numerator = routing_num.split('')[5..8].join.to_i.to_s
184
182
  denominator = routing_num.split('')[0..4].join.to_i.to_s
185
- prefix + '-' + numerator + '/' + denominator
183
+ "#{prefix}-#{numerator}/#{denominator}"
186
184
  end
187
185
 
188
186
  def rand_numstring
@@ -11,7 +11,7 @@ module Faker
11
11
  # Faker::Barcode.ean(8) => "30152700"
12
12
  # Faker::Barcode.ean(13) => "2115190480285"
13
13
  #
14
- # @faker.version next
14
+ # @faker.version 2.14.0
15
15
  def ean(length = 8)
16
16
  generate_barcode("barcode.ean_#{Integer(length)}")
17
17
  end
@@ -24,7 +24,7 @@ module Faker
24
24
  # Faker::Barcode.ean_with_composite_sumbology(8) => "38357961|XUYJ3266"
25
25
  # Faker::Barcode.ean_with_composite_sumbology(13) => "9530722443911|CKHWQHID"
26
26
  #
27
- # @faker.version next
27
+ # @faker.version 2.14.0
28
28
  def ean_with_composite_symbology(length = 8)
29
29
  "#{ean(length)}|#{bothify(parse('barcode.composite_symbol'))}"
30
30
  end
@@ -35,7 +35,7 @@ module Faker
35
35
  # @example
36
36
  # Faker::Barcode.upc_a => "766807541831"
37
37
  #
38
- # @faker.version next
38
+ # @faker.version 2.14.0
39
39
  def upc_a
40
40
  generate_barcode('barcode.upc_a')
41
41
  end
@@ -46,7 +46,7 @@ module Faker
46
46
  # @example
47
47
  # Faker::Barcode.upc_e => "03746820"
48
48
  #
49
- # @faker.version next
49
+ # @faker.version 2.14.0
50
50
  def upc_e
51
51
  generate_barcode('barcode.upc_e')
52
52
  end
@@ -57,7 +57,7 @@ module Faker
57
57
  # @example
58
58
  # Faker::Barcode.upc_a_with_composite_symbology => "790670155765|JOVG6208"
59
59
  #
60
- # @faker.version next
60
+ # @faker.version 2.14.0
61
61
  def upc_a_with_composite_symbology
62
62
  "#{upc_a}|#{bothify(parse('barcode.composite_symbol'))}"
63
63
  end
@@ -68,7 +68,7 @@ module Faker
68
68
  # @example
69
69
  # Faker::Barcode.upc_e_with_composite_symbology => "05149247|BKZX9722"
70
70
  #
71
- # @faker.version next
71
+ # @faker.version 2.14.0
72
72
  def upc_e_with_composite_symbology
73
73
  "#{upc_e}|#{bothify(parse('barcode.composite_symbol'))}"
74
74
  end
@@ -79,7 +79,7 @@ module Faker
79
79
  # @example
80
80
  # Faker::Barcode.isbn => "9798363807732"
81
81
  #
82
- # @faker.version next
82
+ # @faker.version 2.14.0
83
83
  def isbn
84
84
  generate_barcode('barcode.isbn')
85
85
  end
@@ -90,7 +90,7 @@ module Faker
90
90
  # @example
91
91
  # Faker::Barcode.ismn => "9790527672897"
92
92
  #
93
- # @faker.version next
93
+ # @faker.version 2.14.0
94
94
  def ismn
95
95
  generate_barcode('barcode.ismn')
96
96
  end
@@ -101,7 +101,7 @@ module Faker
101
101
  # @example
102
102
  # Faker::Barcode.issn => "9775541703338"
103
103
  #
104
- # @faker.version next
104
+ # @faker.version 2.14.0
105
105
  def issn
106
106
  generate_barcode('barcode.issn')
107
107
  end
@@ -122,7 +122,7 @@ module Faker
122
122
  # Faker::Barcode.send(:sum_even_odd, 12345) => [9, 5]
123
123
  # Faker::Barcode.send(:sum_even_odd, 87465) => [17, 13]
124
124
  #
125
- # @faker.version next
125
+ # @faker.version 2.14.0
126
126
  def sum_even_odd(fake_num)
127
127
  number = fake_num.to_i
128
128
  sum_even, sum_odd = 0, 0, index = 1
@@ -145,7 +145,7 @@ module Faker
145
145
  # Faker::Barcode.send(:generate_check_digit, 12, 4) => 0
146
146
  # Faker::Barcode.send(:generate_check_digit, 23, 5) => 6
147
147
  #
148
- # @faker.version next
148
+ # @faker.version 2.14.0
149
149
  def generate_check_digit(odd_sum, even_sum)
150
150
  (10 - (odd_sum * 3 + even_sum) % 10) % 10
151
151
  end