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
@@ -1,5 +1,4 @@
1
1
  require 'yaml'
2
- require 'delegate'
3
2
 
4
3
  module ActiveSupport
5
4
  module Deprecation #:nodoc:
@@ -145,8 +144,8 @@ module ActiveSupport
145
144
  end
146
145
  end
147
146
 
148
- # Stand-in for @request, @attributes, @params, etc which emits deprecation
149
- # warnings on any method call (except #inspect).
147
+ # Stand-in for <tt>@request</tt>, <tt>@attributes</tt>, <tt>@params</tt>, etc.
148
+ # which emits deprecation warnings on any method call (except +inspect+).
150
149
  class DeprecatedInstanceVariableProxy #:nodoc:
151
150
  silence_warnings do
152
151
  instance_methods.each { |m| undef_method m unless m =~ /^__/ }
@@ -176,20 +175,7 @@ module ActiveSupport
176
175
  ActiveSupport::Deprecation.warn("#{@var} is deprecated! Call #{@method}.#{called} instead of #{@var}.#{called}. Args: #{args.inspect}", callstack)
177
176
  end
178
177
  end
179
-
180
- class DeprecatedInstanceVariable < Delegator
181
- def initialize(value, method)
182
- super(value)
183
- @method = method
184
- @value = value
185
- end
186
178
 
187
- def __getobj__
188
- ActiveSupport::Deprecation.warn("Instance variable @#{@method} is deprecated! Call instance method #{@method} instead.")
189
- @value
190
- end
191
- end
192
-
193
179
  end
194
180
  end
195
181
 
@@ -51,14 +51,14 @@ module ActiveSupport
51
51
 
52
52
  # Calculates a new Time or Date that is as far in the future
53
53
  # as this Duration represents.
54
- def since(time = ::Time.now)
54
+ def since(time = ::Time.current)
55
55
  sum(1, time)
56
56
  end
57
57
  alias :from_now :since
58
58
 
59
59
  # Calculates a new Time or Date that is as far in the past
60
60
  # as this Duration represents.
61
- def ago(time = ::Time.now)
61
+ def ago(time = ::Time.current)
62
62
  sum(-1, time)
63
63
  end
64
64
  alias :until :ago
@@ -73,7 +73,7 @@ module ActiveSupport
73
73
 
74
74
  protected
75
75
 
76
- def sum(sign, time = ::Time.now) #:nodoc:
76
+ def sum(sign, time = ::Time.current) #:nodoc:
77
77
  parts.inject(time) do |t,(type,number)|
78
78
  if t.acts_like?(:time) || t.acts_like?(:date)
79
79
  if type == :seconds
@@ -82,7 +82,7 @@ module ActiveSupport
82
82
  t.advance(type => sign * number)
83
83
  end
84
84
  else
85
- raise ArgumentError, "expected a time or date, got #{time.inspect}"
85
+ raise ::ArgumentError, "expected a time or date, got #{time.inspect}"
86
86
  end
87
87
  end
88
88
  end
@@ -0,0 +1,25 @@
1
+ require 'zlib'
2
+ require 'stringio'
3
+
4
+ module ActiveSupport
5
+ # A convenient wrapper for the zlib standard library that allows compression/decompression of strings with gzip.
6
+ module Gzip
7
+ class Stream < StringIO
8
+ def close; rewind; end
9
+ end
10
+
11
+ # Decompresses a gzipped string.
12
+ def self.decompress(source)
13
+ Zlib::GzipReader.new(StringIO.new(source)).read
14
+ end
15
+
16
+ # Compresses a string using gzip.
17
+ def self.compress(source)
18
+ output = Stream.new
19
+ gz = Zlib::GzipWriter.new(output)
20
+ gz.write(source)
21
+ gz.close
22
+ output.string
23
+ end
24
+ end
25
+ end
@@ -3,6 +3,11 @@ require 'singleton'
3
3
  # The Inflector transforms words from singular to plural, class names to table names, modularized class names to ones without,
4
4
  # and class names to foreign keys. The default inflections for pluralization, singularization, and uncountable words are kept
5
5
  # in inflections.rb.
6
+ #
7
+ # The Rails core team has stated patches for the inflections library will not be accepted
8
+ # in order to avoid breaking legacy applications which may be relying on errant inflections.
9
+ # If you discover an incorrect inflection and require it for your application, you'll need
10
+ # to correct it yourself (explained below).
6
11
  module Inflector
7
12
  # A singleton instance of this class is yielded by Inflector.inflections, which can then be used to specify additional
8
13
  # inflection rules. Examples:
@@ -68,8 +73,9 @@ module Inflector
68
73
  (@uncountables << words).flatten!
69
74
  end
70
75
 
71
- # Clears the loaded inflections within a given scope (default is :all). Give the scope as a symbol of the inflection type,
72
- # the options are: :plurals, :singulars, :uncountables
76
+ # Clears the loaded inflections within a given scope (default is <tt>:all</tt>).
77
+ # Give the scope as a symbol of the inflection type, the options are: <tt>:plurals</tt>,
78
+ # <tt>:singulars</tt>, <tt>:uncountables</tt>.
73
79
  #
74
80
  # Examples:
75
81
  # clear :all
@@ -86,6 +92,13 @@ module Inflector
86
92
 
87
93
  extend self
88
94
 
95
+ # Yields a singleton instance of Inflector::Inflections so you can specify additional
96
+ # inflector rules.
97
+ #
98
+ # Example:
99
+ # Inflector.inflections do |inflect|
100
+ # inflect.uncountable "rails"
101
+ # end
89
102
  def inflections
90
103
  if block_given?
91
104
  yield Inflections.instance
@@ -96,13 +109,13 @@ module Inflector
96
109
 
97
110
  # Returns the plural form of the word in the string.
98
111
  #
99
- # Examples
100
- # "post".pluralize #=> "posts"
101
- # "octopus".pluralize #=> "octopi"
102
- # "sheep".pluralize #=> "sheep"
103
- # "words".pluralize #=> "words"
104
- # "the blue mailman".pluralize #=> "the blue mailmen"
105
- # "CamelOctopus".pluralize #=> "CamelOctopi"
112
+ # Examples:
113
+ # "post".pluralize # => "posts"
114
+ # "octopus".pluralize # => "octopi"
115
+ # "sheep".pluralize # => "sheep"
116
+ # "words".pluralize # => "words"
117
+ # "the blue mailman".pluralize # => "the blue mailmen"
118
+ # "CamelOctopus".pluralize # => "CamelOctopi"
106
119
  def pluralize(word)
107
120
  result = word.to_s.dup
108
121
 
@@ -114,15 +127,15 @@ module Inflector
114
127
  end
115
128
  end
116
129
 
117
- # The reverse of pluralize, returns the singular form of a word in a string.
130
+ # The reverse of +pluralize+, returns the singular form of a word in a string.
118
131
  #
119
- # Examples
120
- # "posts".singularize #=> "post"
121
- # "octopi".singularize #=> "octopus"
122
- # "sheep".singluarize #=> "sheep"
123
- # "word".singluarize #=> "word"
124
- # "the blue mailmen".singularize #=> "the blue mailman"
125
- # "CamelOctopi".singularize #=> "CamelOctopus"
132
+ # Examples:
133
+ # "posts".singularize # => "post"
134
+ # "octopi".singularize # => "octopus"
135
+ # "sheep".singluarize # => "sheep"
136
+ # "word".singluarize # => "word"
137
+ # "the blue mailmen".singularize # => "the blue mailman"
138
+ # "CamelOctopi".singularize # => "CamelOctopus"
126
139
  def singularize(word)
127
140
  result = word.to_s.dup
128
141
 
@@ -134,44 +147,44 @@ module Inflector
134
147
  end
135
148
  end
136
149
 
137
- # By default, camelize converts strings to UpperCamelCase. If the argument to camelize
138
- # is set to ":lower" then camelize produces lowerCamelCase.
150
+ # By default, +camelize+ converts strings to UpperCamelCase. If the argument to +camelize+
151
+ # is set to <tt>:lower</tt> then +camelize+ produces lowerCamelCase.
139
152
  #
140
- # camelize will also convert '/' to '::' which is useful for converting paths to namespaces
153
+ # +camelize+ will also convert '/' to '::' which is useful for converting paths to namespaces.
141
154
  #
142
- # Examples
143
- # "active_record".camelize #=> "ActiveRecord"
144
- # "active_record".camelize(:lower) #=> "activeRecord"
145
- # "active_record/errors".camelize #=> "ActiveRecord::Errors"
146
- # "active_record/errors".camelize(:lower) #=> "activeRecord::Errors"
155
+ # Examples:
156
+ # "active_record".camelize # => "ActiveRecord"
157
+ # "active_record".camelize(:lower) # => "activeRecord"
158
+ # "active_record/errors".camelize # => "ActiveRecord::Errors"
159
+ # "active_record/errors".camelize(:lower) # => "activeRecord::Errors"
147
160
  def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true)
148
161
  if first_letter_in_uppercase
149
- lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
162
+ lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
150
163
  else
151
164
  lower_case_and_underscored_word.first + camelize(lower_case_and_underscored_word)[1..-1]
152
165
  end
153
166
  end
154
167
 
155
168
  # Capitalizes all the words and replaces some characters in the string to create
156
- # a nicer looking title. Titleize is meant for creating pretty output. It is not
169
+ # a nicer looking title. +titleize+ is meant for creating pretty output. It is not
157
170
  # used in the Rails internals.
158
171
  #
159
- # titleize is also aliased as as titlecase
172
+ # +titleize+ is also aliased as as +titlecase+.
160
173
  #
161
- # Examples
162
- # "man from the boondocks".titleize #=> "Man From The Boondocks"
163
- # "x-men: the last stand".titleize #=> "X Men: The Last Stand"
174
+ # Examples:
175
+ # "man from the boondocks".titleize # => "Man From The Boondocks"
176
+ # "x-men: the last stand".titleize # => "X Men: The Last Stand"
164
177
  def titleize(word)
165
178
  humanize(underscore(word)).gsub(/\b('?[a-z])/) { $1.capitalize }
166
179
  end
167
180
 
168
- # The reverse of +camelize+. Makes an underscored form from the expression in the string.
181
+ # The reverse of +camelize+. Makes an underscored, lowercase form from the expression in the string.
169
182
  #
170
183
  # Changes '::' to '/' to convert namespaces to paths.
171
184
  #
172
- # Examples
173
- # "ActiveRecord".underscore #=> "active_record"
174
- # "ActiveRecord::Errors".underscore #=> active_record/errors
185
+ # Examples:
186
+ # "ActiveRecord".underscore # => "active_record"
187
+ # "ActiveRecord::Errors".underscore # => active_record/errors
175
188
  def underscore(camel_cased_word)
176
189
  camel_cased_word.to_s.gsub(/::/, '/').
177
190
  gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
@@ -182,52 +195,52 @@ module Inflector
182
195
 
183
196
  # Replaces underscores with dashes in the string.
184
197
  #
185
- # Example
186
- # "puni_puni" #=> "puni-puni"
198
+ # Example:
199
+ # "puni_puni" # => "puni-puni"
187
200
  def dasherize(underscored_word)
188
201
  underscored_word.gsub(/_/, '-')
189
202
  end
190
203
 
191
- # Capitalizes the first word and turns underscores into spaces and strips _id.
192
- # Like titleize, this is meant for creating pretty output.
204
+ # Capitalizes the first word and turns underscores into spaces and strips a
205
+ # trailing "_id", if any. Like +titleize+, this is meant for creating pretty output.
193
206
  #
194
- # Examples
195
- # "employee_salary" #=> "Employee salary"
196
- # "author_id" #=> "Author"
207
+ # Examples:
208
+ # "employee_salary" # => "Employee salary"
209
+ # "author_id" # => "Author"
197
210
  def humanize(lower_case_and_underscored_word)
198
211
  lower_case_and_underscored_word.to_s.gsub(/_id$/, "").gsub(/_/, " ").capitalize
199
212
  end
200
213
 
201
- # Removes the module part from the expression in the string
214
+ # Removes the module part from the expression in the string.
202
215
  #
203
- # Examples
204
- # "ActiveRecord::CoreExtensions::String::Inflections".demodulize #=> "Inflections"
205
- # "Inflections".demodulize #=> "Inflections"
216
+ # Examples:
217
+ # "ActiveRecord::CoreExtensions::String::Inflections".demodulize # => "Inflections"
218
+ # "Inflections".demodulize # => "Inflections"
206
219
  def demodulize(class_name_in_module)
207
220
  class_name_in_module.to_s.gsub(/^.*::/, '')
208
221
  end
209
222
 
210
223
  # Create the name of a table like Rails does for models to table names. This method
211
- # uses the pluralize method on the last word in the string.
224
+ # uses the +pluralize+ method on the last word in the string.
212
225
  #
213
226
  # Examples
214
- # "RawScaledScorer".tableize #=> "raw_scaled_scorers"
215
- # "egg_and_ham".tableize #=> "egg_and_hams"
216
- # "fancyCategory".tableize #=> "fancy_categories"
227
+ # "RawScaledScorer".tableize # => "raw_scaled_scorers"
228
+ # "egg_and_ham".tableize # => "egg_and_hams"
229
+ # "fancyCategory".tableize # => "fancy_categories"
217
230
  def tableize(class_name)
218
231
  pluralize(underscore(class_name))
219
232
  end
220
233
 
221
234
  # Create a class name from a plural table name like Rails does for table names to models.
222
235
  # Note that this returns a string and not a Class. (To convert to an actual class
223
- # follow classify with constantize.)
236
+ # follow +classify+ with +constantize+.)
224
237
  #
225
- # Examples
226
- # "egg_and_hams".classify #=> "EggAndHam"
227
- # "posts".classify #=> "Post"
238
+ # Examples:
239
+ # "egg_and_hams".classify # => "EggAndHam"
240
+ # "posts".classify # => "Post"
228
241
  #
229
- # Singular names are not handled correctly
230
- # "business".classify #=> "Busines"
242
+ # Singular names are not handled correctly:
243
+ # "business".classify # => "Busines"
231
244
  def classify(table_name)
232
245
  # strip out any leading schema name
233
246
  camelize(singularize(table_name.to_s.sub(/.*\./, '')))
@@ -237,21 +250,31 @@ module Inflector
237
250
  # +separate_class_name_and_id_with_underscore+ sets whether
238
251
  # the method should put '_' between the name and 'id'.
239
252
  #
240
- # Examples
241
- # "Message".foreign_key #=> "message_id"
242
- # "Message".foreign_key(false) #=> "messageid"
243
- # "Admin::Post".foreign_key #=> "post_id"
253
+ # Examples:
254
+ # "Message".foreign_key # => "message_id"
255
+ # "Message".foreign_key(false) # => "messageid"
256
+ # "Admin::Post".foreign_key # => "post_id"
244
257
  def foreign_key(class_name, separate_class_name_and_id_with_underscore = true)
245
258
  underscore(demodulize(class_name)) + (separate_class_name_and_id_with_underscore ? "_id" : "id")
246
259
  end
247
260
 
248
- # Constantize tries to find a declared constant with the name specified
249
- # in the string. It raises a NameError when the name is not in CamelCase
250
- # or is not initialized.
261
+ # Tries to find a constant with the name specified in the argument string:
251
262
  #
252
- # Examples
253
- # "Module".constantize #=> Module
254
- # "Class".constantize #=> Class
263
+ # "Module".constantize # => Module
264
+ # "Test::Unit".constantize # => Test::Unit
265
+ #
266
+ # The name is assumed to be the one of a top-level constant, no matter whether
267
+ # it starts with "::" or not. No lexical context is taken into account:
268
+ #
269
+ # C = 'outside'
270
+ # module M
271
+ # C = 'inside'
272
+ # C # => 'inside'
273
+ # "C".constantize # => 'outside', same as ::C
274
+ # end
275
+ #
276
+ # NameError is raised when the name is not in CamelCase or the constant is
277
+ # unknown.
255
278
  def constantize(camel_cased_word)
256
279
  unless /\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/ =~ camel_cased_word
257
280
  raise NameError, "#{camel_cased_word.inspect} is not a valid constant name!"
@@ -260,10 +283,10 @@ module Inflector
260
283
  Object.module_eval("::#{$1}", __FILE__, __LINE__)
261
284
  end
262
285
 
263
- # Ordinalize turns a number into an ordinal string used to denote the
264
- # position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
286
+ # Turns a number into an ordinal string used to denote the position in an
287
+ # ordered sequence such as 1st, 2nd, 3rd, 4th.
265
288
  #
266
- # Examples
289
+ # Examples:
267
290
  # ordinalize(1) # => "1st"
268
291
  # ordinalize(2) # => "2nd"
269
292
  # ordinalize(1002) # => "1002nd"
@@ -1,31 +1,23 @@
1
- require 'active_support/json/encoding'
2
- require 'active_support/json/decoding'
3
-
4
1
  module ActiveSupport
5
- module JSON
6
- RESERVED_WORDS = %w(
7
- abstract delete goto private transient
8
- boolean do if protected try
9
- break double implements public typeof
10
- byte else import return var
11
- case enum in short void
12
- catch export instanceof static volatile
13
- char extends int super while
14
- class final interface switch with
15
- const finally long synchronized
16
- continue float native this
17
- debugger for new throw
18
- default function package throws
19
- ) #:nodoc:
2
+ # If true, use ISO 8601 format for dates and times. Otherwise, fall back to the Active Support legacy format.
3
+ mattr_accessor :use_standard_json_time_format
20
4
 
21
- class << self
22
- def valid_identifier?(key) #:nodoc:
23
- key.to_s =~ /^[[:alpha:]_$][[:alnum:]_$]*$/ && !reserved_word?(key)
24
- end
5
+ class << self
6
+ def escape_html_entities_in_json
7
+ @escape_html_entities_in_json
8
+ end
25
9
 
26
- def reserved_word?(key) #:nodoc:
27
- RESERVED_WORDS.include?(key.to_s)
28
- end
10
+ def escape_html_entities_in_json=(value)
11
+ ActiveSupport::JSON::Encoding.escape_regex = \
12
+ if value
13
+ /[\010\f\n\r\t"\\><&]/
14
+ else
15
+ /[\010\f\n\r\t"\\]/
16
+ end
17
+ @escape_html_entities_in_json = value
29
18
  end
30
19
  end
31
20
  end
21
+
22
+ require 'active_support/json/encoding'
23
+ require 'active_support/json/decoding'
@@ -31,7 +31,7 @@ module ActiveSupport
31
31
  if json[pos..scanner.pos-2] =~ DATE_REGEX
32
32
  # found a date, track the exact positions of the quotes so we can remove them later.
33
33
  # oh, and increment them for each current mark, each one is an extra padded space that bumps
34
- # the position in the final yaml output
34
+ # the position in the final YAML output
35
35
  total_marks = marks.size
36
36
  times << pos+total_marks << scanner.pos+total_marks
37
37
  end
@@ -1,5 +1,14 @@
1
1
  class Date
2
- def to_json(options = nil) #:nodoc:
3
- %("#{strftime("%Y/%m/%d")}")
2
+ # Returns a JSON string representing the date.
3
+ #
4
+ # ==== Example:
5
+ # Date.new(2005,2,1).to_json
6
+ # # => "2005/02/01"
7
+ def to_json(options = nil)
8
+ if ActiveSupport.use_standard_json_time_format
9
+ %("#{strftime("%Y-%m-%d")}")
10
+ else
11
+ %("#{strftime("%Y/%m/%d")}")
12
+ end
4
13
  end
5
14
  end
@@ -1,5 +1,14 @@
1
1
  class DateTime
2
- def to_json(options = nil) #:nodoc:
3
- %("#{strftime("%Y/%m/%d %H:%M:%S %z")}")
2
+ # Returns a JSON string representing the datetime.
3
+ #
4
+ # ==== Example:
5
+ # DateTime.civil(2005,2,1,15,15,10).to_json
6
+ # # => "2005/02/01 15:15:10 +0000"
7
+ def to_json(options = nil)
8
+ if ActiveSupport.use_standard_json_time_format
9
+ xmlschema.inspect
10
+ else
11
+ %("#{strftime("%Y/%m/%d %H:%M:%S %z")}")
12
+ end
4
13
  end
5
14
  end