activesupport 2.3.5 → 3.0.0.beta3

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