activesupport 2.1.2 → 2.2.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activesupport might be problematic. Click here for more details.

Files changed (240) hide show
  1. data/CHANGELOG +64 -5
  2. data/lib/active_support.rb +6 -6
  3. data/lib/active_support/base64.rb +13 -2
  4. data/lib/active_support/basic_object.rb +1 -1
  5. data/lib/active_support/buffered_logger.rb +15 -14
  6. data/lib/active_support/cache.rb +116 -40
  7. data/lib/active_support/cache/compressed_mem_cache_store.rb +7 -2
  8. data/lib/active_support/cache/file_store.rb +7 -5
  9. data/lib/active_support/cache/mem_cache_store.rb +48 -21
  10. data/lib/active_support/cache/memory_store.rb +16 -2
  11. data/lib/active_support/cache/synchronized_memory_store.rb +47 -0
  12. data/lib/active_support/callbacks.rb +14 -9
  13. data/lib/active_support/core_ext/array/access.rb +27 -0
  14. data/lib/active_support/core_ext/array/conversions.rb +12 -7
  15. data/lib/active_support/core_ext/array/grouping.rb +53 -10
  16. data/lib/active_support/core_ext/base64/encoding.rb +3 -0
  17. data/lib/active_support/core_ext/bigdecimal/conversions.rb +18 -22
  18. data/lib/active_support/core_ext/blank.rb +5 -0
  19. data/lib/active_support/core_ext/class/inheritable_attributes.rb +5 -5
  20. data/lib/active_support/core_ext/date/behavior.rb +3 -0
  21. data/lib/active_support/core_ext/date/calculations.rb +24 -9
  22. data/lib/active_support/core_ext/date_time/calculations.rb +19 -5
  23. data/lib/active_support/core_ext/duplicable.rb +6 -0
  24. data/lib/active_support/core_ext/enumerable.rb +42 -4
  25. data/lib/active_support/core_ext/file.rb +4 -20
  26. data/lib/active_support/core_ext/file/atomic.rb +46 -0
  27. data/lib/active_support/core_ext/float.rb +2 -0
  28. data/lib/active_support/core_ext/float/time.rb +27 -0
  29. data/lib/active_support/core_ext/hash.rb +2 -1
  30. data/lib/active_support/core_ext/hash/conversions.rb +1 -1
  31. data/lib/active_support/core_ext/hash/deep_merge.rb +23 -0
  32. data/lib/active_support/core_ext/hash/except.rb +1 -1
  33. data/lib/active_support/core_ext/hash/reverse_merge.rb +12 -5
  34. data/lib/active_support/core_ext/hash/slice.rb +7 -4
  35. data/lib/active_support/core_ext/integer.rb +2 -0
  36. data/lib/active_support/core_ext/integer/time.rb +45 -0
  37. data/lib/active_support/core_ext/kernel/debugger.rb +4 -4
  38. data/lib/active_support/core_ext/logger.rb +128 -1
  39. data/lib/active_support/core_ext/module.rb +11 -1
  40. data/lib/active_support/core_ext/module/aliasing.rb +71 -67
  41. data/lib/active_support/core_ext/module/delegation.rb +32 -1
  42. data/lib/active_support/core_ext/module/introspection.rb +81 -66
  43. data/lib/active_support/core_ext/module/model_naming.rb +8 -7
  44. data/lib/active_support/core_ext/module/synchronization.rb +39 -0
  45. data/lib/active_support/core_ext/numeric/time.rb +0 -10
  46. data/lib/active_support/core_ext/object.rb +1 -0
  47. data/lib/active_support/core_ext/object/extending.rb +29 -7
  48. data/lib/active_support/core_ext/object/instance_variables.rb +1 -1
  49. data/lib/active_support/core_ext/object/metaclass.rb +13 -0
  50. data/lib/active_support/core_ext/object/misc.rb +36 -21
  51. data/lib/active_support/core_ext/rexml.rb +2 -2
  52. data/lib/active_support/core_ext/string.rb +6 -2
  53. data/lib/active_support/core_ext/string/access.rb +5 -5
  54. data/lib/active_support/core_ext/string/behavior.rb +13 -0
  55. data/lib/active_support/core_ext/string/inflections.rb +21 -2
  56. data/lib/active_support/core_ext/string/multibyte.rb +81 -0
  57. data/lib/active_support/core_ext/time/calculations.rb +39 -12
  58. data/lib/active_support/core_ext/time/conversions.rb +1 -0
  59. data/lib/active_support/core_ext/time/zones.rb +1 -1
  60. data/lib/active_support/dependencies.rb +178 -110
  61. data/lib/active_support/deprecation.rb +24 -4
  62. data/lib/active_support/inflector.rb +122 -38
  63. data/lib/active_support/json.rb +1 -1
  64. data/lib/active_support/json/encoders/date.rb +9 -2
  65. data/lib/active_support/json/encoders/date_time.rb +9 -2
  66. data/lib/active_support/json/encoders/time.rb +10 -3
  67. data/lib/active_support/locale/en.yml +32 -0
  68. data/lib/active_support/memoizable.rb +82 -0
  69. data/lib/active_support/multibyte.rb +31 -7
  70. data/lib/active_support/multibyte/chars.rb +664 -122
  71. data/lib/active_support/multibyte/exceptions.rb +8 -0
  72. data/lib/active_support/multibyte/unicode_database.rb +71 -0
  73. data/lib/active_support/option_merger.rb +2 -10
  74. data/lib/active_support/ordered_hash.rb +15 -0
  75. data/lib/active_support/rescuable.rb +108 -0
  76. data/lib/active_support/secure_random.rb +197 -0
  77. data/lib/active_support/string_inquirer.rb +11 -1
  78. data/lib/active_support/test_case.rb +16 -5
  79. data/lib/active_support/testing/core_ext/test.rb +6 -0
  80. data/lib/active_support/{core_ext → testing/core_ext}/test/unit/assertions.rb +14 -6
  81. data/lib/active_support/testing/performance.rb +452 -0
  82. data/lib/active_support/testing/setup_and_teardown.rb +34 -7
  83. data/lib/active_support/time_with_zone.rb +66 -42
  84. data/lib/active_support/values/time_zone.rb +11 -4
  85. data/lib/active_support/values/unicode_tables.dat +0 -0
  86. data/lib/active_support/vendor.rb +13 -5
  87. data/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb +1 -1
  88. data/lib/active_support/vendor/i18n-0.0.1/i18n.rb +194 -0
  89. data/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb +216 -0
  90. data/lib/active_support/vendor/i18n-0.0.1/i18n/exceptions.rb +53 -0
  91. data/lib/active_support/vendor/{memcache-client-1.5.0 → memcache-client-1.5.1}/memcache.rb +5 -5
  92. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo.rb +0 -0
  93. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/data_timezone.rb +0 -0
  94. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/data_timezone_info.rb +0 -0
  95. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Algiers.rb +0 -0
  96. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Cairo.rb +0 -0
  97. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Casablanca.rb +0 -0
  98. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Harare.rb +0 -0
  99. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Johannesburg.rb +0 -0
  100. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Monrovia.rb +0 -0
  101. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Nairobi.rb +0 -0
  102. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +0 -0
  103. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/San_Juan.rb +86 -0
  104. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Bogota.rb +0 -0
  105. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Caracas.rb +0 -0
  106. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Chicago.rb +0 -0
  107. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Chihuahua.rb +0 -0
  108. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Denver.rb +0 -0
  109. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Godthab.rb +0 -0
  110. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Guatemala.rb +0 -0
  111. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Halifax.rb +0 -0
  112. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Indiana/Indianapolis.rb +0 -0
  113. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Juneau.rb +0 -0
  114. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/La_Paz.rb +0 -0
  115. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Lima.rb +0 -0
  116. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Los_Angeles.rb +0 -0
  117. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Mazatlan.rb +0 -0
  118. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Mexico_City.rb +0 -0
  119. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Monterrey.rb +0 -0
  120. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/New_York.rb +0 -0
  121. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Phoenix.rb +0 -0
  122. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Regina.rb +0 -0
  123. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Santiago.rb +0 -0
  124. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Sao_Paulo.rb +0 -0
  125. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/St_Johns.rb +0 -0
  126. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Tijuana.rb +0 -0
  127. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Almaty.rb +0 -0
  128. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Baghdad.rb +0 -0
  129. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Baku.rb +0 -0
  130. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Bangkok.rb +0 -0
  131. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Chongqing.rb +0 -0
  132. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Colombo.rb +30 -0
  133. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Dhaka.rb +0 -0
  134. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Hong_Kong.rb +0 -0
  135. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Irkutsk.rb +0 -0
  136. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Jakarta.rb +0 -0
  137. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Jerusalem.rb +0 -0
  138. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kabul.rb +0 -0
  139. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kamchatka.rb +0 -0
  140. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Karachi.rb +0 -0
  141. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Katmandu.rb +0 -0
  142. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kolkata.rb +0 -0
  143. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Krasnoyarsk.rb +0 -0
  144. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kuala_Lumpur.rb +0 -0
  145. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kuwait.rb +0 -0
  146. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Magadan.rb +0 -0
  147. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Muscat.rb +0 -0
  148. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Novosibirsk.rb +0 -0
  149. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Rangoon.rb +0 -0
  150. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Riyadh.rb +0 -0
  151. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Seoul.rb +0 -0
  152. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Shanghai.rb +0 -0
  153. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Singapore.rb +0 -0
  154. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Taipei.rb +0 -0
  155. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Tashkent.rb +0 -0
  156. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Tbilisi.rb +0 -0
  157. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Tehran.rb +0 -0
  158. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Tokyo.rb +0 -0
  159. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Ulaanbaatar.rb +0 -0
  160. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Urumqi.rb +0 -0
  161. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Vladivostok.rb +0 -0
  162. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Yakutsk.rb +0 -0
  163. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Yekaterinburg.rb +0 -0
  164. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Yerevan.rb +0 -0
  165. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Atlantic/Azores.rb +0 -0
  166. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Atlantic/Cape_Verde.rb +0 -0
  167. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Atlantic/South_Georgia.rb +0 -0
  168. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Adelaide.rb +0 -0
  169. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Brisbane.rb +0 -0
  170. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Darwin.rb +0 -0
  171. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Hobart.rb +0 -0
  172. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Melbourne.rb +0 -0
  173. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Perth.rb +0 -0
  174. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Sydney.rb +0 -0
  175. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Etc/UTC.rb +0 -0
  176. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Amsterdam.rb +0 -0
  177. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Athens.rb +0 -0
  178. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Belgrade.rb +0 -0
  179. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Berlin.rb +0 -0
  180. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Bratislava.rb +0 -0
  181. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Brussels.rb +0 -0
  182. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Bucharest.rb +0 -0
  183. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Budapest.rb +0 -0
  184. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Copenhagen.rb +0 -0
  185. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Dublin.rb +0 -0
  186. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Helsinki.rb +0 -0
  187. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Istanbul.rb +0 -0
  188. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Kiev.rb +0 -0
  189. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Lisbon.rb +0 -0
  190. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Ljubljana.rb +0 -0
  191. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/London.rb +0 -0
  192. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Madrid.rb +0 -0
  193. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Minsk.rb +0 -0
  194. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Moscow.rb +0 -0
  195. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Paris.rb +0 -0
  196. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Prague.rb +0 -0
  197. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Riga.rb +0 -0
  198. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Rome.rb +0 -0
  199. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Sarajevo.rb +0 -0
  200. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Skopje.rb +0 -0
  201. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Sofia.rb +0 -0
  202. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Stockholm.rb +0 -0
  203. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Tallinn.rb +0 -0
  204. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Vienna.rb +0 -0
  205. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Vilnius.rb +0 -0
  206. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Warsaw.rb +0 -0
  207. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Zagreb.rb +0 -0
  208. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Auckland.rb +0 -0
  209. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Fiji.rb +0 -0
  210. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Guam.rb +0 -0
  211. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Honolulu.rb +0 -0
  212. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Majuro.rb +0 -0
  213. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Midway.rb +0 -0
  214. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Noumea.rb +0 -0
  215. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Pago_Pago.rb +0 -0
  216. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Port_Moresby.rb +0 -0
  217. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Tongatapu.rb +0 -0
  218. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/info_timezone.rb +0 -0
  219. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/linked_timezone.rb +0 -0
  220. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/linked_timezone_info.rb +0 -0
  221. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/offset_rationals.rb +0 -0
  222. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/ruby_core_support.rb +0 -0
  223. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/time_or_datetime.rb +0 -0
  224. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone.rb +0 -0
  225. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_definition.rb +0 -0
  226. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_info.rb +0 -0
  227. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_offset_info.rb +0 -0
  228. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_period.rb +0 -0
  229. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_transition_info.rb +0 -0
  230. data/lib/active_support/vendor/xml-simple-1.0.11/xmlsimple.rb +3 -3
  231. data/lib/active_support/version.rb +1 -1
  232. metadata +185 -167
  233. data/lib/active_support/clean_logger.rb +0 -127
  234. data/lib/active_support/core_ext/string/unicode.rb +0 -66
  235. data/lib/active_support/core_ext/test.rb +0 -1
  236. data/lib/active_support/multibyte/generators/generate_tables.rb +0 -149
  237. data/lib/active_support/multibyte/handlers/passthru_handler.rb +0 -9
  238. data/lib/active_support/multibyte/handlers/utf8_handler.rb +0 -564
  239. data/lib/active_support/multibyte/handlers/utf8_handler_proc.rb +0 -43
  240. data/lib/active_support/vendor/tzinfo-0.3.11/tzinfo/definitions/America/Argentina/San_Juan.rb +0 -170
@@ -6,7 +6,7 @@ require 'rexml/entity'
6
6
  # This fix is identical to rexml-expansion-fix version 1.0.1
7
7
 
8
8
  # Earlier versions of rexml defined REXML::Version, newer ones REXML::VERSION
9
- unless (defined?(REXML::VERSION) ? REXML::VERSION : REXML::Version) > "3.1.7.2"
9
+ unless REXML::Document.respond_to?(:entity_expansion_limit=)
10
10
  module REXML
11
11
  class Entity < Child
12
12
  undef_method :unnormalized
@@ -33,4 +33,4 @@ unless (defined?(REXML::VERSION) ? REXML::VERSION : REXML::Version) > "3.1.7.2"
33
33
  end
34
34
  end
35
35
  end
36
- end
36
+ end
@@ -1,11 +1,14 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'active_support/core_ext/string/inflections'
2
4
  require 'active_support/core_ext/string/conversions'
3
5
  require 'active_support/core_ext/string/access'
4
6
  require 'active_support/core_ext/string/starts_ends_with'
5
7
  require 'active_support/core_ext/string/iterators'
6
- require 'active_support/core_ext/string/unicode'
8
+ require 'active_support/core_ext/string/multibyte'
7
9
  require 'active_support/core_ext/string/xchar'
8
10
  require 'active_support/core_ext/string/filters'
11
+ require 'active_support/core_ext/string/behavior'
9
12
 
10
13
  class String #:nodoc:
11
14
  include ActiveSupport::CoreExtensions::String::Access
@@ -14,5 +17,6 @@ class String #:nodoc:
14
17
  include ActiveSupport::CoreExtensions::String::Inflections
15
18
  include ActiveSupport::CoreExtensions::String::StartsEndsWith
16
19
  include ActiveSupport::CoreExtensions::String::Iterators
17
- include ActiveSupport::CoreExtensions::String::Unicode
20
+ include ActiveSupport::CoreExtensions::String::Behavior
21
+ include ActiveSupport::CoreExtensions::String::Multibyte
18
22
  end
@@ -11,7 +11,7 @@ module ActiveSupport #:nodoc:
11
11
  # "hello".at(4) # => "o"
12
12
  # "hello".at(10) # => nil
13
13
  def at(position)
14
- chars[position, 1].to_s
14
+ mb_chars[position, 1].to_s
15
15
  end
16
16
 
17
17
  # Returns the remaining of the string from the +position+ treating the string as an array (where 0 is the first character).
@@ -21,7 +21,7 @@ module ActiveSupport #:nodoc:
21
21
  # "hello".from(2) # => "llo"
22
22
  # "hello".from(10) # => nil
23
23
  def from(position)
24
- chars[position..-1].to_s
24
+ mb_chars[position..-1].to_s
25
25
  end
26
26
 
27
27
  # Returns the beginning of the string up to the +position+ treating the string as an array (where 0 is the first character).
@@ -31,7 +31,7 @@ module ActiveSupport #:nodoc:
31
31
  # "hello".to(2) # => "hel"
32
32
  # "hello".to(10) # => "hello"
33
33
  def to(position)
34
- chars[0..position].to_s
34
+ mb_chars[0..position].to_s
35
35
  end
36
36
 
37
37
  # Returns the first character of the string or the first +limit+ characters.
@@ -41,7 +41,7 @@ module ActiveSupport #:nodoc:
41
41
  # "hello".first(2) # => "he"
42
42
  # "hello".first(10) # => "hello"
43
43
  def first(limit = 1)
44
- chars[0..(limit - 1)].to_s
44
+ mb_chars[0..(limit - 1)].to_s
45
45
  end
46
46
 
47
47
  # Returns the last character of the string or the last +limit+ characters.
@@ -51,7 +51,7 @@ module ActiveSupport #:nodoc:
51
51
  # "hello".last(2) # => "lo"
52
52
  # "hello".last(10) # => "hello"
53
53
  def last(limit = 1)
54
- (chars[(-limit)..-1] || self).to_s
54
+ (mb_chars[(-limit)..-1] || self).to_s
55
55
  end
56
56
  end
57
57
  else
@@ -0,0 +1,13 @@
1
+ module ActiveSupport #:nodoc:
2
+ module CoreExtensions #:nodoc:
3
+ module String #:nodoc:
4
+ module Behavior
5
+ # Enable more predictable duck-typing on String-like classes. See
6
+ # Object#acts_like?.
7
+ def acts_like_string?
8
+ true
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -24,8 +24,8 @@ module ActiveSupport #:nodoc:
24
24
  #
25
25
  # "posts".singularize # => "post"
26
26
  # "octopi".singularize # => "octopus"
27
- # "sheep".singluarize # => "sheep"
28
- # "word".singluarize # => "word"
27
+ # "sheep".singularize # => "sheep"
28
+ # "word".singularize # => "word"
29
29
  # "the blue mailmen".singularize # => "the blue mailman"
30
30
  # "CamelOctopi".singularize # => "CamelOctopus"
31
31
  def singularize
@@ -87,6 +87,25 @@ module ActiveSupport #:nodoc:
87
87
  Inflector.demodulize(self)
88
88
  end
89
89
 
90
+ # Replaces special characters in a string so that it may be used as part of a 'pretty' URL.
91
+ #
92
+ # ==== Examples
93
+ #
94
+ # class Person
95
+ # def to_param
96
+ # "#{id}-#{name.parameterize}"
97
+ # end
98
+ # end
99
+ #
100
+ # @person = Person.find(1)
101
+ # # => #<Person id: 1, name: "Donald E. Knuth">
102
+ #
103
+ # <%= link_to(@person.name, person_path %>
104
+ # # => <a href="/person/1-donald-e-knuth">Donald E. Knuth</a>
105
+ def parameterize
106
+ Inflector.parameterize(self)
107
+ end
108
+
90
109
  # Creates the name of a table like Rails does for models to table names. This method
91
110
  # uses the +pluralize+ method on the last word in the string.
92
111
  #
@@ -0,0 +1,81 @@
1
+ # encoding: utf-8
2
+
3
+ module ActiveSupport #:nodoc:
4
+ module CoreExtensions #:nodoc:
5
+ module String #:nodoc:
6
+ # Implements multibyte methods for easier access to multibyte characters in a String instance.
7
+ module Multibyte
8
+ unless '1.9'.respond_to?(:force_encoding)
9
+ # == Multibyte proxy
10
+ #
11
+ # +mb_chars+ is a multibyte safe proxy for string methods.
12
+ #
13
+ # In Ruby 1.8 and older it creates and returns an instance of the ActiveSupport::Multibyte::Chars class which
14
+ # encapsulates the original string. A Unicode safe version of all the String methods are defined on this proxy
15
+ # class. If the proxy class doesn't respond to a certain method, it's forwarded to the encapsuled string.
16
+ #
17
+ # name = 'Claus Müller'
18
+ # name.reverse #=> "rell??M sualC"
19
+ # name.length #=> 13
20
+ #
21
+ # name.mb_chars.reverse.to_s #=> "rellüM sualC"
22
+ # name.mb_chars.length #=> 12
23
+ #
24
+ # In Ruby 1.9 and newer +mb_chars+ returns +self+ because String is (mostly) encoding aware. This means that
25
+ # it becomes easy to run one version of your code on multiple Ruby versions.
26
+ #
27
+ # == Method chaining
28
+ #
29
+ # All the methods on the Chars proxy which normally return a string will return a Chars object. This allows
30
+ # method chaining on the result of any of these methods.
31
+ #
32
+ # name.mb_chars.reverse.length #=> 12
33
+ #
34
+ # == Interoperability and configuration
35
+ #
36
+ # The Chars object tries to be as interchangeable with String objects as possible: sorting and comparing between
37
+ # String and Char work like expected. The bang! methods change the internal string representation in the Chars
38
+ # object. Interoperability problems can be resolved easily with a +to_s+ call.
39
+ #
40
+ # For more information about the methods defined on the Chars proxy see ActiveSupport::Multibyte::Chars. For
41
+ # information about how to change the default Multibyte behaviour see ActiveSupport::Multibyte.
42
+ def mb_chars
43
+ if ActiveSupport::Multibyte.proxy_class.wants?(self)
44
+ ActiveSupport::Multibyte.proxy_class.new(self)
45
+ else
46
+ self
47
+ end
48
+ end
49
+
50
+ # Returns true if the string has UTF-8 semantics (a String used for purely byte resources is unlikely to have
51
+ # them), returns false otherwise.
52
+ def is_utf8?
53
+ ActiveSupport::Multibyte::Chars.consumes?(self)
54
+ end
55
+
56
+ unless '1.8.7 and later'.respond_to?(:chars)
57
+ def chars
58
+ ActiveSupport::Deprecation.warn('String#chars has been deprecated in favor of String#mb_chars.', caller)
59
+ mb_chars
60
+ end
61
+ end
62
+ else
63
+ def mb_chars #:nodoc
64
+ self
65
+ end
66
+
67
+ def is_utf8? #:nodoc
68
+ case encoding
69
+ when Encoding::UTF_8
70
+ valid_encoding?
71
+ when Encoding::ASCII_8BIT, Encoding::US_ASCII
72
+ dup.force_encoding(Encoding::UTF_8).valid_encoding?
73
+ else
74
+ false
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -1,3 +1,5 @@
1
+ require 'active_support/duration'
2
+
1
3
  module ActiveSupport #:nodoc:
2
4
  module CoreExtensions #:nodoc:
3
5
  module Time #:nodoc:
@@ -9,13 +11,13 @@ module ActiveSupport #:nodoc:
9
11
  base.class_eval do
10
12
  alias_method :plus_without_duration, :+
11
13
  alias_method :+, :plus_with_duration
12
-
14
+
13
15
  alias_method :minus_without_duration, :-
14
16
  alias_method :-, :minus_with_duration
15
-
17
+
16
18
  alias_method :minus_without_coercion, :-
17
19
  alias_method :-, :minus_with_coercion
18
-
20
+
19
21
  alias_method :compare_without_coercion, :<=>
20
22
  alias_method :<=>, :compare_with_coercion
21
23
  end
@@ -28,9 +30,9 @@ module ActiveSupport #:nodoc:
28
30
  def ===(other)
29
31
  other.is_a?(::Time)
30
32
  end
31
-
32
- # Return the number of days in the given month.
33
- # If no year is specified, it will use the current year.
33
+
34
+ # Return the number of days in the given month.
35
+ # If no year is specified, it will use the current year.
34
36
  def days_in_month(month, year = now.year)
35
37
  return 29 if month == 2 && ::Date.gregorian_leap?(year)
36
38
  COMMON_YEAR_DAYS_IN_MONTH[month]
@@ -57,6 +59,21 @@ module ActiveSupport #:nodoc:
57
59
  end
58
60
  end
59
61
 
62
+ # Tells whether the Time object's time lies in the past
63
+ def past?
64
+ self < ::Time.current
65
+ end
66
+
67
+ # Tells whether the Time object's time is today
68
+ def today?
69
+ self.to_date == ::Date.current
70
+ end
71
+
72
+ # Tells whether the Time object's time lies in the future
73
+ def future?
74
+ self > ::Time.current
75
+ end
76
+
60
77
  # Seconds since midnight: Time.now.seconds_since_midnight
61
78
  def seconds_since_midnight
62
79
  self.to_i - self.change(:hour => 0).to_i + (self.usec/1.0e+6)
@@ -83,6 +100,16 @@ module ActiveSupport #:nodoc:
83
100
  # <tt>:months</tt>, <tt>:weeks</tt>, <tt>:days</tt>, <tt>:hours</tt>,
84
101
  # <tt>:minutes</tt>, <tt>:seconds</tt>.
85
102
  def advance(options)
103
+ unless options[:weeks].nil?
104
+ options[:weeks], partial_weeks = options[:weeks].divmod(1)
105
+ options[:days] = (options[:days] || 0) + 7 * partial_weeks
106
+ end
107
+
108
+ unless options[:days].nil?
109
+ options[:days], partial_days = options[:days].divmod(1)
110
+ options[:hours] = (options[:hours] || 0) + 24 * partial_days
111
+ end
112
+
86
113
  d = to_date.advance(options)
87
114
  time_advanced_by_date = change(:year => d.year, :month => d.month, :day => d.day)
88
115
  seconds_to_advance = (options[:seconds] || 0) + (options[:minutes] || 0) * 60 + (options[:hours] || 0) * 3600
@@ -106,7 +133,7 @@ module ActiveSupport #:nodoc:
106
133
  (seconds.abs >= 86400 && initial_dst != final_dst) ? f + (initial_dst - final_dst).hours : f
107
134
  end
108
135
  rescue
109
- self.to_datetime.since(seconds)
136
+ self.to_datetime.since(seconds)
110
137
  end
111
138
  alias :in :since
112
139
 
@@ -199,7 +226,7 @@ module ActiveSupport #:nodoc:
199
226
  change(:day => last_day, :hour => 23, :min => 59, :sec => 59, :usec => 0)
200
227
  end
201
228
  alias :at_end_of_month :end_of_month
202
-
229
+
203
230
  # Returns a new Time representing the start of the quarter (1st of january, april, july, october, 0:00)
204
231
  def beginning_of_quarter
205
232
  beginning_of_month.change(:month => [10, 7, 4, 1].detect { |m| m <= self.month })
@@ -208,7 +235,7 @@ module ActiveSupport #:nodoc:
208
235
 
209
236
  # Returns a new Time representing the end of the quarter (last day of march, june, september, december, 23:59:59)
210
237
  def end_of_quarter
211
- change(:month => [3, 6, 9, 12].detect { |m| m >= self.month }).end_of_month
238
+ beginning_of_month.change(:month => [3, 6, 9, 12].detect { |m| m >= self.month }).end_of_month
212
239
  end
213
240
  alias :at_end_of_quarter :end_of_quarter
214
241
 
@@ -249,7 +276,7 @@ module ActiveSupport #:nodoc:
249
276
  minus_without_duration(other)
250
277
  end
251
278
  end
252
-
279
+
253
280
  # Time#- can also be used to determine the number of seconds between two Time instances.
254
281
  # We're layering on additional behavior so that ActiveSupport::TimeWithZone instances
255
282
  # are coerced into values that Time#- will recognize
@@ -257,11 +284,11 @@ module ActiveSupport #:nodoc:
257
284
  other = other.comparable_time if other.respond_to?(:comparable_time)
258
285
  minus_without_coercion(other)
259
286
  end
260
-
287
+
261
288
  # Layers additional behavior on Time#<=> so that DateTime and ActiveSupport::TimeWithZone instances
262
289
  # can be chronologically compared with a Time
263
290
  def compare_with_coercion(other)
264
- # if other is an ActiveSupport::TimeWithZone, coerce a Time instance from it so we can do <=> comparision
291
+ # if other is an ActiveSupport::TimeWithZone, coerce a Time instance from it so we can do <=> comparison
265
292
  other = other.comparable_time if other.respond_to?(:comparable_time)
266
293
  if other.acts_like?(:date)
267
294
  # other is a Date/DateTime, so coerce self #to_datetime and hand off to DateTime#<=>
@@ -30,6 +30,7 @@ module ActiveSupport #:nodoc:
30
30
  # time.to_s(:time) # => "06:10:17"
31
31
  #
32
32
  # time.to_formatted_s(:db) # => "2007-01-18 06:10:17"
33
+ # time.to_formatted_s(:number) # => "20070118061017"
33
34
  # time.to_formatted_s(:short) # => "18 Jan 06:10"
34
35
  # time.to_formatted_s(:long) # => "January 18, 2007 06:10"
35
36
  # time.to_formatted_s(:long_ordinal) # => "January 18th, 2007 06:10"
@@ -78,7 +78,7 @@ module ActiveSupport #:nodoc:
78
78
  #
79
79
  # Time.utc(2000).in_time_zone('Alaska') # => Fri, 31 Dec 1999 15:00:00 AKST -09:00
80
80
  def in_time_zone(zone = ::Time.zone)
81
- ActiveSupport::TimeWithZone.new(utc? ? self : getutc, ::Time.send!(:get_zone, zone))
81
+ ActiveSupport::TimeWithZone.new(utc? ? self : getutc, ::Time.__send__(:get_zone, zone))
82
82
  end
83
83
  end
84
84
  end
@@ -1,8 +1,3 @@
1
- require 'set'
2
- require 'active_support/core_ext/module/attribute_accessors'
3
- require 'active_support/core_ext/load_error'
4
- require 'active_support/core_ext/kernel'
5
-
6
1
  module ActiveSupport #:nodoc:
7
2
  module Dependencies #:nodoc:
8
3
  extend self
@@ -44,6 +39,10 @@ module ActiveSupport #:nodoc:
44
39
  mattr_accessor :explicitly_unloadable_constants
45
40
  self.explicitly_unloadable_constants = []
46
41
 
42
+ # The logger is used for generating information on the action run-time (including benchmarking) if available.
43
+ # Can be set to nil for no logging. Compatible with both Ruby's own Logger and Log4r loggers.
44
+ mattr_accessor :logger
45
+
47
46
  # Set to true to enable logging of const_missing and file loads
48
47
  mattr_accessor :log_activity
49
48
  self.log_activity = false
@@ -52,6 +51,167 @@ module ActiveSupport #:nodoc:
52
51
  mattr_accessor :constant_watch_stack
53
52
  self.constant_watch_stack = []
54
53
 
54
+ # Module includes this module
55
+ module ModuleConstMissing #:nodoc:
56
+ def self.included(base) #:nodoc:
57
+ base.class_eval do
58
+ unless defined? const_missing_without_dependencies
59
+ alias_method_chain :const_missing, :dependencies
60
+ end
61
+ end
62
+ end
63
+
64
+ def self.excluded(base) #:nodoc:
65
+ base.class_eval do
66
+ if defined? const_missing_without_dependencies
67
+ undef_method :const_missing
68
+ alias_method :const_missing, :const_missing_without_dependencies
69
+ undef_method :const_missing_without_dependencies
70
+ end
71
+ end
72
+ end
73
+
74
+ # Use const_missing to autoload associations so we don't have to
75
+ # require_association when using single-table inheritance.
76
+ def const_missing_with_dependencies(class_id)
77
+ ActiveSupport::Dependencies.load_missing_constant self, class_id
78
+ end
79
+
80
+ def unloadable(const_desc = self)
81
+ super(const_desc)
82
+ end
83
+ end
84
+
85
+ # Class includes this module
86
+ module ClassConstMissing #:nodoc:
87
+ def const_missing(const_name)
88
+ if [Object, Kernel].include?(self) || parent == self
89
+ super
90
+ else
91
+ begin
92
+ begin
93
+ Dependencies.load_missing_constant self, const_name
94
+ rescue NameError
95
+ parent.send :const_missing, const_name
96
+ end
97
+ rescue NameError => e
98
+ # Make sure that the name we are missing is the one that caused the error
99
+ parent_qualified_name = Dependencies.qualified_name_for parent, const_name
100
+ raise unless e.missing_name? parent_qualified_name
101
+ qualified_name = Dependencies.qualified_name_for self, const_name
102
+ raise NameError.new("uninitialized constant #{qualified_name}").copy_blame!(e)
103
+ end
104
+ end
105
+ end
106
+ end
107
+
108
+ # Object includes this module
109
+ module Loadable #:nodoc:
110
+ def self.included(base) #:nodoc:
111
+ base.class_eval do
112
+ unless defined? load_without_new_constant_marking
113
+ alias_method_chain :load, :new_constant_marking
114
+ end
115
+ end
116
+ end
117
+
118
+ def self.excluded(base) #:nodoc:
119
+ base.class_eval do
120
+ if defined? load_without_new_constant_marking
121
+ undef_method :load
122
+ alias_method :load, :load_without_new_constant_marking
123
+ undef_method :load_without_new_constant_marking
124
+ end
125
+ end
126
+ end
127
+
128
+ def require_or_load(file_name)
129
+ Dependencies.require_or_load(file_name)
130
+ end
131
+
132
+ def require_dependency(file_name)
133
+ Dependencies.depend_on(file_name)
134
+ end
135
+
136
+ def require_association(file_name)
137
+ Dependencies.associate_with(file_name)
138
+ end
139
+
140
+ def load_with_new_constant_marking(file, *extras) #:nodoc:
141
+ if Dependencies.load?
142
+ Dependencies.new_constants_in(Object) { load_without_new_constant_marking(file, *extras) }
143
+ else
144
+ load_without_new_constant_marking(file, *extras)
145
+ end
146
+ rescue Exception => exception # errors from loading file
147
+ exception.blame_file! file
148
+ raise
149
+ end
150
+
151
+ def require(file, *extras) #:nodoc:
152
+ if Dependencies.load?
153
+ Dependencies.new_constants_in(Object) { super }
154
+ else
155
+ super
156
+ end
157
+ rescue Exception => exception # errors from required file
158
+ exception.blame_file! file
159
+ raise
160
+ end
161
+
162
+ # Mark the given constant as unloadable. Unloadable constants are removed each
163
+ # time dependencies are cleared.
164
+ #
165
+ # Note that marking a constant for unloading need only be done once. Setup
166
+ # or init scripts may list each unloadable constant that may need unloading;
167
+ # each constant will be removed for every subsequent clear, as opposed to for
168
+ # the first clear.
169
+ #
170
+ # The provided constant descriptor may be a (non-anonymous) module or class,
171
+ # or a qualified constant name as a string or symbol.
172
+ #
173
+ # Returns true if the constant was not previously marked for unloading, false
174
+ # otherwise.
175
+ def unloadable(const_desc)
176
+ Dependencies.mark_for_unload const_desc
177
+ end
178
+ end
179
+
180
+ # Exception file-blaming
181
+ module Blamable #:nodoc:
182
+ def blame_file!(file)
183
+ (@blamed_files ||= []).unshift file
184
+ end
185
+
186
+ def blamed_files
187
+ @blamed_files ||= []
188
+ end
189
+
190
+ def describe_blame
191
+ return nil if blamed_files.empty?
192
+ "This error occurred while loading the following files:\n #{blamed_files.join "\n "}"
193
+ end
194
+
195
+ def copy_blame!(exc)
196
+ @blamed_files = exc.blamed_files.clone
197
+ self
198
+ end
199
+ end
200
+
201
+ def hook!
202
+ Object.instance_eval { include Loadable }
203
+ Module.instance_eval { include ModuleConstMissing }
204
+ Class.instance_eval { include ClassConstMissing }
205
+ Exception.instance_eval { include Blamable }
206
+ true
207
+ end
208
+
209
+ def unhook!
210
+ ModuleConstMissing.excluded(Module)
211
+ Loadable.excluded(Object)
212
+ true
213
+ end
214
+
55
215
  def load?
56
216
  mechanism == :load
57
217
  end
@@ -153,6 +313,12 @@ module ActiveSupport #:nodoc:
153
313
  nesting = expanded_path[(expanded_root.size)..-1]
154
314
  nesting = nesting[1..-1] if nesting && nesting[0] == ?/
155
315
  next if nesting.blank?
316
+ nesting_camel = nesting.camelize
317
+ begin
318
+ qualified_const_defined?(nesting_camel)
319
+ rescue NameError
320
+ next
321
+ end
156
322
 
157
323
  [
158
324
  nesting.camelize,
@@ -339,7 +505,7 @@ module ActiveSupport #:nodoc:
339
505
  initial_constants = if qualified_const_defined?(mod_name)
340
506
  mod_name.constantize.local_constant_names
341
507
  else
342
- []
508
+ []
343
509
  end
344
510
  else
345
511
  raise Argument, "#{desc.inspect} does not describe a module!"
@@ -387,7 +553,7 @@ module ActiveSupport #:nodoc:
387
553
  ensure
388
554
  # Remove the stack frames that we added.
389
555
  if defined?(watch_frames) && ! watch_frames.blank?
390
- frame_ids = watch_frames.collect(&:object_id)
556
+ frame_ids = watch_frames.collect { |frame| frame.object_id }
391
557
  constant_watch_stack.delete_if do |watch_frame|
392
558
  frame_ids.include? watch_frame.object_id
393
559
  end
@@ -436,8 +602,8 @@ module ActiveSupport #:nodoc:
436
602
 
437
603
  protected
438
604
  def log_call(*args)
439
- if defined?(RAILS_DEFAULT_LOGGER) && RAILS_DEFAULT_LOGGER && log_activity
440
- arg_str = args.collect(&:inspect) * ', '
605
+ if logger && log_activity
606
+ arg_str = args.collect { |arg| arg.inspect } * ', '
441
607
  /in `([a-z_\?\!]+)'/ =~ caller(1).first
442
608
  selector = $1 || '<unknown>'
443
609
  log "called #{selector}(#{arg_str})"
@@ -445,109 +611,11 @@ module ActiveSupport #:nodoc:
445
611
  end
446
612
 
447
613
  def log(msg)
448
- if defined?(RAILS_DEFAULT_LOGGER) && RAILS_DEFAULT_LOGGER && log_activity
449
- RAILS_DEFAULT_LOGGER.debug "Dependencies: #{msg}"
614
+ if logger && log_activity
615
+ logger.debug "Dependencies: #{msg}"
450
616
  end
451
617
  end
452
618
  end
453
619
  end
454
620
 
455
- Object.instance_eval do
456
- define_method(:require_or_load) { |file_name| ActiveSupport::Dependencies.require_or_load(file_name) } unless Object.respond_to?(:require_or_load)
457
- define_method(:require_dependency) { |file_name| ActiveSupport::Dependencies.depend_on(file_name) } unless Object.respond_to?(:require_dependency)
458
- define_method(:require_association) { |file_name| ActiveSupport::Dependencies.associate_with(file_name) } unless Object.respond_to?(:require_association)
459
- end
460
-
461
- class Module #:nodoc:
462
- # Rename the original handler so we can chain it to the new one
463
- alias :rails_original_const_missing :const_missing
464
-
465
- # Use const_missing to autoload associations so we don't have to
466
- # require_association when using single-table inheritance.
467
- def const_missing(class_id)
468
- ActiveSupport::Dependencies.load_missing_constant self, class_id
469
- end
470
-
471
- def unloadable(const_desc = self)
472
- super(const_desc)
473
- end
474
-
475
- end
476
-
477
- class Class
478
- def const_missing(const_name)
479
- if [Object, Kernel].include?(self) || parent == self
480
- super
481
- else
482
- begin
483
- begin
484
- ActiveSupport::Dependencies.load_missing_constant self, const_name
485
- rescue NameError
486
- parent.send :const_missing, const_name
487
- end
488
- rescue NameError => e
489
- # Make sure that the name we are missing is the one that caused the error
490
- parent_qualified_name = ActiveSupport::Dependencies.qualified_name_for parent, const_name
491
- raise unless e.missing_name? parent_qualified_name
492
- qualified_name = ActiveSupport::Dependencies.qualified_name_for self, const_name
493
- raise NameError.new("uninitialized constant #{qualified_name}").copy_blame!(e)
494
- end
495
- end
496
- end
497
- end
498
-
499
- class Object
500
- alias_method :load_without_new_constant_marking, :load
501
-
502
- def load(file, *extras) #:nodoc:
503
- ActiveSupport::Dependencies.new_constants_in(Object) { super }
504
- rescue Exception => exception # errors from loading file
505
- exception.blame_file! file
506
- raise
507
- end
508
-
509
- def require(file, *extras) #:nodoc:
510
- ActiveSupport::Dependencies.new_constants_in(Object) { super }
511
- rescue Exception => exception # errors from required file
512
- exception.blame_file! file
513
- raise
514
- end
515
-
516
- # Mark the given constant as unloadable. Unloadable constants are removed each
517
- # time dependencies are cleared.
518
- #
519
- # Note that marking a constant for unloading need only be done once. Setup
520
- # or init scripts may list each unloadable constant that may need unloading;
521
- # each constant will be removed for every subsequent clear, as opposed to for
522
- # the first clear.
523
- #
524
- # The provided constant descriptor may be a (non-anonymous) module or class,
525
- # or a qualified constant name as a string or symbol.
526
- #
527
- # Returns true if the constant was not previously marked for unloading, false
528
- # otherwise.
529
- def unloadable(const_desc)
530
- ActiveSupport::Dependencies.mark_for_unload const_desc
531
- end
532
- end
533
-
534
- # Add file-blaming to exceptions
535
- class Exception #:nodoc:
536
- def blame_file!(file)
537
- (@blamed_files ||= []).unshift file
538
- end
539
-
540
- def blamed_files
541
- @blamed_files ||= []
542
- end
543
-
544
- def describe_blame
545
- return nil if blamed_files.empty?
546
- "This error occurred while loading the following files:\n #{blamed_files.join "\n "}"
547
- end
548
-
549
- def copy_blame!(exc)
550
- @blamed_files = exc.blamed_files.clone
551
- self
552
- end
553
- end
621
+ ActiveSupport::Dependencies.hook!