faker 1.8.7 → 1.9.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 (177) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +146 -6
  3. data/README.md +44 -4
  4. data/lib/extensions/array.rb +10 -10
  5. data/lib/extensions/symbol.rb +0 -1
  6. data/lib/faker.rb +42 -35
  7. data/lib/faker/address.rb +39 -13
  8. data/lib/faker/app.rb +1 -3
  9. data/lib/faker/appliance.rb +13 -0
  10. data/lib/faker/avatar.rb +2 -2
  11. data/lib/faker/bank.rb +72 -15
  12. data/lib/faker/beer.rb +0 -1
  13. data/lib/faker/bitcoin.rb +4 -5
  14. data/lib/faker/bojack_horseman.rb +17 -0
  15. data/lib/faker/breaking_bad.rb +0 -3
  16. data/lib/faker/business.rb +1 -2
  17. data/lib/faker/cannabis.rb +42 -0
  18. data/lib/faker/chuck_norris.rb +3 -2
  19. data/lib/faker/code.rb +59 -20
  20. data/lib/faker/coffee.rb +4 -0
  21. data/lib/faker/color.rb +2 -2
  22. data/lib/faker/commerce.rb +3 -4
  23. data/lib/faker/community.rb +13 -0
  24. data/lib/faker/company.rb +80 -24
  25. data/lib/faker/currency.rb +17 -0
  26. data/lib/faker/date.rb +13 -27
  27. data/lib/faker/demographic.rb +2 -2
  28. data/lib/faker/device.rb +29 -0
  29. data/lib/faker/dota.rb +25 -0
  30. data/lib/faker/dr_who.rb +7 -8
  31. data/lib/faker/dumb_and_dumber.rb +1 -1
  32. data/lib/faker/dune.rb +4 -4
  33. data/lib/faker/elder_scrolls.rb +16 -0
  34. data/lib/faker/electrical_components.rb +19 -0
  35. data/lib/faker/ethereum.rb +12 -0
  36. data/lib/faker/famous_last_words.rb +11 -0
  37. data/lib/faker/file.rb +2 -5
  38. data/lib/faker/fillmurray.rb +3 -4
  39. data/lib/faker/finance.rb +3 -4
  40. data/lib/faker/food.rb +21 -1
  41. data/lib/faker/football.rb +21 -0
  42. data/lib/faker/gender.rb +13 -0
  43. data/lib/faker/greek_philosophers.rb +13 -0
  44. data/lib/faker/hacker.rb +9 -11
  45. data/lib/faker/harry_potter.rb +4 -0
  46. data/lib/faker/hipster.rb +12 -4
  47. data/lib/faker/id_number.rb +24 -9
  48. data/lib/faker/internet.rb +69 -57
  49. data/lib/faker/invoice.rb +94 -0
  50. data/lib/faker/job.rb +10 -3
  51. data/lib/faker/lebowski.rb +2 -2
  52. data/lib/faker/lord_of_the_rings.rb +5 -1
  53. data/lib/faker/lorem.rb +32 -8
  54. data/lib/faker/lorem_flickr.rb +43 -0
  55. data/lib/faker/lorem_pixel.rb +20 -5
  56. data/lib/faker/lovecraft.rb +12 -5
  57. data/lib/faker/markdown.rb +12 -4
  58. data/lib/faker/measurement.rb +35 -80
  59. data/lib/faker/michael_scott.rb +9 -0
  60. data/lib/faker/military.rb +25 -0
  61. data/lib/faker/music.rb +13 -1
  62. data/lib/faker/myst.rb +25 -0
  63. data/lib/faker/name.rb +22 -8
  64. data/lib/faker/nation.rb +24 -0
  65. data/lib/faker/nato_phonetic_alphabet.rb +9 -0
  66. data/lib/faker/new_girl.rb +13 -0
  67. data/lib/faker/number.rb +12 -12
  68. data/lib/faker/omniauth.rb +110 -122
  69. data/lib/faker/parks_and_rec.rb +13 -0
  70. data/lib/faker/phone_number.rb +11 -19
  71. data/lib/faker/placeholdit.rb +11 -2
  72. data/lib/faker/princess_bride.rb +13 -0
  73. data/lib/faker/rick_and_morty.rb +1 -1
  74. data/lib/faker/science.rb +4 -2
  75. data/lib/faker/seinfeld.rb +1 -1
  76. data/lib/faker/shakespeare.rb +0 -3
  77. data/lib/faker/silicon_valley.rb +4 -0
  78. data/lib/faker/simpsons.rb +3 -8
  79. data/lib/faker/singular_siegler.rb +9 -0
  80. data/lib/faker/slack_emoji.rb +0 -2
  81. data/lib/faker/source.rb +18 -0
  82. data/lib/faker/space.rb +4 -0
  83. data/lib/faker/star_trek.rb +2 -2
  84. data/lib/faker/star_wars.rb +5 -6
  85. data/lib/faker/stranger_thing.rb +13 -0
  86. data/lib/faker/string.rb +45 -0
  87. data/lib/faker/stripe.rb +63 -0
  88. data/lib/faker/sword_art_online.rb +21 -0
  89. data/lib/faker/team.rb +4 -1
  90. data/lib/faker/the_it_crowd.rb +21 -0
  91. data/lib/faker/time.rb +10 -10
  92. data/lib/faker/twin_peaks.rb +2 -2
  93. data/lib/faker/twitter.rb +1 -1
  94. data/lib/faker/types.rb +36 -40
  95. data/lib/faker/university.rb +3 -3
  96. data/lib/faker/vehicle.rb +72 -10
  97. data/lib/faker/verb.rb +25 -0
  98. data/lib/faker/version.rb +1 -1
  99. data/lib/faker/world_cup.rb +25 -0
  100. data/lib/helpers/char.rb +19 -20
  101. data/lib/helpers/unique_generator.rb +7 -1
  102. data/lib/locales/ca-CAT.yml +1 -1
  103. data/lib/locales/da-DK.yml +1 -0
  104. data/lib/locales/de-AT.yml +3 -2
  105. data/lib/locales/de.yml +6 -5
  106. data/lib/locales/ee.yml +59 -0
  107. data/lib/locales/en-CA.yml +23 -1
  108. data/lib/locales/en-GB.yml +1 -0
  109. data/lib/locales/en-NZ.yml +4 -3
  110. data/lib/locales/en-US.yml +2 -0
  111. data/lib/locales/en.yml +2 -2
  112. data/lib/locales/en/appliance.yml +5 -0
  113. data/lib/locales/en/bank.yml +274 -59
  114. data/lib/locales/en/bojack_horseman.yml +6 -0
  115. data/lib/locales/en/cannabis.yml +12 -0
  116. data/lib/locales/en/community.yml +33 -0
  117. data/lib/locales/en/currency.yml +6 -0
  118. data/lib/locales/en/dessert.yml +3 -3
  119. data/lib/locales/en/device.yml +7 -0
  120. data/lib/locales/en/dota.yml +102 -0
  121. data/lib/locales/en/dr_who.yml +5 -1
  122. data/lib/locales/en/dumb_and_dumber.yml +1 -1
  123. data/lib/locales/en/elder_scrolls.yml +8 -5
  124. data/lib/locales/en/electrical_components.yml +6 -0
  125. data/lib/locales/en/famous_last_words.yml +4 -0
  126. data/lib/locales/en/food.yml +6 -3
  127. data/lib/locales/en/football.yml +7 -0
  128. data/lib/locales/en/gender.yml +5 -0
  129. data/lib/locales/en/greek_philosophers.yml +26 -0
  130. data/lib/locales/en/harry_potter.yml +2 -1
  131. data/lib/locales/en/invoice.yml +6 -0
  132. data/lib/locales/en/job.yml +2 -2
  133. data/lib/locales/en/lord_of_the_rings.yml +1 -0
  134. data/lib/locales/en/lorem.yml +4 -0
  135. data/lib/locales/en/michael_scott.yml +45 -0
  136. data/lib/locales/en/military.yml +8 -0
  137. data/lib/locales/en/music.yml +29 -1
  138. data/lib/locales/en/myst.yml +47 -0
  139. data/lib/locales/en/name.yml +13 -12
  140. data/lib/locales/en/nation.yml +8 -0
  141. data/lib/locales/en/nato_phonetic_alphabet.yml +4 -0
  142. data/lib/locales/en/new_girl.yml +40 -0
  143. data/lib/locales/en/overwatch.yml +3 -2
  144. data/lib/locales/en/parks_and_rec.yml +7 -0
  145. data/lib/locales/en/princess_bride.yml +5 -0
  146. data/lib/locales/en/programming_language.yml +2 -1
  147. data/lib/locales/en/science.yml +1 -0
  148. data/lib/locales/en/silicon_valley.yml +1 -0
  149. data/lib/locales/en/singular_siegler.yml +37 -0
  150. data/lib/locales/en/source.yml +16 -0
  151. data/lib/locales/en/space.yml +2 -1
  152. data/lib/locales/en/star_wars.yml +10 -0
  153. data/lib/locales/en/stranger_thing.yml +36 -0
  154. data/lib/locales/en/stripe.yml +42 -0
  155. data/lib/locales/en/sword_art_online.yml +334 -0
  156. data/lib/locales/en/team.yml +1 -1
  157. data/lib/locales/en/the_it_crowd.yml +155 -0
  158. data/lib/locales/en/vehicle.yml +24 -0
  159. data/lib/locales/en/verbs.yml +8 -0
  160. data/lib/locales/en/world_cup.yml +271 -0
  161. data/lib/locales/es.yml +6 -1
  162. data/lib/locales/fi-FI.yml +9 -4
  163. data/lib/locales/fr-CA.yml +90 -0
  164. data/lib/locales/fr-CH.yml +73 -0
  165. data/lib/locales/fr.yml +4 -2
  166. data/lib/locales/it.yml +1 -1
  167. data/lib/locales/ja.yml +11 -0
  168. data/lib/locales/lv.yml +53 -0
  169. data/lib/locales/nl.yml +1 -1
  170. data/lib/locales/no.yml +7 -0
  171. data/lib/locales/pl.yml +1 -0
  172. data/lib/locales/pt-BR.yml +21 -13
  173. data/lib/locales/pt.yml +1 -0
  174. data/lib/locales/sv.yml +4 -4
  175. data/lib/locales/tr.yml +8 -0
  176. data/lib/locales/uk.yml +9 -0
  177. metadata +167 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 944952e87f63a6622a831db987f0948701896e5b
4
- data.tar.gz: 536fd89b04f1771df3689efed63dfe78f103eb17
3
+ metadata.gz: 69ca03e4a0c0987882bc0e8c84bf7ace7dc8baf1
4
+ data.tar.gz: 5e527dd1240311ce6f9375769bb5713c44d1fff0
5
5
  SHA512:
6
- metadata.gz: 0b5d48c448435729c111c1d5c915f84e71a9722989c5900313a8f8e12335e1faf0361b9188a0567b0efec20ef5439329c3a523de688b5032723c1ec40d0db869
7
- data.tar.gz: 132d9a6e91c418304b13e179dc13d1c75b9fe76719d22e3cff97ca20e3a9c9c0df523e147083cc4d1bc56ac7f5f325551c285405d043f1310a96b58f9aa07885
6
+ metadata.gz: e3626f60935374a293694a8bd94555e8d46b209eb6db8b1e5f62414b5a6e75a7b07662abbd5dc534ce30588db85909e240855420e3acf60a07dd81fa01c94c17
7
+ data.tar.gz: 0ba1336aee2bd2deeab78a0ff167fc2675fe92ab53faf8d5476ed55efdac5abb0c2105a71e05f6431da146ce8bcb03c21949fe6111ed3ed9659ccf3cb0ae5290
@@ -1,5 +1,146 @@
1
1
  # Change Log
2
2
 
3
+ ## HEAD Unreleased
4
+
5
+ ## [v1.9.1](https://github.com/stympy/faker/tree/v1.9.1) (2018-07-11)
6
+ [Full Changelog](https://github.com/stympy/faker/compare/v1.8.7...v1.9.1)
7
+
8
+ ### Feature Request
9
+ - [PR #1308](https://github.com/stympy/faker/pull/1308) Add Faker::BojackHorseman [@saurabhudaniya200](https://github.com/saurabhudaniya200)
10
+ - [PR #1292](https://github.com/stympy/faker/pull/1292) Add Faker::Bank - account_number and routing_number [@vbrazo](https://github.com/vbrazo)
11
+ - [PR #1300](https://github.com/stympy/faker/pull/1300) Add Faker::GreekPhilosophers [@15ngburton](https://github.com/15ngburton)
12
+ - [PR #1004](https://github.com/stympy/faker/pull/1004) Add Faker::Ethereum [@kaizenx](https://github.com/kaizenx)
13
+ - [PR #551](https://github.com/stympy/faker/pull/551) Add gender to name generator [@Maicolben](https://github.com/Maicolben)
14
+ - [PR #1283](https://github.com/stympy/faker/pull/1283) Add Faker::Military [@jjasghar](https://github.com/jjasghar)
15
+ - [PR #1279](https://github.com/stympy/faker/pull/1279) Add Faker::HarryPotter.spell [@A9u](https://github.com/A9u)
16
+ - [PR #799](https://github.com/stympy/faker/pull/799) Faker::ElectricalComponents [@bheim6](https://github.com/bheim6)
17
+ - [PR #1050](https://github.com/stympy/faker/pull/1050) Add Faker::Invoice to generate valid bank slip references [@onnimonni](https://github.com/onnimonni)
18
+ - [PR #817](https://github.com/stympy/faker/pull/817) Faker::Lorem.multibyte for multibyte chars [@frankywahl](https://github.com/frankywahl)
19
+ - [PR #877](https://github.com/stympy/faker/pull/877) Add Canada SIN generator in Faker::Code [@gkunwar](https://github.com/gkunwar)
20
+ - [PR #1268](https://github.com/stympy/faker/pull/1268) Add Faker::Nation.national_sport [@gkunwar](https://github.com/gkunwar)
21
+ - [PR #1273](https://github.com/stympy/faker/pull/1273) Add Faker::Device [@vbrazo](https://github.com/vbrazo)
22
+ - [PR #1272](https://github.com/stympy/faker/pull/1272) Add Faker::DrWho.actor [@timcustard](https://github.com/timcustard)
23
+ - [PR #1270](https://github.com/stympy/faker/pull/1270) Add Faker::Name.middle_name [@vbrazo](https://github.com/vbrazo)
24
+ - [PR #1266](https://github.com/stympy/faker/pull/1266) Add Faker::Science.element_symbol [@timcustard](https://github.com/timcustard)
25
+ - [PR #1101](https://github.com/stympy/faker/pull/1101) Add Faker::Company.czech_organisation_number [@jindrichskupa](https://github.com/jindrichskupa)
26
+ - [PR #1265](https://github.com/stympy/faker/pull/1265) Add Faker::WorldCup [@snayrouz](https://github.com/snayrouz)
27
+ - [PR #1141](https://github.com/stympy/faker/pull/1141) Add Faker::Coffee.intensifier [@oyeanuj](https://github.com/oyeanuj)
28
+ - [PR #1260](https://github.com/stympy/faker/pull/1260) Add Faker::Auto features to Faker::Vehicle [@mrstebo](https://github.com/mrstebo)
29
+ - [PR #1259](https://github.com/stympy/faker/pull/1259) Add the ability to add separators to emails. [@aamarill](https://github.com/aamarill)
30
+ - [PR #1064](https://github.com/stympy/faker/pull/1064) Add Faker::Markdown.sandwich [@russellschmidt](https://github.com/russellschmidt)
31
+ - [PR #1222](https://github.com/stympy/faker/pull/1222) Add paragraph_by_chars functionality [@jguthrie100](https://github.com/jguthrie100)
32
+ - [PR #1107](https://github.com/stympy/faker/pull/1107) Add tokens to Faker::Stripe [@wecohere](https://github.com/wecohere)
33
+ - [PR #1258](https://github.com/stympy/faker/pull/1258) Remove simplecov-console and add coverage_report rake task [@vbrazo](https://github.com/vbrazo)
34
+ - [PR #1247](https://github.com/stympy/faker/pull/1247) Generate capital city of random Nation [@gkunwar](https://github.com/gkunwar)
35
+ - [PR #1250](https://github.com/stympy/faker/pull/1250) House appliances [@rafaelcpalmeida](https://github.com/rafaelcpalmeida)
36
+ - [PR #1239](https://github.com/stympy/faker/pull/1239) Update Faker::Food to separate out Fruits and Veggies [@susiirwin](https://github.com/susiirwin)
37
+ - [PR #1221](https://github.com/stympy/faker/pull/1221) Updated the Readme file with the new logo [@tobaloidee](https://github.com/tobaloidee)
38
+ - [PR #1109](https://github.com/stympy/faker/pull/1109) Added Princess Bride [@jayphodges](https://github.com/jayphodges)
39
+ - [PR #987](https://github.com/stympy/faker/pull/987) Add Faker::Cannabis class [@GhostGroup](https://github.com/GhostGroup)
40
+ - [PR #1199](https://github.com/stympy/faker/pull/1199) Add Faker::StrangerThings [@Connerh92](https://github.com/Connerh92)
41
+ - [PR #1129](https://github.com/stympy/faker/pull/1129) Added SingularSiegler quotes [@splashinn](https://github.com/splashinn)
42
+ - [PR #1235](https://github.com/stympy/faker/pull/1235) Added Faker::Community [@vbrazo](https://github.com/vbrazo)
43
+ - [PR #1144](https://github.com/stympy/faker/pull/1144) Added polish_register_of_national_economy and polish_taxpayer_identification_number [@rafalpetryka](https://github.com/rafalpetryka)
44
+ - [PR #1201](https://github.com/stympy/faker/pull/1201) Adding Currency Symbol to Faker [@SaimonL](https://github.com/SaimonL)
45
+ - [PR #1230](https://github.com/stympy/faker/pull/1230) Add Faker::SwordArtOnline [@lnchambers](https://github.com/lnchambers)
46
+ - [PR #792](https://github.com/stympy/faker/pull/792) Add Faker::FamousLastWords [@susiirwin](https://github.com/susiirwin)
47
+ - [PR #1174](https://github.com/stympy/faker/pull/1174) Dota API: Str Heroes, heroes quotes, Items, Teams, Players [@felipesousafs](https://github.com/darylf)
48
+ - [PR #1220](https://github.com/stympy/faker/pull/1220) Updates for Faker::Myst [@SpyMaster356](https://github.com/SpyMaster356)
49
+ - [PR #1218](https://github.com/stympy/faker/pull/1218) Add Faker::Myst [@SpyMaster356](https://github.com/SpyMaster356)
50
+ - [PR #818](https://github.com/stympy/faker/pull/818) LoremFlickr support [@mrstebo](https://github.com/mrstebo)
51
+ - [PR #1192](https://github.com/stympy/faker/pull/1192) Space: Added space launch vehicule [@gauth-ier](https://github.com/Gauth-ier)
52
+ - [PR #1211](https://github.com/stympy/faker/pull/1211) Add bands, genres, and albums to Music [@jmkoni](https://github.com/jmkoni)
53
+ - [PR #1215](https://github.com/stympy/faker/pull/1215) Added Nato Phonetic Alphabet [@timcustard](https://github.com/timcustard)
54
+ - [PR #1209](https://github.com/stympy/faker/pull/1209) Add Faker::Source [@graciano](https://github.com/graciano)
55
+ - [PR #1147](https://github.com/stympy/faker/pull/1147) Add Spanish citizen id and docs [@PuZZleDucK](https://github.com/PuZZleDucK)
56
+ - [PR #1189](https://github.com/stympy/faker/pull/1189) Add Faker::Football [@AlexGascon](https://github.com/AlexGascon)
57
+ - [PR #1202](https://github.com/stympy/faker/pull/1202) adds both inclusive and binary gender option [@jmkoni](https://github.com/jmkoni)
58
+ - [PR #1193](https://github.com/stympy/faker/pull/1193) Add Faker::MichaelScott API [@snayrouz](https://github.com/snayrouz)
59
+ - [PR #1179](https://github.com/stympy/faker/pull/1179) Random color with Placeholdit [@nicolas-brousse](https://github.com/nicolas-brousse)
60
+ - [PR #1190](https://github.com/stympy/faker/pull/1190) Add Nation object, its specs and docs [@gkunwar](https://github.com/gkunwar)
61
+ - [PR #1210](https://github.com/stympy/faker/pull/1210) Add coveralls [@vbrazo](https://github.com/vbrazo)
62
+ - [PR #924](https://github.com/stympy/faker/pull/924) Rubocop + fixes [@stephengroat](https://github.com/stephengroat)
63
+ - [PR #900](https://github.com/stympy/faker/pull/900) Add Japanese lorem words to locale [@vietqhoang](https://github.com/vietqhoang)
64
+
65
+ ### Update/add locales
66
+ - [PR #1297](https://github.com/stympy/faker/pull/1297) Faker::WorldCup updates [@JoaoHenriqueVale](https://github.com/JoaoHenriqueVale)
67
+ - [PR #616](https://github.com/stympy/faker/pull/616) add german commerce translations [@weh](https://github.com/weh)
68
+ - [PR #1281](https://github.com/stympy/faker/pull/1281) Some competitions were in the coaches array [@Eusebiotrigo](https://github.com/Eusebiotrigo)
69
+ - [PR #1103](https://github.com/stympy/faker/pull/1103) Fix inconsistent capitalization in dishes, ingredients and spices, and some other small issues under 'food' [@evrimfeyyaz](https://github.com/evrimfeyyaz)
70
+ - [PR #1262](https://github.com/stympy/faker/pull/1262) Add fr_CH locale [@elentras](https://github.com/elentras)
71
+ - [PR #1261](https://github.com/stympy/faker/pull/1261) Add fr_CA locale [@elentras](https://github.com/elentras)
72
+ - [PR #1275](https://github.com/stympy/faker/pull/1275) Fix typo; RedWine should be two words [@johnmuhl](https://github.com/johnmuhl)
73
+ - [PR #1269](https://github.com/stympy/faker/pull/1269) Update Faker::ProgrammingLanguage.name locales [@vbrazo](https://github.com/vbrazo)
74
+ - [PR #1140](https://github.com/stympy/faker/pull/1140) Add Estonian and Latvian locales [@maciej-szlosarczyk](https://github.com/maciej-szlosarczyk)
75
+ - [PR #1249](https://github.com/stympy/faker/pull/1249) Update list of name prefixes for sv locale. [kamilbielawski](https://github.com/kamilbielawski)
76
+ - [PR #1228](https://github.com/stympy/faker/pull/1228) Added Japanese color to yml [@katao](https://github.com/katao)
77
+ - [PR #1106](https://github.com/stympy/faker/pull/1106) Adds turkish phone number formats [@zasman](https://github.com/ZASMan)
78
+ - [PR #794](https://github.com/stympy/faker/pull/794) Adding country code + minor locale updates [@vveliev](https://github.com/vveliev)
79
+ - [PR #439](https://github.com/stympy/faker/pull/439) Remove Eichmann surname [@jonahwh](https://github.com/jonahwh)
80
+ - [PR #1203](https://github.com/stympy/faker/pull/1203) Finnish locale has 50 most common male, female, and last names [@Glenf](https://github.com/Glenf)
81
+ - [PR #1183](https://github.com/stympy/faker/pull/1183) Correct the spelling of Gringotts [@rhoen](https://github.com/rhoen)
82
+ - [PR #1236](https://github.com/stympy/faker/pull/1236) Updates dessert faker [@susiirwin](https://github.com/susiirwin)
83
+ - [PR #1229](https://github.com/stympy/faker/pull/1229) sv.yml: Typos [@olleolleolle](https://github.com/olleolleolle)
84
+ - [PR #1108](https://github.com/stympy/faker/pull/1108) Update Faker::Dessert [@natalietate](https://github.com/natalietate)
85
+ - [PR #1122](https://github.com/stympy/faker/pull/1122) Fix formatting for Brazilian phone and cell phone numbers [@lucasqueiroz](https://github.com/lucasqueiroz)
86
+ - [PR #1138](https://github.com/stympy/faker/pull/1138) Update locales - Faker::Overwatch [@tanner0101](https://github.com/tanner0101)
87
+ - [PR #1117](https://github.com/stympy/faker/pull/1117) Added Ukrainian entries to yml [@RomanIsko](https://github.com/RomanIsko)
88
+
89
+ ### Bug/Fixes
90
+ - [PR #1305](https://github.com/stympy/faker/pull/1305) Fix YAML syntax - single quote escape (on vehicle.yml) [@YumaInaura](https://github.com/YumaInaura)
91
+ - [PR #1196](https://github.com/stympy/faker/pull/1196) Fix PhoneNumber in es-MX [@drewish](https://github.com/drewish)
92
+ - [PR #1133](https://github.com/stympy/faker/pull/1133) Fix I18n 0.9.3 compatibility [@tagliala](https://github.com/tagliala)
93
+ - [PR #1292](https://github.com/stympy/faker/pull/1292) Fix flexible keys crashing when current locale does not provide them [@deivid-rodriguez](https://github.com/deivid-rodriguez)
94
+ - [PR #1274](https://github.com/stympy/faker/pull/1274) Allow Faker::Address.zip_code to have leading zero [@igor-starostenko](https://github.com/igor-starostenko)
95
+ - [PR #1241](https://github.com/stympy/faker/pull/1241) Add missing tests reported by SimpleCov [@aamarill](https://github.com/aamarill)
96
+ - [PR #1240](https://github.com/stympy/faker/pull/1240) Add some tests [@aamarill](https://github.com/aamarill)
97
+ - [PR #1238](https://github.com/stympy/faker/pull/1238) pluralized file to match link name in the readme [@Connerh92](https://github.com/Connerh92)
98
+ - [PR #1232](https://github.com/stympy/faker/pull/1232) Fix file permissions [@tagliala](https://github.com/tagliala)
99
+ - [PR #1205](https://github.com/stympy/faker/pull/1205) Show the type of field that violated a uniqueness constraint [@AndrewRayCode](https://github.com/AndrewRayCode)
100
+ - [PR #1227](https://github.com/stympy/faker/pull/1227) Update RuboCop to 0.56.0 [@tagliala](https://github.com/tagliala)
101
+ - [PR #1225](https://github.com/stympy/faker/pull/1225) Test against latest Ruby versions [@tagliala](https://github.com/tagliala)
102
+ - [PR #1134](https://github.com/stympy/faker/pull/1134) Test against latest Ruby versions [@tagliala](https://github.com/tagliala)
103
+ - [PR #1223](https://github.com/stympy/faker/pull/1223) Fix minitest warnings [@vbrazo](https://github.com/vbrazo)
104
+ - [PR #1198](https://github.com/stympy/faker/pull/1198) Rename methods on Faker::Types to avoid shadowing ruby standard methods [@MarcPer](https://github.com/MarcPer)
105
+ - [PR #1142](https://github.com/stympy/faker/pull/1142) Missing i18n jobs fix [@PuZZleDucK](https://github.com/PuZZleDucK)
106
+ - [PR #1213](https://github.com/stympy/faker/pull/1213) Add missing tests after adding Coveralls [@vbrazo](https://github.com/vbrazo)
107
+ - [PR #1212](https://github.com/stympy/faker/pull/1212) Coveralls should ignore test folder [@vbrazo](https://github.com/timcustard)
108
+ - [PR #1181](https://github.com/stympy/faker/pull/1181) Fix: Moved the Google Omniauth key id_info from root into extra [@SirRawlins](https://github.com/SirRawlins)
109
+ - [PR #1207](https://github.com/stympy/faker/pull/1207) use default rake task [@stephengroat](https://github.com/stephengroat)
110
+ - [PR #1136](https://github.com/stympy/faker/pull/1136) Modify Faker::Internet.slug [@philduffen](https://github.com/philduffen)
111
+ - [PR #1170](https://github.com/stympy/faker/pull/1170) First_name and last_name should use the parse method - :ru locale [@vbrazo](https://github.com/vbrazo)
112
+ - [PR #1197](https://github.com/stympy/faker/pull/1197) Fixes NL postcode [@JonathanWThom](https://github.com/JonathanWThom)
113
+ - [PR #1172](https://github.com/stympy/faker/pull/1172) Fix Fixnum reference warning [@vbrazo](https://github.com/vbrazo)
114
+ - [PR #1173](https://github.com/stympy/faker/pull/1173) Fix tests warning [@vbrazo](https://github.com/vbrazo)
115
+
116
+ ### Chores
117
+ - [PR #1304](https://github.com/stympy/faker/pull/1304) Fix Faker::Source ruby language examples [@YumaInaura](https://github.com/YumaInaura)
118
+ - [PR #1306](https://github.com/stympy/faker/pull/1306) Rename Internet#user_name to #username [@tylerhunt](https://github.com/tylerhunt)
119
+ - [PR #1293](https://github.com/stympy/faker/pull/1293) Update RuboCop to 0.57.2 [@tagliala](https://github.com/tagliala)
120
+ - [PR #1294](https://github.com/stympy/faker/pull/1294) Simpler requiring of test helper [@deivid-rodriguez](https://github.com/deivid-rodriguez)
121
+ - [PR #1288](https://github.com/stympy/faker/pull/1288) rake console changes - description and contributing.md [@MarcPer](https://github.com/MarcPer)
122
+ - [PR #719](https://github.com/stympy/faker/pull/719) Random words to add should be 0 [@swapsCAPS](https://github.com/swapsCAPS)
123
+
124
+ ### Documentation
125
+ - [PR #1121](https://github.com/stympy/faker/pull/1121) Better docs for Faker::Food.description [@jujulisan](https://github.com/jujulisan)
126
+ - [PR #1257](https://github.com/stympy/faker/pull/1257) Fix method name in Faker::SingularSiegler [@mrstebo](https://github.com/mrstebo)
127
+ - [PR #1256](https://github.com/stympy/faker/pull/1256) Fixing documentation - Faker::Name to Faker::Zelda [@mrstebo](https://github.com/mrstebo)
128
+ - [PR #1254](https://github.com/stympy/faker/pull/1254) Added missing documentation. [@mrstebo](https://github.com/mrstebo)
129
+ - [PR #1252](https://github.com/stympy/faker/pull/1252) Add missing documentation - Faker::Address to Faker::Myst [@vbrazo](https://github.com/vbrazo)
130
+ - [PR #1248](https://github.com/stympy/faker/pull/1248) Remove duplications from company.md [@vrinek](https://github.com/vrinek)
131
+ - [PR #1146](https://github.com/stympy/faker/pull/1146) Update company docs [@PuZZleDucK](https://github.com/PuZZleDucK)
132
+ - [PR #974](https://github.com/stympy/faker/pull/974) Specify version number each class was introduced [@darylf](https://github.com/darylf)
133
+ - [PR #1128](https://github.com/stympy/faker/pull/1128) Use ruby syntax highlighting in Omniauth doc [@swrobel](https://github.com/swrobel)
134
+ - [PR #1204](https://github.com/stympy/faker/pull/1204) Update sample output of `Faker::App.version` [@joshuapinter](https://github.com/joshuapinter)
135
+ - [PR #1135](https://github.com/stympy/faker/pull/1135) Added documentation for dumb and dumber [@cnharris10](https://github.com/cnharris10)
136
+ - [PR #1177](https://github.com/stympy/faker/pull/1177) Update Faker::Number.between docs [@SpyMaster356](https://github.com/SpyMaster356)
137
+ - [PR #1124](https://github.com/stympy/faker/pull/1124) Fix ranges for Brazilian zip codes [@lucasqueiroz](https://github.com/lucasqueiroz)
138
+ - New collaborator - Vitor Oliveira [@vbrazo](https://github.com/vbrazo)
139
+
140
+ ### Deprecation
141
+ - [PR #1264](https://github.com/stympy/faker/pull/1264) Prepare Faker::Name.job_titles and Faker::Name.title for deprecation
142
+ - Removing these methods as they are available in `Faker::Job`
143
+
3
144
  ## [v1.8.7](https://github.com/stympy/faker/tree/v1.8.7) (2017-12-22)
4
145
  [Full Changelog](https://github.com/stympy/faker/compare/v1.8.6...v1.8.7)
5
146
 
@@ -159,7 +300,7 @@
159
300
  - Faker::Time.between produces times out of range [\#894](https://github.com/stympy/faker/issues/894)
160
301
  - \[Feature Request\] Add User Agent strings [\#880](https://github.com/stympy/faker/issues/880)
161
302
  - Faker::Omniauth is not deterministic and breaking the build [\#876](https://github.com/stympy/faker/issues/876)
162
- - undefined method `name =' or undefined method ` =' [\#871](https://github.com/stympy/faker/issues/871)
303
+ - undefined method `name =' or undefined method ` =' [\#871](https://github.com/stympy/faker/issues/871)
163
304
  - Faker::French Suggestion [\#869](https://github.com/stympy/faker/issues/869)
164
305
  - Documentation not correct for Faker::Color.hsl\_color and hsla\_color [\#866](https://github.com/stympy/faker/issues/866)
165
306
  - Faker::PhoneNumber.area\_code and .exchange\_code returning nil [\#861](https://github.com/stympy/faker/issues/861)
@@ -321,7 +462,6 @@
321
462
  - undefined method `Number' for Faker:Module [\#153](https://github.com/stympy/faker/issues/153)
322
463
 
323
464
  **Merged pull requests:**
324
-
325
465
  - Refactors code in Faker::Color [\#777](https://github.com/stympy/faker/pull/777) ([tiagofsilva](https://github.com/tiagofsilva))
326
466
  - Add Faker::TwinPeaks \[fixed\] [\#775](https://github.com/stympy/faker/pull/775) ([pedantic-git](https://github.com/pedantic-git))
327
467
  - Added wookie\_sentence method documentation to README [\#772](https://github.com/stympy/faker/pull/772) ([toddnestor](https://github.com/toddnestor))
@@ -451,7 +591,7 @@
451
591
  ## v1.6.0 (2015-11-23)
452
592
  * Lots of bug fixes -- most notably, a fix for email addresses and domains in non-en locales
453
593
  * Updated locales: de, en-AU, en-NZ, en-SG, en-US, en-au-ocker, en, es, fr, he, it, ja, nb-NO, pl, pt-BR, sk, and zh-CN
454
- * Updated classes: Address, Avatar, Book, Code, Commerce, Company, Hipster, IDNumber, Internet, Number, Placeholdit, Shakespeare, and Time
594
+ * Updated classes: Address, Avatar, Book, Code, Commerce, Company, Hipster, IDNumber, Internet, Number, Placeholdit, Shakespeare, and Time
455
595
 
456
596
  ## v1.5.0 (2015-08-17)
457
597
  * Added logos
@@ -501,7 +641,7 @@
501
641
  * 1 major change:
502
642
  * Removed deprecated methods from Address: earth_country, us_state, us_state_abbr, uk_postcode, uk_county
503
643
  * Many minor changes (please see github pull requests for credits)
504
- * Added many localizations
644
+ * Added many localizations
505
645
  * Added range and array support for Lorem
506
646
 
507
647
  ## v1.0.1 (2011-09-27)
@@ -535,7 +675,7 @@
535
675
  * Added Canadian translation [igbanam]
536
676
  * Added Norwegian translation [kytrinyx]
537
677
  * Lots of translation-related cleanup [kytrinyx]
538
-
678
+
539
679
 
540
680
  ## v0.9.5 (2011-01-27)
541
681
  * 1 minor bug fix:
@@ -577,7 +717,7 @@
577
717
  * 3 major enhancements:
578
718
  * Added Lorem to generate fake Latin
579
719
  * Added secondary_address to Address, and made inclusion of
580
- secondary address in street_address optional (false by
720
+ secondary address in street_address optional (false by
581
721
  default).
582
722
  * Added UK address methods [Caius Durling]
583
723
 
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
- # Faker [![Build Status](https://travis-ci.org/stympy/faker.svg?branch=master)](https://travis-ci.org/stympy/faker) [![Gem Version](https://badge.fury.io/rb/faker.svg)](https://badge.fury.io/rb/faker)
1
+ ![logotype a happy-07](https://user-images.githubusercontent.com/36028424/40263395-4318481e-5b44-11e8-92e5-3dcc1ce169b3.png)
2
2
 
3
+ # Faker [![Build Status](https://travis-ci.org/stympy/faker.svg?branch=master)](https://travis-ci.org/stympy/faker) [![Gem Version](https://badge.fury.io/rb/faker.svg)](https://badge.fury.io/rb/faker) [![Test Coverage](https://api.codeclimate.com/v1/badges/ef54c7f9df86e965d64b/test_coverage)](https://codeclimate.com/github/stympy/faker/test_coverage) [![Maintainability](https://api.codeclimate.com/v1/badges/ef54c7f9df86e965d64b/maintainability)](https://codeclimate.com/github/stympy/faker/maintainability)
3
4
 
4
5
  This gem is a port of Perl's Data::Faker library that generates fake data.
5
6
 
@@ -26,70 +27,101 @@ Contents
26
27
  - [Faker::Address](doc/address.md)
27
28
  - [Faker::Ancient](doc/ancient.md)
28
29
  - [Faker::App](doc/app.md)
30
+ - [Faker::Appliance](doc/appliance.md)
31
+ - [Faker::Artist](doc/artist.md)
29
32
  - [Faker::AquaTeenHungerForce](doc/aqua_teen_hunger_force.md)
30
33
  - [Faker::Avatar](doc/avatar.md)
31
34
  - [Faker::BackToTheFuture](doc/back_to_the_future.md)
32
35
  - [Faker::Bank](doc/bank.md)
33
36
  - [Faker::Beer](doc/beer.md)
34
37
  - [Faker::Bitcoin](doc/bitcoin.md)
38
+ - [Faker::BojackHorseman](doc/bojack_horseman.md)
35
39
  - [Faker::Book](doc/book.md)
36
40
  - [Faker::Boolean](doc/boolean.md)
37
41
  - [Faker::BossaNova](doc/bossa_nova.md)
42
+ - [Faker::BreakingBad](doc/breaking_bad.md)
38
43
  - [Faker::Business](doc/business.md)
44
+ - [Faker::Cannabis](doc/cannabis.md)
39
45
  - [Faker::Cat](doc/cat.md)
40
46
  - [Faker::ChuckNorris](doc/chuck_norris.md)
41
47
  - [Faker::Code](doc/code.md)
42
48
  - [Faker::Coffee](doc/coffee.md)
43
49
  - [Faker::Color](doc/color.md)
44
50
  - [Faker::Commerce](doc/commerce.md)
51
+ - [Faker::Community](doc/community.md)
45
52
  - [Faker::Company](doc/company.md)
46
53
  - [Faker::Compass](doc/compass.md)
47
54
  - [Faker::Crypto](doc/crypto.md)
55
+ - [Faker::Currency](doc/currency.md)
48
56
  - [Faker::Date](doc/date.md)
49
57
  - [Faker::Demographic](doc/demographic.md)
50
58
  - [Faker::Dessert](doc/dessert.md)
59
+ - [Faker::Device](doc/device.md)
51
60
  - [Faker::Dog](doc/dog.md)
52
- - [Faker::DragonBall](doc/dragon_ball.md)
61
+ - [Faker::Dota](doc/dota.md)
53
62
  - [Faker::DrWho](doc/dr_who.md)
63
+ - [Faker::DragonBall](doc/dragon_ball.md)
64
+ - [Faker::DumbAndDumber](doc/dumb_and_dumber.md)
54
65
  - [Faker::Dune](doc/dune.md)
55
66
  - [Faker::Educator](doc/educator.md)
56
67
  - [Faker::ElderScrolls](doc/elder_scrolls.md)
68
+ - [Faker::ElectricalComponents](doc/electrical_components.md)
69
+ - [Faker::Esport](doc/esport.md)
70
+ - [Faker::Ethereum](doc/ethereum.md)
57
71
  - [Faker::Fallout](doc/fallout.md)
58
72
  - [Faker::FamilyGuy](doc/family_guy.md)
73
+ - [Faker::FamousLastWords](doc/famous_last_words.md)
59
74
  - [Faker::File](doc/file.md)
60
75
  - [Faker::Fillmurray](doc/fillmurray.md)
76
+ - [Faker::Finance](doc/finance.md)
61
77
  - [Faker::Food](doc/food.md)
78
+ - [Faker::Football](doc/football.md)
62
79
  - [Faker::Friends](doc/friends.md)
80
+ - [Faker::FunnyName](doc/funny_name.md)
63
81
  - [Faker::GameOfThrones](doc/game_of_thrones.md)
82
+ - [Faker::Gender](doc/gender.md)
83
+ - [Faker::GreekPhilosophers](doc/greek_philosophers.md)
64
84
  - [Faker::Hacker](doc/hacker.md)
65
85
  - [Faker::HarryPotter](doc/harry_potter.md)
66
86
  - [Faker::HeyArnold](doc/hey_arnold.md)
67
87
  - [Faker::Hipster](doc/hipster.md)
88
+ - [Faker::HitchhikersGuideToTheGalaxy](doc/hitchhikers_guide_to_the_galaxy.md)
68
89
  - [Faker::Hobbit](doc/hobbit.md)
69
90
  - [Faker::HowIMetYourMother](doc/how_i_met_your_mother.md)
70
- - [Faker::HitchhikersGuideToTheGalaxy](doc/hitchhikers_guide_to_the_galaxy.md)
91
+ - [Faker::IDNumber](doc/id_number.md)
71
92
  - [Faker::Internet](doc/internet.md)
93
+ - [Faker::Invoice](doc/invoice.md)
72
94
  - [Faker::Job](doc/job.md)
73
95
  - [Faker::Kpop](doc/kpop.md)
74
96
  - [Faker::LeagueOfLegends](doc/league_of_legends.md)
97
+ - [Faker::Lebowski](doc/lebowski.md)
75
98
  - [Faker::LordOfTheRings](doc/lord_of_the_rings.md)
76
- - [Faker::LoremPixel](doc/lorem_pixel.md)
77
99
  - [Faker::Lorem](doc/lorem.md)
100
+ - [Faker::LoremFlickr](doc/lorem_flickr.md)
101
+ - [Faker::LoremPixel](doc/lorem_pixel.md)
78
102
  - [Faker::Lovecraft](doc/lovecraft.md)
79
103
  - [Faker::Markdown](doc/markdown.md)
80
104
  - [Faker::Matz](doc/matz.md)
81
105
  - [Faker::Measurement](doc/measurement.md)
106
+ - [Faker::MichaelScott](doc/michael_scott.md)
107
+ - [Faker::Military](doc/military.md)
82
108
  - [Faker::MostInterestingManInTheWorld](doc/most_interesting_man_in_the_world.md)
83
109
  - [Faker::Movie](doc/movie.md)
84
110
  - [Faker::Music](doc/music.md)
111
+ - [Faker::Myst](doc/myst.md)
85
112
  - [Faker::Name](doc/name.md)
113
+ - [Faker::Nation](doc/nation.md)
114
+ - [Faker::NatoPhoneticAlphabet](doc/nato_phonetic_alphabet.md)
115
+ - [Faker::NewGirl](doc/new_girl.md)
86
116
  - [Faker::Number](doc/number.md)
87
117
  - [Faker::Omniauth](doc/omniauth.md)
88
118
  - [Faker::OnePiece](doc/one_piece.md)
89
119
  - [Faker::Overwatch](doc/overwatch.md)
120
+ - [Faker::ParksAndRec](doc/parks_and_rec.md)
90
121
  - [Faker::PhoneNumber](doc/phone_number.md)
91
122
  - [Faker::Placeholdit](doc/placeholdit.md)
92
123
  - [Faker::Pokemon](doc/pokemon.md)
124
+ - [Faker::PrincessBride](doc/princess_bride.md)
93
125
  - [Faker::ProgrammingLanguage](doc/programming_language.md)
94
126
  - [Faker::RickAndMorty](doc/rick_and_morty.md)
95
127
  - [Faker::Robin](doc/robin.md)
@@ -99,13 +131,20 @@ Contents
99
131
  - [Faker::Seinfeld](doc/seinfeld.md)
100
132
  - [Faker::SiliconValley](doc/silicon_valley.md)
101
133
  - [Faker::Simpsons](doc/simpsons.md)
134
+ - [Faker::SingularSiegler](doc/singular_siegler.md)
102
135
  - [Faker::SlackEmoji](doc/slack_emoji.md)
136
+ - [Faker::Source](doc/source.md)
103
137
  - [Faker::Space](doc/space.md)
104
138
  - [Faker::StarTrek](doc/star_trek.md)
105
139
  - [Faker::StarWars](doc/star_wars.md)
140
+ - [Faker::StrangerThings](doc/stranger_things.md)
141
+ - [Faker::String](doc/string.md)
142
+ - [Faker::Stripe](doc/stripe.md)
106
143
  - [Faker::Superhero](doc/superhero.md)
144
+ - [Faker::SwordArtOnline](doc/sword_art_online.md)
107
145
  - [Faker::Team](doc/team.md)
108
146
  - [Faker::TheFreshPrinceOfBelAir](doc/the_fresh_prince_of_bel_air.md)
147
+ - [Faker::TheITCrowd](doc/the_it_crowd.md)
109
148
  - [Faker::TheThickOfIt](doc/the_thick_of_it.md)
110
149
  - [Faker::Time](doc/time.md)
111
150
  - [Faker::TwinPeaks](doc/twin_peaks.md)
@@ -117,6 +156,7 @@ Contents
117
156
  - [Faker::VentureBros](doc/venture_bros.md)
118
157
  - [Faker::VForVendetta](doc/v_for_vendetta.md)
119
158
  - [Faker::Witcher](doc/witcher.md)
159
+ - [Faker::WorldCup](doc/world_cup.md)
120
160
  - [Faker::WorldOfWarcraft](doc/world_of_warcraft.md)
121
161
  - [Faker::Zelda](doc/zelda.md)
122
162
  - [Customization](#customization)
@@ -1,21 +1,21 @@
1
1
  class Array
2
- unless self.method_defined? :sample
3
- def sample(n = nil)
4
- #based on code from https://github.com/marcandre/backports
5
- size = self.length
6
- return self[Kernel.rand(size)] if n.nil?
2
+ unless method_defined? :sample
3
+ def sample(arr = nil)
4
+ # based on code from https://github.com/marcandre/backports
5
+ size = length
6
+ return self[Kernel.rand(size)] if arr.nil?
7
7
 
8
- n = n.to_int
9
- raise ArgumentError, "negative array size" if n < 0
8
+ arr = arr.to_int
9
+ raise ArgumentError, 'negative array size' if arr < 0
10
10
 
11
- n = size if n > size
11
+ arr = size if arr > size
12
12
 
13
13
  result = Array.new(self)
14
- n.times do |i|
14
+ arr.times do |i|
15
15
  r = i + Kernel.rand(size - i)
16
16
  result[i], result[r] = result[r], result[i]
17
17
  end
18
- result[n..size] = []
18
+ result[arr..size] = []
19
19
  result
20
20
  end
21
21
  end
@@ -6,4 +6,3 @@ unless :symbol.respond_to?(:downcase)
6
6
  end
7
7
  end
8
8
  end
9
-
@@ -1,9 +1,7 @@
1
- # -*- coding: utf-8 -*-
2
- mydir = File.expand_path(File.dirname(__FILE__))
1
+ mydir = __dir__
3
2
 
4
3
  begin
5
4
  require 'psych'
6
- rescue LoadError
7
5
  end
8
6
 
9
7
  require 'i18n'
@@ -15,7 +13,6 @@ end
15
13
  I18n.load_path += Dir[File.join(mydir, 'locales', '**/*.yml')]
16
14
  I18n.reload! if I18n.backend.initialized?
17
15
 
18
-
19
16
  module Faker
20
17
  class Config
21
18
  @locale = nil
@@ -45,9 +42,10 @@ module Faker
45
42
  Letters = ULetters + Array('a'..'z')
46
43
 
47
44
  class << self
48
- ## make sure numerify results doesn’t start with a zero
49
- def numerify(number_string)
50
- number_string.sub(/#/) { (rand(9)+1).to_s }.gsub(/#/) { rand(10).to_s }
45
+ ## by default numerify results do not start with a zero
46
+ def numerify(number_string, leading_zero: false)
47
+ return number_string.gsub(/#/) { rand(10).to_s } if leading_zero
48
+ number_string.sub(/#/) { rand(1..9).to_s }.gsub(/#/) { rand(10).to_s }
51
49
  end
52
50
 
53
51
  def letterify(letter_string)
@@ -77,26 +75,26 @@ module Faker
77
75
  #
78
76
  # "U3V 3TP"
79
77
  #
80
- def regexify(re)
81
- re = re.source if re.respond_to?(:source) # Handle either a Regexp or a String that looks like a Regexp
82
- re.
83
- gsub(/^\/?\^?/, '').gsub(/\$?\/?$/, ''). # Ditch the anchors
84
- gsub(/\{(\d+)\}/, '{\1,\1}').gsub(/\?/, '{0,1}'). # All {2} become {2,2} and ? become {0,1}
85
- gsub(/(\[[^\]]+\])\{(\d+),(\d+)\}/) {|match| $1 * sample(Array(Range.new($2.to_i, $3.to_i))) }. # [12]{1,2} becomes [12] or [12][12]
86
- gsub(/(\([^\)]+\))\{(\d+),(\d+)\}/) {|match| $1 * sample(Array(Range.new($2.to_i, $3.to_i))) }. # (12|34){1,2} becomes (12|34) or (12|34)(12|34)
87
- gsub(/(\\?.)\{(\d+),(\d+)\}/) {|match| $1 * sample(Array(Range.new($2.to_i, $3.to_i))) }. # A{1,2} becomes A or AA or \d{3} becomes \d\d\d
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)
90
- gsub(/\[([^\]]+)\]/) {|match| sample($1.split('')) }. # All [ABC] become B (or A or C)
91
- gsub('\d') {|match| sample(Numbers) }.
92
- gsub('\w') {|match| sample(Letters) }
78
+ def regexify(reg)
79
+ reg = reg.source if reg.respond_to?(:source) # Handle either a Regexp or a String that looks like a Regexp
80
+ reg
81
+ .gsub(%r{^\/?\^?}, '').gsub(%r{\$?\/?$}, '') # Ditch the anchors
82
+ .gsub(/\{(\d+)\}/, '{\1,\1}').gsub(/\?/, '{0,1}') # All {2} become {2,2} and ? become {0,1}
83
+ .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]
84
+ .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)
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))) } # A{1,2} becomes A or AA or \d{3} becomes \d\d\d
86
+ .gsub(/\((.*?)\)/) { |match| sample(match.gsub(/[\(\)]/, '').split('|')) } # (this|that) becomes 'this' or 'that'
87
+ .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(Regexp.last_match(1).split('')) } # All [ABC] become B (or A or C)
89
+ .gsub('\d') { |_match| sample(Numbers) }
90
+ .gsub('\w') { |_match| sample(Letters) }
93
91
  end
94
92
 
95
93
  # Helper for the common approach of grabbing a translation
96
94
  # with an array of values and selecting one of them.
97
95
  def fetch(key)
98
96
  fetched = sample(translate("faker.#{key}"))
99
- if fetched && fetched.match(/^\//) and fetched.match(/\/$/) # A regex
97
+ if fetched && fetched.match(%r{^\/}) && fetched.match(%r{\/$}) # A regex
100
98
  regexify(fetched)
101
99
  else
102
100
  fetched
@@ -108,7 +106,7 @@ module Faker
108
106
  def fetch_all(key)
109
107
  fetched = translate("faker.#{key}")
110
108
  fetched = fetched.last if fetched.size <= 1
111
- if !fetched.respond_to?(:sample) && fetched.match(/^\//) and fetched.match(/\/$/) # A regex
109
+ if !fetched.respond_to?(:sample) && fetched.match(%r{^\/}) && fetched.match(%r{\/$}) # A regex
112
110
  regexify(fetched)
113
111
  else
114
112
  fetched
@@ -120,7 +118,7 @@ module Faker
120
118
  # formatted translation: e.g., "#{first_name} #{last_name}".
121
119
  def parse(key)
122
120
  fetched = fetch(key)
123
- parts = fetched.scan(/(\(?)#\{([A-Za-z]+\.)?([^\}]+)\}([^#]+)?/).map {|prefix, kls, meth, etc|
121
+ parts = fetched.scan(/(\(?)#\{([A-Za-z]+\.)?([^\}]+)\}([^#]+)?/).map do |prefix, kls, meth, etc|
124
122
  # If the token had a class Prefix (e.g., Name.first_name)
125
123
  # grab the constant, otherwise use self
126
124
  cls = kls ? Faker.const_get(kls.chop) : self
@@ -129,13 +127,19 @@ module Faker
129
127
  # In either case the information will be retained for reconstruction of the string.
130
128
  text = prefix
131
129
 
132
- # If the class has the method, call it, otherwise
133
- # fetch the transation (i.e., faker.name.first_name)
134
- text += cls.respond_to?(meth) ? cls.send(meth) : fetch("#{(kls || self).to_s.split('::').last.downcase}.#{meth.downcase}")
130
+ # If the class has the method, call it, otherwise fetch the transation
131
+ # (e.g., faker.phone_number.area_code)
132
+ text += if cls.respond_to?(meth)
133
+ cls.send(meth)
134
+ else
135
+ # Do just enough snake casing to convert PhoneNumber to phone_number
136
+ key_path = cls.to_s.split('::').last.gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase
137
+ fetch("#{key_path}.#{meth.downcase}")
138
+ end
135
139
 
136
140
  # And tack on spaces, commas, etc. left over in the string
137
- text += etc.to_s
138
- }
141
+ text + etc.to_s
142
+ end
139
143
  # If the fetched key couldn't be parsed, then fallback to numerify
140
144
  parts.any? ? parts.join : numerify(fetched)
141
145
  end
@@ -146,7 +150,7 @@ module Faker
146
150
  opts = args.last.is_a?(Hash) ? args.pop : {}
147
151
  opts[:locale] ||= Faker::Config.locale
148
152
  opts[:raise] = true
149
- I18n.translate(*(args.push(opts)))
153
+ I18n.translate(*args.push(opts))
150
154
  rescue I18n::MissingTranslationData
151
155
  opts = args.last.is_a?(Hash) ? args.pop : {}
152
156
  opts[:locale] = :en
@@ -154,7 +158,7 @@ module Faker
154
158
  # Super-simple fallback -- fallback to en if the
155
159
  # translation was missing. If the translation isn't
156
160
  # in en either, then it will raise again.
157
- I18n.translate(*(args.push(opts)))
161
+ I18n.translate(*args.push(opts))
158
162
  end
159
163
 
160
164
  # Executes block with given locale set.
@@ -175,17 +179,20 @@ module Faker
175
179
  # name:
176
180
  # girls_name: ["Alice", "Cheryl", "Tatiana"]
177
181
  # Then you can call Faker::Name.girls_name and it will act like #first_name
178
- def method_missing(m, *args, &block)
182
+ def method_missing(mth, *args, &block)
179
183
  super unless @flexible_key
180
184
 
181
- # Use the alternate form of translate to get a nil rather than a "missing translation" string
182
- if translation = translate(:faker)[@flexible_key][m]
185
+ if (translation = translate("faker.#{@flexible_key}.#{mth}"))
183
186
  sample(translation)
184
187
  else
185
188
  super
186
189
  end
187
190
  end
188
191
 
192
+ def respond_to_missing?(method_name, include_private = false)
193
+ super
194
+ end
195
+
189
196
  # Generates a random value between the interval
190
197
  def rand_in_range(from, to)
191
198
  from, to = to, from if to < from
@@ -193,7 +200,7 @@ module Faker
193
200
  end
194
201
 
195
202
  def unique(max_retries = 10_000)
196
- @unique_generator ||= UniqueGenerator.new(self, max_retries)
203
+ @unique ||= UniqueGenerator.new(self, max_retries)
197
204
  end
198
205
 
199
206
  def sample(list)
@@ -217,7 +224,7 @@ module Faker
217
224
  end
218
225
  end
219
226
 
220
- Dir.glob(File.join(File.dirname(__FILE__), 'faker','*.rb')).sort.each {|f| require f }
227
+ Dir.glob(File.join(File.dirname(__FILE__), 'faker', '*.rb')).sort.each { |f| require f }
221
228
 
222
229
  require 'extensions/array'
223
230
  require 'extensions/symbol'