faker 2.14.0 → 2.15.1

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 (118) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +89 -0
  3. data/README.md +9 -0
  4. data/lib/faker.rb +11 -12
  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/id.yml +1 -0
  113. data/lib/locales/ja.yml +5 -1
  114. data/lib/locales/pt-BR.yml +1 -1
  115. data/lib/locales/uk.yml +2 -0
  116. metadata +38 -10
  117. data/lib/locales/en/hobbit.yml +0 -19
  118. 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: c64eb124941da11f6f02bdf234dcf3fe2b83568e1b951e97d198b458495a4956
4
+ data.tar.gz: 2d589426b8f0d7f7845f3e7f0f104ee0258a37a312e7400cf8a0fd3fabd2475b
5
5
  SHA512:
6
- metadata.gz: ee17e0c0333a8e5456d167ed3f7ccc26be29c5f95efdcf6aa866cc2b80789afb95a910922af3405f9d3484b0c266c5217fa40fb593c08eefcc8aab0159b83f91
7
- data.tar.gz: 66fa28264c8fbe299c025e6bd566a55870fd9059bda1863dfbe3d03c7fe56a176f04432c784f3d1a079429bb375cc18c56da6d38341b2167edce1f3abbae9074
6
+ metadata.gz: fd8f47c75906cc93e8d45db108478fea154409e86aef1b7d33c4b25c3266c540d91b174ae4cb4e17359fc6ab148cd9751d03db574d94e8726ed0d52f611c9031
7
+ data.tar.gz: 4dccd79f0c6b1ed2b9fcd1c765b0276500b03f951b096d81e563cf5dddd0a28f0910c902e3de69233d17042011f41b2372957ccb80a89bf347d7567575129f63
@@ -1,5 +1,94 @@
1
1
  # Change Log
2
2
 
3
+ ## [v2.15.1](https://github.com/faker-ruby/faker/tree/v2.15.1) (2020-11-24)
4
+
5
+ - Rollback PR #2169 and bump 2.15.1 [#2203](https://github.com/faker-ruby/faker/pull/2203) @vbrazo
6
+
7
+ ------------------------------------------------------------------------------
8
+
9
+ ## [v2.15.0](https://github.com/faker-ruby/faker/tree/v2.15.0) (2020-11-24)
10
+
11
+ ## Bug/Fixes
12
+
13
+ - Rubocop 1.0 fixes [#2182](https://github.com/faker-ruby/faker/pull/2182) @amatsuda
14
+ - Get rid of broken I18n locales configuration for the tests [#2168](https://github.com/faker-ruby/faker/pull/2168) @amatsuda
15
+ - Fixes a bug when generating a password with min_length eq 1 [#2138](https://github.com/faker-ruby/faker/pull/2138) @adrian-rivera @Zeragamba
16
+ - Improve Faker::Company.spanish_organisation_number [#2106](https://github.com/faker-ruby/faker/pull/2106)
17
+
18
+ ## Chores
19
+
20
+ - Reformat demographic yaml [#2189](https://github.com/faker-ruby/faker/pull/2189) @fiteclub
21
+ - An attempt to load only necessary locales on the fly [#2169](https://github.com/faker-ruby/faker/pull/2169) @amatsuda
22
+ - Faker::Config can be a Module rather than a Class [#2167](https://github.com/faker-ruby/faker/pull/2167) @amatsuda
23
+ - Cleanup games [#2155](https://github.com/faker-ruby/faker/pull/2155) @mathisto
24
+ - Deprecate `celebrity` methods in favor of `actor` [#2133](https://github.com/faker-ruby/faker/pull/2133) @vraravam
25
+
26
+ ## Documentation
27
+
28
+ - Fix class name in volleyball.md [#2198](https://github.com/faker-ruby/faker/pull/2198) @connorshea
29
+ - Fix typo in doc/games/heroes.md [#2145](https://github.com/faker-ruby/faker/pull/2145) @Crysicia
30
+ - fix typo [#2141](https://github.com/faker-ruby/faker/pull/2141) @Zeragamba
31
+ - Updated versions in doc for methods. [#2123](https://github.com/faker-ruby/faker/pull/2123) @sudeeptarlekar
32
+
33
+ ## Feature Request
34
+
35
+ - Add `Faker::Mountain` [#2196](https://github.com/faker-ruby/faker/pull/2196) @bipashant
36
+ - Add Faker::Volleyball [#2178](https://github.com/faker-ruby/faker/pull/2178) @RubyHuntsman
37
+ - Add artifact generator to Faker::Game::Heroes [#2177](https://github.com/faker-ruby/faker/pull/2177) @droznyk
38
+ - Add generator to Faker::Games:ElderScrolls [#2171](https://github.com/faker-ruby/faker/pull/2171) @RubyHuntsman
39
+ - Augment opera [#2170](https://github.com/faker-ruby/faker/pull/2170) @Gaitorius
40
+ - Add generator to Faker::Games::ElderScrolls [#2164](https://github.com/faker-ruby/faker/pull/2164) @RubyHuntsman
41
+ - Add more generators to Faker::Minecraft [#2162](https://github.com/faker-ruby/faker/pull/2162) @RubyHuntsman
42
+ - I added more programming languages to the source [#2161](https://github.com/faker-ruby/faker/pull/2161) @JoaoHenriqueVale
43
+ - Add Faker:Camera [#2159](https://github.com/faker-ruby/faker/pull/2159) @RubyHuntsman
44
+ - Add how to train your dragon [#2158](https://github.com/faker-ruby/faker/pull/2158) @archbloom
45
+ - Add Faker::Fantasy::Tolkien [#2152](https://github.com/faker-ruby/faker/pull/2152) @mathisto
46
+ - Feature: Add north dakota driving licence [#2149](https://github.com/faker-ruby/faker/pull/2149) @martinjaimem
47
+ - Add Final Space to TvShows category [#2147](https://github.com/faker-ruby/faker/pull/2147)
48
+ - Add finance/stock generators [#2146](https://github.com/faker-ruby/faker/pull/2146) @johnpitchko
49
+ - Add Clash Of Clans to the Game category [#2143](https://github.com/faker-ruby/faker/pull/2143) @jamesmai0512
50
+ - Add Conan to the JapaneseMedia category [#2142](https://github.com/faker-ruby/faker/pull/2142) @jamesmai0512
51
+ - Add Naruto to the JapaneseMedia category [#2139](https://github.com/faker-ruby/faker/pull/2139) @jamesmai0512
52
+ - Add Doraemon to the JapaneseMedia category [#2137](https://github.com/faker-ruby/faker/pull/2137) @jamesmai0512
53
+ - Add space force and coast guard to military [#2136](https://github.com/faker-ruby/faker/pull/2136) @mathisto
54
+ - Add Super Mario [#2135](https://github.com/faker-ruby/faker/pull/2135) @fblupi
55
+ - Add The Room (2003) to Movies [#2134](https://github.com/faker-ruby/faker/pull/2134) @fiteclub
56
+ - Faker adjectives [#2130](https://github.com/faker-ruby/faker/pull/2130) @loicboset
57
+ - Add Studio Ghibli to the JapaneseMedia category [#2124](https://github.com/faker-ruby/faker/pull/2124) @Kadaaran
58
+ - Created New Method Faker::Quote.fortune_cookie [#2112](https://github.com/faker-ruby/faker/pull/2112) @catonmat
59
+ - Allow disabling the usage of open compounds in sentences [#2109](https://github.com/faker-ruby/faker/pull/2109) @tjozwik
60
+ - Add faker for hiphop artist [#1923](https://github.com/faker-ruby/faker/pull/1923) @Josiassejod1
61
+ - Add races and class names to WorldOfWarcraft [#1787](https://github.com/faker-ruby/faker/pull/1787) @mathisto
62
+ - Add planets and races to DragonBall [#1786](https://github.com/faker-ruby/faker/pull/1786) @mathisto
63
+ - Add planets, cities, and quotes to Dune [#1784](https://github.com/faker-ruby/faker/pull/1784) @mathisto
64
+
65
+ ## Update locales
66
+
67
+ - add japanese gender first name [#2191](https://github.com/faker-ruby/faker/pull/2191) @issei126
68
+ - Add full_address to Ukrainian locale [#2176](https://github.com/faker-ruby/faker/pull/2176) @Ptico
69
+ - Fixed some spelling issues in company.yml [#2173](https://github.com/faker-ruby/faker/pull/2173) @coreymaher
70
+ - Update Faker::Games::SuperSmashBros [#2164](https://github.com/faker-ruby/faker/pull/2164) @boardfish
71
+ - Add more quotes to Faker::Games::Witcher [#2163](https://github.com/faker-ruby/faker/pull/2163) @RubyHuntsman
72
+ - Add Jack Handey's Deep Thoughts to quotes [#2150](https://github.com/faker-ruby/faker/pull/2150) @fiteclub
73
+ - add brazil license plate from mercosul rules [#2144](https://github.com/faker-ruby/faker/pull/2144) @gabrielbaldao
74
+ - Add additional quotes to Studio Ghibli [#2132](https://github.com/faker-ruby/faker/pull/2132) @lambda2
75
+ - Change 'Nyota Uhuru' to 'Nyota Uhura' [#2121](https://github.com/faker-ruby/faker/pull/2121) @TrevorA-TrevorA
76
+ - Add spanish license plates [#2103](https://github.com/faker-ruby/faker/pull/2103)
77
+
78
+ ## Update local dependencies
79
+
80
+ - Update rubocop requirement from = 1.0.0 to = 1.1.0 [#2185](https://github.com/faker-ruby/faker/pull/2185)
81
+ - Update rubocop requirement from = 0.93.1 to = 1.0.0 [#2172](https://github.com/faker-ruby/faker/pull/2172)
82
+ - Update rubocop requirement from = 0.93.0 to = 0.93.1 [#2156](https://github.com/faker-ruby/faker/pull/2156)
83
+ - Update rubocop requirement from = 0.92.0 to = 0.93.0 [#2151](https://github.com/faker-ruby/faker/pull/2151)
84
+ - Update rubocop requirement from = 0.91.1 to = 0.92.0 [#2129](https://github.com/faker-ruby/faker/pull/2129)
85
+ - Update rubocop requirement from = 0.91.0 to = 0.91.1 [#2126](https://github.com/faker-ruby/faker/pull/2126)
86
+ - Update rubocop requirement from = 0.90.0 to = 0.91.0 [#2122](https://github.com/faker-ruby/faker/pull/2122)
87
+ - Update test-unit requirement from = 3.3.6 to = 3.3.7 [#2195](https://github.com/faker-ruby/faker/pull/2195)
88
+ - Update timecop requirement from = 0.9.1 to = 0.9.2 [#2160](https://github.com/faker-ruby/faker/pull/2160)
89
+
90
+ ------------------------------------------------------------------------------
91
+
3
92
  ## [v2.14.0](https://github.com/faker-ruby/faker/tree/v2.14.0) (2020-09-15)
4
93
 
5
94
  ## 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)
@@ -12,13 +12,12 @@ I18n.load_path += Dir[File.join(mydir, 'locales', '**/*.yml')]
12
12
  I18n.reload! if I18n.backend.initialized?
13
13
 
14
14
  module Faker
15
- class Config
15
+ module Config
16
16
  @locale = nil
17
17
  @random = nil
18
18
 
19
19
  class << self
20
- attr_writer :locale
21
- attr_writer :random
20
+ attr_writer :locale, :random
22
21
 
23
22
  def locale
24
23
  # Because I18n.locale defaults to :en, if we don't have :en in our available_locales, errors will happen
@@ -81,13 +80,13 @@ module Faker
81
80
  def regexify(reg)
82
81
  reg = reg.source if reg.respond_to?(:source) # Handle either a Regexp or a String that looks like a Regexp
83
82
  reg
84
- .gsub(%r{^\/?\^?}, '').gsub(%r{\$?\/?$}, '') # Ditch the anchors
83
+ .gsub(%r{^/?\^?}, '').gsub(%r{\$?/?$}, '') # Ditch the anchors
85
84
  .gsub(/\{(\d+)\}/, '{\1,\1}').gsub(/\?/, '{0,1}') # All {2} become {2,2} and ? become {0,1}
86
85
  .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)
86
+ .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
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))) } # 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)
88
+ .gsub(/\((.*?)\)/) { |match| sample(match.gsub(/[()]/, '').split('|')) } # (this|that) becomes 'this' or 'that'
89
+ .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
90
  .gsub(/\[([^\]]+)\]/) { |_match| sample(Regexp.last_match(1).split('')) } # All [ABC] become B (or A or C)
92
91
  .gsub('\d') { |_match| sample(Numbers) }
93
92
  .gsub('\w') { |_match| sample(Letters) }
@@ -97,7 +96,7 @@ module Faker
97
96
  # with an array of values and selecting one of them.
98
97
  def fetch(key)
99
98
  fetched = sample(translate("faker.#{key}"))
100
- if fetched&.match(%r{^\/}) && fetched&.match(%r{\/$}) # A regex
99
+ if fetched&.match(%r{^/}) && fetched&.match(%r{/$}) # A regex
101
100
  regexify(fetched)
102
101
  else
103
102
  fetched
@@ -109,7 +108,7 @@ module Faker
109
108
  def fetch_all(key)
110
109
  fetched = translate("faker.#{key}")
111
110
  fetched = fetched.last if fetched.size <= 1
112
- if !fetched.respond_to?(:sample) && fetched.match(%r{^\/}) && fetched.match(%r{\/$}) # A regex
111
+ if !fetched.respond_to?(:sample) && fetched.match(%r{^/}) && fetched.match(%r{/$}) # A regex
113
112
  regexify(fetched)
114
113
  else
115
114
  fetched
@@ -121,7 +120,7 @@ module Faker
121
120
  # formatted translation: e.g., "#{first_name} #{last_name}".
122
121
  def parse(key)
123
122
  fetched = fetch(key)
124
- parts = fetched.scan(/(\(?)#\{([A-Za-z]+\.)?([^\}]+)\}([^#]+)?/).map do |prefix, kls, meth, etc|
123
+ parts = fetched.scan(/(\(?)#\{([A-Za-z]+\.)?([^}]+)\}([^#]+)?/).map do |prefix, kls, meth, etc|
125
124
  # If the token had a class Prefix (e.g., Name.first_name)
126
125
  # grab the constant, otherwise use self
127
126
  cls = kls ? Faker.const_get(kls.chop) : self
@@ -165,12 +164,12 @@ module Faker
165
164
  end
166
165
 
167
166
  # Executes block with given locale set.
168
- def with_locale(tmp_locale = nil)
167
+ def with_locale(tmp_locale = nil, &block)
169
168
  current_locale = Faker::Config.own_locale
170
169
  Faker::Config.locale = tmp_locale
171
170
 
172
171
  disable_enforce_available_locales do
173
- I18n.with_locale(tmp_locale) { yield }
172
+ I18n.with_locale(tmp_locale, &block)
174
173
  end
175
174
  ensure
176
175
  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