activesupport 3.0.0.beta4 → 3.0.pre

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 (333) hide show
  1. data/CHANGELOG +1 -100
  2. data/lib/active_support.rb +4 -38
  3. data/lib/active_support/autoload.rb +28 -0
  4. data/lib/active_support/backtrace_cleaner.rb +9 -31
  5. data/lib/active_support/benchmarkable.rb +0 -1
  6. data/lib/active_support/buffered_logger.rb +1 -0
  7. data/lib/active_support/cache.rb +81 -436
  8. data/lib/active_support/cache/compressed_mem_cache_store.rb +13 -6
  9. data/lib/active_support/cache/file_store.rb +41 -139
  10. data/lib/active_support/cache/mem_cache_store.rb +75 -120
  11. data/lib/active_support/cache/memory_store.rb +27 -127
  12. data/lib/active_support/cache/strategy/local_cache.rb +58 -111
  13. data/lib/active_support/cache/synchronized_memory_store.rb +38 -2
  14. data/lib/active_support/callbacks.rb +48 -87
  15. data/lib/active_support/configurable.rb +18 -19
  16. data/lib/active_support/core_ext/array.rb +0 -1
  17. data/lib/active_support/core_ext/array/access.rb +1 -1
  18. data/lib/active_support/core_ext/array/conversions.rb +54 -29
  19. data/lib/active_support/core_ext/array/extract_options.rb +1 -16
  20. data/lib/active_support/core_ext/array/random_access.rb +5 -19
  21. data/lib/active_support/core_ext/array/wrap.rb +9 -13
  22. data/lib/active_support/core_ext/benchmark.rb +12 -0
  23. data/lib/active_support/core_ext/boolean.rb +1 -0
  24. data/lib/active_support/core_ext/boolean/conversions.rb +11 -0
  25. data/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +0 -2
  26. data/lib/active_support/core_ext/class.rb +1 -1
  27. data/lib/active_support/core_ext/class/attribute_accessors.rb +27 -33
  28. data/lib/active_support/core_ext/class/delegating_attributes.rb +41 -35
  29. data/lib/active_support/core_ext/class/inheritable_attributes.rb +13 -22
  30. data/lib/active_support/core_ext/class/removal.rb +53 -0
  31. data/lib/active_support/core_ext/date.rb +7 -0
  32. data/lib/active_support/core_ext/date/calculations.rb +8 -30
  33. data/lib/active_support/core_ext/date/conversions.rb +2 -2
  34. data/lib/active_support/core_ext/date_time.rb +5 -0
  35. data/lib/active_support/core_ext/date_time/calculations.rb +1 -2
  36. data/lib/active_support/core_ext/date_time/conversions.rb +5 -23
  37. data/lib/active_support/core_ext/enumerable.rb +9 -5
  38. data/lib/active_support/core_ext/exception.rb +47 -0
  39. data/lib/active_support/core_ext/file.rb +0 -1
  40. data/lib/active_support/core_ext/file/atomic.rb +2 -3
  41. data/lib/active_support/core_ext/float/rounding.rb +2 -3
  42. data/lib/active_support/core_ext/hash/conversions.rb +145 -65
  43. data/lib/active_support/core_ext/hash/deep_merge.rb +7 -6
  44. data/lib/active_support/core_ext/hash/except.rb +0 -8
  45. data/lib/active_support/core_ext/hash/indifferent_access.rb +0 -5
  46. data/lib/active_support/core_ext/hash/keys.rb +11 -10
  47. data/lib/active_support/core_ext/hash/slice.rb +0 -6
  48. data/lib/active_support/core_ext/integer.rb +1 -1
  49. data/lib/active_support/core_ext/integer/even_odd.rb +16 -0
  50. data/lib/active_support/core_ext/kernel.rb +1 -1
  51. data/lib/active_support/core_ext/kernel/daemonizing.rb +7 -0
  52. data/lib/active_support/core_ext/kernel/debugger.rb +2 -3
  53. data/lib/active_support/core_ext/kernel/reporting.rb +1 -2
  54. data/lib/active_support/core_ext/load_error.rb +30 -17
  55. data/lib/active_support/core_ext/logger.rb +1 -1
  56. data/lib/active_support/core_ext/module.rb +3 -5
  57. data/lib/active_support/core_ext/module/aliasing.rb +1 -1
  58. data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +1 -1
  59. data/lib/active_support/core_ext/module/attr_internal.rb +2 -2
  60. data/lib/active_support/core_ext/module/attribute_accessors.rb +21 -25
  61. data/lib/active_support/core_ext/module/delegation.rb +10 -21
  62. data/lib/active_support/core_ext/module/inclusion.rb +30 -0
  63. data/lib/active_support/core_ext/module/introspection.rb +8 -8
  64. data/lib/active_support/core_ext/module/loading.rb +23 -0
  65. data/lib/active_support/core_ext/module/synchronization.rb +1 -2
  66. data/lib/active_support/core_ext/name_error.rb +1 -3
  67. data/lib/active_support/core_ext/nil.rb +1 -0
  68. data/lib/active_support/core_ext/nil/conversions.rb +5 -0
  69. data/lib/active_support/core_ext/object.rb +2 -6
  70. data/lib/active_support/core_ext/object/blank.rb +2 -20
  71. data/lib/active_support/core_ext/object/conversions.rb +16 -2
  72. data/lib/active_support/core_ext/object/duplicable.rb +1 -23
  73. data/lib/active_support/core_ext/object/extending.rb +77 -8
  74. data/lib/active_support/core_ext/object/instance_variables.rb +7 -0
  75. data/lib/active_support/core_ext/object/metaclass.rb +13 -0
  76. data/lib/active_support/core_ext/object/misc.rb +1 -0
  77. data/lib/active_support/core_ext/object/tap.rb +16 -0
  78. data/lib/active_support/core_ext/object/with_options.rb +0 -2
  79. data/lib/active_support/core_ext/proc.rb +4 -4
  80. data/lib/active_support/core_ext/regexp.rb +22 -0
  81. data/lib/active_support/core_ext/rexml.rb +1 -4
  82. data/lib/active_support/core_ext/string.rb +2 -3
  83. data/lib/active_support/core_ext/string/access.rb +2 -4
  84. data/lib/active_support/core_ext/string/bytesize.rb +5 -0
  85. data/lib/active_support/core_ext/string/conversions.rb +1 -36
  86. data/lib/active_support/core_ext/string/filters.rb +0 -29
  87. data/lib/active_support/core_ext/string/inflections.rb +12 -1
  88. data/lib/active_support/core_ext/string/interpolation.rb +92 -2
  89. data/lib/active_support/core_ext/string/iterators.rb +13 -0
  90. data/lib/active_support/core_ext/string/multibyte.rb +19 -16
  91. data/lib/active_support/core_ext/string/output_safety.rb +35 -101
  92. data/lib/active_support/core_ext/string/starts_ends_with.rb +14 -0
  93. data/lib/active_support/core_ext/string/xchar.rb +1 -1
  94. data/lib/active_support/core_ext/symbol.rb +1 -0
  95. data/lib/active_support/core_ext/symbol/to_proc.rb +14 -0
  96. data/lib/active_support/core_ext/time.rb +10 -0
  97. data/lib/active_support/core_ext/time/calculations.rb +7 -9
  98. data/lib/active_support/core_ext/time/conversions.rb +0 -1
  99. data/lib/active_support/core_ext/time/marshal_with_utc_flag.rb +22 -0
  100. data/lib/active_support/core_ext/uri.rb +4 -10
  101. data/lib/active_support/dependencies.rb +192 -179
  102. data/lib/active_support/deprecated_callbacks.rb +283 -0
  103. data/lib/active_support/deprecation/behaviors.rb +1 -1
  104. data/lib/active_support/deprecation/method_wrappers.rb +9 -10
  105. data/lib/active_support/deprecation/reporting.rb +1 -2
  106. data/lib/active_support/duration.rb +2 -6
  107. data/lib/active_support/hash_with_indifferent_access.rb +1 -9
  108. data/lib/active_support/inflections.rb +1 -1
  109. data/lib/active_support/inflector.rb +407 -4
  110. data/lib/active_support/json/backends/jsongem.rb +9 -12
  111. data/lib/active_support/json/decoding.rb +1 -16
  112. data/lib/active_support/json/encoding.rb +12 -42
  113. data/lib/active_support/locale/en.yml +1 -4
  114. data/lib/active_support/memoizable.rb +1 -1
  115. data/lib/active_support/message_encryptor.rb +0 -1
  116. data/lib/active_support/message_verifier.rb +5 -6
  117. data/lib/active_support/multibyte.rb +22 -7
  118. data/lib/active_support/multibyte/chars.rb +392 -164
  119. data/lib/active_support/multibyte/unicode_database.rb +71 -0
  120. data/lib/active_support/multibyte/utils.rb +7 -6
  121. data/lib/active_support/notifications.rb +113 -23
  122. data/lib/active_support/ordered_hash.rb +11 -35
  123. data/lib/active_support/ordered_options.rb +0 -6
  124. data/lib/active_support/rescuable.rb +4 -7
  125. data/lib/active_support/ruby/shim.rb +6 -4
  126. data/lib/active_support/test_case.rb +7 -2
  127. data/lib/active_support/testing/assertions.rb +0 -15
  128. data/lib/active_support/testing/declarative.rb +1 -1
  129. data/lib/active_support/testing/isolation.rb +19 -63
  130. data/lib/active_support/testing/performance.rb +337 -342
  131. data/lib/active_support/testing/setup_and_teardown.rb +29 -51
  132. data/lib/active_support/time.rb +3 -23
  133. data/lib/active_support/time_with_zone.rb +10 -5
  134. data/lib/active_support/values/time_zone.rb +84 -40
  135. data/lib/active_support/values/unicode_tables.dat +0 -0
  136. data/lib/active_support/vendor.rb +16 -0
  137. data/lib/active_support/vendor/builder-2.1.2/lib/blankslate.rb +113 -0
  138. data/lib/active_support/vendor/builder-2.1.2/lib/builder.rb +13 -0
  139. data/lib/active_support/vendor/builder-2.1.2/lib/builder/blankslate.rb +20 -0
  140. data/lib/active_support/vendor/builder-2.1.2/lib/builder/css.rb +250 -0
  141. data/lib/active_support/vendor/builder-2.1.2/lib/builder/xchar.rb +115 -0
  142. data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlbase.rb +139 -0
  143. data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlevents.rb +63 -0
  144. data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlmarkup.rb +328 -0
  145. data/lib/active_support/vendor/i18n-0.1.3/MIT-LICENSE +20 -0
  146. data/lib/active_support/vendor/i18n-0.1.3/README.textile +20 -0
  147. data/lib/active_support/vendor/i18n-0.1.3/Rakefile +5 -0
  148. data/lib/active_support/vendor/i18n-0.1.3/i18n.gemspec +27 -0
  149. data/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb +204 -0
  150. data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb +215 -0
  151. data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/exceptions.rb +53 -0
  152. data/lib/active_support/vendor/i18n-0.1.3/test/all.rb +5 -0
  153. data/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb +99 -0
  154. data/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb +124 -0
  155. data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.rb +1 -0
  156. data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.yml +3 -0
  157. data/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb +567 -0
  158. data/lib/active_support/vendor/memcache-client-1.7.5/lib/memcache.rb +1133 -0
  159. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo.rb +33 -0
  160. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/data_timezone.rb +47 -0
  161. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/data_timezone_info.rb +228 -0
  162. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Algiers.rb +55 -0
  163. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Cairo.rb +219 -0
  164. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Casablanca.rb +42 -0
  165. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Harare.rb +18 -0
  166. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Johannesburg.rb +25 -0
  167. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Monrovia.rb +22 -0
  168. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Nairobi.rb +23 -0
  169. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +166 -0
  170. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Argentina/San_Juan.rb +86 -0
  171. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Bogota.rb +23 -0
  172. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Caracas.rb +23 -0
  173. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Chicago.rb +283 -0
  174. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Chihuahua.rb +136 -0
  175. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Denver.rb +204 -0
  176. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Godthab.rb +161 -0
  177. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Guatemala.rb +27 -0
  178. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Halifax.rb +274 -0
  179. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Indiana/Indianapolis.rb +149 -0
  180. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Juneau.rb +194 -0
  181. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/La_Paz.rb +22 -0
  182. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Lima.rb +35 -0
  183. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Los_Angeles.rb +232 -0
  184. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Mazatlan.rb +139 -0
  185. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Mexico_City.rb +144 -0
  186. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Monterrey.rb +131 -0
  187. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/New_York.rb +282 -0
  188. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Phoenix.rb +30 -0
  189. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Regina.rb +74 -0
  190. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Santiago.rb +205 -0
  191. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Sao_Paulo.rb +171 -0
  192. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/St_Johns.rb +288 -0
  193. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Tijuana.rb +196 -0
  194. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Almaty.rb +67 -0
  195. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Baghdad.rb +73 -0
  196. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Baku.rb +161 -0
  197. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Bangkok.rb +20 -0
  198. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Chongqing.rb +33 -0
  199. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Colombo.rb +30 -0
  200. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Dhaka.rb +27 -0
  201. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Hong_Kong.rb +87 -0
  202. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Irkutsk.rb +165 -0
  203. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Jakarta.rb +30 -0
  204. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Jerusalem.rb +163 -0
  205. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kabul.rb +20 -0
  206. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kamchatka.rb +163 -0
  207. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Karachi.rb +32 -0
  208. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kathmandu.rb +20 -0
  209. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kolkata.rb +25 -0
  210. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Krasnoyarsk.rb +163 -0
  211. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kuala_Lumpur.rb +31 -0
  212. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kuwait.rb +18 -0
  213. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Magadan.rb +163 -0
  214. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Muscat.rb +18 -0
  215. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Novosibirsk.rb +164 -0
  216. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Rangoon.rb +24 -0
  217. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Riyadh.rb +18 -0
  218. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Seoul.rb +34 -0
  219. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Shanghai.rb +35 -0
  220. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Singapore.rb +33 -0
  221. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Taipei.rb +59 -0
  222. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tashkent.rb +47 -0
  223. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tbilisi.rb +78 -0
  224. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tehran.rb +121 -0
  225. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tokyo.rb +30 -0
  226. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Ulaanbaatar.rb +65 -0
  227. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Urumqi.rb +33 -0
  228. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Vladivostok.rb +164 -0
  229. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yakutsk.rb +163 -0
  230. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yekaterinburg.rb +165 -0
  231. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yerevan.rb +165 -0
  232. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/Azores.rb +270 -0
  233. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/Cape_Verde.rb +23 -0
  234. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/South_Georgia.rb +18 -0
  235. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Adelaide.rb +187 -0
  236. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Brisbane.rb +35 -0
  237. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Darwin.rb +29 -0
  238. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Hobart.rb +193 -0
  239. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Melbourne.rb +185 -0
  240. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Perth.rb +37 -0
  241. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Sydney.rb +185 -0
  242. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Etc/UTC.rb +16 -0
  243. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Amsterdam.rb +228 -0
  244. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Athens.rb +185 -0
  245. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Belgrade.rb +163 -0
  246. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Berlin.rb +188 -0
  247. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Bratislava.rb +13 -0
  248. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Brussels.rb +232 -0
  249. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Bucharest.rb +181 -0
  250. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Budapest.rb +197 -0
  251. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Copenhagen.rb +179 -0
  252. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Dublin.rb +276 -0
  253. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Helsinki.rb +163 -0
  254. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Istanbul.rb +218 -0
  255. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Kiev.rb +168 -0
  256. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Lisbon.rb +268 -0
  257. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Ljubljana.rb +13 -0
  258. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/London.rb +288 -0
  259. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Madrid.rb +211 -0
  260. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Minsk.rb +170 -0
  261. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Moscow.rb +181 -0
  262. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Paris.rb +232 -0
  263. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Prague.rb +187 -0
  264. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Riga.rb +176 -0
  265. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Rome.rb +215 -0
  266. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Sarajevo.rb +13 -0
  267. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Skopje.rb +13 -0
  268. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Sofia.rb +173 -0
  269. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Stockholm.rb +165 -0
  270. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Tallinn.rb +172 -0
  271. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Vienna.rb +183 -0
  272. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Vilnius.rb +170 -0
  273. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Warsaw.rb +212 -0
  274. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Zagreb.rb +13 -0
  275. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Auckland.rb +202 -0
  276. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Fiji.rb +23 -0
  277. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Guam.rb +22 -0
  278. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Honolulu.rb +28 -0
  279. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Majuro.rb +20 -0
  280. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Midway.rb +25 -0
  281. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Noumea.rb +25 -0
  282. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Pago_Pago.rb +26 -0
  283. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Port_Moresby.rb +20 -0
  284. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Tongatapu.rb +27 -0
  285. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/info_timezone.rb +52 -0
  286. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/linked_timezone.rb +51 -0
  287. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/linked_timezone_info.rb +44 -0
  288. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/offset_rationals.rb +98 -0
  289. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/ruby_core_support.rb +56 -0
  290. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/time_or_datetime.rb +292 -0
  291. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone.rb +508 -0
  292. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_definition.rb +56 -0
  293. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_info.rb +40 -0
  294. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_offset_info.rb +94 -0
  295. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_period.rb +198 -0
  296. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_transition_info.rb +129 -0
  297. data/lib/active_support/version.rb +2 -3
  298. data/lib/active_support/whiny_nil.rb +7 -9
  299. data/lib/active_support/xml_mini.rb +1 -126
  300. data/lib/active_support/xml_mini/jdom.rb +0 -2
  301. data/lib/active_support/xml_mini/libxml.rb +86 -24
  302. data/lib/active_support/xml_mini/nokogiri.rb +24 -27
  303. data/lib/active_support/xml_mini/rexml.rb +1 -7
  304. metadata +191 -49
  305. data/lib/active_support/builder.rb +0 -6
  306. data/lib/active_support/core_ext/array/uniq_by.rb +0 -17
  307. data/lib/active_support/core_ext/class/attribute.rb +0 -67
  308. data/lib/active_support/core_ext/class/subclasses.rb +0 -55
  309. data/lib/active_support/core_ext/file/path.rb +0 -5
  310. data/lib/active_support/core_ext/integer/multiple.rb +0 -6
  311. data/lib/active_support/core_ext/kernel/singleton_class.rb +0 -13
  312. data/lib/active_support/core_ext/module/anonymous.rb +0 -24
  313. data/lib/active_support/core_ext/module/method_names.rb +0 -14
  314. data/lib/active_support/core_ext/module/reachable.rb +0 -10
  315. data/lib/active_support/core_ext/module/remove_method.rb +0 -6
  316. data/lib/active_support/core_ext/object/to_param.rb +0 -49
  317. data/lib/active_support/core_ext/object/to_query.rb +0 -27
  318. data/lib/active_support/core_ext/string/encoding.rb +0 -11
  319. data/lib/active_support/core_ext/string/exclude.rb +0 -6
  320. data/lib/active_support/core_ext/time/marshal.rb +0 -56
  321. data/lib/active_support/dependencies/autoload.rb +0 -50
  322. data/lib/active_support/i18n.rb +0 -8
  323. data/lib/active_support/inflector/inflections.rb +0 -211
  324. data/lib/active_support/inflector/methods.rb +0 -141
  325. data/lib/active_support/inflector/transliterate.rb +0 -97
  326. data/lib/active_support/json/backends/yajl.rb +0 -40
  327. data/lib/active_support/lazy_load_hooks.rb +0 -27
  328. data/lib/active_support/multibyte/unicode.rb +0 -393
  329. data/lib/active_support/notifications/fanout.rb +0 -93
  330. data/lib/active_support/notifications/instrumenter.rb +0 -56
  331. data/lib/active_support/railtie.rb +0 -100
  332. data/lib/active_support/xml_mini/libxmlsax.rb +0 -85
  333. data/lib/active_support/xml_mini/nokogirisax.rb +0 -83
@@ -1,5 +1,4 @@
1
1
  require 'active_support/inflector'
2
- require 'active_support/core_ext/time/publicize_conversion_methods'
3
2
  require 'active_support/values/time_zone'
4
3
 
5
4
  class Time
@@ -0,0 +1,22 @@
1
+ # Pre-1.9 versions of Ruby have a bug with marshaling Time instances, where utc instances are
2
+ # unmarshalled in the local zone, instead of utc. We're layering behavior on the _dump and _load
3
+ # methods so that utc instances can be flagged on dump, and coerced back to utc on load.
4
+ if RUBY_VERSION < '1.9'
5
+ class Time
6
+ class << self
7
+ alias_method :_original_load, :_load
8
+ def _load(marshaled_time)
9
+ time = _original_load(marshaled_time)
10
+ utc = time.instance_variable_get('@marshal_with_utc_coercion')
11
+ utc ? time.utc : time
12
+ end
13
+ end
14
+
15
+ alias_method :_original_dump, :_dump
16
+ def _dump(*args)
17
+ obj = frozen? ? dup : self
18
+ obj.instance_variable_set('@marshal_with_utc_coercion', utc?)
19
+ obj._original_dump(*args)
20
+ end
21
+ end
22
+ end
@@ -1,20 +1,14 @@
1
- # encoding: utf-8
2
-
3
1
  if RUBY_VERSION >= '1.9'
4
2
  require 'uri'
5
3
 
6
4
  str = "\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E" # Ni-ho-nn-go in UTF-8, means Japanese.
5
+ str.force_encoding(Encoding::UTF_8) if str.respond_to?(:force_encoding)
7
6
 
8
- parser = URI::Parser.new
9
-
10
- unless str == parser.unescape(parser.escape(str))
7
+ unless str == URI.unescape(URI.escape(str))
11
8
  URI::Parser.class_eval do
12
9
  remove_method :unescape
13
- def unescape(str, escaped = /%[a-fA-F\d]{2}/)
14
- # TODO: Are we actually sure that ASCII == UTF-8?
15
- # YK: My initial experiments say yes, but let's be sure please
16
- enc = str.encoding
17
- enc = Encoding::UTF_8 if enc == Encoding::US_ASCII
10
+ def unescape(str, escaped = @regexp[:ESCAPED])
11
+ enc = (str.encoding == Encoding::US_ASCII) ? Encoding::UTF_8 : str.encoding
18
12
  str.gsub(escaped) { [$&[1, 2].hex].pack('C') }.force_encoding(enc)
19
13
  end
20
14
  end
@@ -1,10 +1,8 @@
1
1
  require 'set'
2
2
  require 'thread'
3
- require 'pathname'
4
3
  require 'active_support/core_ext/module/aliasing'
5
4
  require 'active_support/core_ext/module/attribute_accessors'
6
5
  require 'active_support/core_ext/module/introspection'
7
- require 'active_support/core_ext/module/anonymous'
8
6
  require 'active_support/core_ext/object/blank'
9
7
  require 'active_support/core_ext/load_error'
10
8
  require 'active_support/core_ext/name_error'
@@ -47,9 +45,6 @@ module ActiveSupport #:nodoc:
47
45
  mattr_accessor :autoloaded_constants
48
46
  self.autoloaded_constants = []
49
47
 
50
- mattr_accessor :references
51
- self.references = {}
52
-
53
48
  # An array of constant names that need to be unloaded on every request. Used
54
49
  # to allow arbitrary constants to be marked for unloading.
55
50
  mattr_accessor :explicitly_unloadable_constants
@@ -63,118 +58,85 @@ module ActiveSupport #:nodoc:
63
58
  mattr_accessor :log_activity
64
59
  self.log_activity = false
65
60
 
66
- class WatchStack < Array
67
- def initialize
68
- @mutex = Mutex.new
69
- end
70
-
71
- def self.locked(*methods)
72
- methods.each { |m| class_eval "def #{m}(*) lock { super } end", __FILE__, __LINE__ }
73
- end
74
-
75
- def get(key)
76
- (val = assoc(key)) ? val[1] : []
77
- end
78
-
79
- locked :concat, :each, :delete_if, :<<
80
-
81
- def new_constants_for(frames)
82
- constants = []
83
- frames.each do |mod_name, prior_constants|
84
- mod = Inflector.constantize(mod_name) if Dependencies.qualified_const_defined?(mod_name)
85
- next unless mod.is_a?(Module)
86
-
87
- new_constants = mod.local_constant_names - prior_constants
88
- get(mod_name).concat(new_constants)
89
-
90
- new_constants.each do |suffix|
91
- constants << ([mod_name, suffix] - ["Object"]).join("::")
92
- end
93
- end
94
- constants
95
- end
96
-
97
- # Add a set of modules to the watch stack, remembering the initial constants
98
- def add_modules(modules)
99
- list = modules.map do |desc|
100
- name = Dependencies.to_constant_name(desc)
101
- consts = Dependencies.qualified_const_defined?(name) ?
102
- Inflector.constantize(name).local_constant_names : []
103
- [name, consts]
104
- end
105
- concat(list)
106
- list
107
- end
108
-
109
- def lock
110
- @mutex.synchronize { yield self }
111
- end
112
- end
113
-
114
61
  # An internal stack used to record which constants are loaded by any block.
115
62
  mattr_accessor :constant_watch_stack
116
- self.constant_watch_stack = WatchStack.new
63
+ self.constant_watch_stack = []
64
+
65
+ mattr_accessor :constant_watch_stack_mutex
66
+ self.constant_watch_stack_mutex = Mutex.new
117
67
 
118
68
  # Module includes this module
119
69
  module ModuleConstMissing #:nodoc:
120
- def self.append_features(base)
70
+ def self.included(base) #:nodoc:
121
71
  base.class_eval do
122
- # Emulate #exclude via an ivar
123
- return if defined?(@_const_missing) && @_const_missing
124
- @_const_missing = instance_method(:const_missing)
125
- remove_method(:const_missing)
72
+ unless defined? const_missing_without_dependencies
73
+ alias_method_chain :const_missing, :dependencies
74
+ end
126
75
  end
127
- super
128
76
  end
129
77
 
130
- def self.exclude_from(base)
78
+ def self.excluded(base) #:nodoc:
131
79
  base.class_eval do
132
- define_method :const_missing, @_const_missing
133
- @_const_missing = nil
80
+ if defined? const_missing_without_dependencies
81
+ undef_method :const_missing
82
+ alias_method :const_missing, :const_missing_without_dependencies
83
+ undef_method :const_missing_without_dependencies
84
+ end
134
85
  end
135
86
  end
136
87
 
137
88
  # Use const_missing to autoload associations so we don't have to
138
89
  # require_association when using single-table inheritance.
139
- def const_missing(const_name, nesting = nil)
140
- klass_name = name.presence || "Object"
141
-
142
- if !nesting
143
- # We'll assume that the nesting of Foo::Bar is ["Foo::Bar", "Foo"]
144
- # even though it might not be, such as in the case of
145
- # class Foo::Bar; Baz; end
146
- nesting = []
147
- klass_name.to_s.scan(/::|$/) { nesting.unshift $` }
148
- end
90
+ def const_missing_with_dependencies(class_id)
91
+ ActiveSupport::Dependencies.load_missing_constant self, class_id
92
+ end
149
93
 
150
- # If there are multiple levels of nesting to search under, the top
151
- # level is the one we want to report as the lookup fail.
152
- error = nil
94
+ def unloadable(const_desc = self)
95
+ super(const_desc)
96
+ end
97
+ end
153
98
 
154
- nesting.each do |namespace|
99
+ # Class includes this module
100
+ module ClassConstMissing #:nodoc:
101
+ def const_missing(const_name)
102
+ if [Object, Kernel].include?(self) || parent == self
103
+ super
104
+ else
155
105
  begin
156
- return Dependencies.load_missing_constant namespace.constantize, const_name
157
- rescue NoMethodError then raise
106
+ begin
107
+ Dependencies.load_missing_constant self, const_name
108
+ rescue NameError
109
+ parent.send :const_missing, const_name
110
+ end
158
111
  rescue NameError => e
159
- error ||= e
112
+ # Make sure that the name we are missing is the one that caused the error
113
+ parent_qualified_name = Dependencies.qualified_name_for parent, const_name
114
+ raise unless e.missing_name? parent_qualified_name
115
+ qualified_name = Dependencies.qualified_name_for self, const_name
116
+ raise NameError.new("uninitialized constant #{qualified_name}").copy_blame!(e)
160
117
  end
161
118
  end
162
-
163
- # Raise the first error for this set. If this const_missing came from an
164
- # earlier const_missing, this will result in the real error bubbling
165
- # all the way up
166
- raise error
167
- end
168
-
169
- def unloadable(const_desc = self)
170
- super(const_desc)
171
119
  end
172
120
  end
173
121
 
174
122
  # Object includes this module
175
123
  module Loadable #:nodoc:
176
- def self.exclude_from(base)
177
- base.class_eval { define_method(:load, Kernel.instance_method(:load)) }
124
+ def self.included(base) #:nodoc:
125
+ base.class_eval do
126
+ unless defined? load_without_new_constant_marking
127
+ alias_method_chain :load, :new_constant_marking
128
+ end
129
+ end
130
+ end
131
+
132
+ def self.excluded(base) #:nodoc:
133
+ base.class_eval do
134
+ if defined? load_without_new_constant_marking
135
+ undef_method :load
136
+ alias_method :load, :load_without_new_constant_marking
137
+ undef_method :load_without_new_constant_marking
138
+ end
139
+ end
178
140
  end
179
141
 
180
142
  def require_or_load(file_name)
@@ -182,10 +144,6 @@ module ActiveSupport #:nodoc:
182
144
  end
183
145
 
184
146
  def require_dependency(file_name, message = "No such file to load -- %s")
185
- unless file_name.is_a?(String)
186
- raise ArgumentError, "the file name must be a String -- you passed #{file_name.inspect}"
187
- end
188
-
189
147
  Dependencies.depend_on(file_name, false, message)
190
148
  end
191
149
 
@@ -193,23 +151,26 @@ module ActiveSupport #:nodoc:
193
151
  Dependencies.associate_with(file_name)
194
152
  end
195
153
 
196
- def load_dependency(file)
154
+ def load_with_new_constant_marking(file, *extras) #:nodoc:
197
155
  if Dependencies.load?
198
- Dependencies.new_constants_in(Object) { yield }.presence
156
+ Dependencies.new_constants_in(Object) { load_without_new_constant_marking(file, *extras) }
199
157
  else
200
- yield
158
+ load_without_new_constant_marking(file, *extras)
201
159
  end
202
160
  rescue Exception => exception # errors from loading file
203
161
  exception.blame_file! file
204
162
  raise
205
163
  end
206
164
 
207
- def load(file, *)
208
- load_dependency(file) { super }
209
- end
210
-
211
- def require(file, *)
212
- load_dependency(file) { super }
165
+ def require(file, *extras) #:nodoc:
166
+ if Dependencies.load?
167
+ Dependencies.new_constants_in(Object) { super }
168
+ else
169
+ super
170
+ end
171
+ rescue Exception => exception # errors from required file
172
+ exception.blame_file! file
173
+ raise
213
174
  end
214
175
 
215
176
  # Mark the given constant as unloadable. Unloadable constants are removed each
@@ -252,15 +213,16 @@ module ActiveSupport #:nodoc:
252
213
  end
253
214
 
254
215
  def hook!
255
- Object.class_eval { include Loadable }
256
- Module.class_eval { include ModuleConstMissing }
257
- Exception.class_eval { include Blamable }
216
+ Object.instance_eval { include Loadable }
217
+ Module.instance_eval { include ModuleConstMissing }
218
+ Class.instance_eval { include ClassConstMissing }
219
+ Exception.instance_eval { include Blamable }
258
220
  true
259
221
  end
260
222
 
261
223
  def unhook!
262
- ModuleConstMissing.exclude_from(Module)
263
- Loadable.exclude_from(Object)
224
+ ModuleConstMissing.excluded(Module)
225
+ Loadable.excluded(Object)
264
226
  true
265
227
  end
266
228
 
@@ -274,7 +236,7 @@ module ActiveSupport #:nodoc:
274
236
  rescue LoadError => load_error
275
237
  unless swallow_load_errors
276
238
  if file_name = load_error.message[/ -- (.*?)(\.rb)?$/, 1]
277
- raise LoadError.new(message % file_name).copy_blame!(load_error)
239
+ raise MissingSourceFile.new(message % file_name, load_error.path).copy_blame!(load_error)
278
240
  end
279
241
  raise
280
242
  end
@@ -330,22 +292,29 @@ module ActiveSupport #:nodoc:
330
292
 
331
293
  # Is the provided constant path defined?
332
294
  def qualified_const_defined?(path)
333
- names = path.sub(/^::/, '').to_s.split('::')
295
+ raise NameError, "#{path.inspect} is not a valid constant name!" unless
296
+ /^(::)?([A-Z]\w*)(::[A-Z]\w*)*$/ =~ path
334
297
 
298
+ names = path.to_s.split('::')
299
+ names.shift if names.first.empty?
300
+
301
+ # We can't use defined? because it will invoke const_missing for the parent
302
+ # of the name we are checking.
335
303
  names.inject(Object) do |mod, name|
336
- return false unless local_const_defined?(mod, name)
304
+ return false unless uninherited_const_defined?(mod, name)
337
305
  mod.const_get name
338
306
  end
307
+ return true
339
308
  end
340
309
 
341
310
  if Module.method(:const_defined?).arity == 1
342
311
  # Does this module define this constant?
343
312
  # Wrapper to accomodate changing Module#const_defined? in Ruby 1.9
344
- def local_const_defined?(mod, const)
313
+ def uninherited_const_defined?(mod, const)
345
314
  mod.const_defined?(const)
346
315
  end
347
316
  else
348
- def local_const_defined?(mod, const) #:nodoc:
317
+ def uninherited_const_defined?(mod, const) #:nodoc:
349
318
  mod.const_defined?(const, false)
350
319
  end
351
320
  end
@@ -353,20 +322,29 @@ module ActiveSupport #:nodoc:
353
322
  # Given +path+, a filesystem path to a ruby file, return an array of constant
354
323
  # paths which would cause Dependencies to attempt to load this file.
355
324
  def loadable_constants_for_path(path, bases = load_paths)
356
- expanded_path = Pathname.new(path[/\A(.*?)(\.rb)?\Z/, 1]).expand_path
357
-
358
- bases.inject([]) do |paths, root|
359
- expanded_root = Pathname.new(root).expand_path
360
- nesting = expanded_path.relative_path_from(expanded_root).to_s
361
- next paths if nesting =~ /\.\./
362
- paths << nesting.camelize
363
- end.uniq
325
+ path = $1 if path =~ /\A(.*)\.rb\Z/
326
+ expanded_path = File.expand_path(path)
327
+
328
+ bases.collect do |root|
329
+ expanded_root = File.expand_path(root)
330
+ next unless %r{\A#{Regexp.escape(expanded_root)}(/|\\)} =~ expanded_path
331
+
332
+ nesting = expanded_path[(expanded_root.size)..-1]
333
+ nesting = nesting[1..-1] if nesting && nesting[0] == ?/
334
+ next if nesting.blank?
335
+ nesting_camel = nesting.camelize
336
+ begin
337
+ qualified_const_defined?(nesting_camel)
338
+ rescue NameError
339
+ next
340
+ end
341
+ [ nesting_camel ]
342
+ end.flatten.compact.uniq
364
343
  end
365
344
 
366
345
  # Search for a file in load_paths matching the provided suffix.
367
346
  def search_for_file(path_suffix)
368
- path_suffix = path_suffix.sub(/(\.rb)?$/, ".rb")
369
-
347
+ path_suffix = "#{path_suffix}.rb" unless path_suffix =~ /\.rb\Z/
370
348
  load_paths.each do |root|
371
349
  path = File.join(root, path_suffix)
372
350
  return path if File.file? path
@@ -415,7 +393,7 @@ module ActiveSupport #:nodoc:
415
393
 
416
394
  result = nil
417
395
  newly_defined_paths = new_constants_in(*parent_paths) do
418
- result = Kernel.load path
396
+ result = load_without_new_constant_marking path
419
397
  end
420
398
 
421
399
  autoloaded_constants.concat newly_defined_paths unless load_once_path?(path)
@@ -427,7 +405,7 @@ module ActiveSupport #:nodoc:
427
405
  # Return the constant path for the provided parent and constant name.
428
406
  def qualified_name_for(mod, name)
429
407
  mod_name = to_constant_name mod
430
- mod_name == "Object" ? name.to_s : "#{mod_name}::#{name}"
408
+ (%w(Object Kernel).include? mod_name) ? name.to_s : "#{mod_name}::#{name}"
431
409
  end
432
410
 
433
411
  # Load the constant named +const_name+ which is missing from +from_mod+. If
@@ -435,30 +413,38 @@ module ActiveSupport #:nodoc:
435
413
  # using const_missing.
436
414
  def load_missing_constant(from_mod, const_name)
437
415
  log_call from_mod, const_name
416
+ if from_mod == Kernel
417
+ if ::Object.const_defined?(const_name)
418
+ log "Returning Object::#{const_name} for Kernel::#{const_name}"
419
+ return ::Object.const_get(const_name)
420
+ else
421
+ log "Substituting Object for Kernel"
422
+ from_mod = Object
423
+ end
424
+ end
425
+
426
+ # If we have an anonymous module, all we can do is attempt to load from Object.
427
+ from_mod = Object if from_mod.name.blank?
438
428
 
439
- unless qualified_const_defined?(from_mod.name) && Inflector.constantize(from_mod.name).equal?(from_mod)
429
+ unless qualified_const_defined?(from_mod.name) && Inflector.constantize(from_mod.name).object_id == from_mod.object_id
440
430
  raise ArgumentError, "A copy of #{from_mod} has been removed from the module tree but is still active!"
441
431
  end
442
432
 
443
- raise ArgumentError, "#{from_mod} is not missing constant #{const_name}!" if local_const_defined?(from_mod, const_name)
433
+ raise ArgumentError, "#{from_mod} is not missing constant #{const_name}!" if uninherited_const_defined?(from_mod, const_name)
444
434
 
445
435
  qualified_name = qualified_name_for from_mod, const_name
446
436
  path_suffix = qualified_name.underscore
447
-
448
- trace = caller.reject {|l| l =~ %r{#{Regexp.escape(__FILE__)}}}
449
437
  name_error = NameError.new("uninitialized constant #{qualified_name}")
450
- name_error.set_backtrace(trace)
451
438
 
452
439
  file_path = search_for_file(path_suffix)
453
-
454
440
  if file_path && ! loaded.include?(File.expand_path(file_path)) # We found a matching file to load
455
441
  require_or_load file_path
456
- raise LoadError, "Expected #{file_path} to define #{qualified_name}" unless local_const_defined?(from_mod, const_name)
442
+ raise LoadError, "Expected #{file_path} to define #{qualified_name}" unless uninherited_const_defined?(from_mod, const_name)
457
443
  return from_mod.const_get(const_name)
458
444
  elsif mod = autoload_module!(from_mod, const_name, qualified_name, path_suffix)
459
445
  return mod
460
446
  elsif (parent = from_mod.parent) && parent != from_mod &&
461
- ! from_mod.parents.any? { |p| local_const_defined?(p, const_name) }
447
+ ! from_mod.parents.any? { |p| uninherited_const_defined?(p, const_name) }
462
448
  # If our parents do not have a constant named +const_name+ then we are free
463
449
  # to attempt to load upwards. If they do have such a constant, then this
464
450
  # const_missing must be due to from_mod::const_name, which should not
@@ -479,41 +465,13 @@ module ActiveSupport #:nodoc:
479
465
  def remove_unloadable_constants!
480
466
  autoloaded_constants.each { |const| remove_constant const }
481
467
  autoloaded_constants.clear
482
- Reference.clear!
483
468
  explicitly_unloadable_constants.each { |const| remove_constant const }
484
469
  end
485
470
 
486
- class Reference
487
- @@constants = Hash.new { |h, k| h[k] = Inflector.constantize(k) }
488
-
489
- attr_reader :name
490
-
491
- def initialize(name)
492
- @name = name.to_s
493
- @@constants[@name] = name if name.respond_to?(:name)
494
- end
495
-
496
- def get
497
- @@constants[@name]
498
- end
499
-
500
- def self.clear!
501
- @@constants.clear
502
- end
503
- end
504
-
505
- def ref(name)
506
- references[name] ||= Reference.new(name)
507
- end
508
-
509
- def constantize(name)
510
- ref(name).get
511
- end
512
-
513
471
  # Determine if the given constant has been automatically loaded.
514
472
  def autoloaded?(desc)
515
473
  # No name => anonymous module.
516
- return false if desc.is_a?(Module) && desc.anonymous?
474
+ return false if desc.is_a?(Module) && desc.name.blank?
517
475
  name = to_constant_name desc
518
476
  return false unless qualified_const_defined? name
519
477
  return autoloaded_constants.include?(name)
@@ -547,26 +505,79 @@ module ActiveSupport #:nodoc:
547
505
  # and will be removed immediately.
548
506
  def new_constants_in(*descs)
549
507
  log_call(*descs)
550
- watch_frames = constant_watch_stack.add_modules(descs)
508
+
509
+ # Build the watch frames. Each frame is a tuple of
510
+ # [module_name_as_string, constants_defined_elsewhere]
511
+ watch_frames = descs.collect do |desc|
512
+ if desc.is_a? Module
513
+ mod_name = desc.name
514
+ initial_constants = desc.local_constant_names
515
+ elsif desc.is_a?(String) || desc.is_a?(Symbol)
516
+ mod_name = desc.to_s
517
+
518
+ # Handle the case where the module has yet to be defined.
519
+ initial_constants = if qualified_const_defined?(mod_name)
520
+ Inflector.constantize(mod_name).local_constant_names
521
+ else
522
+ []
523
+ end
524
+ else
525
+ raise Argument, "#{desc.inspect} does not describe a module!"
526
+ end
527
+
528
+ [mod_name, initial_constants]
529
+ end
530
+
531
+ constant_watch_stack_mutex.synchronize do
532
+ constant_watch_stack.concat watch_frames
533
+ end
551
534
 
552
535
  aborting = true
553
536
  begin
554
537
  yield # Now yield to the code that is to define new constants.
555
538
  aborting = false
556
539
  ensure
557
- new_constants = constant_watch_stack.new_constants_for(watch_frames)
540
+ # Find the new constants.
541
+ new_constants = watch_frames.collect do |mod_name, prior_constants|
542
+ # Module still doesn't exist? Treat it as if it has no constants.
543
+ next [] unless qualified_const_defined?(mod_name)
544
+
545
+ mod = Inflector.constantize(mod_name)
546
+ next [] unless mod.is_a? Module
547
+ new_constants = mod.local_constant_names - prior_constants
548
+
549
+ # Make sure no other frames takes credit for these constants.
550
+ constant_watch_stack_mutex.synchronize do
551
+ constant_watch_stack.each do |frame_name, constants|
552
+ constants.concat new_constants if frame_name == mod_name
553
+ end
554
+ end
555
+
556
+ new_constants.collect do |suffix|
557
+ mod_name == "Object" ? suffix : "#{mod_name}::#{suffix}"
558
+ end
559
+ end.flatten
558
560
 
559
561
  log "New constants: #{new_constants * ', '}"
560
- return new_constants unless aborting
561
562
 
562
- log "Error during loading, removing partially loaded constants "
563
- new_constants.each {|c| remove_constant(c) }.clear
563
+ if aborting
564
+ log "Error during loading, removing partially loaded constants "
565
+ new_constants.each { |name| remove_constant name }
566
+ new_constants.clear
567
+ end
564
568
  end
565
569
 
566
- return []
570
+ return new_constants
567
571
  ensure
568
572
  # Remove the stack frames that we added.
569
- watch_frames.each {|f| constant_watch_stack.delete(f) } if watch_frames.present?
573
+ if defined?(watch_frames) && ! watch_frames.blank?
574
+ frame_ids = watch_frames.collect { |frame| frame.object_id }
575
+ constant_watch_stack_mutex.synchronize do
576
+ constant_watch_stack.delete_if do |watch_frame|
577
+ frame_ids.include? watch_frame.object_id
578
+ end
579
+ end
580
+ end
570
581
  end
571
582
 
572
583
  class LoadingModule #:nodoc:
@@ -584,11 +595,11 @@ module ActiveSupport #:nodoc:
584
595
  # A module, class, symbol, or string may be provided.
585
596
  def to_constant_name(desc) #:nodoc:
586
597
  name = case desc
587
- when String then desc.sub(/^::/, '')
598
+ when String then desc.starts_with?('::') ? desc[2..-1] : desc
588
599
  when Symbol then desc.to_s
589
600
  when Module
590
- desc.name.presence ||
591
- raise(ArgumentError, "Anonymous modules have no name to be referenced by")
601
+ raise ArgumentError, "Anonymous modules have no name to be referenced by" if desc.name.blank?
602
+ desc.name
592
603
  else raise TypeError, "Not a valid constant descriptor: #{desc.inspect}"
593
604
  end
594
605
  end
@@ -596,14 +607,16 @@ module ActiveSupport #:nodoc:
596
607
  def remove_constant(const) #:nodoc:
597
608
  return false unless qualified_const_defined? const
598
609
 
599
- # Normalize ::Foo, Foo, Object::Foo, and ::Object::Foo to Object::Foo
600
- names = const.to_s.sub(/^::(Object)?/, 'Object::').split("::")
601
- to_remove = names.pop
602
- parent = Inflector.constantize(names * '::')
610
+ const = $1 if /\A::(.*)\Z/ =~ const.to_s
611
+ names = const.to_s.split('::')
612
+ if names.size == 1 # It's under Object
613
+ parent = Object
614
+ else
615
+ parent = Inflector.constantize(names[0..-2] * '::')
616
+ end
603
617
 
604
618
  log "removing constant #{const}"
605
- parent.instance_eval { remove_const to_remove }
606
-
619
+ parent.instance_eval { remove_const names.last }
607
620
  return true
608
621
  end
609
622