activesupport 3.0.0.beta4 → 3.0.pre

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

Potentially problematic release.


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

Files changed (333) hide show
  1. data/CHANGELOG +1 -100
  2. data/lib/active_support.rb +4 -38
  3. data/lib/active_support/autoload.rb +28 -0
  4. data/lib/active_support/backtrace_cleaner.rb +9 -31
  5. data/lib/active_support/benchmarkable.rb +0 -1
  6. data/lib/active_support/buffered_logger.rb +1 -0
  7. data/lib/active_support/cache.rb +81 -436
  8. data/lib/active_support/cache/compressed_mem_cache_store.rb +13 -6
  9. data/lib/active_support/cache/file_store.rb +41 -139
  10. data/lib/active_support/cache/mem_cache_store.rb +75 -120
  11. data/lib/active_support/cache/memory_store.rb +27 -127
  12. data/lib/active_support/cache/strategy/local_cache.rb +58 -111
  13. data/lib/active_support/cache/synchronized_memory_store.rb +38 -2
  14. data/lib/active_support/callbacks.rb +48 -87
  15. data/lib/active_support/configurable.rb +18 -19
  16. data/lib/active_support/core_ext/array.rb +0 -1
  17. data/lib/active_support/core_ext/array/access.rb +1 -1
  18. data/lib/active_support/core_ext/array/conversions.rb +54 -29
  19. data/lib/active_support/core_ext/array/extract_options.rb +1 -16
  20. data/lib/active_support/core_ext/array/random_access.rb +5 -19
  21. data/lib/active_support/core_ext/array/wrap.rb +9 -13
  22. data/lib/active_support/core_ext/benchmark.rb +12 -0
  23. data/lib/active_support/core_ext/boolean.rb +1 -0
  24. data/lib/active_support/core_ext/boolean/conversions.rb +11 -0
  25. data/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +0 -2
  26. data/lib/active_support/core_ext/class.rb +1 -1
  27. data/lib/active_support/core_ext/class/attribute_accessors.rb +27 -33
  28. data/lib/active_support/core_ext/class/delegating_attributes.rb +41 -35
  29. data/lib/active_support/core_ext/class/inheritable_attributes.rb +13 -22
  30. data/lib/active_support/core_ext/class/removal.rb +53 -0
  31. data/lib/active_support/core_ext/date.rb +7 -0
  32. data/lib/active_support/core_ext/date/calculations.rb +8 -30
  33. data/lib/active_support/core_ext/date/conversions.rb +2 -2
  34. data/lib/active_support/core_ext/date_time.rb +5 -0
  35. data/lib/active_support/core_ext/date_time/calculations.rb +1 -2
  36. data/lib/active_support/core_ext/date_time/conversions.rb +5 -23
  37. data/lib/active_support/core_ext/enumerable.rb +9 -5
  38. data/lib/active_support/core_ext/exception.rb +47 -0
  39. data/lib/active_support/core_ext/file.rb +0 -1
  40. data/lib/active_support/core_ext/file/atomic.rb +2 -3
  41. data/lib/active_support/core_ext/float/rounding.rb +2 -3
  42. data/lib/active_support/core_ext/hash/conversions.rb +145 -65
  43. data/lib/active_support/core_ext/hash/deep_merge.rb +7 -6
  44. data/lib/active_support/core_ext/hash/except.rb +0 -8
  45. data/lib/active_support/core_ext/hash/indifferent_access.rb +0 -5
  46. data/lib/active_support/core_ext/hash/keys.rb +11 -10
  47. data/lib/active_support/core_ext/hash/slice.rb +0 -6
  48. data/lib/active_support/core_ext/integer.rb +1 -1
  49. data/lib/active_support/core_ext/integer/even_odd.rb +16 -0
  50. data/lib/active_support/core_ext/kernel.rb +1 -1
  51. data/lib/active_support/core_ext/kernel/daemonizing.rb +7 -0
  52. data/lib/active_support/core_ext/kernel/debugger.rb +2 -3
  53. data/lib/active_support/core_ext/kernel/reporting.rb +1 -2
  54. data/lib/active_support/core_ext/load_error.rb +30 -17
  55. data/lib/active_support/core_ext/logger.rb +1 -1
  56. data/lib/active_support/core_ext/module.rb +3 -5
  57. data/lib/active_support/core_ext/module/aliasing.rb +1 -1
  58. data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +1 -1
  59. data/lib/active_support/core_ext/module/attr_internal.rb +2 -2
  60. data/lib/active_support/core_ext/module/attribute_accessors.rb +21 -25
  61. data/lib/active_support/core_ext/module/delegation.rb +10 -21
  62. data/lib/active_support/core_ext/module/inclusion.rb +30 -0
  63. data/lib/active_support/core_ext/module/introspection.rb +8 -8
  64. data/lib/active_support/core_ext/module/loading.rb +23 -0
  65. data/lib/active_support/core_ext/module/synchronization.rb +1 -2
  66. data/lib/active_support/core_ext/name_error.rb +1 -3
  67. data/lib/active_support/core_ext/nil.rb +1 -0
  68. data/lib/active_support/core_ext/nil/conversions.rb +5 -0
  69. data/lib/active_support/core_ext/object.rb +2 -6
  70. data/lib/active_support/core_ext/object/blank.rb +2 -20
  71. data/lib/active_support/core_ext/object/conversions.rb +16 -2
  72. data/lib/active_support/core_ext/object/duplicable.rb +1 -23
  73. data/lib/active_support/core_ext/object/extending.rb +77 -8
  74. data/lib/active_support/core_ext/object/instance_variables.rb +7 -0
  75. data/lib/active_support/core_ext/object/metaclass.rb +13 -0
  76. data/lib/active_support/core_ext/object/misc.rb +1 -0
  77. data/lib/active_support/core_ext/object/tap.rb +16 -0
  78. data/lib/active_support/core_ext/object/with_options.rb +0 -2
  79. data/lib/active_support/core_ext/proc.rb +4 -4
  80. data/lib/active_support/core_ext/regexp.rb +22 -0
  81. data/lib/active_support/core_ext/rexml.rb +1 -4
  82. data/lib/active_support/core_ext/string.rb +2 -3
  83. data/lib/active_support/core_ext/string/access.rb +2 -4
  84. data/lib/active_support/core_ext/string/bytesize.rb +5 -0
  85. data/lib/active_support/core_ext/string/conversions.rb +1 -36
  86. data/lib/active_support/core_ext/string/filters.rb +0 -29
  87. data/lib/active_support/core_ext/string/inflections.rb +12 -1
  88. data/lib/active_support/core_ext/string/interpolation.rb +92 -2
  89. data/lib/active_support/core_ext/string/iterators.rb +13 -0
  90. data/lib/active_support/core_ext/string/multibyte.rb +19 -16
  91. data/lib/active_support/core_ext/string/output_safety.rb +35 -101
  92. data/lib/active_support/core_ext/string/starts_ends_with.rb +14 -0
  93. data/lib/active_support/core_ext/string/xchar.rb +1 -1
  94. data/lib/active_support/core_ext/symbol.rb +1 -0
  95. data/lib/active_support/core_ext/symbol/to_proc.rb +14 -0
  96. data/lib/active_support/core_ext/time.rb +10 -0
  97. data/lib/active_support/core_ext/time/calculations.rb +7 -9
  98. data/lib/active_support/core_ext/time/conversions.rb +0 -1
  99. data/lib/active_support/core_ext/time/marshal_with_utc_flag.rb +22 -0
  100. data/lib/active_support/core_ext/uri.rb +4 -10
  101. data/lib/active_support/dependencies.rb +192 -179
  102. data/lib/active_support/deprecated_callbacks.rb +283 -0
  103. data/lib/active_support/deprecation/behaviors.rb +1 -1
  104. data/lib/active_support/deprecation/method_wrappers.rb +9 -10
  105. data/lib/active_support/deprecation/reporting.rb +1 -2
  106. data/lib/active_support/duration.rb +2 -6
  107. data/lib/active_support/hash_with_indifferent_access.rb +1 -9
  108. data/lib/active_support/inflections.rb +1 -1
  109. data/lib/active_support/inflector.rb +407 -4
  110. data/lib/active_support/json/backends/jsongem.rb +9 -12
  111. data/lib/active_support/json/decoding.rb +1 -16
  112. data/lib/active_support/json/encoding.rb +12 -42
  113. data/lib/active_support/locale/en.yml +1 -4
  114. data/lib/active_support/memoizable.rb +1 -1
  115. data/lib/active_support/message_encryptor.rb +0 -1
  116. data/lib/active_support/message_verifier.rb +5 -6
  117. data/lib/active_support/multibyte.rb +22 -7
  118. data/lib/active_support/multibyte/chars.rb +392 -164
  119. data/lib/active_support/multibyte/unicode_database.rb +71 -0
  120. data/lib/active_support/multibyte/utils.rb +7 -6
  121. data/lib/active_support/notifications.rb +113 -23
  122. data/lib/active_support/ordered_hash.rb +11 -35
  123. data/lib/active_support/ordered_options.rb +0 -6
  124. data/lib/active_support/rescuable.rb +4 -7
  125. data/lib/active_support/ruby/shim.rb +6 -4
  126. data/lib/active_support/test_case.rb +7 -2
  127. data/lib/active_support/testing/assertions.rb +0 -15
  128. data/lib/active_support/testing/declarative.rb +1 -1
  129. data/lib/active_support/testing/isolation.rb +19 -63
  130. data/lib/active_support/testing/performance.rb +337 -342
  131. data/lib/active_support/testing/setup_and_teardown.rb +29 -51
  132. data/lib/active_support/time.rb +3 -23
  133. data/lib/active_support/time_with_zone.rb +10 -5
  134. data/lib/active_support/values/time_zone.rb +84 -40
  135. data/lib/active_support/values/unicode_tables.dat +0 -0
  136. data/lib/active_support/vendor.rb +16 -0
  137. data/lib/active_support/vendor/builder-2.1.2/lib/blankslate.rb +113 -0
  138. data/lib/active_support/vendor/builder-2.1.2/lib/builder.rb +13 -0
  139. data/lib/active_support/vendor/builder-2.1.2/lib/builder/blankslate.rb +20 -0
  140. data/lib/active_support/vendor/builder-2.1.2/lib/builder/css.rb +250 -0
  141. data/lib/active_support/vendor/builder-2.1.2/lib/builder/xchar.rb +115 -0
  142. data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlbase.rb +139 -0
  143. data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlevents.rb +63 -0
  144. data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlmarkup.rb +328 -0
  145. data/lib/active_support/vendor/i18n-0.1.3/MIT-LICENSE +20 -0
  146. data/lib/active_support/vendor/i18n-0.1.3/README.textile +20 -0
  147. data/lib/active_support/vendor/i18n-0.1.3/Rakefile +5 -0
  148. data/lib/active_support/vendor/i18n-0.1.3/i18n.gemspec +27 -0
  149. data/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb +204 -0
  150. data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb +215 -0
  151. data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/exceptions.rb +53 -0
  152. data/lib/active_support/vendor/i18n-0.1.3/test/all.rb +5 -0
  153. data/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb +99 -0
  154. data/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb +124 -0
  155. data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.rb +1 -0
  156. data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.yml +3 -0
  157. data/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb +567 -0
  158. data/lib/active_support/vendor/memcache-client-1.7.5/lib/memcache.rb +1133 -0
  159. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo.rb +33 -0
  160. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/data_timezone.rb +47 -0
  161. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/data_timezone_info.rb +228 -0
  162. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Algiers.rb +55 -0
  163. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Cairo.rb +219 -0
  164. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Casablanca.rb +42 -0
  165. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Harare.rb +18 -0
  166. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Johannesburg.rb +25 -0
  167. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Monrovia.rb +22 -0
  168. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Nairobi.rb +23 -0
  169. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +166 -0
  170. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Argentina/San_Juan.rb +86 -0
  171. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Bogota.rb +23 -0
  172. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Caracas.rb +23 -0
  173. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Chicago.rb +283 -0
  174. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Chihuahua.rb +136 -0
  175. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Denver.rb +204 -0
  176. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Godthab.rb +161 -0
  177. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Guatemala.rb +27 -0
  178. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Halifax.rb +274 -0
  179. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Indiana/Indianapolis.rb +149 -0
  180. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Juneau.rb +194 -0
  181. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/La_Paz.rb +22 -0
  182. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Lima.rb +35 -0
  183. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Los_Angeles.rb +232 -0
  184. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Mazatlan.rb +139 -0
  185. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Mexico_City.rb +144 -0
  186. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Monterrey.rb +131 -0
  187. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/New_York.rb +282 -0
  188. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Phoenix.rb +30 -0
  189. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Regina.rb +74 -0
  190. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Santiago.rb +205 -0
  191. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Sao_Paulo.rb +171 -0
  192. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/St_Johns.rb +288 -0
  193. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Tijuana.rb +196 -0
  194. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Almaty.rb +67 -0
  195. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Baghdad.rb +73 -0
  196. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Baku.rb +161 -0
  197. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Bangkok.rb +20 -0
  198. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Chongqing.rb +33 -0
  199. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Colombo.rb +30 -0
  200. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Dhaka.rb +27 -0
  201. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Hong_Kong.rb +87 -0
  202. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Irkutsk.rb +165 -0
  203. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Jakarta.rb +30 -0
  204. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Jerusalem.rb +163 -0
  205. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kabul.rb +20 -0
  206. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kamchatka.rb +163 -0
  207. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Karachi.rb +32 -0
  208. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kathmandu.rb +20 -0
  209. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kolkata.rb +25 -0
  210. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Krasnoyarsk.rb +163 -0
  211. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kuala_Lumpur.rb +31 -0
  212. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kuwait.rb +18 -0
  213. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Magadan.rb +163 -0
  214. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Muscat.rb +18 -0
  215. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Novosibirsk.rb +164 -0
  216. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Rangoon.rb +24 -0
  217. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Riyadh.rb +18 -0
  218. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Seoul.rb +34 -0
  219. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Shanghai.rb +35 -0
  220. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Singapore.rb +33 -0
  221. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Taipei.rb +59 -0
  222. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tashkent.rb +47 -0
  223. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tbilisi.rb +78 -0
  224. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tehran.rb +121 -0
  225. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tokyo.rb +30 -0
  226. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Ulaanbaatar.rb +65 -0
  227. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Urumqi.rb +33 -0
  228. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Vladivostok.rb +164 -0
  229. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yakutsk.rb +163 -0
  230. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yekaterinburg.rb +165 -0
  231. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yerevan.rb +165 -0
  232. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/Azores.rb +270 -0
  233. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/Cape_Verde.rb +23 -0
  234. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/South_Georgia.rb +18 -0
  235. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Adelaide.rb +187 -0
  236. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Brisbane.rb +35 -0
  237. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Darwin.rb +29 -0
  238. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Hobart.rb +193 -0
  239. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Melbourne.rb +185 -0
  240. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Perth.rb +37 -0
  241. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Sydney.rb +185 -0
  242. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Etc/UTC.rb +16 -0
  243. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Amsterdam.rb +228 -0
  244. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Athens.rb +185 -0
  245. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Belgrade.rb +163 -0
  246. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Berlin.rb +188 -0
  247. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Bratislava.rb +13 -0
  248. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Brussels.rb +232 -0
  249. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Bucharest.rb +181 -0
  250. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Budapest.rb +197 -0
  251. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Copenhagen.rb +179 -0
  252. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Dublin.rb +276 -0
  253. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Helsinki.rb +163 -0
  254. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Istanbul.rb +218 -0
  255. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Kiev.rb +168 -0
  256. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Lisbon.rb +268 -0
  257. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Ljubljana.rb +13 -0
  258. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/London.rb +288 -0
  259. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Madrid.rb +211 -0
  260. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Minsk.rb +170 -0
  261. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Moscow.rb +181 -0
  262. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Paris.rb +232 -0
  263. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Prague.rb +187 -0
  264. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Riga.rb +176 -0
  265. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Rome.rb +215 -0
  266. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Sarajevo.rb +13 -0
  267. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Skopje.rb +13 -0
  268. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Sofia.rb +173 -0
  269. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Stockholm.rb +165 -0
  270. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Tallinn.rb +172 -0
  271. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Vienna.rb +183 -0
  272. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Vilnius.rb +170 -0
  273. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Warsaw.rb +212 -0
  274. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Zagreb.rb +13 -0
  275. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Auckland.rb +202 -0
  276. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Fiji.rb +23 -0
  277. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Guam.rb +22 -0
  278. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Honolulu.rb +28 -0
  279. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Majuro.rb +20 -0
  280. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Midway.rb +25 -0
  281. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Noumea.rb +25 -0
  282. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Pago_Pago.rb +26 -0
  283. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Port_Moresby.rb +20 -0
  284. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Tongatapu.rb +27 -0
  285. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/info_timezone.rb +52 -0
  286. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/linked_timezone.rb +51 -0
  287. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/linked_timezone_info.rb +44 -0
  288. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/offset_rationals.rb +98 -0
  289. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/ruby_core_support.rb +56 -0
  290. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/time_or_datetime.rb +292 -0
  291. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone.rb +508 -0
  292. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_definition.rb +56 -0
  293. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_info.rb +40 -0
  294. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_offset_info.rb +94 -0
  295. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_period.rb +198 -0
  296. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_transition_info.rb +129 -0
  297. data/lib/active_support/version.rb +2 -3
  298. data/lib/active_support/whiny_nil.rb +7 -9
  299. data/lib/active_support/xml_mini.rb +1 -126
  300. data/lib/active_support/xml_mini/jdom.rb +0 -2
  301. data/lib/active_support/xml_mini/libxml.rb +86 -24
  302. data/lib/active_support/xml_mini/nokogiri.rb +24 -27
  303. data/lib/active_support/xml_mini/rexml.rb +1 -7
  304. metadata +191 -49
  305. data/lib/active_support/builder.rb +0 -6
  306. data/lib/active_support/core_ext/array/uniq_by.rb +0 -17
  307. data/lib/active_support/core_ext/class/attribute.rb +0 -67
  308. data/lib/active_support/core_ext/class/subclasses.rb +0 -55
  309. data/lib/active_support/core_ext/file/path.rb +0 -5
  310. data/lib/active_support/core_ext/integer/multiple.rb +0 -6
  311. data/lib/active_support/core_ext/kernel/singleton_class.rb +0 -13
  312. data/lib/active_support/core_ext/module/anonymous.rb +0 -24
  313. data/lib/active_support/core_ext/module/method_names.rb +0 -14
  314. data/lib/active_support/core_ext/module/reachable.rb +0 -10
  315. data/lib/active_support/core_ext/module/remove_method.rb +0 -6
  316. data/lib/active_support/core_ext/object/to_param.rb +0 -49
  317. data/lib/active_support/core_ext/object/to_query.rb +0 -27
  318. data/lib/active_support/core_ext/string/encoding.rb +0 -11
  319. data/lib/active_support/core_ext/string/exclude.rb +0 -6
  320. data/lib/active_support/core_ext/time/marshal.rb +0 -56
  321. data/lib/active_support/dependencies/autoload.rb +0 -50
  322. data/lib/active_support/i18n.rb +0 -8
  323. data/lib/active_support/inflector/inflections.rb +0 -211
  324. data/lib/active_support/inflector/methods.rb +0 -141
  325. data/lib/active_support/inflector/transliterate.rb +0 -97
  326. data/lib/active_support/json/backends/yajl.rb +0 -40
  327. data/lib/active_support/lazy_load_hooks.rb +0 -27
  328. data/lib/active_support/multibyte/unicode.rb +0 -393
  329. data/lib/active_support/notifications/fanout.rb +0 -93
  330. data/lib/active_support/notifications/instrumenter.rb +0 -56
  331. data/lib/active_support/railtie.rb +0 -100
  332. data/lib/active_support/xml_mini/libxmlsax.rb +0 -85
  333. data/lib/active_support/xml_mini/nokogirisax.rb +0 -83
@@ -1,5 +1,3 @@
1
- require 'active_support/core_ext/string/multibyte'
2
-
3
1
  class String
4
2
  # Returns the string, first removing all whitespace on both ends of
5
3
  # the string, and then changing remaining consecutive whitespace
@@ -19,31 +17,4 @@ class String
19
17
  gsub!(/\s+/, ' ')
20
18
  self
21
19
  end
22
-
23
- # Truncates a given +text+ after a given <tt>length</tt> if +text+ is longer than <tt>length</tt>:
24
- #
25
- # "Once upon a time in a world far far away".truncate(27)
26
- # # => "Once upon a time in a wo..."
27
- #
28
- # The last characters will be replaced with the <tt>:omission</tt> string (defaults to "...")
29
- # for a total length not exceeding <tt>:length</tt>:
30
- #
31
- # "Once upon a time in a world far far away".truncate(27, :separator => ' ')
32
- # # => "Once upon a time in a..."
33
- #
34
- # Pass a <tt>:separator</tt> to truncate +text+ at a natural break:
35
- #
36
- # "And they found that many people were sleeping better.".truncate(25, :omission => "... (continued)")
37
- # # => "And they f... (continued)"
38
- def truncate(length, options = {})
39
- text = self.dup
40
- options[:omission] ||= "..."
41
-
42
- length_with_room_for_omission = length - options[:omission].mb_chars.length
43
- chars = text.mb_chars
44
- stop = options[:separator] ?
45
- (chars.rindex(options[:separator].mb_chars, length_with_room_for_omission) || length_with_room_for_omission) : length_with_room_for_omission
46
-
47
- (chars.length > length ? chars[0...stop] + options[:omission] : text).to_s
48
- end
49
20
  end
@@ -2,7 +2,7 @@
2
2
  # For instance, you can figure out the name of a database from the name of a class.
3
3
  #
4
4
  # "ScaleScore".tableize # => "scale_scores"
5
- #
5
+
6
6
  class String
7
7
  # Returns the plural form of the word in the string.
8
8
  #
@@ -146,4 +146,15 @@ class String
146
146
  def foreign_key(separate_class_name_and_id_with_underscore = true)
147
147
  ActiveSupport::Inflector.foreign_key(self, separate_class_name_and_id_with_underscore)
148
148
  end
149
+
150
+ # +constantize+ tries to find a declared constant with the name specified
151
+ # in the string. It raises a NameError when the name is not in CamelCase
152
+ # or is not initialized.
153
+ #
154
+ # Examples
155
+ # "Module".constantize # => Module
156
+ # "Class".constantize # => Class
157
+ def constantize
158
+ ActiveSupport::Inflector.constantize(self)
159
+ end
149
160
  end
@@ -1,2 +1,92 @@
1
- require 'active_support/i18n'
2
- require 'i18n/core_ext/string/interpolate'
1
+ =begin
2
+ heavily based on Masao Mutoh's gettext String interpolation extension
3
+ http://github.com/mutoh/gettext/blob/f6566738b981fe0952548c421042ad1e0cdfb31e/lib/gettext/core_ext/string.rb
4
+ Copyright (C) 2005-2009 Masao Mutoh
5
+ You may redistribute it and/or modify it under the same license terms as Ruby.
6
+ =end
7
+
8
+ if RUBY_VERSION < '1.9'
9
+ require 'active_support/core_ext/string/bytesize'
10
+
11
+ # KeyError is raised by String#% when the string contains a named placeholder
12
+ # that is not contained in the given arguments hash. Ruby 1.9 includes and
13
+ # raises this exception natively. We define it to mimic Ruby 1.9's behaviour
14
+ # in Ruby 1.8.x
15
+
16
+ class KeyError < IndexError
17
+ def initialize(message = nil)
18
+ super(message || "key not found")
19
+ end
20
+ end unless defined?(KeyError)
21
+
22
+ # Extension for String class. This feature is included in Ruby 1.9 or later but not occur TypeError.
23
+ #
24
+ # String#% method which accept "named argument". The translator can know
25
+ # the meaning of the msgids using "named argument" instead of %s/%d style.
26
+
27
+ class String
28
+ alias :interpolate_without_ruby_19_syntax :% # :nodoc:
29
+
30
+ INTERPOLATION_PATTERN = Regexp.union(
31
+ /%%/,
32
+ /%\{(\w+)\}/, # matches placeholders like "%{foo}"
33
+ /%<(\w+)>(.*?\d*\.?\d*[bBdiouxXeEfgGcps])/ # matches placeholders like "%<foo>.d"
34
+ )
35
+
36
+ # % uses self (i.e. the String) as a format specification and returns the
37
+ # result of applying it to the given arguments. In other words it interpolates
38
+ # the given arguments to the string according to the formats the string
39
+ # defines.
40
+ #
41
+ # There are three ways to use it:
42
+ #
43
+ # * Using a single argument or Array of arguments.
44
+ #
45
+ # This is the default behaviour of the String class. See Kernel#sprintf for
46
+ # more details about the format string.
47
+ #
48
+ # Example:
49
+ #
50
+ # "%d %s" % [1, "message"]
51
+ # # => "1 message"
52
+ #
53
+ # * Using a Hash as an argument and unformatted, named placeholders.
54
+ #
55
+ # When you pass a Hash as an argument and specify placeholders with %{foo}
56
+ # it will interpret the hash values as named arguments.
57
+ #
58
+ # Example:
59
+ #
60
+ # "%{firstname}, %{lastname}" % {:firstname => "Masao", :lastname => "Mutoh"}
61
+ # # => "Masao Mutoh"
62
+ #
63
+ # * Using a Hash as an argument and formatted, named placeholders.
64
+ #
65
+ # When you pass a Hash as an argument and specify placeholders with %<foo>d
66
+ # it will interpret the hash values as named arguments and format the value
67
+ # according to the formatting instruction appended to the closing >.
68
+ #
69
+ # Example:
70
+ #
71
+ # "%<integer>d, %<float>.1f" % { :integer => 10, :float => 43.4 }
72
+ # # => "10, 43.3"
73
+ def %(args)
74
+ if args.kind_of?(Hash)
75
+ dup.gsub(INTERPOLATION_PATTERN) do |match|
76
+ if match == '%%'
77
+ '%'
78
+ else
79
+ key = ($1 || $2).to_sym
80
+ raise KeyError unless args.has_key?(key)
81
+ $3 ? sprintf("%#{$3}", args[key]) : args[key]
82
+ end
83
+ end
84
+ elsif self =~ INTERPOLATION_PATTERN
85
+ raise ArgumentError.new('one hash required')
86
+ else
87
+ result = gsub(/%([{<])/, '%%\1')
88
+ result.send :'interpolate_without_ruby_19_syntax', args
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,13 @@
1
+ unless '1.9'.respond_to?(:each_char)
2
+ class String
3
+ # Yields a single-character string for each character in the string.
4
+ # When $KCODE = 'UTF8', multi-byte characters are yielded appropriately.
5
+ def each_char
6
+ require 'strscan' unless defined? ::StringScanner
7
+ scanner, char = ::StringScanner.new(self), /./mu
8
+ while c = scanner.scan(char)
9
+ yield c
10
+ end
11
+ end
12
+ end
13
+ end
@@ -2,7 +2,7 @@
2
2
  require 'active_support/multibyte'
3
3
 
4
4
  class String
5
- if '1.9'.respond_to?(:force_encoding)
5
+ unless '1.9'.respond_to?(:force_encoding)
6
6
  # == Multibyte proxy
7
7
  #
8
8
  # +mb_chars+ is a multibyte safe proxy for string methods.
@@ -37,13 +37,30 @@ class String
37
37
  # For more information about the methods defined on the Chars proxy see ActiveSupport::Multibyte::Chars. For
38
38
  # information about how to change the default Multibyte behaviour see ActiveSupport::Multibyte.
39
39
  def mb_chars
40
- if ActiveSupport::Multibyte.proxy_class.consumes?(self)
40
+ if ActiveSupport::Multibyte.proxy_class.wants?(self)
41
41
  ActiveSupport::Multibyte.proxy_class.new(self)
42
42
  else
43
43
  self
44
44
  end
45
45
  end
46
+
47
+ # Returns true if the string has UTF-8 semantics (a String used for purely byte resources is unlikely to have
48
+ # them), returns false otherwise.
49
+ def is_utf8?
50
+ ActiveSupport::Multibyte::Chars.consumes?(self)
51
+ end
46
52
 
53
+ unless '1.8.7 and later'.respond_to?(:chars)
54
+ def chars
55
+ ActiveSupport::Deprecation.warn('String#chars has been deprecated in favor of String#mb_chars.', caller)
56
+ mb_chars
57
+ end
58
+ end
59
+ else
60
+ def mb_chars #:nodoc
61
+ self
62
+ end
63
+
47
64
  def is_utf8? #:nodoc
48
65
  case encoding
49
66
  when Encoding::UTF_8
@@ -54,19 +71,5 @@ class String
54
71
  false
55
72
  end
56
73
  end
57
- else
58
- def mb_chars
59
- if ActiveSupport::Multibyte.proxy_class.wants?(self)
60
- ActiveSupport::Multibyte.proxy_class.new(self)
61
- else
62
- self
63
- end
64
- end
65
-
66
- # Returns true if the string has UTF-8 semantics (a String used for purely byte resources is unlikely to have
67
- # them), returns false otherwise.
68
- def is_utf8?
69
- ActiveSupport::Multibyte::Chars.consumes?(self)
70
- end
71
74
  end
72
75
  end
@@ -1,109 +1,43 @@
1
- require 'erb'
2
- require 'active_support/core_ext/kernel/singleton_class'
3
-
4
- class ERB
5
- module Util
6
- HTML_ESCAPE = { '&' => '&amp;', '>' => '&gt;', '<' => '&lt;', '"' => '&quot;' }
7
- JSON_ESCAPE = { '&' => '\u0026', '>' => '\u003E', '<' => '\u003C' }
8
-
9
- # A utility method for escaping HTML tag characters.
10
- # This method is also aliased as <tt>h</tt>.
11
- #
12
- # In your ERb templates, use this method to escape any unsafe content. For example:
13
- # <%=h @person.name %>
14
- #
15
- # ==== Example:
16
- # puts html_escape("is a > 0 & a < 10?")
17
- # # => is a &gt; 0 &amp; a &lt; 10?
18
- def html_escape(s)
19
- s = s.to_s
20
- if s.html_safe?
21
- s
22
- else
23
- s.gsub(/[&"><]/) { |special| HTML_ESCAPE[special] }.html_safe
24
- end
25
- end
26
-
27
- remove_method(:h)
28
- alias h html_escape
29
-
30
- module_function :h
31
-
32
- singleton_class.send(:remove_method, :html_escape)
33
- module_function :html_escape
34
-
35
- # A utility method for escaping HTML entities in JSON strings.
36
- # This method is also aliased as <tt>j</tt>.
37
- #
38
- # In your ERb templates, use this method to escape any HTML entities:
39
- # <%=j @person.to_json %>
40
- #
41
- # ==== Example:
42
- # puts json_escape("is a > 0 & a < 10?")
43
- # # => is a \u003E 0 \u0026 a \u003C 10?
44
- def json_escape(s)
45
- s.to_s.gsub(/[&"><]/) { |special| JSON_ESCAPE[special] }
46
- end
47
-
48
- alias j json_escape
49
- module_function :j
50
- module_function :json_escape
51
- end
52
- end
53
-
54
- class Object
1
+ class String
55
2
  def html_safe?
56
- false
3
+ defined?(@_rails_html_safe) && @_rails_html_safe
57
4
  end
58
- end
59
5
 
60
- class Fixnum
61
- def html_safe?
62
- true
6
+ def html_safe!
7
+ @_rails_html_safe = true
8
+ self
63
9
  end
64
- end
65
-
66
- module ActiveSupport #:nodoc:
67
- class SafeBuffer < String
68
- alias safe_concat concat
69
-
70
- def concat(value)
71
- if value.html_safe?
72
- super(value)
73
- else
74
- super(ERB::Util.h(value))
75
- end
76
- end
77
- alias << concat
78
-
79
- def +(other)
80
- dup.concat(other)
81
- end
82
-
83
- def html_safe?
84
- true
85
- end
86
-
87
- def html_safe
88
- self
89
- end
90
-
91
- def to_s
92
- self
93
- end
94
-
95
- def to_yaml(*args)
96
- to_str.to_yaml(*args)
10
+
11
+ def html_safe
12
+ dup.html_safe!
13
+ end
14
+
15
+ alias original_plus +
16
+ def +(other)
17
+ result = original_plus(other)
18
+ if html_safe? && also_html_safe?(other)
19
+ result.html_safe!
20
+ else
21
+ result
97
22
  end
98
23
  end
99
- end
100
-
101
- class String
102
- def html_safe!
103
- raise "You can't call html_safe! on a String"
24
+
25
+ alias original_concat <<
26
+ def <<(other)
27
+ result = original_concat(other)
28
+ unless html_safe? && also_html_safe?(other)
29
+ @_rails_html_safe = false
30
+ end
31
+ result
104
32
  end
105
-
106
- def html_safe
107
- ActiveSupport::SafeBuffer.new(self)
33
+
34
+ def concat(other)
35
+ self << other
108
36
  end
109
- end
37
+
38
+ private
39
+ def also_html_safe?(other)
40
+ other.respond_to?(:html_safe?) && other.html_safe?
41
+ end
42
+
43
+ end
@@ -1,4 +1,18 @@
1
1
  class String
2
+ unless '1.8.7 and up'.respond_to?(:start_with?)
3
+ # Does the string start with the specified +prefix+?
4
+ def start_with?(prefix)
5
+ prefix = prefix.to_s
6
+ self[0, prefix.length] == prefix
7
+ end
8
+
9
+ # Does the string end with the specified +suffix+?
10
+ def end_with?(suffix)
11
+ suffix = suffix.to_s
12
+ self[-suffix.length, suffix.length] == suffix
13
+ end
14
+ end
15
+
2
16
  alias_method :starts_with?, :start_with?
3
17
  alias_method :ends_with?, :end_with?
4
18
  end
@@ -1,5 +1,5 @@
1
1
  begin
2
- # See http://fast-xs.rubyforge.org/ by Eric Wong.
2
+ # See http://bogomips.org/fast_xs/ by Eric Wong.
3
3
  # Also included with hpricot.
4
4
  require 'fast_xs'
5
5
  rescue LoadError
@@ -0,0 +1 @@
1
+ require 'active_support/core_ext/symbol/to_proc'
@@ -0,0 +1,14 @@
1
+ class Symbol
2
+ # Turns the symbol into a simple proc, which is especially useful for enumerations. Examples:
3
+ #
4
+ # # The same as people.collect { |p| p.name }
5
+ # people.collect(&:name)
6
+ #
7
+ # # The same as people.select { |p| p.manager? }.collect { |p| p.salary }
8
+ # people.select(&:manager?).collect(&:salary)
9
+ #
10
+ # This is a builtin method in Ruby 1.8.7 and later.
11
+ def to_proc
12
+ Proc.new { |*args| args.shift.__send__(self, *args) }
13
+ end unless :to_proc.respond_to?(:to_proc)
14
+ end
@@ -0,0 +1,10 @@
1
+ require 'date'
2
+ require 'time'
3
+
4
+ require 'active_support/core_ext/time/publicize_conversion_methods'
5
+ require 'active_support/core_ext/time/marshal_with_utc_flag'
6
+
7
+ require 'active_support/core_ext/time/acts_like'
8
+ require 'active_support/core_ext/time/calculations'
9
+ require 'active_support/core_ext/time/conversions'
10
+ require 'active_support/core_ext/time/zones'
@@ -1,7 +1,5 @@
1
1
  require 'active_support/duration'
2
- require 'active_support/core_ext/date/acts_like'
3
2
  require 'active_support/core_ext/date/calculations'
4
- require 'active_support/core_ext/date_time/conversions'
5
3
 
6
4
  class Time
7
5
  COMMON_YEAR_DAYS_IN_MONTH = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
@@ -24,11 +22,10 @@ class Time
24
22
  # (i.e., if year is within either 1970..2038 or 1902..2038, depending on system architecture);
25
23
  # otherwise returns a DateTime
26
24
  def time_with_datetime_fallback(utc_or_local, year, month=1, day=1, hour=0, min=0, sec=0, usec=0)
27
- time = ::Time.send(utc_or_local, year, month, day, hour, min, sec, usec)
28
- # This check is needed because Time.utc(y) returns a time object in the 2000s for 0 <= y <= 138.
29
- time.year == year ? time : ::DateTime.civil_from_format(utc_or_local, year, month, day, hour, min, sec)
25
+ ::Time.send(utc_or_local, year, month, day, hour, min, sec, usec)
30
26
  rescue
31
- ::DateTime.civil_from_format(utc_or_local, year, month, day, hour, min, sec)
27
+ offset = utc_or_local.to_sym == :local ? ::DateTime.local_offset : 0
28
+ ::DateTime.civil(year, month, day, hour, min, sec, offset)
32
29
  end
33
30
 
34
31
  # Wraps class method +time_with_datetime_fallback+ with +utc_or_local+ set to <tt>:utc</tt>.
@@ -133,7 +130,7 @@ class Time
133
130
  end
134
131
 
135
132
  # Short-hand for years_ago(1)
136
- def prev_year
133
+ def last_year
137
134
  years_ago(1)
138
135
  end
139
136
 
@@ -142,8 +139,9 @@ class Time
142
139
  years_since(1)
143
140
  end
144
141
 
142
+
145
143
  # Short-hand for months_ago(1)
146
- def prev_month
144
+ def last_month
147
145
  months_ago(1)
148
146
  end
149
147
 
@@ -260,7 +258,7 @@ class Time
260
258
  # are coerced into values that Time#- will recognize
261
259
  def minus_with_coercion(other)
262
260
  other = other.comparable_time if other.respond_to?(:comparable_time)
263
- other.is_a?(DateTime) ? to_f - other.to_f : minus_without_coercion(other)
261
+ minus_without_coercion(other)
264
262
  end
265
263
  alias_method :minus_without_coercion, :-
266
264
  alias_method :-, :minus_with_coercion