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
@@ -42,6 +42,14 @@ module Kernel
42
42
  stream.reopen(old_stream)
43
43
  end
44
44
 
45
+ # Blocks and ignores any exception passed as argument if raised within the block.
46
+ #
47
+ # suppress(ZeroDivisionError) do
48
+ # 1/0
49
+ # puts "This code is NOT reached"
50
+ # end
51
+ #
52
+ # puts "This code gets executed and nothing related to ZeroDivisionError was seen"
45
53
  def suppress(*exception_classes)
46
54
  begin yield
47
55
  rescue Exception => e
@@ -1,19 +1,20 @@
1
1
  class Module
2
- # Declare an attribute reader backed by an internally-named instance variable.
2
+ # Declares an attribute reader backed by an internally-named instance variable.
3
3
  def attr_internal_reader(*attrs)
4
4
  attrs.each do |attr|
5
5
  module_eval "def #{attr}() #{attr_internal_ivar_name(attr)} end"
6
6
  end
7
7
  end
8
8
 
9
- # Declare an attribute writer backed by an internally-named instance variable.
9
+ # Declares an attribute writer backed by an internally-named instance variable.
10
10
  def attr_internal_writer(*attrs)
11
11
  attrs.each do |attr|
12
12
  module_eval "def #{attr}=(v) #{attr_internal_ivar_name(attr)} = v end"
13
13
  end
14
14
  end
15
15
 
16
- # Declare attributes backed by 'internal' instance variables names.
16
+ # Declares an attribute reader and writer backed by an internally-named instance
17
+ # variable.
17
18
  def attr_internal_accessor(*attrs)
18
19
  attr_internal_reader(*attrs)
19
20
  attr_internal_writer(*attrs)
@@ -1,6 +1,16 @@
1
1
  # Extends the module object with module and instance accessors for class attributes,
2
2
  # just like the native attr* accessors for instance attributes.
3
- class Module # :nodoc:
3
+ #
4
+ # module AppConfiguration
5
+ # mattr_accessor :google_api_key
6
+ # self.google_api_key = "123456789"
7
+ #
8
+ # mattr_accessor :paypal_url
9
+ # self.paypal_url = "www.sandbox.paypal.com"
10
+ # end
11
+ #
12
+ # AppConfiguration.google_api_key = "overriding the api key!"
13
+ class Module
4
14
  def mattr_reader(*syms)
5
15
  syms.each do |sym|
6
16
  next if sym.is_a?(Hash)
@@ -1,8 +1,8 @@
1
1
  class Module
2
2
  # Provides a delegate class method to easily expose contained objects' methods
3
3
  # as your own. Pass one or more methods (specified as symbols or strings)
4
- # and the name of the target object as the final :to option (also a symbol
5
- # or string). At least one method and the :to option are required.
4
+ # and the name of the target object as the final <tt>:to</tt> option (also a symbol
5
+ # or string). At least one method and the <tt>:to</tt> option are required.
6
6
  #
7
7
  # Delegation is particularly useful with Active Record associations:
8
8
  #
@@ -20,6 +20,7 @@ class Module
20
20
  # Foo.new.goodbye # => NoMethodError: undefined method `goodbye' for #<Foo:0x1af30c>
21
21
  #
22
22
  # Multiple delegates to the same target are allowed:
23
+ #
23
24
  # class Foo < ActiveRecord::Base
24
25
  # belongs_to :greeter
25
26
  # delegate :hello, :goodbye, :to => :greeter
@@ -28,7 +29,8 @@ class Module
28
29
  # Foo.new.goodbye # => "goodbye"
29
30
  #
30
31
  # Methods can be delegated to instance variables, class variables, or constants
31
- # by providing the variable as a symbol:
32
+ # by providing them as a symbols:
33
+ #
32
34
  # class Foo
33
35
  # CONSTANT_ARRAY = [0,1,2,3]
34
36
  # @@class_array = [4,5,6,7]
@@ -1,4 +1,23 @@
1
1
  class Module
2
+ # Returns the classes in the current ObjectSpace where this module has been
3
+ # mixed in according to Module#included_modules.
4
+ #
5
+ # module M
6
+ # end
7
+ #
8
+ # module N
9
+ # include M
10
+ # end
11
+ #
12
+ # class C
13
+ # include M
14
+ # end
15
+ #
16
+ # class D < C
17
+ # end
18
+ #
19
+ # p M.included_in_classes # => [C, D]
20
+ #
2
21
  def included_in_classes
3
22
  classes = []
4
23
  ObjectSpace.each_object(Class) { |k| classes << k if k.included_modules.include?(self) }
@@ -1,13 +1,38 @@
1
1
  class Module
2
- # Return the module which contains this one; if this is a root module, such as
3
- # +::MyModule+, then Object is returned.
2
+ # Returns the module which contains this one according to its name.
3
+ #
4
+ # module M
5
+ # module N
6
+ # end
7
+ # end
8
+ # X = M::N
9
+ #
10
+ # p M::N.parent # => M
11
+ # p X.parent # => M
12
+ #
13
+ # The parent of top-level and anonymous modules is Object.
14
+ #
15
+ # p M.parent # => Object
16
+ # p Module.new.parent # => Object
17
+ #
4
18
  def parent
5
19
  parent_name = name.split('::')[0..-2] * '::'
6
20
  parent_name.empty? ? Object : parent_name.constantize
7
21
  end
8
-
9
- # Return all the parents of this module, ordered from nested outwards. The
10
- # receiver is not contained within the result.
22
+
23
+ # Returns all the parents of this module according to its name, ordered from
24
+ # nested outwards. The receiver is not contained within the result.
25
+ #
26
+ # module M
27
+ # module N
28
+ # end
29
+ # end
30
+ # X = M::N
31
+ #
32
+ # p M.parents # => [Object]
33
+ # p M::N.parents # => [M, Object]
34
+ # p X.parents # => [M, Object]
35
+ #
11
36
  def parents
12
37
  parents = []
13
38
  parts = name.split('::')[0..-2]
@@ -18,18 +43,27 @@ class Module
18
43
  parents << Object unless parents.include? Object
19
44
  parents
20
45
  end
21
-
22
- # Return the constants that have been defined locally by this object and not
23
- # in an ancestor. This method may miss some constants if their definition in
24
- # the ancestor is identical to their definition in the receiver.
25
- def local_constants
26
- inherited = {}
27
- ancestors.each do |anc|
28
- next if anc == self
29
- anc.constants.each { |const| inherited[const] = anc.const_get(const) }
46
+
47
+ if RUBY_VERSION < '1.9'
48
+ # Returns the constants that have been defined locally by this object and
49
+ # not in an ancestor. This method is exact if running under Ruby 1.9. In
50
+ # previous versions it may miss some constants if their definition in some
51
+ # ancestor is identical to their definition in the receiver.
52
+ def local_constants
53
+ inherited = {}
54
+
55
+ ancestors.each do |anc|
56
+ next if anc == self
57
+ anc.constants.each { |const| inherited[const] = anc.const_get(const) }
58
+ end
59
+
60
+ constants.select do |const|
61
+ !inherited.key?(const) || inherited[const].object_id != const_get(const).object_id
62
+ end
30
63
  end
31
- constants.select do |const|
32
- ! inherited.key?(const) || inherited[const].object_id != const_get(const).object_id
64
+ else
65
+ def local_constants #:nodoc:
66
+ constants(false)
33
67
  end
34
68
  end
35
69
 
@@ -1,4 +1,14 @@
1
1
  class Module
2
+ # Returns String#underscore applied to the module name minus trailing classes.
3
+ #
4
+ # ActiveRecord.as_load_path # => "active_record"
5
+ # ActiveRecord::Associations.as_load_path # => "active_record/associations"
6
+ # ActiveRecord::Base.as_load_path # => "active_record" (Base is a class)
7
+ #
8
+ # The Kernel module gives an empty string by definition.
9
+ #
10
+ # Kernel.as_load_path # => ""
11
+ # Math.as_load_path # => "math"
2
12
  def as_load_path
3
13
  if self == Object || self == Kernel
4
14
  ''
@@ -1,7 +1,9 @@
1
1
  require 'active_support/core_ext/numeric/time'
2
2
  require 'active_support/core_ext/numeric/bytes'
3
+ require 'active_support/core_ext/numeric/conversions'
3
4
 
4
5
  class Numeric #:nodoc:
5
6
  include ActiveSupport::CoreExtensions::Numeric::Time
6
- include ActiveSupport::CoreExtensions::Numeric::Bytes
7
+ include ActiveSupport::CoreExtensions::Numeric::Bytes
8
+ include ActiveSupport::CoreExtensions::Numeric::Conversions
7
9
  end
@@ -0,0 +1,19 @@
1
+ module ActiveSupport #:nodoc:
2
+ module CoreExtensions #:nodoc:
3
+ module Numeric #:nodoc:
4
+ module Conversions
5
+ # Assumes self represents an offset from UTC in seconds (as returned from Time#utc_offset)
6
+ # and turns this into an +HH:MM formatted string. Example:
7
+ #
8
+ # -21_600.to_utc_offset_s # => "-06:00"
9
+ def to_utc_offset_s(colon=true)
10
+ seconds = self
11
+ sign = (seconds < 0 ? -1 : 1)
12
+ hours = seconds.abs / 3600
13
+ minutes = (seconds.abs % 3600) / 60
14
+ "%+03d%s%02d" % [ hours * sign, colon ? ":" : "", minutes ]
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -6,6 +6,16 @@ class Object
6
6
  end
7
7
  end
8
8
 
9
+ # Returns a hash that maps instance variable names without "@" to their
10
+ # corresponding values. Keys are strings both in Ruby 1.8 and 1.9.
11
+ #
12
+ # class C
13
+ # def initialize(x, y)
14
+ # @x, @y = x, y
15
+ # end
16
+ # end
17
+ #
18
+ # C.new(0, 1).instance_values # => {"x" => 0, "y" => 1}
9
19
  def instance_values #:nodoc:
10
20
  instance_variables.inject({}) do |values, name|
11
21
  values[name.to_s[1..-1]] = instance_variable_get(name)
@@ -13,6 +23,48 @@ class Object
13
23
  end
14
24
  end
15
25
 
26
+ # Returns an array of instance variable names including "@". They are strings
27
+ # both in Ruby 1.8 and 1.9.
28
+ #
29
+ # class C
30
+ # def initialize(x, y)
31
+ # @x, @y = x, y
32
+ # end
33
+ # end
34
+ #
35
+ # C.new(0, 1).instance_variable_names # => ["@y", "@x"]
36
+ if RUBY_VERSION >= '1.9'
37
+ def instance_variable_names
38
+ instance_variables.map(&:to_s)
39
+ end
40
+ else
41
+ alias_method :instance_variable_names, :instance_variables
42
+ end
43
+
44
+ # Copies the instance variables of +object+ into +self+.
45
+ #
46
+ # Instance variable names in the +exclude+ array are ignored. If +object+
47
+ # responds to <tt>protected_instance_variables</tt> the ones returned are
48
+ # also ignored. For example, Rails controllers implement that method.
49
+ #
50
+ # In both cases strings and symbols are understood, and they have to include
51
+ # the at sign.
52
+ #
53
+ # class C
54
+ # def initialize(x, y, z)
55
+ # @x, @y, @z = x, y, z
56
+ # end
57
+ #
58
+ # def protected_instance_variables
59
+ # %w(@z)
60
+ # end
61
+ # end
62
+ #
63
+ # a = C.new(0, 1, 2)
64
+ # b = C.new(3, 4, 5)
65
+ #
66
+ # a.copy_instance_variables_from(b, [:@y])
67
+ # # a is now: @x = 3, @y = 1, @z = 2
16
68
  def copy_instance_variables_from(object, exclude = []) #:nodoc:
17
69
  exclude += object.protected_instance_variables if object.respond_to? :protected_instance_variables
18
70
 
@@ -48,7 +48,7 @@ class Object
48
48
  yield ActiveSupport::OptionMerger.new(self, options)
49
49
  end
50
50
 
51
- # A duck-type assistant method. For example, ActiveSupport extends Date
51
+ # A duck-type assistant method. For example, Active Support extends Date
52
52
  # to define an acts_like_date? method, and extends Time to define
53
53
  # acts_like_time?. As a result, we can do "x.acts_like?(:time)" and
54
54
  # "x.acts_like?(:date)" to do duck-type-safe comparisons, since classes that
@@ -0,0 +1 @@
1
+ require 'active_support/core_ext/process/daemon'
@@ -0,0 +1,25 @@
1
+ if RUBY_VERSION < "1.9"
2
+ module Process
3
+ def self.daemon(nochdir = nil, noclose = nil)
4
+ exit if fork # Parent exits, child continues.
5
+ Process.setsid # Become session leader.
6
+ exit if fork # Zap session leader. See [1].
7
+
8
+ unless nochdir
9
+ Dir.chdir "/" # Release old working directory.
10
+ end
11
+
12
+ File.umask 0000 # Ensure sensible umask. Adjust as needed.
13
+
14
+ unless noclose
15
+ STDIN.reopen "/dev/null" # Free file descriptors and
16
+ STDOUT.reopen "/dev/null", "a" # point them somewhere sensible.
17
+ STDERR.reopen '/dev/null', 'a'
18
+ end
19
+
20
+ trap("TERM") { exit }
21
+
22
+ return 0
23
+ end
24
+ end
25
+ end
@@ -13,7 +13,11 @@ module ActiveSupport #:nodoc:
13
13
  alias_method :to_s, :to_formatted_s
14
14
  end
15
15
  end
16
-
16
+ # Gives a human readable format of the range.
17
+ #
18
+ # ==== Example:
19
+ #
20
+ # [1..100].to_formatted_s # => "1..100"
17
21
  def to_formatted_s(format = :default)
18
22
  RANGE_FORMATS[format] ? RANGE_FORMATS[format].call(first, last) : to_default_s
19
23
  end
@@ -7,6 +7,14 @@ module ActiveSupport #:nodoc:
7
7
  base.alias_method_chain :include?, :range
8
8
  end
9
9
 
10
+ # Extends the default Range#include? to support range comparisons.
11
+ # (1..5).include?(1..5) # => true
12
+ # (1..5).include?(2..3) # => true
13
+ # (1..5).include?(2..6) # => false
14
+ #
15
+ # The native Range#include? behavior is untouched.
16
+ # ("a".."f").include?("c") # => true
17
+ # (5..9).include?(11) # => false
10
18
  def include_with_range?(value)
11
19
  if value.is_a?(::Range)
12
20
  operator = exclude_end? ? :< : :<=
@@ -3,6 +3,9 @@ module ActiveSupport #:nodoc:
3
3
  module Range #:nodoc:
4
4
  # Check if Ranges overlap.
5
5
  module Overlaps
6
+ # Compare two ranges and see if they overlap eachother
7
+ # (1..5).overlaps?(4..6) # => true
8
+ # (1..5).overlaps?(7..9) # => false
6
9
  def overlaps?(other)
7
10
  include?(other.first) || other.include?(first)
8
11
  end
@@ -2,22 +2,17 @@ require 'active_support/core_ext/string/inflections'
2
2
  require 'active_support/core_ext/string/conversions'
3
3
  require 'active_support/core_ext/string/access'
4
4
  require 'active_support/core_ext/string/starts_ends_with'
5
- require 'active_support/core_ext/string/iterators' unless 'test'.respond_to?(:each_char)
5
+ require 'active_support/core_ext/string/iterators'
6
6
  require 'active_support/core_ext/string/unicode'
7
7
  require 'active_support/core_ext/string/xchar'
8
+ require 'active_support/core_ext/string/filters'
8
9
 
9
10
  class String #:nodoc:
10
11
  include ActiveSupport::CoreExtensions::String::Access
11
12
  include ActiveSupport::CoreExtensions::String::Conversions
13
+ include ActiveSupport::CoreExtensions::String::Filters
12
14
  include ActiveSupport::CoreExtensions::String::Inflections
13
- if RUBY_VERSION < '1.9'
14
- include ActiveSupport::CoreExtensions::String::StartsEndsWith
15
- else
16
- alias starts_with? start_with?
17
- alias ends_with? end_with?
18
- end
19
- if defined? ActiveSupport::CoreExtensions::String::Iterators
20
- include ActiveSupport::CoreExtensions::String::Iterators
21
- end
15
+ include ActiveSupport::CoreExtensions::String::StartsEndsWith
16
+ include ActiveSupport::CoreExtensions::String::Iterators
22
17
  include ActiveSupport::CoreExtensions::String::Unicode
23
18
  end
@@ -1,56 +1,80 @@
1
1
  module ActiveSupport #:nodoc:
2
2
  module CoreExtensions #:nodoc:
3
3
  module String #:nodoc:
4
- # Makes it easier to access parts of a string, such as specific characters and substrings.
5
- module Access
6
- # Returns the character at the +position+ treating the string as an array (where 0 is the first character).
7
- #
8
- # Examples:
9
- # "hello".at(0) # => "h"
10
- # "hello".at(4) # => "o"
11
- # "hello".at(10) # => nil
12
- def at(position)
13
- chars[position, 1].to_s
14
- end
15
-
16
- # Returns the remaining of the string from the +position+ treating the string as an array (where 0 is the first character).
17
- #
18
- # Examples:
19
- # "hello".from(0) # => "hello"
20
- # "hello".from(2) # => "llo"
21
- # "hello".from(10) # => nil
22
- def from(position)
23
- chars[position..-1].to_s
24
- end
25
-
26
- # Returns the beginning of the string up to the +position+ treating the string as an array (where 0 is the first character).
27
- #
28
- # Examples:
29
- # "hello".to(0) # => "h"
30
- # "hello".to(2) # => "hel"
31
- # "hello".to(10) # => "hello"
32
- def to(position)
33
- chars[0..position].to_s
34
- end
4
+ unless '1.9'.respond_to?(:force_encoding)
5
+ # Makes it easier to access parts of a string, such as specific characters and substrings.
6
+ module Access
7
+ # Returns the character at the +position+ treating the string as an array (where 0 is the first character).
8
+ #
9
+ # Examples:
10
+ # "hello".at(0) # => "h"
11
+ # "hello".at(4) # => "o"
12
+ # "hello".at(10) # => nil
13
+ def at(position)
14
+ chars[position, 1].to_s
15
+ end
16
+
17
+ # Returns the remaining of the string from the +position+ treating the string as an array (where 0 is the first character).
18
+ #
19
+ # Examples:
20
+ # "hello".from(0) # => "hello"
21
+ # "hello".from(2) # => "llo"
22
+ # "hello".from(10) # => nil
23
+ def from(position)
24
+ chars[position..-1].to_s
25
+ end
26
+
27
+ # Returns the beginning of the string up to the +position+ treating the string as an array (where 0 is the first character).
28
+ #
29
+ # Examples:
30
+ # "hello".to(0) # => "h"
31
+ # "hello".to(2) # => "hel"
32
+ # "hello".to(10) # => "hello"
33
+ def to(position)
34
+ chars[0..position].to_s
35
+ end
35
36
 
36
- # Returns the first character of the string or the first +limit+ characters.
37
- #
38
- # Examples:
39
- # "hello".first # => "h"
40
- # "hello".first(2) # => "he"
41
- # "hello".first(10) # => "hello"
42
- def first(limit = 1)
43
- chars[0..(limit - 1)].to_s
37
+ # Returns the first character of the string or the first +limit+ characters.
38
+ #
39
+ # Examples:
40
+ # "hello".first # => "h"
41
+ # "hello".first(2) # => "he"
42
+ # "hello".first(10) # => "hello"
43
+ def first(limit = 1)
44
+ chars[0..(limit - 1)].to_s
45
+ end
46
+
47
+ # Returns the last character of the string or the last +limit+ characters.
48
+ #
49
+ # Examples:
50
+ # "hello".last # => "o"
51
+ # "hello".last(2) # => "lo"
52
+ # "hello".last(10) # => "hello"
53
+ def last(limit = 1)
54
+ (chars[(-limit)..-1] || self).to_s
55
+ end
44
56
  end
45
-
46
- # Returns the last character of the string or the last +limit+ characters.
47
- #
48
- # Examples:
49
- # "hello".last # => "o"
50
- # "hello".last(2) # => "lo"
51
- # "hello".last(10) # => "hello"
52
- def last(limit = 1)
53
- (chars[(-limit)..-1] || self).to_s
57
+ else
58
+ module Access #:nodoc:
59
+ def at(position)
60
+ self[position]
61
+ end
62
+
63
+ def from(position)
64
+ self[position..-1]
65
+ end
66
+
67
+ def to(position)
68
+ self[0..position]
69
+ end
70
+
71
+ def first(limit = 1)
72
+ self[0..(limit - 1)]
73
+ end
74
+
75
+ def last(limit = 1)
76
+ from(-limit) || self
77
+ end
54
78
  end
55
79
  end
56
80
  end