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
data/CHANGELOG CHANGED
@@ -1,14 +1,192 @@
1
- *2.0.5* (October 19th, 2008)
1
+ *2.1.0 (May 31st, 2008)*
2
2
 
3
- * Included in Rails 2.0.5
3
+ * TimeZone#to_s shows offset as GMT instead of UTC, because GMT will be more familiar to end users (see time zone selects used by Windows OS, google.com and yahoo.com.) Reverts [8370] [Geoff Buesing]
4
4
 
5
+ * Hash.from_xml: datetime xml types overflow to Ruby DateTime class when out of range of Time. Adding tests for utc offsets [Geoff Buesing]
5
6
 
6
- *2.0.4* (2nd September 2008)
7
+ * TimeWithZone #+ and #- : ensure overflow to DateTime with Numeric arg [Geoff Buesing]
7
8
 
8
- * Fixed the rexml vulnerability disclosed at http://www.ruby-lang.org/en/news/2008/08/23/dos-vulnerability-in-rexml/ [koz]
9
+ * Time#to_json: don't convert to utc before encoding. References #175 [Geoff Buesing]
10
+
11
+ * Remove unused JSON::RESERVED_WORDS, JSON.valid_identifier? and JSON.reserved_word? methods. Resolves #164. [Cheah Chu Yeow]
12
+
13
+ * Adding Date.current, which returns Time.zone.today if config.time_zone is set; otherwise returns Date.today [Geoff Buesing]
14
+
15
+ * TimeWithZone: date part getter methods (#year #mon #day etc) are defined on class; no longer relying on method_missing [Geoff Buesing]
16
+
17
+ * Time.zone.parse return nil for strings with no date information [Geoff Buesing]
18
+
19
+ * Time.zone.parse respects offset information in string. Resolves #105. [Scott Fleckenstein, Geoff Buesing]
20
+
21
+ * Added Ruby 1.8 implementation of Process.daemon
22
+
23
+ * Duration #since and #ago with no argument (e.g., 5.days.ago) return TimeWithZone when config.time_zone is set. Introducing Time.current, which returns Time.zone.now if config.time_zone is set, otherwise just returns Time.now [Geoff Buesing]
24
+
25
+ * Time#since behaves correctly when passed a Duration. Closes #11527 [kemiller]
26
+
27
+ * Add #getutc alias for DateTime#utc [Geoff Buesing]
28
+
29
+ * Refactor TimeWithZone: don't send #since, #ago, #+, #-, #advance through method_missing [Geoff Buesing]
30
+
31
+ * TimeWithZone respects config.active_support.use_standard_json_time_format [Geoff Buesing]
32
+
33
+ * Add config.active_support.escape_html_entities_in_json to allow disabling of html entity escaping. [rick]
34
+
35
+ * Improve documentation. [Xavier Noria]
36
+
37
+ * Modified ActiveSupport::Callbacks::Callback#call to accept multiple arguments.
38
+
39
+ * Time #yesterday and #tomorrow behave correctly crossing DST boundary. Closes #7399 [sblackstone]
40
+
41
+ * TimeWithZone: Adding tests for dst and leap day edge cases when advancing time [Geoff Buesing]
42
+
43
+ * TimeWithZone#method_missing: send to utc to advance with dst correctness, otherwise send to time. Adding tests for time calculations methods [Geoff Buesing]
44
+
45
+ * Add config.active_support.use_standard_json_time_format setting so that Times and Dates export to ISO 8601 dates. [rick]
46
+
47
+ * TZInfo: Removing unneeded TimezoneProxy class [Geoff Buesing]
48
+
49
+ * TZInfo: Removing unneeded TimezoneIndexDefinition, since we're not including Indexes::Timezones [Geoff Buesing]
50
+
51
+ * Removing unnecessary uses_tzinfo helper from tests, given that TZInfo is now bundled [Geoff Buesing]
52
+
53
+ * Bundling abbreviated version of TZInfo gem 0.3.8: only the classes and zone definitions required to support Rails time zone features are included. If a recent version of the full TZInfo gem is installed, this will take precedence over the bundled version [Geoff Buesing]
54
+
55
+ * TimeWithZone#marshal_load does zone lookup via Time.get_zone, so that tzinfo/Olson identifiers are handled [Geoff Buesing]
56
+
57
+ * Time.zone= accepts TZInfo::Timezone instances and Olson identifiers; wraps result in TimeZone instance [Geoff Buesing]
58
+
59
+ * TimeWithZone time conversions don't need to be wrapped in TimeOrDateTime, because TZInfo does this internally [Geoff Buesing]
60
+
61
+ * TimeWithZone#usec returns 0 instead of error when DateTime is wrapped [Geoff Buesing]
62
+
63
+ * Improve documentation. [Radar, Jan De Poorter, chuyeow, xaviershay, danger, miloops, Xavier Noria, Sunny Ripert]
64
+
65
+ * Ensure that TimeWithZone#to_yaml works when passed a YAML::Emitter. [rick]
66
+
67
+ * Ensure correct TimeWithZone#to_date [Geoff Buesing]
68
+
69
+ * Make TimeWithZone work with tzinfo 0.2.x: use TZInfo::Timezone#zone_identifier alias for #abbreviation, silence warnings on tests. Raise LoadError when TZInfo version is < 0.2 by sniffing for TZInfo::TimeOrDateTime constant. Move all tzinfo-dependent TimeZone tests into uses_tzinfo block [Geoff Buesing]
70
+
71
+ * Time, DateTime and TimeWithZone #in_time_zone defaults to Time.zone. Removing now unneeded #in_current_time_zone [Geoff Buesing]
72
+
73
+ * TZInfo caches Timezone instances in its own internal hash cache, so TimeZone::MAPPING doesn't need to cache them as well [Geoff Buesing]
74
+
75
+ * Adding TimeZone#parse [Geoff Buesing]
76
+
77
+ * Adding TimeZone#at and DateTime#to_f [Geoff Buesing]
78
+
79
+ * TimeWithZone responds to Ruby 1.9 weekday-named query methods [Geoff Buesing]
80
+
81
+ * TimeWithZone caches TZInfo::TimezonePeriod used for time conversion so that it can be reused, and enforces DST rules correctly when instance is created from a local time [Geoff Buesing]
82
+
83
+ * Fixed that BufferedLogger should create its own directory if one doesn't already exist #11285 [lotswholetime]
84
+
85
+ * Fix Numeric time tests broken by DST change by anchoring them to fixed times instead of Time.now. Anchor TimeZone#now DST test to time specified with Time.at instead of Time.local to work around platform differences with Time.local and DST representation [Geoff Buesing]
86
+
87
+ * Removing unneeded #change_time_zone method from Time, DateTime and TimeWithZone [Geoff Buesing]
88
+
89
+ * TimeZone #local and #now correctly enforce DST rules [Geoff Buesing]
90
+
91
+ * TimeWithZone instances correctly enforce DST rules. Adding TimeZone#period_for_utc [Geoff Buesing]
92
+
93
+ * test_time_with_datetime_fallback expects DateTime.local_offset instead of DateTime.now.offset [Geoff Buesing]
94
+
95
+ * Adding TimeWithZone #marshal_dump and #marshal_load [Geoff Buesing]
96
+
97
+ * Add OrderedHash#to_hash [josh]
98
+
99
+ * Adding Time#end_of_day, _quarter, _week, and _year. #9312 [Juanjo Bazan, Tarmo Tänav, BigTitus]
100
+
101
+ * Adding TimeWithZone#between? [Geoff Buesing]
102
+
103
+ * Time.=== returns true for TimeWithZone instances [Geoff Buesing]
104
+
105
+ * TimeWithZone #+ and #- behave consistently with numeric arguments regardless of whether wrapped time is a Time or DateTime; consistenty answers false to #acts_like?(:date) [Geoff Buesing]
106
+
107
+ * Add String#squish and String#squish! to remove consecutive chunks of whitespace. #11123 [jordi, Henrik N]
108
+
109
+ * Serialize BigDecimals as Floats when using to_yaml. #8746 [ernesto.jimenez]
110
+
111
+ * Adding TimeWithZone #to_yaml, #to_datetime, #eql? and method aliases for duck-typing compatibility with Time [Geoff Buesing]
112
+
113
+ * TimeWithZone #in_time_zone returns +self+ if zone argument is the same as #time_zone [Geoff Buesing]
114
+
115
+ * Adding TimeWithZone #to_a, #to_f, #to_i, #httpdate, #rfc2822 [Geoff Buesing]
116
+
117
+ * Pruning unneeded TimeWithZone#change_time_zone_to_current [Geoff Buesing]
118
+
119
+ * Time#zone=, #in_time_zone and #change_time_zone accept a Duration [Geoff Buesing]
120
+
121
+ * Time#in_time_zone handles Time.local instances correctly [Geoff Buesing]
122
+
123
+ * Pruning unneeded Time#change_time_zone_to_current. Enhanced docs to #change_time_zone to explain the difference between this method and #in_time_zone [Geoff Buesing]
124
+
125
+ * TimeZone#new method renamed #local; when used with Time.zone, constructor now reads: Time.zone.local() [Geoff Buesing]
126
+
127
+ * Added Base64.encode64s to encode values in base64 without the newlines. This makes the values immediately usable as URL parameters or memcache keys without further processing [DHH]
9
128
 
10
129
  * Remove :nodoc: entries around the ActiveSupport test/unit assertions. #10946 [dancroak, jamesh]
11
130
 
131
+ * Add Time.zone_default accessor for setting the default time zone. Rails::Configuration.time_zone sets this. #10982 [Geoff Buesing]
132
+
133
+ * cache.fetch(key, :force => true) to force a cache miss. [Jeremy Kemper]
134
+
135
+ * Support retrieving TimeZones with a Duration. TimeZone[-28800] == TimeZone[-480.minutes]. [rick]
136
+
137
+ * TimeWithZone#- added, so that #- can handle a Time or TimeWithZone argument correctly [Geoff Buesing]
138
+
139
+ * with_timezone test helper renamed with_env_tz, to distinguish between setting ENV['TZ'] and setting Time.zone in tests [Geoff Buesing]
140
+
141
+ * Time#- coerces TimeWithZone argument to a Time instance so that difference in seconds can be calculated. Closes #10914 [Geoff Buesing, yyyc514]
142
+
143
+ * Adding UTC zone to TimeZone; TimeWithZone no longer has to fake UTC zone with nil [Geoff Buesing]
144
+
145
+ * Time.get_zone refactored to private method, given that the encapsulated logic is only useful internally [Geoff Buesing]
146
+
147
+ * Time.zone uses thread-local variable for thread safety. Adding Time.use_zone, for overriding Time.zone locally inside a block. Removing unneeded Time.zone_reset! [Geoff Buesing]
148
+
149
+ * TimeZone#to_s uses UTC rather than GMT; reapplying change that was undone in [8679]. #1689 [Cheah Chu Yeow]
150
+
151
+ * Time.days_in_month defaults to current year if no year is supplied as argument #10799 [Radar], uses Date.gregorian_leap? to determine leap year, and uses constant lookup to determine days in month [Geoff Buesing]
152
+
153
+ * Adding Time and DateTime #compare_with_coercion, which layers behavior on #<=> so that any combination of Time, DateTime and ActiveSupport::TimeWithZone instances can be chronologically compared [Geoff Buesing]
154
+
155
+ * TimeZone#now returns an ActiveSupport::TimeWithZone [Geoff Buesing]
156
+
157
+ * Time #in_current_time_zone and #change_time_zone_to_current return self when Time.zone is nil [Geoff Buesing]
158
+
159
+ * Remove unneeded #to_datetime_default_s alias for DateTime#to_s, given that we inherit a #to_default_s from Date that does exactly the same thing [Geoff Buesing]
160
+
161
+ * Refactor Time and DateTime #to_formatted_s: use ternary instead of nested if/else [Geoff Buesing]
162
+
163
+ * Adding Time and DateTime #formatted_offset, for outputting +HH:MM utc offset strings with cross-platform consistency [Geoff Buesing]
164
+
165
+ * Adding alternate_utc_string option to TimeZone#formatted_offset. Removing unneeded TimeZone#offset. [Geoff Buesing]
166
+
167
+ * Introduce ActiveSupport::TimeWithZone, for wrapping Time instances with a TimeZone. Introduce instance methods to Time for creating TimeWithZone instances, and class methods for managing a global time zone. [Geoff Buesing]
168
+
169
+ >>>>>>> .r8815
170
+ * Replace non-dst-aware TimeZone class with dst-aware class from tzinfo_timezone plugin. TimeZone#adjust and #unadjust are no longer available; tzinfo gem must now be present in order to perform time zone calculations, via #local_to_utc and #utc_to_local methods. [Geoff Buesing]
171
+
172
+ * Extract ActiveSupport::Callbacks from Active Record, test case setup and teardown, and ActionController::Dispatcher. #10727 [Josh Peek]
173
+
174
+ * Introducing DateTime #utc, #utc? and #utc_offset, for duck-typing compatibility with Time. Closes #10002 [Geoff Buesing]
175
+
176
+ * Time#to_json uses Numeric#to_utc_offset_s to output a cross-platform-consistent representation without having to convert to DateTime. References #9750 [Geoff Buesing]
177
+
178
+ * Refactor number-to-HH:MM-string conversion logic from TimeZone#formatted_offset to a reusable Numeric#to_utc_offset_s method. [Geoff Buesing]
179
+
180
+ * Continue evolution toward ActiveSupport::TestCase. #10679 [Josh Peek]
181
+
182
+ * TestCase: introduce declared setup and teardown callbacks. Pass a list of methods and an optional block to call before setup or after teardown. Setup callbacks are run in the order declared; teardown callbacks are run in reverse. [Jeremy Kemper]
183
+
184
+ * Added ActiveSupport::Gzip.decompress/compress(source) as an easy wrapper for Zlib [Tobias Luetke]
185
+
186
+ * Included MemCache-Client to make the improved ActiveSupport::Cache::MemCacheStore work out of the box [Bob Cottrell, Eric Hodel]
187
+
188
+ * Added ActiveSupport::Cache::* framework as an extraction from ActionController::Caching::Fragments::* [DHH]
189
+
12
190
  * Fixed String#titleize to work for strings with 's too #10571 [trek]
13
191
 
14
192
  * Changed the implementation of Enumerable#group_by to use a double array approach instead of a hash such that the insert order is honored [DHH/Marcel]
@@ -17,7 +195,7 @@
17
195
 
18
196
  * Hash#symbolize_keys skips keys that can't be symbolized. #10500 [Brad Greenlee]
19
197
 
20
- * Ruby 1.9 compatibility. #1689, #10466, #10468, #10554 [Cheah Chu Yeow, Pratik Naik, Jeremy Kemper, Dirkjan Bussink]
198
+ * Ruby 1.9 compatibility. #1689, #10466, #10468, #10554, #10594, #10632 [Cheah Chu Yeow, Pratik Naik, Jeremy Kemper, Dirkjan Bussink, fxn]
21
199
 
22
200
  * TimeZone#to_s uses UTC rather than GMT. #1689 [Cheah Chu Yeow]
23
201
 
@@ -26,15 +26,20 @@ $:.unshift(File.dirname(__FILE__))
26
26
  require 'active_support/vendor'
27
27
  require 'active_support/basic_object'
28
28
  require 'active_support/inflector'
29
+ require 'active_support/callbacks'
29
30
 
30
31
  require 'active_support/core_ext'
31
32
 
32
33
  require 'active_support/clean_logger'
33
34
  require 'active_support/buffered_logger'
34
35
 
36
+ require 'active_support/gzip'
37
+ require 'active_support/cache'
38
+
35
39
  require 'active_support/dependencies'
36
40
  require 'active_support/deprecation'
37
41
 
42
+ require 'active_support/ordered_hash'
38
43
  require 'active_support/ordered_options'
39
44
  require 'active_support/option_merger'
40
45
 
@@ -47,5 +52,4 @@ require 'active_support/multibyte'
47
52
 
48
53
  require 'active_support/base64'
49
54
 
50
- require 'active_support/testing'
51
-
55
+ require 'active_support/time_with_zone'
@@ -1,3 +1,8 @@
1
+ begin
2
+ require 'base64'
3
+ rescue LoadError
4
+ end
5
+
1
6
  module ActiveSupport
2
7
  if defined? ::Base64
3
8
  Base64 = ::Base64
@@ -1,5 +1,24 @@
1
- # Ruby 1.9 introduces BasicObject. Use Builder's BlankSlate until then.
2
- unless defined? BasicObject
3
- require 'blankslate'
4
- BasicObject = BlankSlate
1
+ # A base class with no predefined methods that tries to behave like Builder's
2
+ # BlankSlate in Ruby 1.9. In Ruby pre-1.9, this is actually the
3
+ # Builder::BlankSlate class.
4
+ #
5
+ # Ruby 1.9 introduces BasicObject which differs slightly from Builder's
6
+ # BlankSlate that has been used so far. ActiveSupport::BasicObject provides a
7
+ # barebones base class that emulates Builder::BlankSlate while still relying on
8
+ # Ruby 1.9's BasicObject in Ruby 1.9.
9
+ module ActiveSupport
10
+ if RUBY_VERSION >= '1.9'
11
+ class BasicObject < ::BasicObject
12
+ undef_method :==
13
+ undef_method :equal?
14
+
15
+ # Let ActiveSupport::BasicObject at least raise exceptions.
16
+ def raise(*args)
17
+ ::Object.send(:raise, *args)
18
+ end
19
+ end
20
+ else
21
+ require 'blankslate'
22
+ BasicObject = BlankSlate
23
+ end
5
24
  end
@@ -39,6 +39,7 @@ module ActiveSupport
39
39
  @level = level
40
40
  @buffer = []
41
41
  @auto_flushing = 1
42
+ @no_block = false
42
43
 
43
44
  if log.respond_to?(:write)
44
45
  @log = log
@@ -46,19 +47,26 @@ module ActiveSupport
46
47
  @log = open(log, (File::WRONLY | File::APPEND))
47
48
  @log.sync = true
48
49
  else
50
+ FileUtils.mkdir_p(File.dirname(log))
49
51
  @log = open(log, (File::WRONLY | File::APPEND | File::CREAT))
50
52
  @log.sync = true
51
53
  @log.write("# Logfile created on %s" % [Time.now.to_s])
52
54
  end
53
55
  end
54
56
 
57
+ def set_non_blocking_io
58
+ if !RUBY_PLATFORM.match(/java|mswin/) && !(@log == STDOUT) && @log.respond_to?(:write_nonblock)
59
+ @no_block = true
60
+ end
61
+ end
62
+
55
63
  def add(severity, message = nil, progname = nil, &block)
56
64
  return if @level > severity
57
65
  message = (message || (block && block.call) || progname).to_s
58
66
  # If a newline is necessary then create a new message ending with a newline.
59
67
  # Ensures that the original message is not mutated.
60
68
  message = "#{message}\n" unless message[-1] == ?\n
61
- @buffer << message
69
+ buffer << message
62
70
  auto_flush
63
71
  message
64
72
  end
@@ -90,7 +98,13 @@ module ActiveSupport
90
98
  end
91
99
 
92
100
  def flush
93
- @log.write(@buffer.slice!(0..-1).join) unless @buffer.empty?
101
+ unless buffer.empty?
102
+ if @no_block
103
+ @log.write_nonblock(buffer.slice!(0..-1).join)
104
+ else
105
+ @log.write(buffer.slice!(0..-1).join)
106
+ end
107
+ end
94
108
  end
95
109
 
96
110
  def close
@@ -101,7 +115,7 @@ module ActiveSupport
101
115
 
102
116
  protected
103
117
  def auto_flush
104
- flush if @buffer.size >= @auto_flushing
118
+ flush if buffer.size >= @auto_flushing
105
119
  end
106
120
  end
107
121
  end
@@ -0,0 +1,145 @@
1
+ require 'benchmark'
2
+
3
+ module ActiveSupport
4
+ module Cache
5
+ def self.lookup_store(*store_option)
6
+ store, *parameters = *([ store_option ].flatten)
7
+
8
+ case store
9
+ when Symbol
10
+ store_class_name = (store == :drb_store ? "DRbStore" : store.to_s.camelize)
11
+ store_class = ActiveSupport::Cache.const_get(store_class_name)
12
+ store_class.new(*parameters)
13
+ when nil
14
+ ActiveSupport::Cache::MemoryStore.new
15
+ else
16
+ store
17
+ end
18
+ end
19
+
20
+ def self.expand_cache_key(key, namespace = nil)
21
+ expanded_cache_key = namespace ? "#{namespace}/" : ""
22
+
23
+ if ENV["RAILS_CACHE_ID"] || ENV["RAILS_APP_VERSION"]
24
+ expanded_cache_key << "#{ENV["RAILS_CACHE_ID"] || ENV["RAILS_APP_VERSION"]}/"
25
+ end
26
+
27
+ expanded_cache_key << case
28
+ when key.respond_to?(:cache_key)
29
+ key.cache_key
30
+ when key.is_a?(Array)
31
+ key.collect { |element| expand_cache_key(element) }.to_param
32
+ when key.respond_to?(:to_param)
33
+ key.to_param
34
+ end
35
+
36
+ expanded_cache_key
37
+ end
38
+
39
+
40
+ class Store
41
+ cattr_accessor :logger
42
+
43
+ def initialize
44
+ end
45
+
46
+ def threadsafe!
47
+ @mutex = Mutex.new
48
+ self.class.send :include, ThreadSafety
49
+ self
50
+ end
51
+
52
+ # Pass <tt>:force => true</tt> to force a cache miss.
53
+ def fetch(key, options = {})
54
+ @logger_off = true
55
+ if !options[:force] && value = read(key, options)
56
+ @logger_off = false
57
+ log("hit", key, options)
58
+ value
59
+ elsif block_given?
60
+ @logger_off = false
61
+ log("miss", key, options)
62
+
63
+ value = nil
64
+ seconds = Benchmark.realtime { value = yield }
65
+
66
+ @logger_off = true
67
+ write(key, value, options)
68
+ @logger_off = false
69
+
70
+ log("write (will save #{'%.5f' % seconds})", key, nil)
71
+
72
+ value
73
+ end
74
+ end
75
+
76
+ def read(key, options = nil)
77
+ log("read", key, options)
78
+ end
79
+
80
+ def write(key, value, options = nil)
81
+ log("write", key, options)
82
+ end
83
+
84
+ def delete(key, options = nil)
85
+ log("delete", key, options)
86
+ end
87
+
88
+ def delete_matched(matcher, options = nil)
89
+ log("delete matched", matcher.inspect, options)
90
+ end
91
+
92
+ def exist?(key, options = nil)
93
+ log("exist?", key, options)
94
+ end
95
+
96
+ def increment(key, amount = 1)
97
+ log("incrementing", key, amount)
98
+ if num = read(key)
99
+ write(key, num + amount)
100
+ else
101
+ nil
102
+ end
103
+ end
104
+
105
+ def decrement(key, amount = 1)
106
+ log("decrementing", key, amount)
107
+ if num = read(key)
108
+ write(key, num - amount)
109
+ else
110
+ nil
111
+ end
112
+ end
113
+
114
+ private
115
+ def log(operation, key, options)
116
+ logger.debug("Cache #{operation}: #{key}#{options ? " (#{options.inspect})" : ""}") if logger && !@logger_off
117
+ end
118
+ end
119
+
120
+
121
+ module ThreadSafety #:nodoc:
122
+ def read(key, options = nil) #:nodoc:
123
+ @mutex.synchronize { super }
124
+ end
125
+
126
+ def write(key, value, options = nil) #:nodoc:
127
+ @mutex.synchronize { super }
128
+ end
129
+
130
+ def delete(key, options = nil) #:nodoc:
131
+ @mutex.synchronize { super }
132
+ end
133
+
134
+ def delete_matched(matcher, options = nil) #:nodoc:
135
+ @mutex.synchronize { super }
136
+ end
137
+ end
138
+ end
139
+ end
140
+
141
+ require 'active_support/cache/file_store'
142
+ require 'active_support/cache/memory_store'
143
+ require 'active_support/cache/drb_store'
144
+ require 'active_support/cache/mem_cache_store'
145
+ require 'active_support/cache/compressed_mem_cache_store'