activesupport 3.0.0.beta4 → 3.0.pre

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

Potentially problematic release.


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

Files changed (333) hide show
  1. data/CHANGELOG +1 -100
  2. data/lib/active_support.rb +4 -38
  3. data/lib/active_support/autoload.rb +28 -0
  4. data/lib/active_support/backtrace_cleaner.rb +9 -31
  5. data/lib/active_support/benchmarkable.rb +0 -1
  6. data/lib/active_support/buffered_logger.rb +1 -0
  7. data/lib/active_support/cache.rb +81 -436
  8. data/lib/active_support/cache/compressed_mem_cache_store.rb +13 -6
  9. data/lib/active_support/cache/file_store.rb +41 -139
  10. data/lib/active_support/cache/mem_cache_store.rb +75 -120
  11. data/lib/active_support/cache/memory_store.rb +27 -127
  12. data/lib/active_support/cache/strategy/local_cache.rb +58 -111
  13. data/lib/active_support/cache/synchronized_memory_store.rb +38 -2
  14. data/lib/active_support/callbacks.rb +48 -87
  15. data/lib/active_support/configurable.rb +18 -19
  16. data/lib/active_support/core_ext/array.rb +0 -1
  17. data/lib/active_support/core_ext/array/access.rb +1 -1
  18. data/lib/active_support/core_ext/array/conversions.rb +54 -29
  19. data/lib/active_support/core_ext/array/extract_options.rb +1 -16
  20. data/lib/active_support/core_ext/array/random_access.rb +5 -19
  21. data/lib/active_support/core_ext/array/wrap.rb +9 -13
  22. data/lib/active_support/core_ext/benchmark.rb +12 -0
  23. data/lib/active_support/core_ext/boolean.rb +1 -0
  24. data/lib/active_support/core_ext/boolean/conversions.rb +11 -0
  25. data/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +0 -2
  26. data/lib/active_support/core_ext/class.rb +1 -1
  27. data/lib/active_support/core_ext/class/attribute_accessors.rb +27 -33
  28. data/lib/active_support/core_ext/class/delegating_attributes.rb +41 -35
  29. data/lib/active_support/core_ext/class/inheritable_attributes.rb +13 -22
  30. data/lib/active_support/core_ext/class/removal.rb +53 -0
  31. data/lib/active_support/core_ext/date.rb +7 -0
  32. data/lib/active_support/core_ext/date/calculations.rb +8 -30
  33. data/lib/active_support/core_ext/date/conversions.rb +2 -2
  34. data/lib/active_support/core_ext/date_time.rb +5 -0
  35. data/lib/active_support/core_ext/date_time/calculations.rb +1 -2
  36. data/lib/active_support/core_ext/date_time/conversions.rb +5 -23
  37. data/lib/active_support/core_ext/enumerable.rb +9 -5
  38. data/lib/active_support/core_ext/exception.rb +47 -0
  39. data/lib/active_support/core_ext/file.rb +0 -1
  40. data/lib/active_support/core_ext/file/atomic.rb +2 -3
  41. data/lib/active_support/core_ext/float/rounding.rb +2 -3
  42. data/lib/active_support/core_ext/hash/conversions.rb +145 -65
  43. data/lib/active_support/core_ext/hash/deep_merge.rb +7 -6
  44. data/lib/active_support/core_ext/hash/except.rb +0 -8
  45. data/lib/active_support/core_ext/hash/indifferent_access.rb +0 -5
  46. data/lib/active_support/core_ext/hash/keys.rb +11 -10
  47. data/lib/active_support/core_ext/hash/slice.rb +0 -6
  48. data/lib/active_support/core_ext/integer.rb +1 -1
  49. data/lib/active_support/core_ext/integer/even_odd.rb +16 -0
  50. data/lib/active_support/core_ext/kernel.rb +1 -1
  51. data/lib/active_support/core_ext/kernel/daemonizing.rb +7 -0
  52. data/lib/active_support/core_ext/kernel/debugger.rb +2 -3
  53. data/lib/active_support/core_ext/kernel/reporting.rb +1 -2
  54. data/lib/active_support/core_ext/load_error.rb +30 -17
  55. data/lib/active_support/core_ext/logger.rb +1 -1
  56. data/lib/active_support/core_ext/module.rb +3 -5
  57. data/lib/active_support/core_ext/module/aliasing.rb +1 -1
  58. data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +1 -1
  59. data/lib/active_support/core_ext/module/attr_internal.rb +2 -2
  60. data/lib/active_support/core_ext/module/attribute_accessors.rb +21 -25
  61. data/lib/active_support/core_ext/module/delegation.rb +10 -21
  62. data/lib/active_support/core_ext/module/inclusion.rb +30 -0
  63. data/lib/active_support/core_ext/module/introspection.rb +8 -8
  64. data/lib/active_support/core_ext/module/loading.rb +23 -0
  65. data/lib/active_support/core_ext/module/synchronization.rb +1 -2
  66. data/lib/active_support/core_ext/name_error.rb +1 -3
  67. data/lib/active_support/core_ext/nil.rb +1 -0
  68. data/lib/active_support/core_ext/nil/conversions.rb +5 -0
  69. data/lib/active_support/core_ext/object.rb +2 -6
  70. data/lib/active_support/core_ext/object/blank.rb +2 -20
  71. data/lib/active_support/core_ext/object/conversions.rb +16 -2
  72. data/lib/active_support/core_ext/object/duplicable.rb +1 -23
  73. data/lib/active_support/core_ext/object/extending.rb +77 -8
  74. data/lib/active_support/core_ext/object/instance_variables.rb +7 -0
  75. data/lib/active_support/core_ext/object/metaclass.rb +13 -0
  76. data/lib/active_support/core_ext/object/misc.rb +1 -0
  77. data/lib/active_support/core_ext/object/tap.rb +16 -0
  78. data/lib/active_support/core_ext/object/with_options.rb +0 -2
  79. data/lib/active_support/core_ext/proc.rb +4 -4
  80. data/lib/active_support/core_ext/regexp.rb +22 -0
  81. data/lib/active_support/core_ext/rexml.rb +1 -4
  82. data/lib/active_support/core_ext/string.rb +2 -3
  83. data/lib/active_support/core_ext/string/access.rb +2 -4
  84. data/lib/active_support/core_ext/string/bytesize.rb +5 -0
  85. data/lib/active_support/core_ext/string/conversions.rb +1 -36
  86. data/lib/active_support/core_ext/string/filters.rb +0 -29
  87. data/lib/active_support/core_ext/string/inflections.rb +12 -1
  88. data/lib/active_support/core_ext/string/interpolation.rb +92 -2
  89. data/lib/active_support/core_ext/string/iterators.rb +13 -0
  90. data/lib/active_support/core_ext/string/multibyte.rb +19 -16
  91. data/lib/active_support/core_ext/string/output_safety.rb +35 -101
  92. data/lib/active_support/core_ext/string/starts_ends_with.rb +14 -0
  93. data/lib/active_support/core_ext/string/xchar.rb +1 -1
  94. data/lib/active_support/core_ext/symbol.rb +1 -0
  95. data/lib/active_support/core_ext/symbol/to_proc.rb +14 -0
  96. data/lib/active_support/core_ext/time.rb +10 -0
  97. data/lib/active_support/core_ext/time/calculations.rb +7 -9
  98. data/lib/active_support/core_ext/time/conversions.rb +0 -1
  99. data/lib/active_support/core_ext/time/marshal_with_utc_flag.rb +22 -0
  100. data/lib/active_support/core_ext/uri.rb +4 -10
  101. data/lib/active_support/dependencies.rb +192 -179
  102. data/lib/active_support/deprecated_callbacks.rb +283 -0
  103. data/lib/active_support/deprecation/behaviors.rb +1 -1
  104. data/lib/active_support/deprecation/method_wrappers.rb +9 -10
  105. data/lib/active_support/deprecation/reporting.rb +1 -2
  106. data/lib/active_support/duration.rb +2 -6
  107. data/lib/active_support/hash_with_indifferent_access.rb +1 -9
  108. data/lib/active_support/inflections.rb +1 -1
  109. data/lib/active_support/inflector.rb +407 -4
  110. data/lib/active_support/json/backends/jsongem.rb +9 -12
  111. data/lib/active_support/json/decoding.rb +1 -16
  112. data/lib/active_support/json/encoding.rb +12 -42
  113. data/lib/active_support/locale/en.yml +1 -4
  114. data/lib/active_support/memoizable.rb +1 -1
  115. data/lib/active_support/message_encryptor.rb +0 -1
  116. data/lib/active_support/message_verifier.rb +5 -6
  117. data/lib/active_support/multibyte.rb +22 -7
  118. data/lib/active_support/multibyte/chars.rb +392 -164
  119. data/lib/active_support/multibyte/unicode_database.rb +71 -0
  120. data/lib/active_support/multibyte/utils.rb +7 -6
  121. data/lib/active_support/notifications.rb +113 -23
  122. data/lib/active_support/ordered_hash.rb +11 -35
  123. data/lib/active_support/ordered_options.rb +0 -6
  124. data/lib/active_support/rescuable.rb +4 -7
  125. data/lib/active_support/ruby/shim.rb +6 -4
  126. data/lib/active_support/test_case.rb +7 -2
  127. data/lib/active_support/testing/assertions.rb +0 -15
  128. data/lib/active_support/testing/declarative.rb +1 -1
  129. data/lib/active_support/testing/isolation.rb +19 -63
  130. data/lib/active_support/testing/performance.rb +337 -342
  131. data/lib/active_support/testing/setup_and_teardown.rb +29 -51
  132. data/lib/active_support/time.rb +3 -23
  133. data/lib/active_support/time_with_zone.rb +10 -5
  134. data/lib/active_support/values/time_zone.rb +84 -40
  135. data/lib/active_support/values/unicode_tables.dat +0 -0
  136. data/lib/active_support/vendor.rb +16 -0
  137. data/lib/active_support/vendor/builder-2.1.2/lib/blankslate.rb +113 -0
  138. data/lib/active_support/vendor/builder-2.1.2/lib/builder.rb +13 -0
  139. data/lib/active_support/vendor/builder-2.1.2/lib/builder/blankslate.rb +20 -0
  140. data/lib/active_support/vendor/builder-2.1.2/lib/builder/css.rb +250 -0
  141. data/lib/active_support/vendor/builder-2.1.2/lib/builder/xchar.rb +115 -0
  142. data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlbase.rb +139 -0
  143. data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlevents.rb +63 -0
  144. data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlmarkup.rb +328 -0
  145. data/lib/active_support/vendor/i18n-0.1.3/MIT-LICENSE +20 -0
  146. data/lib/active_support/vendor/i18n-0.1.3/README.textile +20 -0
  147. data/lib/active_support/vendor/i18n-0.1.3/Rakefile +5 -0
  148. data/lib/active_support/vendor/i18n-0.1.3/i18n.gemspec +27 -0
  149. data/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb +204 -0
  150. data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb +215 -0
  151. data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/exceptions.rb +53 -0
  152. data/lib/active_support/vendor/i18n-0.1.3/test/all.rb +5 -0
  153. data/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb +99 -0
  154. data/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb +124 -0
  155. data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.rb +1 -0
  156. data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.yml +3 -0
  157. data/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb +567 -0
  158. data/lib/active_support/vendor/memcache-client-1.7.5/lib/memcache.rb +1133 -0
  159. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo.rb +33 -0
  160. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/data_timezone.rb +47 -0
  161. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/data_timezone_info.rb +228 -0
  162. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Algiers.rb +55 -0
  163. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Cairo.rb +219 -0
  164. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Casablanca.rb +42 -0
  165. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Harare.rb +18 -0
  166. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Johannesburg.rb +25 -0
  167. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Monrovia.rb +22 -0
  168. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Nairobi.rb +23 -0
  169. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +166 -0
  170. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Argentina/San_Juan.rb +86 -0
  171. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Bogota.rb +23 -0
  172. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Caracas.rb +23 -0
  173. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Chicago.rb +283 -0
  174. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Chihuahua.rb +136 -0
  175. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Denver.rb +204 -0
  176. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Godthab.rb +161 -0
  177. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Guatemala.rb +27 -0
  178. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Halifax.rb +274 -0
  179. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Indiana/Indianapolis.rb +149 -0
  180. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Juneau.rb +194 -0
  181. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/La_Paz.rb +22 -0
  182. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Lima.rb +35 -0
  183. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Los_Angeles.rb +232 -0
  184. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Mazatlan.rb +139 -0
  185. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Mexico_City.rb +144 -0
  186. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Monterrey.rb +131 -0
  187. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/New_York.rb +282 -0
  188. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Phoenix.rb +30 -0
  189. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Regina.rb +74 -0
  190. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Santiago.rb +205 -0
  191. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Sao_Paulo.rb +171 -0
  192. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/St_Johns.rb +288 -0
  193. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Tijuana.rb +196 -0
  194. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Almaty.rb +67 -0
  195. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Baghdad.rb +73 -0
  196. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Baku.rb +161 -0
  197. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Bangkok.rb +20 -0
  198. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Chongqing.rb +33 -0
  199. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Colombo.rb +30 -0
  200. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Dhaka.rb +27 -0
  201. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Hong_Kong.rb +87 -0
  202. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Irkutsk.rb +165 -0
  203. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Jakarta.rb +30 -0
  204. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Jerusalem.rb +163 -0
  205. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kabul.rb +20 -0
  206. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kamchatka.rb +163 -0
  207. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Karachi.rb +32 -0
  208. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kathmandu.rb +20 -0
  209. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kolkata.rb +25 -0
  210. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Krasnoyarsk.rb +163 -0
  211. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kuala_Lumpur.rb +31 -0
  212. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kuwait.rb +18 -0
  213. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Magadan.rb +163 -0
  214. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Muscat.rb +18 -0
  215. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Novosibirsk.rb +164 -0
  216. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Rangoon.rb +24 -0
  217. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Riyadh.rb +18 -0
  218. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Seoul.rb +34 -0
  219. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Shanghai.rb +35 -0
  220. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Singapore.rb +33 -0
  221. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Taipei.rb +59 -0
  222. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tashkent.rb +47 -0
  223. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tbilisi.rb +78 -0
  224. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tehran.rb +121 -0
  225. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tokyo.rb +30 -0
  226. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Ulaanbaatar.rb +65 -0
  227. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Urumqi.rb +33 -0
  228. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Vladivostok.rb +164 -0
  229. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yakutsk.rb +163 -0
  230. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yekaterinburg.rb +165 -0
  231. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yerevan.rb +165 -0
  232. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/Azores.rb +270 -0
  233. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/Cape_Verde.rb +23 -0
  234. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/South_Georgia.rb +18 -0
  235. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Adelaide.rb +187 -0
  236. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Brisbane.rb +35 -0
  237. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Darwin.rb +29 -0
  238. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Hobart.rb +193 -0
  239. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Melbourne.rb +185 -0
  240. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Perth.rb +37 -0
  241. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Sydney.rb +185 -0
  242. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Etc/UTC.rb +16 -0
  243. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Amsterdam.rb +228 -0
  244. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Athens.rb +185 -0
  245. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Belgrade.rb +163 -0
  246. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Berlin.rb +188 -0
  247. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Bratislava.rb +13 -0
  248. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Brussels.rb +232 -0
  249. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Bucharest.rb +181 -0
  250. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Budapest.rb +197 -0
  251. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Copenhagen.rb +179 -0
  252. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Dublin.rb +276 -0
  253. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Helsinki.rb +163 -0
  254. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Istanbul.rb +218 -0
  255. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Kiev.rb +168 -0
  256. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Lisbon.rb +268 -0
  257. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Ljubljana.rb +13 -0
  258. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/London.rb +288 -0
  259. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Madrid.rb +211 -0
  260. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Minsk.rb +170 -0
  261. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Moscow.rb +181 -0
  262. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Paris.rb +232 -0
  263. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Prague.rb +187 -0
  264. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Riga.rb +176 -0
  265. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Rome.rb +215 -0
  266. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Sarajevo.rb +13 -0
  267. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Skopje.rb +13 -0
  268. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Sofia.rb +173 -0
  269. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Stockholm.rb +165 -0
  270. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Tallinn.rb +172 -0
  271. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Vienna.rb +183 -0
  272. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Vilnius.rb +170 -0
  273. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Warsaw.rb +212 -0
  274. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Zagreb.rb +13 -0
  275. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Auckland.rb +202 -0
  276. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Fiji.rb +23 -0
  277. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Guam.rb +22 -0
  278. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Honolulu.rb +28 -0
  279. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Majuro.rb +20 -0
  280. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Midway.rb +25 -0
  281. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Noumea.rb +25 -0
  282. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Pago_Pago.rb +26 -0
  283. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Port_Moresby.rb +20 -0
  284. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Tongatapu.rb +27 -0
  285. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/info_timezone.rb +52 -0
  286. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/linked_timezone.rb +51 -0
  287. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/linked_timezone_info.rb +44 -0
  288. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/offset_rationals.rb +98 -0
  289. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/ruby_core_support.rb +56 -0
  290. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/time_or_datetime.rb +292 -0
  291. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone.rb +508 -0
  292. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_definition.rb +56 -0
  293. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_info.rb +40 -0
  294. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_offset_info.rb +94 -0
  295. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_period.rb +198 -0
  296. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_transition_info.rb +129 -0
  297. data/lib/active_support/version.rb +2 -3
  298. data/lib/active_support/whiny_nil.rb +7 -9
  299. data/lib/active_support/xml_mini.rb +1 -126
  300. data/lib/active_support/xml_mini/jdom.rb +0 -2
  301. data/lib/active_support/xml_mini/libxml.rb +86 -24
  302. data/lib/active_support/xml_mini/nokogiri.rb +24 -27
  303. data/lib/active_support/xml_mini/rexml.rb +1 -7
  304. metadata +191 -49
  305. data/lib/active_support/builder.rb +0 -6
  306. data/lib/active_support/core_ext/array/uniq_by.rb +0 -17
  307. data/lib/active_support/core_ext/class/attribute.rb +0 -67
  308. data/lib/active_support/core_ext/class/subclasses.rb +0 -55
  309. data/lib/active_support/core_ext/file/path.rb +0 -5
  310. data/lib/active_support/core_ext/integer/multiple.rb +0 -6
  311. data/lib/active_support/core_ext/kernel/singleton_class.rb +0 -13
  312. data/lib/active_support/core_ext/module/anonymous.rb +0 -24
  313. data/lib/active_support/core_ext/module/method_names.rb +0 -14
  314. data/lib/active_support/core_ext/module/reachable.rb +0 -10
  315. data/lib/active_support/core_ext/module/remove_method.rb +0 -6
  316. data/lib/active_support/core_ext/object/to_param.rb +0 -49
  317. data/lib/active_support/core_ext/object/to_query.rb +0 -27
  318. data/lib/active_support/core_ext/string/encoding.rb +0 -11
  319. data/lib/active_support/core_ext/string/exclude.rb +0 -6
  320. data/lib/active_support/core_ext/time/marshal.rb +0 -56
  321. data/lib/active_support/dependencies/autoload.rb +0 -50
  322. data/lib/active_support/i18n.rb +0 -8
  323. data/lib/active_support/inflector/inflections.rb +0 -211
  324. data/lib/active_support/inflector/methods.rb +0 -141
  325. data/lib/active_support/inflector/transliterate.rb +0 -97
  326. data/lib/active_support/json/backends/yajl.rb +0 -40
  327. data/lib/active_support/lazy_load_hooks.rb +0 -27
  328. data/lib/active_support/multibyte/unicode.rb +0 -393
  329. data/lib/active_support/notifications/fanout.rb +0 -93
  330. data/lib/active_support/notifications/instrumenter.rb +0 -56
  331. data/lib/active_support/railtie.rb +0 -100
  332. data/lib/active_support/xml_mini/libxmlsax.rb +0 -85
  333. data/lib/active_support/xml_mini/nokogirisax.rb +0 -83
@@ -1,22 +1,18 @@
1
1
  class Array
2
2
  # Wraps the object in an Array unless it's an Array. Converts the
3
3
  # object to an Array using #to_ary if it implements that.
4
- #
5
- # It differs with Array() in that it does not call +to_a+ on
6
- # the argument:
7
- #
8
- # Array(:foo => :bar) # => [[:foo, :bar]]
9
- # Array.wrap(:foo => :bar) # => [{:foo => :bar}]
10
- #
11
- # Array("foo\nbar") # => ["foo\n", "bar"], in Ruby 1.8
12
- # Array.wrap("foo\nbar") # => ["foo\nbar"]
13
4
  def self.wrap(object)
14
- if object.nil?
5
+ case object
6
+ when nil
15
7
  []
16
- elsif object.respond_to?(:to_ary)
17
- object.to_ary
8
+ when self
9
+ object
18
10
  else
19
- [object]
11
+ if object.respond_to?(:to_ary)
12
+ object.to_ary
13
+ else
14
+ [object]
15
+ end
20
16
  end
21
17
  end
22
18
  end
@@ -1,6 +1,18 @@
1
1
  require 'benchmark'
2
2
 
3
3
  class << Benchmark
4
+ # Earlier Ruby had a slower implementation.
5
+ if RUBY_VERSION < '1.8.7'
6
+ remove_method :realtime
7
+
8
+ def realtime
9
+ r0 = Time.now
10
+ yield
11
+ r1 = Time.now
12
+ r1.to_f - r0.to_f
13
+ end
14
+ end
15
+
4
16
  def ms
5
17
  1000 * realtime { yield }
6
18
  end
@@ -0,0 +1 @@
1
+ require 'active_support/core_ext/boolean/conversions'
@@ -0,0 +1,11 @@
1
+ class TrueClass
2
+ def to_param
3
+ self
4
+ end
5
+ end
6
+
7
+ class FalseClass
8
+ def to_param
9
+ self
10
+ end
11
+ end
@@ -1,5 +1,3 @@
1
- require 'cgi'
2
-
3
1
  class CGI #:nodoc:
4
2
  if RUBY_VERSION >= '1.9'
5
3
  def self.escape_skipping_slashes(str)
@@ -1,4 +1,4 @@
1
1
  require 'active_support/core_ext/class/attribute_accessors'
2
2
  require 'active_support/core_ext/class/inheritable_attributes'
3
+ require 'active_support/core_ext/class/removal'
3
4
  require 'active_support/core_ext/class/delegating_attributes'
4
- require 'active_support/core_ext/class/subclasses'
@@ -10,48 +10,42 @@ require 'active_support/core_ext/array/extract_options'
10
10
  # Person.hair_colors = [:brown, :black, :blonde, :red]
11
11
  class Class
12
12
  def cattr_reader(*syms)
13
- options = syms.extract_options!
14
- syms.each do |sym|
13
+ syms.flatten.each do |sym|
14
+ next if sym.is_a?(Hash)
15
15
  class_eval(<<-EOS, __FILE__, __LINE__ + 1)
16
- unless defined? @@#{sym}
17
- @@#{sym} = nil
18
- end
19
-
20
- def self.#{sym}
21
- @@#{sym}
22
- end
16
+ unless defined? @@#{sym} # unless defined? @@hair_colors
17
+ @@#{sym} = nil # @@hair_colors = nil
18
+ end # end
19
+ #
20
+ def self.#{sym} # def self.hair_colors
21
+ @@#{sym} # @@hair_colors
22
+ end # end
23
+ #
24
+ def #{sym} # def hair_colors
25
+ @@#{sym} # @@hair_colors
26
+ end # end
23
27
  EOS
24
-
25
- unless options[:instance_reader] == false
26
- class_eval(<<-EOS, __FILE__, __LINE__ + 1)
27
- def #{sym}
28
- @@#{sym}
29
- end
30
- EOS
31
- end
32
28
  end
33
29
  end
34
30
 
35
31
  def cattr_writer(*syms)
36
32
  options = syms.extract_options!
37
- syms.each do |sym|
33
+ syms.flatten.each do |sym|
38
34
  class_eval(<<-EOS, __FILE__, __LINE__ + 1)
39
- unless defined? @@#{sym}
40
- @@#{sym} = nil
41
- end
42
-
43
- def self.#{sym}=(obj)
44
- @@#{sym} = obj
45
- end
35
+ unless defined? @@#{sym} # unless defined? @@hair_colors
36
+ @@#{sym} = nil # @@hair_colors = nil
37
+ end # end
38
+ #
39
+ def self.#{sym}=(obj) # def self.hair_colors=(obj)
40
+ @@#{sym} = obj # @@hair_colors = obj
41
+ end # end
42
+ #
43
+ #{" #
44
+ def #{sym}=(obj) # def hair_colors=(obj)
45
+ @@#{sym} = obj # @@hair_colors = obj
46
+ end # end
47
+ " unless options[:instance_writer] == false } # # instance writer above is generated unless options[:instance_writer] == false
46
48
  EOS
47
-
48
- unless options[:instance_writer] == false
49
- class_eval(<<-EOS, __FILE__, __LINE__ + 1)
50
- def #{sym}=(obj)
51
- @@#{sym} = obj
52
- end
53
- EOS
54
- end
55
49
  self.send("#{sym}=", yield) if block_given?
56
50
  end
57
51
  end
@@ -1,44 +1,50 @@
1
1
  require 'active_support/core_ext/object/blank'
2
- require 'active_support/core_ext/array/extract_options'
3
- require 'active_support/core_ext/kernel/singleton_class'
4
- require 'active_support/core_ext/module/remove_method'
5
2
 
6
3
  class Class
7
- def superclass_delegating_accessor(name, options = {})
8
- # Create private _name and _name= methods that can still be used if the public
9
- # methods are overridden. This allows
10
- _superclass_delegating_accessor("_#{name}")
11
-
12
- # Generate the public methods name, name=, and name?
13
- # These methods dispatch to the private _name, and _name= methods, making them
14
- # overridable
15
- singleton_class.send(:define_method, name) { send("_#{name}") }
16
- singleton_class.send(:define_method, "#{name}?") { !!send("_#{name}") }
17
- singleton_class.send(:define_method, "#{name}=") { |value| send("_#{name}=", value) }
18
-
19
- # If an instance_reader is needed, generate methods for name and name= on the
20
- # class itself, so instances will be able to see them
21
- define_method(name) { send("_#{name}") } if options[:instance_reader] != false
22
- define_method("#{name}?") { !!send("#{name}") } if options[:instance_reader] != false
23
- end
24
-
25
- private
26
-
27
- # Take the object being set and store it in a method. This gives us automatic
28
- # inheritance behavior, without having to store the object in an instance
29
- # variable and look up the superclass chain manually.
30
- def _stash_object_in_method(object, method, instance_reader = true)
31
- singleton_class.remove_possible_method(method)
32
- singleton_class.send(:define_method, method) { object }
33
- remove_possible_method(method)
34
- define_method(method) { object } if instance_reader
4
+ def superclass_delegating_reader(*names)
5
+ class_name_to_stop_searching_on = superclass.name.blank? ? "Object" : superclass.name
6
+ names.each do |name|
7
+ class_eval(<<-EOS, __FILE__, __LINE__ + 1)
8
+ def self.#{name} # def self.only_reader
9
+ if defined?(@#{name}) # if defined?(@only_reader)
10
+ @#{name} # @only_reader
11
+ elsif superclass < #{class_name_to_stop_searching_on} && # elsif superclass < Object &&
12
+ superclass.respond_to?(:#{name}) # superclass.respond_to?(:only_reader)
13
+ superclass.#{name} # superclass.only_reader
14
+ end # end
15
+ end # end
16
+ def #{name} # def only_reader
17
+ self.class.#{name} # self.class.only_reader
18
+ end # end
19
+ def self.#{name}? # def self.only_reader?
20
+ !!#{name} # !!only_reader
21
+ end # end
22
+ def #{name}? # def only_reader?
23
+ !!#{name} # !!only_reader
24
+ end # end
25
+ EOS
26
+ end
35
27
  end
36
28
 
37
- def _superclass_delegating_accessor(name, options = {})
38
- singleton_class.send(:define_method, "#{name}=") do |value|
39
- _stash_object_in_method(value, name, options[:instance_reader] != false)
29
+ def superclass_delegating_writer(*names, &block)
30
+ names.each do |name|
31
+ class_eval(<<-EOS, __FILE__, __LINE__ + 1)
32
+ def self.#{name}=(value) # def self.property=(value)
33
+ @#{name} = value # @property = value
34
+ end # end
35
+ EOS
36
+ self.send("#{name}=", yield) if block_given?
40
37
  end
41
- send("#{name}=", nil)
42
38
  end
43
39
 
40
+ # These class attributes behave something like the class
41
+ # inheritable accessors. But instead of copying the hash over at
42
+ # the time the subclass is first defined, the accessors simply
43
+ # delegate to their superclass unless they have been given a
44
+ # specific value. This stops the strange situation where values
45
+ # set after class definition don't get applied to subclasses.
46
+ def superclass_delegating_accessor(*names, &block)
47
+ superclass_delegating_reader(*names)
48
+ superclass_delegating_writer(*names, &block)
49
+ end
44
50
  end
@@ -1,5 +1,4 @@
1
1
  require 'active_support/core_ext/object/duplicable'
2
- require 'active_support/core_ext/array/extract_options'
3
2
 
4
3
  # Retain for backward compatibility. Methods are now included in Class.
5
4
  module ClassInheritableAttributes # :nodoc:
@@ -9,24 +8,18 @@ end
9
8
  # their parents' attributes, instead of just a pointer to the same. This means that the child can add elements
10
9
  # to, for example, an array without those additions being shared with either their parent, siblings, or
11
10
  # children, which is unlike the regular class-level attributes that are shared across the entire hierarchy.
12
- #
13
- # The copies of inheritable parent attributes are added to subclasses when they are created, via the
14
- # +inherited+ hook.
15
11
  class Class # :nodoc:
16
12
  def class_inheritable_reader(*syms)
17
- options = syms.extract_options!
18
13
  syms.each do |sym|
19
14
  next if sym.is_a?(Hash)
20
15
  class_eval(<<-EOS, __FILE__, __LINE__ + 1)
21
- def self.#{sym} # def self.after_add
22
- read_inheritable_attribute(:#{sym}) # read_inheritable_attribute(:after_add)
23
- end # end
24
- #
25
- #{" #
26
- def #{sym} # def after_add
27
- self.class.#{sym} # self.class.after_add
28
- end # end
29
- " unless options[:instance_reader] == false } # # the reader above is generated unless options[:instance_reader] == false
16
+ def self.#{sym} # def self.after_add
17
+ read_inheritable_attribute(:#{sym}) # read_inheritable_attribute(:after_add)
18
+ end # end
19
+
20
+ def #{sym} # def after_add
21
+ self.class.#{sym} # self.class.after_add
22
+ end # end
30
23
  EOS
31
24
  end
32
25
  end
@@ -162,8 +155,8 @@ class Class
162
155
  # (error out or do the same as other methods above) instead of silently
163
156
  # moving on). In particular, this makes the return value of this function
164
157
  # less useful.
165
- def extlib_inheritable_reader(*ivars, &block)
166
- options = ivars.extract_options!
158
+ def extlib_inheritable_reader(*ivars)
159
+ instance_reader = ivars.pop[:reader] if ivars.last.is_a?(Hash)
167
160
 
168
161
  ivars.each do |ivar|
169
162
  self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
@@ -171,17 +164,16 @@ class Class
171
164
  return @#{ivar} if self.object_id == #{self.object_id} || defined?(@#{ivar})
172
165
  ivar = superclass.#{ivar}
173
166
  return nil if ivar.nil? && !#{self}.instance_variable_defined?("@#{ivar}")
174
- @#{ivar} = ivar.duplicable? ? ivar.dup : ivar
167
+ @#{ivar} = ivar && !ivar.is_a?(Module) && !ivar.is_a?(Numeric) && !ivar.is_a?(TrueClass) && !ivar.is_a?(FalseClass) ? ivar.dup : ivar
175
168
  end
176
169
  RUBY
177
- unless options[:instance_reader] == false
170
+ unless instance_reader == false
178
171
  self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
179
172
  def #{ivar}
180
173
  self.class.#{ivar}
181
174
  end
182
175
  RUBY
183
176
  end
184
- instance_variable_set(:"@#{ivar}", yield) if block_given?
185
177
  end
186
178
  end
187
179
 
@@ -198,15 +190,14 @@ class Class
198
190
  # @todo We need a style for class_eval <<-HEREDOC. I'd like to make it
199
191
  # class_eval(<<-RUBY, __FILE__, __LINE__), but we should codify it somewhere.
200
192
  def extlib_inheritable_writer(*ivars)
201
- options = ivars.extract_options!
202
-
193
+ instance_writer = ivars.pop[:writer] if ivars.last.is_a?(Hash)
203
194
  ivars.each do |ivar|
204
195
  self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
205
196
  def self.#{ivar}=(obj)
206
197
  @#{ivar} = obj
207
198
  end
208
199
  RUBY
209
- unless options[:instance_writer] == false
200
+ unless instance_writer == false
210
201
  self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
211
202
  def #{ivar}=(obj) self.class.#{ivar} = obj end
212
203
  RUBY
@@ -0,0 +1,53 @@
1
+ require 'active_support/core_ext/object/extending'
2
+ require 'active_support/core_ext/module/introspection'
3
+
4
+ class Class #:nodoc:
5
+
6
+ # Unassociates the class with its subclasses and removes the subclasses
7
+ # themselves.
8
+ #
9
+ # Integer.remove_subclasses # => [Bignum, Fixnum]
10
+ # Fixnum # => NameError: uninitialized constant Fixnum
11
+ def remove_subclasses
12
+ Object.remove_subclasses_of(self)
13
+ end
14
+
15
+ # Returns an array with the names of the subclasses of +self+ as strings.
16
+ #
17
+ # Integer.subclasses # => ["Bignum", "Fixnum"]
18
+ def subclasses
19
+ Object.subclasses_of(self).map { |o| o.to_s }
20
+ end
21
+
22
+ # Removes the classes in +klasses+ from their parent module.
23
+ #
24
+ # Ordinary classes belong to some module via a constant. This method computes
25
+ # that constant name from the class name and removes it from the module it
26
+ # belongs to.
27
+ #
28
+ # Object.remove_class(Integer) # => [Integer]
29
+ # Integer # => NameError: uninitialized constant Integer
30
+ #
31
+ # Take into account that in general the class object could be still stored
32
+ # somewhere else.
33
+ #
34
+ # i = Integer # => Integer
35
+ # Object.remove_class(Integer) # => [Integer]
36
+ # Integer # => NameError: uninitialized constant Integer
37
+ # i.subclasses # => ["Bignum", "Fixnum"]
38
+ # Fixnum.superclass # => Integer
39
+ def remove_class(*klasses)
40
+ klasses.flatten.each do |klass|
41
+ # Skip this class if there is nothing bound to this name
42
+ next unless defined?(klass.name)
43
+
44
+ basename = klass.to_s.split("::").last
45
+ parent = klass.parent
46
+
47
+ # Skip this class if it does not match the current one bound to this name
48
+ next unless parent.const_defined?(basename) && klass = parent.const_get(basename)
49
+
50
+ parent.instance_eval { remove_const basename } unless parent == klass
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,7 @@
1
+ require 'date'
2
+
3
+ require 'active_support/core_ext/date/acts_like'
4
+ require 'active_support/core_ext/date/freeze'
5
+
6
+ require 'active_support/core_ext/date/calculations'
7
+ require 'active_support/core_ext/date/conversions'
@@ -1,36 +1,15 @@
1
- require 'date'
2
1
  require 'active_support/duration'
3
- require 'active_support/core_ext/time/zones'
4
- require 'active_support/core_ext/object/acts_like'
5
2
 
6
3
  class Date
7
- if RUBY_VERSION < '1.9'
8
- undef :>>
9
-
10
- # Backported from 1.9. The one in 1.8 leads to incorrect next_month and
11
- # friends for dates where the calendar reform is involved. It additionally
12
- # prevents an infinite loop fixed in r27013.
13
- def >>(n)
14
- y, m = (year * 12 + (mon - 1) + n).divmod(12)
15
- m, = (m + 1) .divmod(1)
16
- d = mday
17
- until jd2 = self.class.valid_civil?(y, m, d, start)
18
- d -= 1
19
- raise ArgumentError, 'invalid date' unless d > 0
20
- end
21
- self + (jd2 - jd)
22
- end
23
- end
24
-
25
4
  class << self
26
5
  # Returns a new Date representing the date 1 day ago (i.e. yesterday's date).
27
6
  def yesterday
28
- ::Date.current.yesterday
7
+ ::Date.today.yesterday
29
8
  end
30
9
 
31
10
  # Returns a new Date representing the date 1 day after today (i.e. tomorrow's date).
32
11
  def tomorrow
33
- ::Date.current.tomorrow
12
+ ::Date.today.tomorrow
34
13
  end
35
14
 
36
15
  # Returns Time.zone.today when config.time_zone is set, otherwise just returns Date.today.
@@ -146,20 +125,20 @@ class Date
146
125
  advance(:years => years)
147
126
  end
148
127
 
149
- # Shorthand for years_ago(1)
150
- def prev_year
128
+ # Short-hand for years_ago(1)
129
+ def last_year
151
130
  years_ago(1)
152
- end unless method_defined?(:prev_year)
131
+ end
153
132
 
154
133
  # Short-hand for years_since(1)
155
134
  def next_year
156
135
  years_since(1)
157
136
  end unless method_defined?(:next_year)
158
-
137
+
159
138
  # Short-hand for months_ago(1)
160
- def prev_month
139
+ def last_month
161
140
  months_ago(1)
162
- end unless method_defined?(:prev_month)
141
+ end
163
142
 
164
143
  # Short-hand for months_since(1)
165
144
  def next_month
@@ -181,7 +160,6 @@ class Date
181
160
  result = self + days_to_sunday.days
182
161
  self.acts_like?(:time) ? result.end_of_day : result
183
162
  end
184
- alias :sunday :end_of_week
185
163
  alias :at_end_of_week :end_of_week
186
164
 
187
165
  # Returns a new Date/DateTime representing the start of the given day in next week (default is Monday).