activesupport 3.0.0.beta4 → 3.0.pre

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

Potentially problematic release.


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

Files changed (333) hide show
  1. data/CHANGELOG +1 -100
  2. data/lib/active_support.rb +4 -38
  3. data/lib/active_support/autoload.rb +28 -0
  4. data/lib/active_support/backtrace_cleaner.rb +9 -31
  5. data/lib/active_support/benchmarkable.rb +0 -1
  6. data/lib/active_support/buffered_logger.rb +1 -0
  7. data/lib/active_support/cache.rb +81 -436
  8. data/lib/active_support/cache/compressed_mem_cache_store.rb +13 -6
  9. data/lib/active_support/cache/file_store.rb +41 -139
  10. data/lib/active_support/cache/mem_cache_store.rb +75 -120
  11. data/lib/active_support/cache/memory_store.rb +27 -127
  12. data/lib/active_support/cache/strategy/local_cache.rb +58 -111
  13. data/lib/active_support/cache/synchronized_memory_store.rb +38 -2
  14. data/lib/active_support/callbacks.rb +48 -87
  15. data/lib/active_support/configurable.rb +18 -19
  16. data/lib/active_support/core_ext/array.rb +0 -1
  17. data/lib/active_support/core_ext/array/access.rb +1 -1
  18. data/lib/active_support/core_ext/array/conversions.rb +54 -29
  19. data/lib/active_support/core_ext/array/extract_options.rb +1 -16
  20. data/lib/active_support/core_ext/array/random_access.rb +5 -19
  21. data/lib/active_support/core_ext/array/wrap.rb +9 -13
  22. data/lib/active_support/core_ext/benchmark.rb +12 -0
  23. data/lib/active_support/core_ext/boolean.rb +1 -0
  24. data/lib/active_support/core_ext/boolean/conversions.rb +11 -0
  25. data/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +0 -2
  26. data/lib/active_support/core_ext/class.rb +1 -1
  27. data/lib/active_support/core_ext/class/attribute_accessors.rb +27 -33
  28. data/lib/active_support/core_ext/class/delegating_attributes.rb +41 -35
  29. data/lib/active_support/core_ext/class/inheritable_attributes.rb +13 -22
  30. data/lib/active_support/core_ext/class/removal.rb +53 -0
  31. data/lib/active_support/core_ext/date.rb +7 -0
  32. data/lib/active_support/core_ext/date/calculations.rb +8 -30
  33. data/lib/active_support/core_ext/date/conversions.rb +2 -2
  34. data/lib/active_support/core_ext/date_time.rb +5 -0
  35. data/lib/active_support/core_ext/date_time/calculations.rb +1 -2
  36. data/lib/active_support/core_ext/date_time/conversions.rb +5 -23
  37. data/lib/active_support/core_ext/enumerable.rb +9 -5
  38. data/lib/active_support/core_ext/exception.rb +47 -0
  39. data/lib/active_support/core_ext/file.rb +0 -1
  40. data/lib/active_support/core_ext/file/atomic.rb +2 -3
  41. data/lib/active_support/core_ext/float/rounding.rb +2 -3
  42. data/lib/active_support/core_ext/hash/conversions.rb +145 -65
  43. data/lib/active_support/core_ext/hash/deep_merge.rb +7 -6
  44. data/lib/active_support/core_ext/hash/except.rb +0 -8
  45. data/lib/active_support/core_ext/hash/indifferent_access.rb +0 -5
  46. data/lib/active_support/core_ext/hash/keys.rb +11 -10
  47. data/lib/active_support/core_ext/hash/slice.rb +0 -6
  48. data/lib/active_support/core_ext/integer.rb +1 -1
  49. data/lib/active_support/core_ext/integer/even_odd.rb +16 -0
  50. data/lib/active_support/core_ext/kernel.rb +1 -1
  51. data/lib/active_support/core_ext/kernel/daemonizing.rb +7 -0
  52. data/lib/active_support/core_ext/kernel/debugger.rb +2 -3
  53. data/lib/active_support/core_ext/kernel/reporting.rb +1 -2
  54. data/lib/active_support/core_ext/load_error.rb +30 -17
  55. data/lib/active_support/core_ext/logger.rb +1 -1
  56. data/lib/active_support/core_ext/module.rb +3 -5
  57. data/lib/active_support/core_ext/module/aliasing.rb +1 -1
  58. data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +1 -1
  59. data/lib/active_support/core_ext/module/attr_internal.rb +2 -2
  60. data/lib/active_support/core_ext/module/attribute_accessors.rb +21 -25
  61. data/lib/active_support/core_ext/module/delegation.rb +10 -21
  62. data/lib/active_support/core_ext/module/inclusion.rb +30 -0
  63. data/lib/active_support/core_ext/module/introspection.rb +8 -8
  64. data/lib/active_support/core_ext/module/loading.rb +23 -0
  65. data/lib/active_support/core_ext/module/synchronization.rb +1 -2
  66. data/lib/active_support/core_ext/name_error.rb +1 -3
  67. data/lib/active_support/core_ext/nil.rb +1 -0
  68. data/lib/active_support/core_ext/nil/conversions.rb +5 -0
  69. data/lib/active_support/core_ext/object.rb +2 -6
  70. data/lib/active_support/core_ext/object/blank.rb +2 -20
  71. data/lib/active_support/core_ext/object/conversions.rb +16 -2
  72. data/lib/active_support/core_ext/object/duplicable.rb +1 -23
  73. data/lib/active_support/core_ext/object/extending.rb +77 -8
  74. data/lib/active_support/core_ext/object/instance_variables.rb +7 -0
  75. data/lib/active_support/core_ext/object/metaclass.rb +13 -0
  76. data/lib/active_support/core_ext/object/misc.rb +1 -0
  77. data/lib/active_support/core_ext/object/tap.rb +16 -0
  78. data/lib/active_support/core_ext/object/with_options.rb +0 -2
  79. data/lib/active_support/core_ext/proc.rb +4 -4
  80. data/lib/active_support/core_ext/regexp.rb +22 -0
  81. data/lib/active_support/core_ext/rexml.rb +1 -4
  82. data/lib/active_support/core_ext/string.rb +2 -3
  83. data/lib/active_support/core_ext/string/access.rb +2 -4
  84. data/lib/active_support/core_ext/string/bytesize.rb +5 -0
  85. data/lib/active_support/core_ext/string/conversions.rb +1 -36
  86. data/lib/active_support/core_ext/string/filters.rb +0 -29
  87. data/lib/active_support/core_ext/string/inflections.rb +12 -1
  88. data/lib/active_support/core_ext/string/interpolation.rb +92 -2
  89. data/lib/active_support/core_ext/string/iterators.rb +13 -0
  90. data/lib/active_support/core_ext/string/multibyte.rb +19 -16
  91. data/lib/active_support/core_ext/string/output_safety.rb +35 -101
  92. data/lib/active_support/core_ext/string/starts_ends_with.rb +14 -0
  93. data/lib/active_support/core_ext/string/xchar.rb +1 -1
  94. data/lib/active_support/core_ext/symbol.rb +1 -0
  95. data/lib/active_support/core_ext/symbol/to_proc.rb +14 -0
  96. data/lib/active_support/core_ext/time.rb +10 -0
  97. data/lib/active_support/core_ext/time/calculations.rb +7 -9
  98. data/lib/active_support/core_ext/time/conversions.rb +0 -1
  99. data/lib/active_support/core_ext/time/marshal_with_utc_flag.rb +22 -0
  100. data/lib/active_support/core_ext/uri.rb +4 -10
  101. data/lib/active_support/dependencies.rb +192 -179
  102. data/lib/active_support/deprecated_callbacks.rb +283 -0
  103. data/lib/active_support/deprecation/behaviors.rb +1 -1
  104. data/lib/active_support/deprecation/method_wrappers.rb +9 -10
  105. data/lib/active_support/deprecation/reporting.rb +1 -2
  106. data/lib/active_support/duration.rb +2 -6
  107. data/lib/active_support/hash_with_indifferent_access.rb +1 -9
  108. data/lib/active_support/inflections.rb +1 -1
  109. data/lib/active_support/inflector.rb +407 -4
  110. data/lib/active_support/json/backends/jsongem.rb +9 -12
  111. data/lib/active_support/json/decoding.rb +1 -16
  112. data/lib/active_support/json/encoding.rb +12 -42
  113. data/lib/active_support/locale/en.yml +1 -4
  114. data/lib/active_support/memoizable.rb +1 -1
  115. data/lib/active_support/message_encryptor.rb +0 -1
  116. data/lib/active_support/message_verifier.rb +5 -6
  117. data/lib/active_support/multibyte.rb +22 -7
  118. data/lib/active_support/multibyte/chars.rb +392 -164
  119. data/lib/active_support/multibyte/unicode_database.rb +71 -0
  120. data/lib/active_support/multibyte/utils.rb +7 -6
  121. data/lib/active_support/notifications.rb +113 -23
  122. data/lib/active_support/ordered_hash.rb +11 -35
  123. data/lib/active_support/ordered_options.rb +0 -6
  124. data/lib/active_support/rescuable.rb +4 -7
  125. data/lib/active_support/ruby/shim.rb +6 -4
  126. data/lib/active_support/test_case.rb +7 -2
  127. data/lib/active_support/testing/assertions.rb +0 -15
  128. data/lib/active_support/testing/declarative.rb +1 -1
  129. data/lib/active_support/testing/isolation.rb +19 -63
  130. data/lib/active_support/testing/performance.rb +337 -342
  131. data/lib/active_support/testing/setup_and_teardown.rb +29 -51
  132. data/lib/active_support/time.rb +3 -23
  133. data/lib/active_support/time_with_zone.rb +10 -5
  134. data/lib/active_support/values/time_zone.rb +84 -40
  135. data/lib/active_support/values/unicode_tables.dat +0 -0
  136. data/lib/active_support/vendor.rb +16 -0
  137. data/lib/active_support/vendor/builder-2.1.2/lib/blankslate.rb +113 -0
  138. data/lib/active_support/vendor/builder-2.1.2/lib/builder.rb +13 -0
  139. data/lib/active_support/vendor/builder-2.1.2/lib/builder/blankslate.rb +20 -0
  140. data/lib/active_support/vendor/builder-2.1.2/lib/builder/css.rb +250 -0
  141. data/lib/active_support/vendor/builder-2.1.2/lib/builder/xchar.rb +115 -0
  142. data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlbase.rb +139 -0
  143. data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlevents.rb +63 -0
  144. data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlmarkup.rb +328 -0
  145. data/lib/active_support/vendor/i18n-0.1.3/MIT-LICENSE +20 -0
  146. data/lib/active_support/vendor/i18n-0.1.3/README.textile +20 -0
  147. data/lib/active_support/vendor/i18n-0.1.3/Rakefile +5 -0
  148. data/lib/active_support/vendor/i18n-0.1.3/i18n.gemspec +27 -0
  149. data/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb +204 -0
  150. data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb +215 -0
  151. data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/exceptions.rb +53 -0
  152. data/lib/active_support/vendor/i18n-0.1.3/test/all.rb +5 -0
  153. data/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb +99 -0
  154. data/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb +124 -0
  155. data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.rb +1 -0
  156. data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.yml +3 -0
  157. data/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb +567 -0
  158. data/lib/active_support/vendor/memcache-client-1.7.5/lib/memcache.rb +1133 -0
  159. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo.rb +33 -0
  160. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/data_timezone.rb +47 -0
  161. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/data_timezone_info.rb +228 -0
  162. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Algiers.rb +55 -0
  163. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Cairo.rb +219 -0
  164. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Casablanca.rb +42 -0
  165. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Harare.rb +18 -0
  166. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Johannesburg.rb +25 -0
  167. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Monrovia.rb +22 -0
  168. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Nairobi.rb +23 -0
  169. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +166 -0
  170. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Argentina/San_Juan.rb +86 -0
  171. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Bogota.rb +23 -0
  172. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Caracas.rb +23 -0
  173. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Chicago.rb +283 -0
  174. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Chihuahua.rb +136 -0
  175. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Denver.rb +204 -0
  176. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Godthab.rb +161 -0
  177. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Guatemala.rb +27 -0
  178. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Halifax.rb +274 -0
  179. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Indiana/Indianapolis.rb +149 -0
  180. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Juneau.rb +194 -0
  181. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/La_Paz.rb +22 -0
  182. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Lima.rb +35 -0
  183. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Los_Angeles.rb +232 -0
  184. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Mazatlan.rb +139 -0
  185. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Mexico_City.rb +144 -0
  186. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Monterrey.rb +131 -0
  187. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/New_York.rb +282 -0
  188. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Phoenix.rb +30 -0
  189. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Regina.rb +74 -0
  190. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Santiago.rb +205 -0
  191. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Sao_Paulo.rb +171 -0
  192. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/St_Johns.rb +288 -0
  193. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Tijuana.rb +196 -0
  194. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Almaty.rb +67 -0
  195. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Baghdad.rb +73 -0
  196. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Baku.rb +161 -0
  197. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Bangkok.rb +20 -0
  198. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Chongqing.rb +33 -0
  199. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Colombo.rb +30 -0
  200. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Dhaka.rb +27 -0
  201. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Hong_Kong.rb +87 -0
  202. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Irkutsk.rb +165 -0
  203. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Jakarta.rb +30 -0
  204. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Jerusalem.rb +163 -0
  205. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kabul.rb +20 -0
  206. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kamchatka.rb +163 -0
  207. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Karachi.rb +32 -0
  208. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kathmandu.rb +20 -0
  209. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kolkata.rb +25 -0
  210. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Krasnoyarsk.rb +163 -0
  211. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kuala_Lumpur.rb +31 -0
  212. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kuwait.rb +18 -0
  213. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Magadan.rb +163 -0
  214. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Muscat.rb +18 -0
  215. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Novosibirsk.rb +164 -0
  216. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Rangoon.rb +24 -0
  217. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Riyadh.rb +18 -0
  218. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Seoul.rb +34 -0
  219. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Shanghai.rb +35 -0
  220. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Singapore.rb +33 -0
  221. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Taipei.rb +59 -0
  222. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tashkent.rb +47 -0
  223. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tbilisi.rb +78 -0
  224. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tehran.rb +121 -0
  225. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tokyo.rb +30 -0
  226. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Ulaanbaatar.rb +65 -0
  227. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Urumqi.rb +33 -0
  228. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Vladivostok.rb +164 -0
  229. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yakutsk.rb +163 -0
  230. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yekaterinburg.rb +165 -0
  231. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yerevan.rb +165 -0
  232. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/Azores.rb +270 -0
  233. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/Cape_Verde.rb +23 -0
  234. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/South_Georgia.rb +18 -0
  235. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Adelaide.rb +187 -0
  236. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Brisbane.rb +35 -0
  237. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Darwin.rb +29 -0
  238. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Hobart.rb +193 -0
  239. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Melbourne.rb +185 -0
  240. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Perth.rb +37 -0
  241. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Sydney.rb +185 -0
  242. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Etc/UTC.rb +16 -0
  243. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Amsterdam.rb +228 -0
  244. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Athens.rb +185 -0
  245. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Belgrade.rb +163 -0
  246. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Berlin.rb +188 -0
  247. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Bratislava.rb +13 -0
  248. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Brussels.rb +232 -0
  249. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Bucharest.rb +181 -0
  250. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Budapest.rb +197 -0
  251. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Copenhagen.rb +179 -0
  252. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Dublin.rb +276 -0
  253. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Helsinki.rb +163 -0
  254. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Istanbul.rb +218 -0
  255. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Kiev.rb +168 -0
  256. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Lisbon.rb +268 -0
  257. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Ljubljana.rb +13 -0
  258. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/London.rb +288 -0
  259. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Madrid.rb +211 -0
  260. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Minsk.rb +170 -0
  261. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Moscow.rb +181 -0
  262. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Paris.rb +232 -0
  263. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Prague.rb +187 -0
  264. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Riga.rb +176 -0
  265. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Rome.rb +215 -0
  266. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Sarajevo.rb +13 -0
  267. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Skopje.rb +13 -0
  268. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Sofia.rb +173 -0
  269. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Stockholm.rb +165 -0
  270. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Tallinn.rb +172 -0
  271. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Vienna.rb +183 -0
  272. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Vilnius.rb +170 -0
  273. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Warsaw.rb +212 -0
  274. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Zagreb.rb +13 -0
  275. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Auckland.rb +202 -0
  276. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Fiji.rb +23 -0
  277. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Guam.rb +22 -0
  278. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Honolulu.rb +28 -0
  279. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Majuro.rb +20 -0
  280. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Midway.rb +25 -0
  281. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Noumea.rb +25 -0
  282. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Pago_Pago.rb +26 -0
  283. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Port_Moresby.rb +20 -0
  284. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Tongatapu.rb +27 -0
  285. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/info_timezone.rb +52 -0
  286. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/linked_timezone.rb +51 -0
  287. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/linked_timezone_info.rb +44 -0
  288. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/offset_rationals.rb +98 -0
  289. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/ruby_core_support.rb +56 -0
  290. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/time_or_datetime.rb +292 -0
  291. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone.rb +508 -0
  292. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_definition.rb +56 -0
  293. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_info.rb +40 -0
  294. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_offset_info.rb +94 -0
  295. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_period.rb +198 -0
  296. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_transition_info.rb +129 -0
  297. data/lib/active_support/version.rb +2 -3
  298. data/lib/active_support/whiny_nil.rb +7 -9
  299. data/lib/active_support/xml_mini.rb +1 -126
  300. data/lib/active_support/xml_mini/jdom.rb +0 -2
  301. data/lib/active_support/xml_mini/libxml.rb +86 -24
  302. data/lib/active_support/xml_mini/nokogiri.rb +24 -27
  303. data/lib/active_support/xml_mini/rexml.rb +1 -7
  304. metadata +191 -49
  305. data/lib/active_support/builder.rb +0 -6
  306. data/lib/active_support/core_ext/array/uniq_by.rb +0 -17
  307. data/lib/active_support/core_ext/class/attribute.rb +0 -67
  308. data/lib/active_support/core_ext/class/subclasses.rb +0 -55
  309. data/lib/active_support/core_ext/file/path.rb +0 -5
  310. data/lib/active_support/core_ext/integer/multiple.rb +0 -6
  311. data/lib/active_support/core_ext/kernel/singleton_class.rb +0 -13
  312. data/lib/active_support/core_ext/module/anonymous.rb +0 -24
  313. data/lib/active_support/core_ext/module/method_names.rb +0 -14
  314. data/lib/active_support/core_ext/module/reachable.rb +0 -10
  315. data/lib/active_support/core_ext/module/remove_method.rb +0 -6
  316. data/lib/active_support/core_ext/object/to_param.rb +0 -49
  317. data/lib/active_support/core_ext/object/to_query.rb +0 -27
  318. data/lib/active_support/core_ext/string/encoding.rb +0 -11
  319. data/lib/active_support/core_ext/string/exclude.rb +0 -6
  320. data/lib/active_support/core_ext/time/marshal.rb +0 -56
  321. data/lib/active_support/dependencies/autoload.rb +0 -50
  322. data/lib/active_support/i18n.rb +0 -8
  323. data/lib/active_support/inflector/inflections.rb +0 -211
  324. data/lib/active_support/inflector/methods.rb +0 -141
  325. data/lib/active_support/inflector/transliterate.rb +0 -97
  326. data/lib/active_support/json/backends/yajl.rb +0 -40
  327. data/lib/active_support/lazy_load_hooks.rb +0 -27
  328. data/lib/active_support/multibyte/unicode.rb +0 -393
  329. data/lib/active_support/notifications/fanout.rb +0 -93
  330. data/lib/active_support/notifications/instrumenter.rb +0 -56
  331. data/lib/active_support/railtie.rb +0 -100
  332. data/lib/active_support/xml_mini/libxmlsax.rb +0 -85
  333. data/lib/active_support/xml_mini/nokogirisax.rb +0 -83
data/CHANGELOG CHANGED
@@ -1,103 +1,4 @@
1
- *Rails 3.0.0 [beta 4] (June 8th, 2010)*
2
-
3
- * Extracted String#truncate from TextHelper#truncate [DHH]
4
-
5
- * Ruby 1.9: support UTF-8 case folding. #4595 [Norman Clarke]
6
-
7
- * Removes Array#rand and backports Array#sample from Ruby 1.9, thanks to Marc-Andre Lafortune. [fxn]
8
-
9
- * Ruby 1.9: Renames last_(month|year) to prev_(month|year) in Date and Time. [fxn]
10
-
11
- * Aliases Date#sunday to Date#end_of_week. [fxn]
12
-
13
- * Backports Date#>> from 1.9 so that calculations do the right thing around the calendar reform. [fxn]
14
-
15
- * Date#to_time handles properly years in the range 0..138. [fxn]
16
-
17
- * Deprecate {{}} as interpolation syntax for I18n in favor of %{} [José Valim]
18
-
19
- * Array#to_xml is more powerful and able to handle the same types as Hash#to_xml #4490 [Neeraj Singh]
20
-
21
- * Harmonize the caching API and refactor the backends. #4452 [Brian Durand]
22
- All caches:
23
- * Add default options to initializer that will be sent to all read, write, fetch, exist?, increment, and decrement
24
- * Add support for the :expires_in option to fetch and write for all caches. Cache entries are stored with the create timestamp and a ttl so that expiration can be handled independently of the implementation.
25
- * Add support for a :namespace option. This can be used to set a global prefix for cache entries.
26
- * Deprecate expand_cache_key on ActiveSupport::Cache and move it to ActionController::Caching and ActionDispatch::Http::Cache since the logic in the method used some Rails specific environment variables and was only used by ActionPack classes. Not very DRY but there didn't seem to be a good shared spot and ActiveSupport really shouldn't be Rails specific.
27
- * Add support for :race_condition_ttl to fetch. This setting can prevent race conditions on fetch calls where several processes try to regenerate a recently expired entry at once.
28
- * Add support for :compress option to fetch and write which will compress any data over a configurable threshold.
29
- * Nil values can now be stored in the cache and are distinct from cache misses for fetch.
30
- * Easier API to create new implementations. Just need to implement the methods read_entry, write_entry, and delete_entry instead of overwriting existing methods.
31
- * Since all cache implementations support storing objects, update the docs to state that ActiveCache::Cache::Store implementations should store objects. Keys, however, must be strings since some implementations require that.
32
- * Increase test coverage.
33
- * Document methods which are provided as convenience but which may not be universally available.
34
-
35
- MemoryStore:
36
- * MemoryStore can now safely be used as the cache for single server sites.
37
- * Make thread safe so that the default cache implementation used by Rails is thread safe. The overhead is minimal and it is still the fastest store available.
38
- * Provide :size initialization option indicating the maximum size of the cache in memory (defaults to 32Mb).
39
- * Add prune logic that removes the least recently used cache entries to keep the cache size from exceeding the max.
40
- * Deprecated SynchronizedMemoryStore since it isn't needed anymore.
41
-
42
- FileStore:
43
- * Escape key values so they will work as file names on all file systems, be consistent, and case sensitive
44
- * Use a hash algorithm to segment the cache into sub directories so that a large cache doesn't exceed file system limits.
45
- * FileStore can be slow so implement the LocalCache strategy to cache reads for the duration of a request.
46
- * Add cleanup method to keep the disk from filling up with expired entries.
47
- * Fix increment and decrement to use file system locks so they are consistent between processes.
48
-
49
- MemCacheStore:
50
- * Support all keys. Previously keys with spaces in them would fail
51
- * Deprecate CompressedMemCacheStore since it isn't needed anymore (use :compress => true)
52
-
53
- * JSON: encode objects that don't have a native JSON representation using to_hash, if available, instead of instance_values (the old fallback) or to_s (other encoders' default). Encode BigDecimal and Regexp encode as strings to conform with other encoders. Try to transcode non-UTF-8 strings. [Jeremy Kemper]
54
-
55
-
56
- *Rails 3.0.0 [beta 3] (April 13th, 2010)*
57
-
58
- * HashWithIndifferentAccess: remove inherited symbolize_keys! since its keys are always strings. [Santiago Pastorino]
59
-
60
- * Improve transliteration quality. #4374 [Norman Clarke]
61
-
62
- * Speed up and add Ruby 1.9 support for ActiveSupport::Multibyte::Chars#tidy_bytes. #4350 [Norman Clarke]
63
-
64
-
65
- *Rails 3.0.0 [beta 2] (April 1st, 2010)*
66
-
67
- * Reduced load time by deferring configuration of classes using
68
- ActiveSupport::on_load(:component_name) [YK]
69
-
70
- * Rename #metaclass to #singleton_class now that ruby-core has decided [JK]
71
-
72
- * New assertions assert_blank and assert_present. #4299 [Juanjo Bazan]
73
-
74
- * Use Object#singleton_class instead of #metaclass. Prefer Ruby's choice. [Jeremy Kemper]
75
-
76
- * JSON backend for YAJL. Preferred if available. #2666 [Brian Lopez]
77
-
78
-
79
- *Rails 3.0.0 [beta 1] (February 4, 2010)*
80
-
81
- * Introduce class_attribute to declare inheritable class attributes. Writing an attribute on a subclass behaves just like overriding the superclass reader method. Unifies and replaces most usage of cattr_accessor, class_inheritable_attribute, superclass_delegating_attribute, and extlib_inheritable_attribute. [Jeremy Kemper, Yehuda Katz]
82
-
83
- * Time#- with a DateTime argument behaves the same as with a Time argument, i.e. returns the difference between self and arg as a Float #3476 [Geoff Buesing]
84
-
85
- * YAML serialization for OrderedHash. #3608 [Gregor Schmidt]
86
-
87
- * Update bundled TZInfo to v0.3.16 [Geoff Buesing]
88
-
89
- * Georgetown TimeZone is now mapped to "America/Guyana" instead of "America/Argentina/San_Juan" #1821 [Geoff Buesing, Reuben Sivan]
90
-
91
- * Changed the default ActiveSupport.use_standard_json_time_format from false to true and
92
- ActiveSupport.escape_html_entities_in_json from true to false to match previously announced Rails 3 defaults [DHH]
93
-
94
- * Added Object#presence that returns the object if it's #present? otherwise returns nil [DHH/Colin Kelley]
95
-
96
- * Add Enumerable#exclude? to bring parity to Enumerable#include? and avoid if !x.include?/else calls [DHH]
97
-
98
- * Update Edinburgh TimeZone to use "Europe/London" instead of "Europe/Dublin" #3310 [Phil Ross]
99
-
100
- * Update bundled TZInfo to v0.3.15 [Geoff Buesing]
1
+ *Edge*
101
2
 
102
3
  * JSON: +Object#to_json+ calls +as_json+ to coerce itself into something natively encodable like +Hash+, +Integer+, or +String+. Override +as_json+ instead of +to_json+ so you're JSON library agnostic. [Jeremy Kemper]
103
4
 
@@ -34,42 +34,8 @@ module ActiveSupport
34
34
  end
35
35
  end
36
36
 
37
- require "active_support/dependencies/autoload"
37
+ require 'active_support/autoload'
38
+ require 'active_support/vendor'
38
39
 
39
- module ActiveSupport
40
- extend ActiveSupport::Autoload
41
-
42
- # TODO: Narrow this list down
43
- eager_autoload do
44
- autoload :BacktraceCleaner
45
- autoload :Base64
46
- autoload :BasicObject
47
- autoload :Benchmarkable
48
- autoload :BufferedLogger
49
- autoload :Cache
50
- autoload :Callbacks
51
- autoload :Concern
52
- autoload :Configurable
53
- autoload :Deprecation
54
- autoload :Gzip
55
- autoload :Inflector
56
- autoload :JSON
57
- autoload :Memoizable
58
- autoload :MessageEncryptor
59
- autoload :MessageVerifier
60
- autoload :Multibyte
61
- autoload :OptionMerger
62
- autoload :OrderedHash
63
- autoload :OrderedOptions
64
- autoload :Notifications
65
- autoload :Rescuable
66
- autoload :SecureRandom
67
- autoload :StringInquirer
68
- autoload :XmlMini
69
- end
70
-
71
- autoload :SafeBuffer, "active_support/core_ext/string/output_safety"
72
- autoload :TestCase
73
- end
74
-
75
- autoload :I18n, "active_support/i18n"
40
+ require 'i18n'
41
+ I18n.load_path << "#{File.dirname(__FILE__)}/active_support/locale/en.yml"
@@ -0,0 +1,28 @@
1
+ module ActiveSupport
2
+ autoload :BacktraceCleaner, 'active_support/backtrace_cleaner'
3
+ autoload :Base64, 'active_support/base64'
4
+ autoload :BasicObject, 'active_support/basic_object'
5
+ autoload :Benchmarkable, 'active_support/benchmarkable'
6
+ autoload :BufferedLogger, 'active_support/buffered_logger'
7
+ autoload :Cache, 'active_support/cache'
8
+ autoload :Callbacks, 'active_support/callbacks'
9
+ autoload :Concern, 'active_support/concern'
10
+ autoload :Configurable, 'active_support/configurable'
11
+ autoload :DependencyModule, 'active_support/dependency_module'
12
+ autoload :DeprecatedCallbacks, 'active_support/deprecated_callbacks'
13
+ autoload :Deprecation, 'active_support/deprecation'
14
+ autoload :Gzip, 'active_support/gzip'
15
+ autoload :Inflector, 'active_support/inflector'
16
+ autoload :Memoizable, 'active_support/memoizable'
17
+ autoload :MessageEncryptor, 'active_support/message_encryptor'
18
+ autoload :MessageVerifier, 'active_support/message_verifier'
19
+ autoload :Multibyte, 'active_support/multibyte'
20
+ autoload :OptionMerger, 'active_support/option_merger'
21
+ autoload :OrderedHash, 'active_support/ordered_hash'
22
+ autoload :OrderedOptions, 'active_support/ordered_options'
23
+ autoload :Notifications, 'active_support/notifications'
24
+ autoload :Rescuable, 'active_support/rescuable'
25
+ autoload :SecureRandom, 'active_support/secure_random'
26
+ autoload :StringInquirer, 'active_support/string_inquirer'
27
+ autoload :XmlMini, 'active_support/xml_mini'
28
+ end
@@ -4,14 +4,12 @@ module ActiveSupport
4
4
  # context, so only the relevant lines are included.
5
5
  #
6
6
  # If you need to reconfigure an existing BacktraceCleaner, like the one in Rails, to show as much as possible, you can always
7
- # call BacktraceCleaner#remove_silencers! Also, if you need to reconfigure an existing BacktraceCleaner so that it does not
8
- # filter or modify the paths of any lines of the backtrace, you can call BacktraceCleaner#remove_filters! These two methods
9
- # will give you a completely untouched backtrace.
7
+ # call BacktraceCleaner#remove_silencers!
10
8
  #
11
9
  # Example:
12
10
  #
13
11
  # bc = BacktraceCleaner.new
14
- # bc.add_filter { |line| line.gsub(Rails.root, '') }
12
+ # bc.add_filter { |line| line.gsub(Rails.root, '') }
15
13
  # bc.add_silencer { |line| line =~ /mongrel|rubygems/ }
16
14
  # bc.clean(exception.backtrace) # will strip the Rails.root prefix and skip any lines from mongrel or rubygems
17
15
  #
@@ -20,19 +18,10 @@ module ActiveSupport
20
18
  def initialize
21
19
  @filters, @silencers = [], []
22
20
  end
23
-
21
+
24
22
  # Returns the backtrace after all filters and silencers has been run against it. Filters run first, then silencers.
25
- def clean(backtrace, kind = :silent)
26
- filtered = filter(backtrace)
27
-
28
- case kind
29
- when :silent
30
- silence(filtered)
31
- when :noise
32
- noise(filtered)
33
- else
34
- filtered
35
- end
23
+ def clean(backtrace)
24
+ silence(filter(backtrace))
36
25
  end
37
26
 
38
27
  # Adds a filter from the block provided. Each line in the backtrace will be mapped against this filter.
@@ -62,32 +51,21 @@ module ActiveSupport
62
51
  @silencers = []
63
52
  end
64
53
 
65
- def remove_filters!
66
- @filters = []
67
- end
68
-
54
+
69
55
  private
70
56
  def filter(backtrace)
71
57
  @filters.each do |f|
72
58
  backtrace = backtrace.map { |line| f.call(line) }
73
59
  end
74
-
60
+
75
61
  backtrace
76
62
  end
77
-
63
+
78
64
  def silence(backtrace)
79
65
  @silencers.each do |s|
80
66
  backtrace = backtrace.reject { |line| s.call(line) }
81
67
  end
82
-
83
- backtrace
84
- end
85
-
86
- def noise(backtrace)
87
- @silencers.each do |s|
88
- backtrace = backtrace.select { |line| s.call(line) }
89
- end
90
-
68
+
91
69
  backtrace
92
70
  end
93
71
  end
@@ -1,5 +1,4 @@
1
1
  require 'active_support/core_ext/benchmark'
2
- require 'active_support/core_ext/hash/keys'
3
2
 
4
3
  module ActiveSupport
5
4
  module Benchmarkable
@@ -53,6 +53,7 @@ module ActiveSupport
53
53
  FileUtils.mkdir_p(File.dirname(log))
54
54
  @log = open(log, (File::WRONLY | File::APPEND | File::CREAT))
55
55
  @log.sync = true
56
+ @log.write("# Logfile created on %s" % [Time.now.to_s])
56
57
  end
57
58
  end
58
59
 
@@ -1,30 +1,23 @@
1
1
  require 'benchmark'
2
- require 'zlib'
3
- require 'active_support/core_ext/array/extract_options'
4
- require 'active_support/core_ext/array/wrap'
5
2
  require 'active_support/core_ext/benchmark'
6
3
  require 'active_support/core_ext/exception'
7
4
  require 'active_support/core_ext/class/attribute_accessors'
8
- require 'active_support/core_ext/numeric/bytes'
9
- require 'active_support/core_ext/numeric/time'
10
- require 'active_support/core_ext/object/to_param'
11
- require 'active_support/core_ext/string/inflections'
5
+
6
+ %w(hash nil string time date date_time array big_decimal range object boolean).each do |library|
7
+ require "active_support/core_ext/#{library}/conversions"
8
+ end
9
+
10
+ # require 'active_support/core_ext' # FIXME: pulling in all to_param extensions
12
11
 
13
12
  module ActiveSupport
14
13
  # See ActiveSupport::Cache::Store for documentation.
15
14
  module Cache
16
15
  autoload :FileStore, 'active_support/cache/file_store'
17
16
  autoload :MemoryStore, 'active_support/cache/memory_store'
18
- autoload :MemCacheStore, 'active_support/cache/mem_cache_store'
19
17
  autoload :SynchronizedMemoryStore, 'active_support/cache/synchronized_memory_store'
18
+ autoload :MemCacheStore, 'active_support/cache/mem_cache_store'
20
19
  autoload :CompressedMemCacheStore, 'active_support/cache/compressed_mem_cache_store'
21
20
 
22
- EMPTY_OPTIONS = {}.freeze
23
-
24
- # These options mean something to all cache implementations. Individual cache
25
- # implementations may support additional optons.
26
- UNIVERSAL_OPTIONS = [:namespace, :compress, :compress_threshold, :expires_in, :race_condition_ttl]
27
-
28
21
  module Strategy
29
22
  autoload :LocalCache, 'active_support/cache/strategy/local_cache'
30
23
  end
@@ -40,7 +33,7 @@ module ActiveSupport
40
33
  #
41
34
  # ActiveSupport::Cache.lookup_store(:memory_store)
42
35
  # # => returns a new ActiveSupport::Cache::MemoryStore object
43
- #
36
+ #
44
37
  # ActiveSupport::Cache.lookup_store(:mem_cache_store)
45
38
  # # => returns a new ActiveSupport::Cache::MemCacheStore object
46
39
  #
@@ -55,7 +48,7 @@ module ActiveSupport
55
48
  # ActiveSupport::Cache.lookup_store(MyOwnCacheStore.new)
56
49
  # # => returns MyOwnCacheStore.new
57
50
  def self.lookup_store(*store_option)
58
- store, *parameters = *Array.wrap(store_option).flatten
51
+ store, *parameters = *([ store_option ].flatten)
59
52
 
60
53
  case store
61
54
  when Symbol
@@ -69,12 +62,15 @@ module ActiveSupport
69
62
  end
70
63
  end
71
64
 
65
+ RAILS_CACHE_ID = ENV["RAILS_CACHE_ID"]
66
+ RAILS_APP_VERION = ENV["RAILS_APP_VERION"]
67
+ EXPANDED_CACHE = RAILS_CACHE_ID || RAILS_APP_VERION
68
+
72
69
  def self.expand_cache_key(key, namespace = nil)
73
70
  expanded_cache_key = namespace ? "#{namespace}/" : ""
74
71
 
75
- prefix = ENV["RAILS_CACHE_ID"] || ENV["RAILS_APP_VERSION"]
76
- if prefix
77
- expanded_cache_key << "#{prefix}/"
72
+ if EXPANDED_CACHE
73
+ expanded_cache_key << "#{RAILS_CACHE_ID || RAILS_APP_VERION}/"
78
74
  end
79
75
 
80
76
  expanded_cache_key <<
@@ -99,75 +95,26 @@ module ActiveSupport
99
95
  # ActiveSupport::Cache::MemCacheStore. MemCacheStore is currently the most
100
96
  # popular cache store for large production websites.
101
97
  #
102
- # Some implementations may not support all methods beyond the basic cache
103
- # methods of +fetch+, +write+, +read+, +exist?+, and +delete+.
104
- #
105
- # ActiveSupport::Cache::Store can store any serializable Ruby object.
98
+ # ActiveSupport::Cache::Store is meant for caching strings. Some cache
99
+ # store implementations, like MemoryStore, are able to cache arbitrary
100
+ # Ruby objects, but don't count on every cache store to be able to do that.
106
101
  #
107
102
  # cache = ActiveSupport::Cache::MemoryStore.new
108
- #
103
+ #
109
104
  # cache.read("city") # => nil
110
105
  # cache.write("city", "Duckburgh")
111
106
  # cache.read("city") # => "Duckburgh"
112
- #
113
- # Keys are always translated into Strings and are case sensitive. When an
114
- # object is specified as a key, its +cache_key+ method will be called if it
115
- # is defined. Otherwise, the +to_param+ method will be called. Hashes and
116
- # Arrays can be used as keys. The elements will be delimited by slashes
117
- # and Hashes elements will be sorted by key so they are consistent.
118
- #
119
- # cache.read("city") == cache.read(:city) # => true
120
- #
121
- # Nil values can be cached.
122
- #
123
- # If your cache is on a shared infrastructure, you can define a namespace for
124
- # your cache entries. If a namespace is defined, it will be prefixed on to every
125
- # key. The namespace can be either a static value or a Proc. If it is a Proc, it
126
- # will be invoked when each key is evaluated so that you can use application logic
127
- # to invalidate keys.
128
- #
129
- # cache.namespace = lambda { @last_mod_time } # Set the namespace to a variable
130
- # @last_mod_time = Time.now # Invalidate the entire cache by changing namespace
131
- #
132
- # All caches support auto expiring content after a specified number of seconds.
133
- # To set the cache entry time to live, you can either specify +:expires_in+ as
134
- # an option to the constructor to have it affect all entries or to the +fetch+
135
- # or +write+ methods for just one entry.
136
- #
137
- # cache = ActiveSupport::Cache::MemoryStore.new(:expire_in => 5.minutes)
138
- # cache.write(key, value, :expire_in => 1.minute) # Set a lower value for one entry
139
- #
140
- # Caches can also store values in a compressed format to save space and reduce
141
- # time spent sending data. Since there is some overhead, values must be large
142
- # enough to warrant compression. To turn on compression either pass
143
- # <tt>:compress => true</tt> in the initializer or to +fetch+ or +write+.
144
- # To specify the threshold at which to compress values, set
145
- # <tt>:compress_threshold</tt>. The default threshold is 32K.
146
107
  class Store
147
-
148
- cattr_accessor :logger, :instance_writer => true
108
+ cattr_accessor :logger, :instance_writter => false
149
109
 
150
110
  attr_reader :silence
151
111
  alias :silence? :silence
152
112
 
153
- # Create a new cache. The options will be passed to any write method calls except
154
- # for :namespace which can be used to set the global namespace for the cache.
155
- def initialize (options = nil)
156
- @options = options ? options.dup : {}
157
- end
158
-
159
- # Get the default options set when the cache was created.
160
- def options
161
- @options ||= {}
162
- end
163
-
164
- # Silence the logger.
165
113
  def silence!
166
114
  @silence = true
167
115
  self
168
116
  end
169
117
 
170
- # Silence the logger within a block.
171
118
  def mute
172
119
  previous_silence, @silence = defined?(@silence) && @silence, true
173
120
  yield
@@ -195,7 +142,7 @@ module ActiveSupport
195
142
  #
196
143
  # cache.write("today", "Monday")
197
144
  # cache.fetch("today") # => "Monday"
198
- #
145
+ #
199
146
  # cache.fetch("city") # => nil
200
147
  # cache.fetch("city") do
201
148
  # "Duckburgh"
@@ -208,85 +155,28 @@ module ActiveSupport
208
155
  # cache.write("today", "Monday")
209
156
  # cache.fetch("today", :force => true) # => nil
210
157
  #
211
- # Setting <tt>:compress</tt> will store a large cache entry set by the call
212
- # in a compressed format.
213
- #
214
- # Setting <tt>:expires_in</tt> will set an expiration time on the cache
215
- # entry if it is set by call.
216
- #
217
- # Setting <tt>:race_condition_ttl</tt> will invoke logic on entries set with
218
- # an <tt>:expires_in</tt> option. If an entry is found in the cache that is
219
- # expired and it has been expired for less than the number of seconds specified
220
- # by this option and a block was passed to the method call, then the expiration
221
- # future time of the entry in the cache will be updated to that many seconds
222
- # in the and the block will be evaluated and written to the cache.
223
- #
224
- # This is very useful in situations where a cache entry is used very frequently
225
- # under heavy load. The first process to find an expired cache entry will then
226
- # become responsible for regenerating that entry while other processes continue
227
- # to use the slightly out of date entry. This can prevent race conditions where
228
- # too many processes are trying to regenerate the entry all at once. If the
229
- # process regenerating the entry errors out, the entry will be regenerated
230
- # after the specified number of seconds.
231
- #
232
- # # Set all values to expire after one minute.
233
- # cache = ActiveSupport::Cache::MemoryCache.new(:expires_in => 1.minute)
234
- #
235
- # cache.write("foo", "original value")
236
- # val_1 = nil
237
- # val_2 = nil
238
- # sleep 60
239
- #
240
- # Thread.new do
241
- # val_1 = cache.fetch("foo", :race_condition_ttl => 10) do
242
- # sleep 1
243
- # "new value 1"
244
- # end
245
- # end
246
- #
247
- # Thread.new do
248
- # val_2 = cache.fetch("foo", :race_condition_ttl => 10) do
249
- # "new value 2"
250
- # end
251
- # end
252
- #
253
- # # val_1 => "new value 1"
254
- # # val_2 => "original value"
255
- # # cache.fetch("foo") => "new value 1"
256
- #
257
158
  # Other options will be handled by the specific cache store implementation.
258
- # Internally, #fetch calls #read_entry, and calls #write_entry on a cache miss.
159
+ # Internally, #fetch calls #read, and calls #write on a cache miss.
259
160
  # +options+ will be passed to the #read and #write calls.
260
161
  #
261
- # For example, MemCacheStore's #write method supports the +:raw+
262
- # option, which tells the memcached server to store all values as strings.
263
- # We can use this option with #fetch too:
162
+ # For example, MemCacheStore's #write method supports the +:expires_in+
163
+ # option, which tells the memcached server to automatically expire the
164
+ # cache item after a certain period. This options is also supported by
165
+ # FileStore's #read method. We can use this option with #fetch too:
264
166
  #
265
167
  # cache = ActiveSupport::Cache::MemCacheStore.new
266
- # cache.fetch("foo", :force => true, :raw => true) do
267
- # :bar
168
+ # cache.fetch("foo", :force => true, :expires_in => 5.seconds) do
169
+ # "bar"
268
170
  # end
269
171
  # cache.fetch("foo") # => "bar"
270
- def fetch(name, options = nil, &block)
271
- options = merged_options(options)
272
- key = namespaced_key(name, options)
273
- entry = instrument(:read, name, options) { read_entry(key, options) } unless options[:force]
274
- if entry && entry.expired?
275
- race_ttl = options[:race_condition_ttl].to_f
276
- if race_ttl and Time.now.to_f - entry.expires_at <= race_ttl
277
- entry.expires_at = Time.now + race_ttl
278
- write_entry(key, entry, :expires_in => race_ttl * 2)
279
- else
280
- delete_entry(key, options)
281
- end
282
- entry = nil
283
- end
284
-
285
- if entry
286
- entry.value
172
+ # sleep(6)
173
+ # cache.fetch("foo") # => nil
174
+ def fetch(key, options = {}, &block)
175
+ if !options[:force] && value = read(key, options)
176
+ value
287
177
  elsif block_given?
288
- result = instrument(:generate, name, options, &block)
289
- write(name, result, options)
178
+ result = instrument(:generate, key, options, &block)
179
+ write(key, result, options)
290
180
  result
291
181
  end
292
182
  end
@@ -295,47 +185,15 @@ module ActiveSupport
295
185
  # the cache with the given key, then that data is returned. Otherwise,
296
186
  # nil is returned.
297
187
  #
298
- # Options are passed to the underlying cache implementation.
299
- def read(name, options = nil)
300
- options = merged_options(options)
301
- key = namespaced_key(name, options)
302
- instrument(:read, name, options) do
303
- entry = read_entry(key, options)
304
- if entry
305
- if entry.expired?
306
- delete_entry(key, options)
307
- nil
308
- else
309
- entry.value
310
- end
311
- else
312
- nil
313
- end
314
- end
315
- end
316
-
317
- # Read multiple values at once from the cache. Options can be passed
318
- # in the last argument.
319
- #
320
- # Some cache implementation may optimize this method.
188
+ # You may also specify additional options via the +options+ argument.
189
+ # The specific cache store implementation will decide what to do with
190
+ # +options+.
321
191
  #
322
- # Returns a hash mapping the names provided to the values found.
323
- def read_multi(*names)
324
- options = names.extract_options!
325
- options = merged_options(options)
326
- results = {}
327
- names.each do |name|
328
- key = namespaced_key(name, options)
329
- entry = read_entry(key, options)
330
- if entry
331
- if entry.expired?
332
- delete_entry(key)
333
- else
334
- results[name] = entry.value
335
- end
336
- end
337
- end
338
- results
192
+ # For example, FileStore supports the +:expires_in+ option, which
193
+ # makes the method return nil for cache items older than the specified
194
+ # period.
195
+ def read(key, options = nil, &block)
196
+ instrument(:read, key, options, &block)
339
197
  end
340
198
 
341
199
  # Writes the given value to the cache, with the given key.
@@ -343,283 +201,70 @@ module ActiveSupport
343
201
  # You may also specify additional options via the +options+ argument.
344
202
  # The specific cache store implementation will decide what to do with
345
203
  # +options+.
346
- def write(name, value, options = nil)
347
- options = merged_options(options)
348
- instrument(:write, name, options) do
349
- entry = Entry.new(value, options)
350
- write_entry(namespaced_key(name, options), entry, options)
351
- end
352
- end
353
-
354
- # Delete an entry in the cache. Returns +true+ if there was an entry to delete.
355
- #
356
- # Options are passed to the underlying cache implementation.
357
- def delete(name, options = nil)
358
- options = merged_options(options)
359
- instrument(:delete, name) do
360
- delete_entry(namespaced_key(name, options), options)
361
- end
362
- end
363
-
364
- # Return true if the cache contains an entry with this name.
365
- #
366
- # Options are passed to the underlying cache implementation.
367
- def exist?(name, options = nil)
368
- options = merged_options(options)
369
- instrument(:exist?, name) do
370
- entry = read_entry(namespaced_key(name, options), options)
371
- if entry && !entry.expired?
372
- true
373
- else
374
- false
375
- end
376
- end
377
- end
378
-
379
- # Delete all entries whose keys match a pattern.
380
- #
381
- # Options are passed to the underlying cache implementation.
382
- #
383
- # Not all implementations may support +delete_matched+.
384
- def delete_matched(matcher, options = nil)
385
- raise NotImplementedError.new("#{self.class.name} does not support delete_matched")
386
- end
387
-
388
- # Increment an integer value in the cache.
389
- #
390
- # Options are passed to the underlying cache implementation.
204
+ #
205
+ # For example, MemCacheStore supports the +:expires_in+ option, which
206
+ # tells the memcached server to automatically expire the cache item after
207
+ # a certain period:
391
208
  #
392
- # Not all implementations may support +delete_matched+.
393
- def increment(name, amount = 1, options = nil)
394
- raise NotImplementedError.new("#{self.class.name} does not support increment")
209
+ # cache = ActiveSupport::Cache::MemCacheStore.new
210
+ # cache.write("foo", "bar", :expires_in => 5.seconds)
211
+ # cache.read("foo") # => "bar"
212
+ # sleep(6)
213
+ # cache.read("foo") # => nil
214
+ def write(key, value, options = nil, &block)
215
+ instrument(:write, key, options, &block)
395
216
  end
396
217
 
397
- # Increment an integer value in the cache.
398
- #
399
- # Options are passed to the underlying cache implementation.
400
- #
401
- # Not all implementations may support +delete_matched+.
402
- def decrement(name, amount = 1, options = nil)
403
- raise NotImplementedError.new("#{self.class.name} does not support decrement")
218
+ def delete(key, options = nil, &block)
219
+ instrument(:delete, key, options, &block)
404
220
  end
405
221
 
406
- # Cleanup the cache by removing expired entries. Not all cache implementations may
407
- # support this method.
408
- #
409
- # Options are passed to the underlying cache implementation.
410
- #
411
- # Not all implementations may support +delete_matched+.
412
- def cleanup(options = nil)
413
- raise NotImplementedError.new("#{self.class.name} does not support cleanup")
222
+ def delete_matched(matcher, options = nil, &block)
223
+ instrument(:delete_matched, matcher.inspect, options, &block)
414
224
  end
415
225
 
416
- # Clear the entire cache. Not all cache implementations may support this method.
417
- # You should be careful with this method since it could affect other processes
418
- # if you are using a shared cache.
419
- #
420
- # Options are passed to the underlying cache implementation.
421
- #
422
- # Not all implementations may support +delete_matched+.
423
- def clear(options = nil)
424
- raise NotImplementedError.new("#{self.class.name} does not support clear")
226
+ def exist?(key, options = nil, &block)
227
+ instrument(:exist?, key, options, &block)
425
228
  end
426
229
 
427
- protected
428
- # Add the namespace defined in the options to a pattern designed to match keys.
429
- # Implementations that support delete_matched should call this method to translate
430
- # a pattern that matches names into one that matches namespaced keys.
431
- def key_matcher(pattern, options)
432
- prefix = options[:namespace].is_a?(Proc) ? options[:namespace].call : options[:namespace]
433
- if prefix
434
- source = pattern.source
435
- if source.start_with?('^')
436
- source = source[1, source.length]
437
- else
438
- source = ".*#{source[0, source.length]}"
439
- end
440
- Regexp.new("^#{Regexp.escape(prefix)}:#{source}", pattern.options)
441
- else
442
- pattern
443
- end
444
- end
445
-
446
- # Read an entry from the cache implementation. Subclasses must implement this method.
447
- def read_entry(key, options) # :nodoc:
448
- raise NotImplementedError.new
449
- end
450
-
451
- # Write an entry to the cache implementation. Subclasses must implement this method.
452
- def write_entry(key, entry, options) # :nodoc:
453
- raise NotImplementedError.new
230
+ def increment(key, amount = 1)
231
+ if num = read(key)
232
+ write(key, num + amount)
233
+ else
234
+ nil
454
235
  end
236
+ end
455
237
 
456
- # Delete an entry from the cache implementation. Subclasses must implement this method.
457
- def delete_entry(key, options) # :nodoc:
458
- raise NotImplementedError.new
238
+ def decrement(key, amount = 1)
239
+ if num = read(key)
240
+ write(key, num - amount)
241
+ else
242
+ nil
459
243
  end
244
+ end
460
245
 
461
246
  private
462
- # Merge the default options with ones specific to a method call.
463
- def merged_options(call_options) # :nodoc:
464
- if call_options
465
- options.merge(call_options)
466
- else
467
- options.dup
468
- end
469
- end
470
-
471
- # Expand a key to be a consistent string value. If the object responds to +cache_key+,
472
- # it will be called. Otherwise, the to_param method will be called. If the key is a
473
- # Hash, the keys will be sorted alphabetically.
474
- def expanded_key(key) # :nodoc:
475
- if key.respond_to?(:cache_key)
476
- key = key.cache_key.to_s
477
- elsif key.is_a?(Array)
478
- if key.size > 1
479
- key.collect{|element| expanded_key(element)}.to_param
480
- else
481
- key.first.to_param
482
- end
483
- elsif key.is_a?(Hash)
484
- key = key.to_a.sort{|a,b| a.first.to_s <=> b.first.to_s}.collect{|k,v| "#{k}=#{v}"}.to_param
485
- else
486
- key = key.to_param
487
- end
488
- end
489
-
490
- # Prefix a key with the namespace. The two values will be delimited with a colon.
491
- def namespaced_key(key, options)
492
- key = expanded_key(key)
493
- namespace = options[:namespace] if options
494
- prefix = namespace.is_a?(Proc) ? namespace.call : namespace
495
- key = "#{prefix}:#{key}" if prefix
496
- key
247
+ def expires_in(options)
248
+ expires_in = options && options[:expires_in]
249
+ raise ":expires_in must be a number" if expires_in && !expires_in.is_a?(Numeric)
250
+ expires_in || 0
497
251
  end
498
252
 
499
- def instrument(operation, key, options = nil)
253
+ def instrument(operation, key, options, &block)
500
254
  log(operation, key, options)
501
255
 
502
256
  if self.class.instrument
503
257
  payload = { :key => key }
504
258
  payload.merge!(options) if options.is_a?(Hash)
505
- ActiveSupport::Notifications.instrument("cache_#{operation}.active_support", payload){ yield }
259
+ ActiveSupport::Notifications.instrument(:"cache_#{operation}", payload, &block)
506
260
  else
507
261
  yield
508
262
  end
509
263
  end
510
264
 
511
- def log(operation, key, options = nil)
512
- return unless logger && logger.debug? && !silence?
513
- logger.debug("Cache #{operation}: #{key}#{options.blank? ? "" : " (#{options.inspect})"}")
514
- end
515
- end
516
-
517
- # Entry that is put into caches. It supports expiration time on entries and can compress values
518
- # to save space in the cache.
519
- class Entry
520
- attr_reader :created_at, :expires_in
521
-
522
- DEFAULT_COMPRESS_LIMIT = 16.kilobytes
523
-
524
- class << self
525
- # Create an entry with internal attributes set. This method is intended to be
526
- # used by implementations that store cache entries in a native format instead
527
- # of as serialized Ruby objects.
528
- def create (raw_value, created_at, options = {})
529
- entry = new(nil)
530
- entry.instance_variable_set(:@value, raw_value)
531
- entry.instance_variable_set(:@created_at, created_at.to_f)
532
- entry.instance_variable_set(:@compressed, !!options[:compressed])
533
- entry.instance_variable_set(:@expires_in, options[:expires_in])
534
- entry
535
- end
536
- end
537
-
538
- # Create a new cache entry for the specified value. Options supported are
539
- # +:compress+, +:compress_threshold+, and +:expires_in+.
540
- def initialize(value, options = {})
541
- @compressed = false
542
- @expires_in = options[:expires_in]
543
- @expires_in = @expires_in.to_f if @expires_in
544
- @created_at = Time.now.to_f
545
- if value
546
- if should_compress?(value, options)
547
- @value = Zlib::Deflate.deflate(Marshal.dump(value))
548
- @compressed = true
549
- else
550
- @value = value
551
- end
552
- else
553
- @value = nil
554
- end
555
- end
556
-
557
- # Get the raw value. This value may be serialized and compressed.
558
- def raw_value
559
- @value
560
- end
561
-
562
- # Get the value stored in the cache.
563
- def value
564
- if @value
565
- val = compressed? ? Marshal.load(Zlib::Inflate.inflate(@value)) : @value
566
- unless val.frozen?
567
- val.freeze rescue nil
568
- end
569
- val
570
- end
571
- end
572
-
573
- def compressed?
574
- @compressed
575
- end
576
-
577
- # Check if the entry is expired. The +expires_in+ parameter can override the
578
- # value set when the entry was created.
579
- def expired?
580
- if @expires_in && @created_at + @expires_in <= Time.now.to_f
581
- true
582
- else
583
- false
584
- end
585
- end
586
-
587
- # Set a new time to live on the entry so it expires at the given time.
588
- def expires_at=(time)
589
- if time
590
- @expires_in = time.to_f - @created_at
591
- else
592
- @expires_in = nil
593
- end
594
- end
595
-
596
- # Seconds since the epoch when the cache entry will expire.
597
- def expires_at
598
- @expires_in ? @created_at + @expires_in : nil
599
- end
600
-
601
- # Get the size of the cached value. This could be less than value.size
602
- # if the data is compressed.
603
- def size
604
- if @value.nil?
605
- 0
606
- elsif @value.respond_to?(:bytesize)
607
- @value.bytesize
608
- else
609
- Marshal.dump(@value).bytesize
610
- end
611
- end
612
-
613
- private
614
- def should_compress?(value, options)
615
- if options[:compress] && value
616
- unless value.is_a?(Numeric)
617
- compress_threshold = options[:compress_threshold] || DEFAULT_COMPRESS_LIMIT
618
- serialized_value = value.is_a?(String) ? value : Marshal.dump(value)
619
- return true if serialized_value.size >= compress_threshold
620
- end
621
- end
622
- false
265
+ def log(operation, key, options)
266
+ return unless logger && !silence?
267
+ logger.debug("Cache #{operation}: #{key}#{options ? " (#{options.inspect})" : ""}")
623
268
  end
624
269
  end
625
270
  end