activesupport 2.0.5 → 2.1.0

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 (236) hide show
  1. data/CHANGELOG +183 -5
  2. data/lib/active_support.rb +6 -2
  3. data/lib/active_support/base64.rb +5 -0
  4. data/lib/active_support/basic_object.rb +23 -4
  5. data/lib/active_support/buffered_logger.rb +17 -3
  6. data/lib/active_support/cache.rb +145 -0
  7. data/lib/active_support/cache/compressed_mem_cache_store.rb +15 -0
  8. data/lib/active_support/cache/drb_store.rb +15 -0
  9. data/lib/active_support/cache/file_store.rb +70 -0
  10. data/lib/active_support/cache/mem_cache_store.rb +100 -0
  11. data/lib/active_support/cache/memory_store.rb +38 -0
  12. data/lib/active_support/callbacks.rb +275 -0
  13. data/lib/active_support/core_ext/array/access.rb +2 -4
  14. data/lib/active_support/core_ext/array/conversions.rb +89 -5
  15. data/lib/active_support/core_ext/array/extract_options.rb +2 -1
  16. data/lib/active_support/core_ext/array/grouping.rb +3 -8
  17. data/lib/active_support/core_ext/array/random_access.rb +1 -1
  18. data/lib/active_support/core_ext/base64.rb +4 -0
  19. data/lib/active_support/core_ext/base64/encoding.rb +13 -0
  20. data/lib/active_support/core_ext/benchmark.rb +12 -0
  21. data/lib/active_support/core_ext/bigdecimal.rb +4 -0
  22. data/lib/active_support/core_ext/bigdecimal/conversions.rb +39 -4
  23. data/lib/active_support/core_ext/blank.rb +5 -2
  24. data/lib/active_support/core_ext/class/attribute_accessors.rb +7 -1
  25. data/lib/active_support/core_ext/class/delegating_attributes.rb +7 -1
  26. data/lib/active_support/core_ext/class/inheritable_attributes.rb +1 -1
  27. data/lib/active_support/core_ext/class/removal.rb +26 -0
  28. data/lib/active_support/core_ext/date/calculations.rb +28 -1
  29. data/lib/active_support/core_ext/date/conversions.rb +1 -0
  30. data/lib/active_support/core_ext/date_time.rb +2 -0
  31. data/lib/active_support/core_ext/date_time/calculations.rb +37 -2
  32. data/lib/active_support/core_ext/date_time/conversions.rb +27 -14
  33. data/lib/active_support/core_ext/enumerable.rb +16 -9
  34. data/lib/active_support/core_ext/exception.rb +8 -0
  35. data/lib/active_support/core_ext/file.rb +6 -6
  36. data/lib/active_support/core_ext/hash/conversions.rb +26 -8
  37. data/lib/active_support/core_ext/hash/indifferent_access.rb +35 -0
  38. data/lib/active_support/core_ext/hash/reverse_merge.rb +4 -1
  39. data/lib/active_support/core_ext/integer/even_odd.rb +10 -5
  40. data/lib/active_support/core_ext/integer/inflections.rb +0 -1
  41. data/lib/active_support/core_ext/kernel/daemonizing.rb +2 -10
  42. data/lib/active_support/core_ext/kernel/reporting.rb +8 -0
  43. data/lib/active_support/core_ext/module/attr_internal.rb +4 -3
  44. data/lib/active_support/core_ext/module/attribute_accessors.rb +11 -1
  45. data/lib/active_support/core_ext/module/delegation.rb +5 -3
  46. data/lib/active_support/core_ext/module/inclusion.rb +19 -0
  47. data/lib/active_support/core_ext/module/introspection.rb +50 -16
  48. data/lib/active_support/core_ext/module/loading.rb +10 -0
  49. data/lib/active_support/core_ext/numeric.rb +3 -1
  50. data/lib/active_support/core_ext/numeric/conversions.rb +19 -0
  51. data/lib/active_support/core_ext/object/instance_variables.rb +52 -0
  52. data/lib/active_support/core_ext/object/misc.rb +1 -1
  53. data/lib/active_support/core_ext/process.rb +1 -0
  54. data/lib/active_support/core_ext/process/daemon.rb +25 -0
  55. data/lib/active_support/core_ext/range/conversions.rb +5 -1
  56. data/lib/active_support/core_ext/range/include_range.rb +8 -0
  57. data/lib/active_support/core_ext/range/overlaps.rb +3 -0
  58. data/lib/active_support/core_ext/string.rb +5 -10
  59. data/lib/active_support/core_ext/string/access.rb +72 -48
  60. data/lib/active_support/core_ext/string/conversions.rb +4 -4
  61. data/lib/active_support/core_ext/string/filters.rb +26 -0
  62. data/lib/active_support/core_ext/string/inflections.rb +56 -64
  63. data/lib/active_support/core_ext/string/iterators.rb +4 -0
  64. data/lib/active_support/core_ext/string/starts_ends_with.rb +12 -4
  65. data/lib/active_support/core_ext/string/unicode.rb +14 -7
  66. data/lib/active_support/core_ext/symbol.rb +1 -1
  67. data/lib/active_support/core_ext/time.rb +2 -0
  68. data/lib/active_support/core_ext/time/calculations.rb +75 -23
  69. data/lib/active_support/core_ext/time/conversions.rb +22 -35
  70. data/lib/active_support/core_ext/time/zones.rb +86 -0
  71. data/lib/active_support/dependencies.rb +92 -80
  72. data/lib/active_support/deprecation.rb +2 -16
  73. data/lib/active_support/duration.rb +4 -4
  74. data/lib/active_support/gzip.rb +25 -0
  75. data/lib/active_support/inflector.rb +92 -69
  76. data/lib/active_support/json.rb +17 -25
  77. data/lib/active_support/json/decoding.rb +1 -1
  78. data/lib/active_support/json/encoders/date.rb +11 -2
  79. data/lib/active_support/json/encoders/date_time.rb +11 -2
  80. data/lib/active_support/json/encoders/enumerable.rb +2 -2
  81. data/lib/active_support/json/encoders/hash.rb +3 -6
  82. data/lib/active_support/json/encoders/object.rb +1 -1
  83. data/lib/active_support/json/encoders/string.rb +8 -2
  84. data/lib/active_support/json/encoders/time.rb +11 -2
  85. data/lib/active_support/json/encoding.rb +0 -1
  86. data/lib/active_support/multibyte/chars.rb +8 -6
  87. data/lib/active_support/multibyte/handlers/utf8_handler.rb +11 -11
  88. data/lib/active_support/ordered_hash.rb +43 -0
  89. data/lib/active_support/ordered_options.rb +0 -38
  90. data/lib/active_support/test_case.rb +10 -2
  91. data/lib/active_support/testing/default.rb +3 -6
  92. data/lib/active_support/testing/setup_and_teardown.rb +93 -0
  93. data/lib/active_support/time_with_zone.rb +283 -0
  94. data/lib/active_support/values/time_zone.rb +336 -123
  95. data/lib/active_support/vendor.rb +12 -0
  96. data/lib/active_support/vendor/memcache-client-1.5.0/memcache.rb +849 -0
  97. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo.rb +33 -0
  98. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/data_timezone.rb +47 -0
  99. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/data_timezone_info.rb +226 -0
  100. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Africa/Algiers.rb +55 -0
  101. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Africa/Cairo.rb +219 -0
  102. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Africa/Casablanca.rb +38 -0
  103. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Africa/Harare.rb +18 -0
  104. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Africa/Johannesburg.rb +25 -0
  105. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Africa/Monrovia.rb +22 -0
  106. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Africa/Nairobi.rb +23 -0
  107. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +166 -0
  108. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Argentina/San_Juan.rb +170 -0
  109. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Bogota.rb +23 -0
  110. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Caracas.rb +23 -0
  111. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Chicago.rb +283 -0
  112. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Chihuahua.rb +136 -0
  113. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Denver.rb +204 -0
  114. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Godthab.rb +161 -0
  115. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Guatemala.rb +27 -0
  116. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Halifax.rb +274 -0
  117. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Indiana/Indianapolis.rb +149 -0
  118. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Juneau.rb +194 -0
  119. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/La_Paz.rb +22 -0
  120. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Lima.rb +35 -0
  121. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Los_Angeles.rb +232 -0
  122. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Mazatlan.rb +139 -0
  123. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Mexico_City.rb +144 -0
  124. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Monterrey.rb +131 -0
  125. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/New_York.rb +282 -0
  126. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Phoenix.rb +30 -0
  127. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Regina.rb +74 -0
  128. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Santiago.rb +205 -0
  129. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/St_Johns.rb +288 -0
  130. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Tijuana.rb +196 -0
  131. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Almaty.rb +67 -0
  132. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Baghdad.rb +73 -0
  133. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Baku.rb +161 -0
  134. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Bangkok.rb +20 -0
  135. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Chongqing.rb +33 -0
  136. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Dhaka.rb +27 -0
  137. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Hong_Kong.rb +87 -0
  138. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Irkutsk.rb +165 -0
  139. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Jakarta.rb +30 -0
  140. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Jerusalem.rb +163 -0
  141. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Kabul.rb +20 -0
  142. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Kamchatka.rb +163 -0
  143. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Karachi.rb +28 -0
  144. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Katmandu.rb +20 -0
  145. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Kolkata.rb +25 -0
  146. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Krasnoyarsk.rb +163 -0
  147. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Kuala_Lumpur.rb +31 -0
  148. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Kuwait.rb +18 -0
  149. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Magadan.rb +163 -0
  150. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Muscat.rb +18 -0
  151. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Novosibirsk.rb +164 -0
  152. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Rangoon.rb +24 -0
  153. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Riyadh.rb +18 -0
  154. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Seoul.rb +34 -0
  155. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Shanghai.rb +35 -0
  156. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Singapore.rb +33 -0
  157. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Taipei.rb +59 -0
  158. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Tashkent.rb +47 -0
  159. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Tbilisi.rb +78 -0
  160. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Tehran.rb +121 -0
  161. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Tokyo.rb +30 -0
  162. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Ulaanbaatar.rb +65 -0
  163. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Urumqi.rb +33 -0
  164. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Vladivostok.rb +164 -0
  165. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Yakutsk.rb +163 -0
  166. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Yekaterinburg.rb +165 -0
  167. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Yerevan.rb +165 -0
  168. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Atlantic/Azores.rb +270 -0
  169. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Atlantic/Cape_Verde.rb +23 -0
  170. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Atlantic/South_Georgia.rb +18 -0
  171. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Australia/Adelaide.rb +187 -0
  172. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Australia/Brisbane.rb +35 -0
  173. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Australia/Darwin.rb +29 -0
  174. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Australia/Hobart.rb +193 -0
  175. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Australia/Melbourne.rb +185 -0
  176. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Australia/Perth.rb +37 -0
  177. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Australia/Sydney.rb +185 -0
  178. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Etc/UTC.rb +16 -0
  179. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Amsterdam.rb +228 -0
  180. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Athens.rb +185 -0
  181. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Belgrade.rb +163 -0
  182. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Berlin.rb +188 -0
  183. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Bratislava.rb +13 -0
  184. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Brussels.rb +232 -0
  185. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Bucharest.rb +181 -0
  186. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Budapest.rb +197 -0
  187. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Copenhagen.rb +179 -0
  188. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Dublin.rb +276 -0
  189. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Helsinki.rb +163 -0
  190. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Istanbul.rb +218 -0
  191. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Kiev.rb +168 -0
  192. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Lisbon.rb +268 -0
  193. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Ljubljana.rb +13 -0
  194. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/London.rb +288 -0
  195. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Madrid.rb +211 -0
  196. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Minsk.rb +170 -0
  197. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Moscow.rb +181 -0
  198. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Paris.rb +232 -0
  199. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Prague.rb +187 -0
  200. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Riga.rb +176 -0
  201. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Rome.rb +215 -0
  202. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Sarajevo.rb +13 -0
  203. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Skopje.rb +13 -0
  204. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Sofia.rb +173 -0
  205. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Stockholm.rb +165 -0
  206. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Tallinn.rb +172 -0
  207. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Vienna.rb +183 -0
  208. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Vilnius.rb +170 -0
  209. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Warsaw.rb +212 -0
  210. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Zagreb.rb +13 -0
  211. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Pacific/Auckland.rb +202 -0
  212. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Pacific/Fiji.rb +23 -0
  213. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Pacific/Guam.rb +22 -0
  214. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Pacific/Honolulu.rb +28 -0
  215. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Pacific/Majuro.rb +20 -0
  216. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Pacific/Midway.rb +25 -0
  217. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Pacific/Noumea.rb +25 -0
  218. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Pacific/Pago_Pago.rb +26 -0
  219. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Pacific/Port_Moresby.rb +20 -0
  220. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Pacific/Tongatapu.rb +27 -0
  221. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/info_timezone.rb +52 -0
  222. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/linked_timezone.rb +51 -0
  223. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/linked_timezone_info.rb +44 -0
  224. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/offset_rationals.rb +95 -0
  225. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/time_or_datetime.rb +292 -0
  226. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/timezone.rb +508 -0
  227. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/timezone_definition.rb +56 -0
  228. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/timezone_info.rb +40 -0
  229. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/timezone_offset_info.rb +94 -0
  230. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/timezone_period.rb +198 -0
  231. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/timezone_transition_info.rb +138 -0
  232. data/lib/active_support/version.rb +2 -2
  233. data/lib/active_support/whiny_nil.rb +30 -10
  234. metadata +175 -5
  235. data/lib/active_support/core_ext/rexml.rb +0 -38
  236. data/lib/active_support/testing.rb +0 -1
@@ -5,6 +5,7 @@ module ActiveSupport #:nodoc:
5
5
  module Conversions
6
6
  DATE_FORMATS = {
7
7
  :db => "%Y-%m-%d %H:%M:%S",
8
+ :number => "%Y%m%d%H%M%S",
8
9
  :time => "%H:%M",
9
10
  :short => "%d %b %H:%M",
10
11
  :long => "%B %d, %Y %H:%M",
@@ -19,11 +20,10 @@ module ActiveSupport #:nodoc:
19
20
  end
20
21
  end
21
22
 
22
- # Convert to a formatted string. See DATE_FORMATS for builtin formats.
23
+ # Converts to a formatted string. See DATE_FORMATS for builtin formats.
23
24
  #
24
25
  # This method is aliased to <tt>to_s</tt>.
25
26
  #
26
- # ==== Examples:
27
27
  # time = Time.now # => Thu Jan 18 06:10:17 CST 2007
28
28
  #
29
29
  # time.to_formatted_s(:time) # => "06:10:17"
@@ -35,7 +35,7 @@ module ActiveSupport #:nodoc:
35
35
  # time.to_formatted_s(:long_ordinal) # => "January 18th, 2007 06:10"
36
36
  # time.to_formatted_s(:rfc822) # => "Thu, 18 Jan 2007 06:10:17 -0600"
37
37
  #
38
- # == Adding your own time formats to to_formatted_s
38
+ # == Adding your own time formats to +to_formatted_s+
39
39
  # You can add your own formats to the Time::DATE_FORMATS hash.
40
40
  # Use the format name as the hash key and either a strftime string
41
41
  # or Proc instance that takes a time argument as the value.
@@ -44,31 +44,25 @@ module ActiveSupport #:nodoc:
44
44
  # Time::DATE_FORMATS[:month_and_year] = "%B %Y"
45
45
  # Time::DATE_FORMATS[:short_ordinal] = lambda { |time| time.strftime("%B #{time.day.ordinalize}") }
46
46
  def to_formatted_s(format = :default)
47
- if formatter = DATE_FORMATS[format]
48
- if formatter.respond_to?(:call)
49
- formatter.call(self).to_s
50
- else
51
- strftime(formatter)
52
- end
53
- else
54
- to_default_s
55
- end
47
+ return to_default_s unless formatter = DATE_FORMATS[format]
48
+ formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter)
56
49
  end
57
-
58
- # Convert a Time object to a Date, dropping hour, minute, and second precision.
50
+
51
+ # Returns the UTC offset as an +HH:MM formatted string.
59
52
  #
60
- # ==== Examples
61
- # my_time = Time.now
62
- # # => Mon Nov 12 22:59:51 -0500 2007
63
- #
64
- # my_time.to_date
65
- # #=> Mon, 12 Nov 2007
53
+ # Time.local(2000).formatted_offset # => "-06:00"
54
+ # Time.local(2000).formatted_offset(false) # => "-0600"
55
+ def formatted_offset(colon = true, alternate_utc_string = nil)
56
+ utc? && alternate_utc_string || utc_offset.to_utc_offset_s(colon)
57
+ end
58
+
59
+ # Converts a Time object to a Date, dropping hour, minute, and second precision.
66
60
  #
67
- # your_time = Time.parse("1/13/2009 1:13:03 P.M.")
68
- # # => Tue Jan 13 13:13:03 -0500 2009
61
+ # my_time = Time.now # => Mon Nov 12 22:59:51 -0500 2007
62
+ # my_time.to_date # => Mon, 12 Nov 2007
69
63
  #
70
- # your_time.to_date
71
- # # => Tue, 13 Jan 2009
64
+ # your_time = Time.parse("1/13/2009 1:13:03 P.M.") # => Tue Jan 13 13:13:03 -0500 2009
65
+ # your_time.to_date # => Tue, 13 Jan 2009
72
66
  def to_date
73
67
  ::Date.new(year, month, day)
74
68
  end
@@ -81,18 +75,11 @@ module ActiveSupport #:nodoc:
81
75
 
82
76
  # Converts a Time instance to a Ruby DateTime instance, preserving UTC offset.
83
77
  #
84
- # ==== Examples
85
- # my_time = Time.now
86
- # # => Mon Nov 12 23:04:21 -0500 2007
87
- #
88
- # my_time.to_datetime
89
- # # => Mon, 12 Nov 2007 23:04:21 -0500
90
- #
91
- # your_time = Time.parse("1/13/2009 1:13:03 P.M.")
92
- # # => Tue Jan 13 13:13:03 -0500 2009
78
+ # my_time = Time.now # => Mon Nov 12 23:04:21 -0500 2007
79
+ # my_time.to_datetime # => Mon, 12 Nov 2007 23:04:21 -0500
93
80
  #
94
- # your_time.to_datetime
95
- # # => Tue, 13 Jan 2009 13:13:03 -0500
81
+ # your_time = Time.parse("1/13/2009 1:13:03 P.M.") # => Tue Jan 13 13:13:03 -0500 2009
82
+ # your_time.to_datetime # => Tue, 13 Jan 2009 13:13:03 -0500
96
83
  def to_datetime
97
84
  ::DateTime.civil(year, month, day, hour, min, sec, Rational(utc_offset, 86400))
98
85
  end
@@ -0,0 +1,86 @@
1
+ module ActiveSupport #:nodoc:
2
+ module CoreExtensions #:nodoc:
3
+ module Time #:nodoc:
4
+ module Zones
5
+ def self.included(base) #:nodoc:
6
+ base.extend(ClassMethods) if base == ::Time # i.e., don't include class methods in DateTime
7
+ end
8
+
9
+ module ClassMethods
10
+ attr_accessor :zone_default
11
+
12
+ # Returns the TimeZone for the current request, if this has been set (via Time.zone=).
13
+ # If <tt>Time.zone</tt> has not been set for the current request, returns the TimeZone specified in <tt>config.time_zone</tt>.
14
+ def zone
15
+ Thread.current[:time_zone] || zone_default
16
+ end
17
+
18
+ # Sets <tt>Time.zone</tt> to a TimeZone object for the current request/thread.
19
+ #
20
+ # This method accepts any of the following:
21
+ #
22
+ # * A Rails TimeZone object.
23
+ # * An identifier for a Rails TimeZone object (e.g., "Eastern Time (US & Canada)", <tt>-5.hours</tt>).
24
+ # * A TZInfo::Timezone object.
25
+ # * An identifier for a TZInfo::Timezone object (e.g., "America/New_York").
26
+ #
27
+ # Here's an example of how you might set <tt>Time.zone</tt> on a per request basis -- <tt>current_user.time_zone</tt>
28
+ # just needs to return a string identifying the user's preferred TimeZone:
29
+ #
30
+ # class ApplicationController < ActionController::Base
31
+ # before_filter :set_time_zone
32
+ #
33
+ # def set_time_zone
34
+ # Time.zone = current_user.time_zone
35
+ # end
36
+ # end
37
+ def zone=(time_zone)
38
+ Thread.current[:time_zone] = get_zone(time_zone)
39
+ end
40
+
41
+ # Allows override of <tt>Time.zone</tt> locally inside supplied block; resets <tt>Time.zone</tt> to existing value when done.
42
+ def use_zone(time_zone)
43
+ old_zone, ::Time.zone = ::Time.zone, get_zone(time_zone)
44
+ yield
45
+ ensure
46
+ ::Time.zone = old_zone
47
+ end
48
+
49
+ # Returns <tt>Time.zone.now</tt> when <tt>config.time_zone</tt> is set, otherwise just returns <tt>Time.now</tt>.
50
+ def current
51
+ ::Time.zone_default ? ::Time.zone.now : ::Time.now
52
+ end
53
+
54
+ private
55
+ def get_zone(time_zone)
56
+ return time_zone if time_zone.nil? || time_zone.is_a?(TimeZone)
57
+ # lookup timezone based on identifier (unless we've been passed a TZInfo::Timezone)
58
+ unless time_zone.respond_to?(:period_for_local)
59
+ time_zone = TimeZone[time_zone] || TZInfo::Timezone.get(time_zone) rescue nil
60
+ end
61
+ # Return if a TimeZone instance, or wrap in a TimeZone instance if a TZInfo::Timezone
62
+ if time_zone
63
+ time_zone.is_a?(TimeZone) ? time_zone : TimeZone.create(time_zone.name, nil, time_zone)
64
+ end
65
+ end
66
+ end
67
+
68
+ # Returns the simultaneous time in <tt>Time.zone</tt>.
69
+ #
70
+ # Time.zone = 'Hawaii' # => 'Hawaii'
71
+ # Time.utc(2000).in_time_zone # => Fri, 31 Dec 1999 14:00:00 HST -10:00
72
+ #
73
+ # This method is similar to Time#localtime, except that it uses <tt>Time.zone</tt> as the local zone
74
+ # instead of the operating system's time zone.
75
+ #
76
+ # You can also pass in a TimeZone instance or string that identifies a TimeZone as an argument,
77
+ # and the conversion will be based on that zone instead of <tt>Time.zone</tt>.
78
+ #
79
+ # Time.utc(2000).in_time_zone('Alaska') # => Fri, 31 Dec 1999 15:00:00 AKST -09:00
80
+ def in_time_zone(zone = ::Time.zone)
81
+ ActiveSupport::TimeWithZone.new(utc? ? self : getutc, ::Time.send!(:get_zone, zone))
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
@@ -21,36 +21,36 @@ module Dependencies #:nodoc:
21
21
  # Should we load files or require them?
22
22
  mattr_accessor :mechanism
23
23
  self.mechanism = :load
24
-
24
+
25
25
  # The set of directories from which we may automatically load files. Files
26
26
  # under these directories will be reloaded on each request in development mode,
27
27
  # unless the directory also appears in load_once_paths.
28
28
  mattr_accessor :load_paths
29
29
  self.load_paths = []
30
-
30
+
31
31
  # The set of directories from which automatically loaded constants are loaded
32
32
  # only once. All directories in this set must also be present in +load_paths+.
33
33
  mattr_accessor :load_once_paths
34
34
  self.load_once_paths = []
35
-
35
+
36
36
  # An array of qualified constant names that have been loaded. Adding a name to
37
37
  # this array will cause it to be unloaded the next time Dependencies are cleared.
38
38
  mattr_accessor :autoloaded_constants
39
39
  self.autoloaded_constants = []
40
-
40
+
41
41
  # An array of constant names that need to be unloaded on every request. Used
42
42
  # to allow arbitrary constants to be marked for unloading.
43
43
  mattr_accessor :explicitly_unloadable_constants
44
44
  self.explicitly_unloadable_constants = []
45
-
45
+
46
46
  # Set to true to enable logging of const_missing and file loads
47
47
  mattr_accessor :log_activity
48
48
  self.log_activity = false
49
-
49
+
50
50
  # An internal stack used to record which constants are loaded by any block.
51
51
  mattr_accessor :constant_watch_stack
52
52
  self.constant_watch_stack = []
53
-
53
+
54
54
  def load?
55
55
  mechanism == :load
56
56
  end
@@ -81,66 +81,78 @@ module Dependencies #:nodoc:
81
81
  # Record that we've seen this file *before* loading it to avoid an
82
82
  # infinite loop with mutual dependencies.
83
83
  loaded << expanded
84
-
85
- if load?
86
- log "loading #{file_name}"
87
- begin
84
+
85
+ begin
86
+ if load?
87
+ log "loading #{file_name}"
88
+
88
89
  # Enable warnings iff this file has not been loaded before and
89
90
  # warnings_on_first_load is set.
90
91
  load_args = ["#{file_name}.rb"]
91
92
  load_args << const_path unless const_path.nil?
92
-
93
+
93
94
  if !warnings_on_first_load or history.include?(expanded)
94
95
  result = load_file(*load_args)
95
96
  else
96
97
  enable_warnings { result = load_file(*load_args) }
97
98
  end
98
- rescue Exception
99
- loaded.delete expanded
100
- raise
99
+ else
100
+ log "requiring #{file_name}"
101
+ result = require file_name
101
102
  end
102
- else
103
- log "requiring #{file_name}"
104
- result = require file_name
103
+ rescue Exception
104
+ loaded.delete expanded
105
+ raise
105
106
  end
106
107
 
107
108
  # Record history *after* loading so first load gets warnings.
108
109
  history << expanded
109
110
  return result
110
111
  end
111
-
112
+
112
113
  # Is the provided constant path defined?
113
114
  def qualified_const_defined?(path)
114
115
  raise NameError, "#{path.inspect} is not a valid constant name!" unless
115
116
  /^(::)?([A-Z]\w*)(::[A-Z]\w*)*$/ =~ path
116
-
117
+
117
118
  names = path.to_s.split('::')
118
119
  names.shift if names.first.empty?
119
-
120
+
120
121
  # We can't use defined? because it will invoke const_missing for the parent
121
122
  # of the name we are checking.
122
123
  names.inject(Object) do |mod, name|
123
- return false unless mod.const_defined? name
124
+ return false unless uninherited_const_defined?(mod, name)
124
125
  mod.const_get name
125
126
  end
126
127
  return true
127
128
  end
128
-
129
+
130
+ if Module.method(:const_defined?).arity == 1
131
+ # Does this module define this constant?
132
+ # Wrapper to accomodate changing Module#const_defined? in Ruby 1.9
133
+ def uninherited_const_defined?(mod, const)
134
+ mod.const_defined?(const)
135
+ end
136
+ else
137
+ def uninherited_const_defined?(mod, const) #:nodoc:
138
+ mod.const_defined?(const, false)
139
+ end
140
+ end
141
+
129
142
  # Given +path+, a filesystem path to a ruby file, return an array of constant
130
143
  # paths which would cause Dependencies to attempt to load this file.
131
- #
132
144
  def loadable_constants_for_path(path, bases = load_paths)
133
145
  path = $1 if path =~ /\A(.*)\.rb\Z/
134
146
  expanded_path = File.expand_path(path)
135
-
147
+
136
148
  bases.collect do |root|
137
149
  expanded_root = File.expand_path(root)
138
150
  next unless %r{\A#{Regexp.escape(expanded_root)}(/|\\)} =~ expanded_path
139
-
151
+
140
152
  nesting = expanded_path[(expanded_root.size)..-1]
141
153
  nesting = nesting[1..-1] if nesting && nesting[0] == ?/
142
154
  next if nesting.blank?
143
-
155
+
144
156
  [
145
157
  nesting.camelize,
146
158
  # Special case: application.rb might define ApplicationControlller.
@@ -148,7 +160,7 @@ module Dependencies #:nodoc:
148
160
  ]
149
161
  end.flatten.compact.uniq
150
162
  end
151
-
163
+
152
164
  # Search for a file in load_paths matching the provided suffix.
153
165
  def search_for_file(path_suffix)
154
166
  path_suffix = path_suffix + '.rb' unless path_suffix.ends_with? '.rb'
@@ -158,20 +170,20 @@ module Dependencies #:nodoc:
158
170
  end
159
171
  nil # Gee, I sure wish we had first_match ;-)
160
172
  end
161
-
173
+
162
174
  # Does the provided path_suffix correspond to an autoloadable module?
163
- # Instead of returning a boolean, the autoload base for this module is returned.
175
+ # Instead of returning a boolean, the autoload base for this module is returned.
164
176
  def autoloadable_module?(path_suffix)
165
177
  load_paths.each do |load_path|
166
178
  return load_path if File.directory? File.join(load_path, path_suffix)
167
179
  end
168
180
  nil
169
181
  end
170
-
182
+
171
183
  def load_once_path?(path)
172
184
  load_once_paths.any? { |base| path.starts_with? base }
173
185
  end
174
-
186
+
175
187
  # Attempt to autoload the provided module name by searching for a directory
176
188
  # matching the expect path suffix. If found, the module is created and assigned
177
189
  # to +into+'s constants with the name +const_name+. Provided that the directory
@@ -184,12 +196,12 @@ module Dependencies #:nodoc:
184
196
  autoloaded_constants << qualified_name unless load_once_paths.include?(base_path)
185
197
  return mod
186
198
  end
187
-
199
+
188
200
  # Load the file at the provided path. +const_paths+ is a set of qualified
189
201
  # constant names. When loading the file, Dependencies will watch for the
190
202
  # addition of these constants. Each that is defined will be marked as
191
203
  # autoloaded, and will be removed when Dependencies.clear is next called.
192
- #
204
+ #
193
205
  # If the second parameter is left off, then Dependencies will construct a set
194
206
  # of names that the file at +path+ may define. See
195
207
  # +loadable_constants_for_path+ for more details.
@@ -197,24 +209,24 @@ module Dependencies #:nodoc:
197
209
  log_call path, const_paths
198
210
  const_paths = [const_paths].compact unless const_paths.is_a? Array
199
211
  parent_paths = const_paths.collect { |const_path| /(.*)::[^:]+\Z/ =~ const_path ? $1 : :Object }
200
-
212
+
201
213
  result = nil
202
214
  newly_defined_paths = new_constants_in(*parent_paths) do
203
215
  result = load_without_new_constant_marking path
204
216
  end
205
-
217
+
206
218
  autoloaded_constants.concat newly_defined_paths unless load_once_path?(path)
207
219
  autoloaded_constants.uniq!
208
220
  log "loading #{path} defined #{newly_defined_paths * ', '}" unless newly_defined_paths.empty?
209
221
  return result
210
222
  end
211
-
223
+
212
224
  # Return the constant path for the provided parent and constant name.
213
225
  def qualified_name_for(mod, name)
214
226
  mod_name = to_constant_name mod
215
227
  (%w(Object Kernel).include? mod_name) ? name.to_s : "#{mod_name}::#{name}"
216
228
  end
217
-
229
+
218
230
  # Load the constant named +const_name+ which is missing from +from_mod+. If
219
231
  # it is not possible to load the constant into from_mod, try its parent module
220
232
  # using const_missing.
@@ -237,21 +249,21 @@ module Dependencies #:nodoc:
237
249
  raise ArgumentError, "A copy of #{from_mod} has been removed from the module tree but is still active!"
238
250
  end
239
251
 
240
- raise ArgumentError, "#{from_mod} is not missing constant #{const_name}!" if from_mod.const_defined?(const_name)
241
-
252
+ raise ArgumentError, "#{from_mod} is not missing constant #{const_name}!" if uninherited_const_defined?(from_mod, const_name)
253
+
242
254
  qualified_name = qualified_name_for from_mod, const_name
243
255
  path_suffix = qualified_name.underscore
244
256
  name_error = NameError.new("uninitialized constant #{qualified_name}")
245
-
257
+
246
258
  file_path = search_for_file(path_suffix)
247
259
  if file_path && ! loaded.include?(File.expand_path(file_path)) # We found a matching file to load
248
260
  require_or_load file_path
249
- raise LoadError, "Expected #{file_path} to define #{qualified_name}" unless from_mod.const_defined?(const_name)
261
+ raise LoadError, "Expected #{file_path} to define #{qualified_name}" unless uninherited_const_defined?(from_mod, const_name)
250
262
  return from_mod.const_get(const_name)
251
263
  elsif mod = autoload_module!(from_mod, const_name, qualified_name, path_suffix)
252
264
  return mod
253
265
  elsif (parent = from_mod.parent) && parent != from_mod &&
254
- ! from_mod.parents.any? { |p| p.const_defined?(const_name) }
266
+ ! from_mod.parents.any? { |p| uninherited_const_defined?(p, const_name) }
255
267
  # If our parents do not have a constant named +const_name+ then we are free
256
268
  # to attempt to load upwards. If they do have such a constant, then this
257
269
  # const_missing must be due to from_mod::const_name, which should not
@@ -266,7 +278,7 @@ module Dependencies #:nodoc:
266
278
  raise name_error
267
279
  end
268
280
  end
269
-
281
+
270
282
  # Remove the constants that have been autoloaded, and those that have been
271
283
  # marked for unloading.
272
284
  def remove_unloadable_constants!
@@ -274,7 +286,7 @@ module Dependencies #:nodoc:
274
286
  autoloaded_constants.clear
275
287
  explicitly_unloadable_constants.each { |const| remove_constant const }
276
288
  end
277
-
289
+
278
290
  # Determine if the given constant has been automatically loaded.
279
291
  def autoloaded?(desc)
280
292
  # No name => anonymous module.
@@ -283,13 +295,13 @@ module Dependencies #:nodoc:
283
295
  return false unless qualified_const_defined? name
284
296
  return autoloaded_constants.include?(name)
285
297
  end
286
-
298
+
287
299
  # Will the provided constant descriptor be unloaded?
288
300
  def will_unload?(const_desc)
289
- autoloaded?(const_desc) ||
301
+ autoloaded?(desc) ||
290
302
  explicitly_unloadable_constants.include?(to_constant_name(const_desc))
291
303
  end
292
-
304
+
293
305
  # Mark the provided constant name for unloading. This constant will be
294
306
  # unloaded on each request, not just the next one.
295
307
  def mark_for_unload(const_desc)
@@ -301,18 +313,18 @@ module Dependencies #:nodoc:
301
313
  return true
302
314
  end
303
315
  end
304
-
316
+
305
317
  # Run the provided block and detect the new constants that were loaded during
306
318
  # its execution. Constants may only be regarded as 'new' once -- so if the
307
319
  # block calls +new_constants_in+ again, then the constants defined within the
308
320
  # inner call will not be reported in this one.
309
- #
321
+ #
310
322
  # If the provided block does not run to completion, and instead raises an
311
323
  # exception, any new constants are regarded as being only partially defined
312
324
  # and will be removed immediately.
313
325
  def new_constants_in(*descs)
314
326
  log_call(*descs)
315
-
327
+
316
328
  # Build the watch frames. Each frame is a tuple of
317
329
  # [module_name_as_string, constants_defined_elsewhere]
318
330
  watch_frames = descs.collect do |desc|
@@ -321,7 +333,7 @@ module Dependencies #:nodoc:
321
333
  initial_constants = desc.local_constant_names
322
334
  elsif desc.is_a?(String) || desc.is_a?(Symbol)
323
335
  mod_name = desc.to_s
324
-
336
+
325
337
  # Handle the case where the module has yet to be defined.
326
338
  initial_constants = if qualified_const_defined?(mod_name)
327
339
  mod_name.constantize.local_constant_names
@@ -331,12 +343,12 @@ module Dependencies #:nodoc:
331
343
  else
332
344
  raise Argument, "#{desc.inspect} does not describe a module!"
333
345
  end
334
-
346
+
335
347
  [mod_name, initial_constants]
336
348
  end
337
-
349
+
338
350
  constant_watch_stack.concat watch_frames
339
-
351
+
340
352
  aborting = true
341
353
  begin
342
354
  yield # Now yield to the code that is to define new constants.
@@ -346,41 +358,41 @@ module Dependencies #:nodoc:
346
358
  new_constants = watch_frames.collect do |mod_name, prior_constants|
347
359
  # Module still doesn't exist? Treat it as if it has no constants.
348
360
  next [] unless qualified_const_defined?(mod_name)
349
-
361
+
350
362
  mod = mod_name.constantize
351
363
  next [] unless mod.is_a? Module
352
364
  new_constants = mod.local_constant_names - prior_constants
353
-
365
+
354
366
  # Make sure no other frames takes credit for these constants.
355
367
  constant_watch_stack.each do |frame_name, constants|
356
368
  constants.concat new_constants if frame_name == mod_name
357
369
  end
358
-
370
+
359
371
  new_constants.collect do |suffix|
360
372
  mod_name == "Object" ? suffix : "#{mod_name}::#{suffix}"
361
373
  end
362
374
  end.flatten
363
-
375
+
364
376
  log "New constants: #{new_constants * ', '}"
365
-
377
+
366
378
  if aborting
367
379
  log "Error during loading, removing partially loaded constants "
368
380
  new_constants.each { |name| remove_constant name }
369
381
  new_constants.clear
370
382
  end
371
383
  end
372
-
384
+
373
385
  return new_constants
374
386
  ensure
375
387
  # Remove the stack frames that we added.
376
- if defined?(watch_frames) && ! watch_frames.empty?
388
+ if defined?(watch_frames) && ! watch_frames.blank?
377
389
  frame_ids = watch_frames.collect(&:object_id)
378
390
  constant_watch_stack.delete_if do |watch_frame|
379
391
  frame_ids.include? watch_frame.object_id
380
392
  end
381
393
  end
382
394
  end
383
-
395
+
384
396
  class LoadingModule #:nodoc:
385
397
  # Old style environment.rb referenced this method directly. Please note, it doesn't
386
398
  # actually *do* anything any more.
@@ -423,18 +435,20 @@ module Dependencies #:nodoc:
423
435
 
424
436
  protected
425
437
  def log_call(*args)
426
- arg_str = args.collect(&:inspect) * ', '
427
- /in `([a-z_\?\!]+)'/ =~ caller(1).first
428
- selector = $1 || '<unknown>'
429
- log "called #{selector}(#{arg_str})"
438
+ if defined?(RAILS_DEFAULT_LOGGER) && RAILS_DEFAULT_LOGGER && log_activity
439
+ arg_str = args.collect(&:inspect) * ', '
440
+ /in `([a-z_\?\!]+)'/ =~ caller(1).first
441
+ selector = $1 || '<unknown>'
442
+ log "called #{selector}(#{arg_str})"
443
+ end
430
444
  end
431
-
445
+
432
446
  def log(msg)
433
447
  if defined?(RAILS_DEFAULT_LOGGER) && RAILS_DEFAULT_LOGGER && log_activity
434
448
  RAILS_DEFAULT_LOGGER.debug "Dependencies: #{msg}"
435
449
  end
436
450
  end
437
-
451
+
438
452
  end
439
453
 
440
454
  Object.instance_eval do
@@ -446,17 +460,17 @@ end
446
460
  class Module #:nodoc:
447
461
  # Rename the original handler so we can chain it to the new one
448
462
  alias :rails_original_const_missing :const_missing
449
-
463
+
450
464
  # Use const_missing to autoload associations so we don't have to
451
465
  # require_association when using single-table inheritance.
452
466
  def const_missing(class_id)
453
467
  Dependencies.load_missing_constant self, class_id
454
468
  end
455
-
469
+
456
470
  def unloadable(const_desc = self)
457
471
  super(const_desc)
458
472
  end
459
-
473
+
460
474
  end
461
475
 
462
476
  class Class
@@ -482,18 +496,17 @@ class Class
482
496
  end
483
497
 
484
498
  class Object
485
-
486
499
  alias_method :load_without_new_constant_marking, :load
487
-
500
+
488
501
  def load(file, *extras) #:nodoc:
489
- Dependencies.new_constants_in(Object) { super(file, *extras) }
502
+ Dependencies.new_constants_in(Object) { super }
490
503
  rescue Exception => exception # errors from loading file
491
504
  exception.blame_file! file
492
505
  raise
493
506
  end
494
507
 
495
508
  def require(file, *extras) #:nodoc:
496
- Dependencies.new_constants_in(Object) { super(file, *extras) }
509
+ Dependencies.new_constants_in(Object) { super }
497
510
  rescue Exception => exception # errors from required file
498
511
  exception.blame_file! file
499
512
  raise
@@ -501,21 +514,20 @@ class Object
501
514
 
502
515
  # Mark the given constant as unloadable. Unloadable constants are removed each
503
516
  # time dependencies are cleared.
504
- #
517
+ #
505
518
  # Note that marking a constant for unloading need only be done once. Setup
506
519
  # or init scripts may list each unloadable constant that may need unloading;
507
520
  # each constant will be removed for every subsequent clear, as opposed to for
508
521
  # the first clear.
509
- #
522
+ #
510
523
  # The provided constant descriptor may be a (non-anonymous) module or class,
511
524
  # or a qualified constant name as a string or symbol.
512
- #
525
+ #
513
526
  # Returns true if the constant was not previously marked for unloading, false
514
527
  # otherwise.
515
528
  def unloadable(const_desc)
516
529
  Dependencies.mark_for_unload const_desc
517
530
  end
518
-
519
531
  end
520
532
 
521
533
  # Add file-blaming to exceptions