activesupport 2.1.2 → 2.2.2

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 (240) hide show
  1. data/CHANGELOG +64 -5
  2. data/lib/active_support.rb +6 -6
  3. data/lib/active_support/base64.rb +13 -2
  4. data/lib/active_support/basic_object.rb +1 -1
  5. data/lib/active_support/buffered_logger.rb +15 -14
  6. data/lib/active_support/cache.rb +116 -40
  7. data/lib/active_support/cache/compressed_mem_cache_store.rb +7 -2
  8. data/lib/active_support/cache/file_store.rb +7 -5
  9. data/lib/active_support/cache/mem_cache_store.rb +48 -21
  10. data/lib/active_support/cache/memory_store.rb +16 -2
  11. data/lib/active_support/cache/synchronized_memory_store.rb +47 -0
  12. data/lib/active_support/callbacks.rb +14 -9
  13. data/lib/active_support/core_ext/array/access.rb +27 -0
  14. data/lib/active_support/core_ext/array/conversions.rb +12 -7
  15. data/lib/active_support/core_ext/array/grouping.rb +53 -10
  16. data/lib/active_support/core_ext/base64/encoding.rb +3 -0
  17. data/lib/active_support/core_ext/bigdecimal/conversions.rb +18 -22
  18. data/lib/active_support/core_ext/blank.rb +5 -0
  19. data/lib/active_support/core_ext/class/inheritable_attributes.rb +5 -5
  20. data/lib/active_support/core_ext/date/behavior.rb +3 -0
  21. data/lib/active_support/core_ext/date/calculations.rb +24 -9
  22. data/lib/active_support/core_ext/date_time/calculations.rb +19 -5
  23. data/lib/active_support/core_ext/duplicable.rb +6 -0
  24. data/lib/active_support/core_ext/enumerable.rb +42 -4
  25. data/lib/active_support/core_ext/file.rb +4 -20
  26. data/lib/active_support/core_ext/file/atomic.rb +46 -0
  27. data/lib/active_support/core_ext/float.rb +2 -0
  28. data/lib/active_support/core_ext/float/time.rb +27 -0
  29. data/lib/active_support/core_ext/hash.rb +2 -1
  30. data/lib/active_support/core_ext/hash/conversions.rb +1 -1
  31. data/lib/active_support/core_ext/hash/deep_merge.rb +23 -0
  32. data/lib/active_support/core_ext/hash/except.rb +1 -1
  33. data/lib/active_support/core_ext/hash/reverse_merge.rb +12 -5
  34. data/lib/active_support/core_ext/hash/slice.rb +7 -4
  35. data/lib/active_support/core_ext/integer.rb +2 -0
  36. data/lib/active_support/core_ext/integer/time.rb +45 -0
  37. data/lib/active_support/core_ext/kernel/debugger.rb +4 -4
  38. data/lib/active_support/core_ext/logger.rb +128 -1
  39. data/lib/active_support/core_ext/module.rb +11 -1
  40. data/lib/active_support/core_ext/module/aliasing.rb +71 -67
  41. data/lib/active_support/core_ext/module/delegation.rb +32 -1
  42. data/lib/active_support/core_ext/module/introspection.rb +81 -66
  43. data/lib/active_support/core_ext/module/model_naming.rb +8 -7
  44. data/lib/active_support/core_ext/module/synchronization.rb +39 -0
  45. data/lib/active_support/core_ext/numeric/time.rb +0 -10
  46. data/lib/active_support/core_ext/object.rb +1 -0
  47. data/lib/active_support/core_ext/object/extending.rb +29 -7
  48. data/lib/active_support/core_ext/object/instance_variables.rb +1 -1
  49. data/lib/active_support/core_ext/object/metaclass.rb +13 -0
  50. data/lib/active_support/core_ext/object/misc.rb +36 -21
  51. data/lib/active_support/core_ext/rexml.rb +2 -2
  52. data/lib/active_support/core_ext/string.rb +6 -2
  53. data/lib/active_support/core_ext/string/access.rb +5 -5
  54. data/lib/active_support/core_ext/string/behavior.rb +13 -0
  55. data/lib/active_support/core_ext/string/inflections.rb +21 -2
  56. data/lib/active_support/core_ext/string/multibyte.rb +81 -0
  57. data/lib/active_support/core_ext/time/calculations.rb +39 -12
  58. data/lib/active_support/core_ext/time/conversions.rb +1 -0
  59. data/lib/active_support/core_ext/time/zones.rb +1 -1
  60. data/lib/active_support/dependencies.rb +178 -110
  61. data/lib/active_support/deprecation.rb +24 -4
  62. data/lib/active_support/inflector.rb +122 -38
  63. data/lib/active_support/json.rb +1 -1
  64. data/lib/active_support/json/encoders/date.rb +9 -2
  65. data/lib/active_support/json/encoders/date_time.rb +9 -2
  66. data/lib/active_support/json/encoders/time.rb +10 -3
  67. data/lib/active_support/locale/en.yml +32 -0
  68. data/lib/active_support/memoizable.rb +82 -0
  69. data/lib/active_support/multibyte.rb +31 -7
  70. data/lib/active_support/multibyte/chars.rb +664 -122
  71. data/lib/active_support/multibyte/exceptions.rb +8 -0
  72. data/lib/active_support/multibyte/unicode_database.rb +71 -0
  73. data/lib/active_support/option_merger.rb +2 -10
  74. data/lib/active_support/ordered_hash.rb +15 -0
  75. data/lib/active_support/rescuable.rb +108 -0
  76. data/lib/active_support/secure_random.rb +197 -0
  77. data/lib/active_support/string_inquirer.rb +11 -1
  78. data/lib/active_support/test_case.rb +16 -5
  79. data/lib/active_support/testing/core_ext/test.rb +6 -0
  80. data/lib/active_support/{core_ext → testing/core_ext}/test/unit/assertions.rb +14 -6
  81. data/lib/active_support/testing/performance.rb +452 -0
  82. data/lib/active_support/testing/setup_and_teardown.rb +34 -7
  83. data/lib/active_support/time_with_zone.rb +66 -42
  84. data/lib/active_support/values/time_zone.rb +11 -4
  85. data/lib/active_support/values/unicode_tables.dat +0 -0
  86. data/lib/active_support/vendor.rb +13 -5
  87. data/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb +1 -1
  88. data/lib/active_support/vendor/i18n-0.0.1/i18n.rb +194 -0
  89. data/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb +216 -0
  90. data/lib/active_support/vendor/i18n-0.0.1/i18n/exceptions.rb +53 -0
  91. data/lib/active_support/vendor/{memcache-client-1.5.0 → memcache-client-1.5.1}/memcache.rb +5 -5
  92. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo.rb +0 -0
  93. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/data_timezone.rb +0 -0
  94. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/data_timezone_info.rb +0 -0
  95. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Algiers.rb +0 -0
  96. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Cairo.rb +0 -0
  97. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Casablanca.rb +0 -0
  98. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Harare.rb +0 -0
  99. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Johannesburg.rb +0 -0
  100. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Monrovia.rb +0 -0
  101. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Nairobi.rb +0 -0
  102. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +0 -0
  103. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/San_Juan.rb +86 -0
  104. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Bogota.rb +0 -0
  105. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Caracas.rb +0 -0
  106. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Chicago.rb +0 -0
  107. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Chihuahua.rb +0 -0
  108. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Denver.rb +0 -0
  109. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Godthab.rb +0 -0
  110. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Guatemala.rb +0 -0
  111. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Halifax.rb +0 -0
  112. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Indiana/Indianapolis.rb +0 -0
  113. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Juneau.rb +0 -0
  114. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/La_Paz.rb +0 -0
  115. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Lima.rb +0 -0
  116. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Los_Angeles.rb +0 -0
  117. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Mazatlan.rb +0 -0
  118. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Mexico_City.rb +0 -0
  119. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Monterrey.rb +0 -0
  120. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/New_York.rb +0 -0
  121. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Phoenix.rb +0 -0
  122. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Regina.rb +0 -0
  123. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Santiago.rb +0 -0
  124. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Sao_Paulo.rb +0 -0
  125. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/St_Johns.rb +0 -0
  126. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Tijuana.rb +0 -0
  127. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Almaty.rb +0 -0
  128. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Baghdad.rb +0 -0
  129. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Baku.rb +0 -0
  130. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Bangkok.rb +0 -0
  131. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Chongqing.rb +0 -0
  132. data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Colombo.rb +30 -0
  133. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Dhaka.rb +0 -0
  134. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Hong_Kong.rb +0 -0
  135. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Irkutsk.rb +0 -0
  136. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Jakarta.rb +0 -0
  137. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Jerusalem.rb +0 -0
  138. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kabul.rb +0 -0
  139. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kamchatka.rb +0 -0
  140. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Karachi.rb +0 -0
  141. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Katmandu.rb +0 -0
  142. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kolkata.rb +0 -0
  143. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Krasnoyarsk.rb +0 -0
  144. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kuala_Lumpur.rb +0 -0
  145. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kuwait.rb +0 -0
  146. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Magadan.rb +0 -0
  147. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Muscat.rb +0 -0
  148. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Novosibirsk.rb +0 -0
  149. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Rangoon.rb +0 -0
  150. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Riyadh.rb +0 -0
  151. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Seoul.rb +0 -0
  152. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Shanghai.rb +0 -0
  153. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Singapore.rb +0 -0
  154. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Taipei.rb +0 -0
  155. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Tashkent.rb +0 -0
  156. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Tbilisi.rb +0 -0
  157. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Tehran.rb +0 -0
  158. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Tokyo.rb +0 -0
  159. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Ulaanbaatar.rb +0 -0
  160. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Urumqi.rb +0 -0
  161. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Vladivostok.rb +0 -0
  162. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Yakutsk.rb +0 -0
  163. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Yekaterinburg.rb +0 -0
  164. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Yerevan.rb +0 -0
  165. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Atlantic/Azores.rb +0 -0
  166. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Atlantic/Cape_Verde.rb +0 -0
  167. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Atlantic/South_Georgia.rb +0 -0
  168. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Adelaide.rb +0 -0
  169. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Brisbane.rb +0 -0
  170. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Darwin.rb +0 -0
  171. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Hobart.rb +0 -0
  172. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Melbourne.rb +0 -0
  173. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Perth.rb +0 -0
  174. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Sydney.rb +0 -0
  175. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Etc/UTC.rb +0 -0
  176. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Amsterdam.rb +0 -0
  177. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Athens.rb +0 -0
  178. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Belgrade.rb +0 -0
  179. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Berlin.rb +0 -0
  180. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Bratislava.rb +0 -0
  181. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Brussels.rb +0 -0
  182. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Bucharest.rb +0 -0
  183. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Budapest.rb +0 -0
  184. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Copenhagen.rb +0 -0
  185. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Dublin.rb +0 -0
  186. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Helsinki.rb +0 -0
  187. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Istanbul.rb +0 -0
  188. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Kiev.rb +0 -0
  189. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Lisbon.rb +0 -0
  190. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Ljubljana.rb +0 -0
  191. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/London.rb +0 -0
  192. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Madrid.rb +0 -0
  193. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Minsk.rb +0 -0
  194. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Moscow.rb +0 -0
  195. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Paris.rb +0 -0
  196. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Prague.rb +0 -0
  197. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Riga.rb +0 -0
  198. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Rome.rb +0 -0
  199. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Sarajevo.rb +0 -0
  200. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Skopje.rb +0 -0
  201. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Sofia.rb +0 -0
  202. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Stockholm.rb +0 -0
  203. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Tallinn.rb +0 -0
  204. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Vienna.rb +0 -0
  205. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Vilnius.rb +0 -0
  206. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Warsaw.rb +0 -0
  207. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Zagreb.rb +0 -0
  208. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Auckland.rb +0 -0
  209. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Fiji.rb +0 -0
  210. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Guam.rb +0 -0
  211. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Honolulu.rb +0 -0
  212. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Majuro.rb +0 -0
  213. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Midway.rb +0 -0
  214. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Noumea.rb +0 -0
  215. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Pago_Pago.rb +0 -0
  216. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Port_Moresby.rb +0 -0
  217. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Tongatapu.rb +0 -0
  218. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/info_timezone.rb +0 -0
  219. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/linked_timezone.rb +0 -0
  220. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/linked_timezone_info.rb +0 -0
  221. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/offset_rationals.rb +0 -0
  222. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/ruby_core_support.rb +0 -0
  223. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/time_or_datetime.rb +0 -0
  224. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone.rb +0 -0
  225. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_definition.rb +0 -0
  226. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_info.rb +0 -0
  227. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_offset_info.rb +0 -0
  228. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_period.rb +0 -0
  229. data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_transition_info.rb +0 -0
  230. data/lib/active_support/vendor/xml-simple-1.0.11/xmlsimple.rb +3 -3
  231. data/lib/active_support/version.rb +1 -1
  232. metadata +185 -167
  233. data/lib/active_support/clean_logger.rb +0 -127
  234. data/lib/active_support/core_ext/string/unicode.rb +0 -66
  235. data/lib/active_support/core_ext/test.rb +0 -1
  236. data/lib/active_support/multibyte/generators/generate_tables.rb +0 -149
  237. data/lib/active_support/multibyte/handlers/passthru_handler.rb +0 -9
  238. data/lib/active_support/multibyte/handlers/utf8_handler.rb +0 -564
  239. data/lib/active_support/multibyte/handlers/utf8_handler_proc.rb +0 -43
  240. data/lib/active_support/vendor/tzinfo-0.3.11/tzinfo/definitions/America/Argentina/San_Juan.rb +0 -170
data/CHANGELOG CHANGED
@@ -1,17 +1,76 @@
1
- *2.1.2 (October 23rd, 2008)*
1
+ *2.2 (November 21st, 2008)*
2
+
3
+ * TimeZone offset tests: use current_period, to ensure TimeZone#utc_offset is up-to-date [Geoff Buesing]
4
+
5
+ * Update bundled TZInfo to 0.3.12 [Geoff Buesing]
6
+
7
+ * Increment the version of our altered memcache-client to prevent confusion caused when the 1.5.0 gem is installed.
8
+
9
+ * Fixed the option merging in Array#to_xml #1126 [Rudolf Gavlas]
10
+
11
+ * Make I18n::Backend::Simple reload its translations in development mode [DHH/Sven Fuchs]
2
12
 
3
13
  * TimeWithZone#freeze: preload instance variables so that we can actually freeze [Geoff Buesing]
4
14
 
15
+ * Fix Brasilia timezone #1180 [Marcus Derencius, Kane]
5
16
 
6
- *2.1.1 (September 4th, 2008)*
17
+ * Time#advance recognizes fractional days and weeks. Deprecate Durations of fractional months and years #970 [Tom Lea]
7
18
 
8
- * Fix Ruby's Time marshaling bug in pre-1.9 versions of Ruby: utc instances are now correctly unmarshaled with a utc zone instead of the system local zone [#900 state:resolved]:activesupport/CHANGELOG
19
+ * Add ActiveSupport::Rescuable module abstracting ActionController::Base rescue_from features. [Norbert Crombach, Pratik]
9
20
 
10
- * TimeWithZone: when crossing DST boundary, treat Durations of days, months or years as variable-length, and all other values as absolute length. A time + 24.hours will advance exactly 24 hours, but a time + 1.day will advance 23-25 hours, depending on the day. Ensure consistent behavior across all advancing methods [Geoff Buesing]
21
+ * Switch from String#chars to String#mb_chars for the unicode proxy. [Manfred Stienstra]
22
+
23
+ This helps with 1.8.7 compatibility and also improves performance for some operations by reducing indirection.
24
+
25
+ * TimeWithZone #wday, #yday and #to_date avoid trip through #method_missing [Geoff Buesing]
26
+
27
+ * Added Time, Date, DateTime and TimeWithZone #past?, #future? and #today? #720 [Clemens Kofler, Geoff Buesing]
28
+
29
+ * Fixed Sri Jayawardenepura time zone to map to Asia/Colombo [Jamis Buck]
30
+
31
+ * Added Inflector#parameterize for easy slug generation ("Donald E. Knuth".parameterize => "donald-e-knuth") #713 [Matt Darby]
32
+
33
+ * Changed cache benchmarking to be reported in milliseconds [DHH]
34
+
35
+ * Fix Ruby's Time marshaling bug in pre-1.9 versions of Ruby: utc instances are now correctly unmarshaled with a utc zone instead of the system local zone [#900 state:resolved] [Luca Guidi, Geoff Buesing]
36
+
37
+ * Add Array#in_groups which splits or iterates over the array in specified number of groups. #579. [Adrian Mugnolo] Example:
38
+
39
+ a = (1..10).to_a
40
+ a.in_groups(3) #=> [[1, 2, 3, 4], [5, 6, 7, nil], [8, 9, 10, nil]]
41
+ a.in_groups(3, false) #=> [[1, 2, 3, 4], [5, 6, 7], [8, 9, 10]]
11
42
 
12
43
  * Fix TimeWithZone unmarshaling: coerce unmarshaled Time instances to utc, because Ruby's marshaling of Time instances doesn't respect the zone [Geoff Buesing]
13
44
 
14
- * Added StringQuestioneer for doing things like StringQuestioneer.new("production").production? # => true and StringQuestioneer.new("production").development? # => false [DHH]
45
+ * Added Memoizable mixin for caching simple lazy loaded attributes [Josh Peek]
46
+
47
+ * Move the test related core_ext stuff out of core_ext so it's only loaded by the test helpers. [Michael Koziarski]
48
+
49
+ * Add Inflection rules for String#humanize. #535 [dcmanges]
50
+
51
+ ActiveSupport::Inflector.inflections do |inflect|
52
+ inflect.human(/_cnt$/i, '\1_count')
53
+ end
54
+
55
+ 'jargon_cnt'.humanize # => 'Jargon count'
56
+
57
+ * TimeWithZone: when crossing DST boundary, treat Durations of days, months or years as variable-length, and all other values as absolute length. A time + 24.hours will advance exactly 24 hours, but a time + 1.day will advance 23-25 hours, depending on the day. Ensure consistent behavior across all advancing methods [Geoff Buesing]
58
+
59
+ * Added TimeZone #=~, to support matching zones by regex in time_zone_select. #195 [Ernie Miller]
60
+
61
+ * Added Array#second through Array#fifth as aliases for Array#[1] through Array#[4] + Array#forty_two as alias for Array[41] [DHH]
62
+
63
+ * Added test/do declaration style testing to ActiveSupport::TestCase [DHH via Jay Fields]
64
+
65
+ * Added Object#present? which is equivalent to !Object#blank? [DHH]
66
+
67
+ * Added Enumberable#many? to encapsulate collection.size > 1 [DHH/Damian Janowski]
68
+
69
+ * Add more standard Hash methods to ActiveSupport::OrderedHash [Steve Purcell]
70
+
71
+ * Namespace Inflector, Dependencies, OrderedOptions, and TimeZone under ActiveSupport [Josh Peek]
72
+
73
+ * Added StringInquirer for doing things like StringInquirer.new("production").production? # => true and StringInquirer.new("production").development? # => false [DHH]
15
74
 
16
75
  * Fixed Date#end_of_quarter to not blow up on May 31st [#289 state:resolved] (Danger)
17
76
 
@@ -21,8 +21,6 @@
21
21
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  #++
23
23
 
24
- $:.unshift(File.dirname(__FILE__))
25
-
26
24
  require 'active_support/vendor'
27
25
  require 'active_support/basic_object'
28
26
  require 'active_support/inflector'
@@ -30,7 +28,6 @@ require 'active_support/callbacks'
30
28
 
31
29
  require 'active_support/core_ext'
32
30
 
33
- require 'active_support/clean_logger'
34
31
  require 'active_support/buffered_logger'
35
32
 
36
33
  require 'active_support/gzip'
@@ -43,6 +40,7 @@ require 'active_support/ordered_hash'
43
40
  require 'active_support/ordered_options'
44
41
  require 'active_support/option_merger'
45
42
 
43
+ require 'active_support/memoizable'
46
44
  require 'active_support/string_inquirer'
47
45
 
48
46
  require 'active_support/values/time_zone'
@@ -56,6 +54,8 @@ require 'active_support/base64'
56
54
 
57
55
  require 'active_support/time_with_zone'
58
56
 
59
- Inflector = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('Inflector', 'ActiveSupport::Inflector')
60
- Dependencies = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('Dependencies', 'ActiveSupport::Dependencies')
61
- TimeZone = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('TimeZone', 'ActiveSupport::TimeZone')
57
+ require 'active_support/secure_random'
58
+
59
+ require 'active_support/rescuable'
60
+
61
+ I18n.load_path << File.dirname(__FILE__) + '/active_support/locale/en.yml'
@@ -7,13 +7,24 @@ module ActiveSupport
7
7
  if defined? ::Base64
8
8
  Base64 = ::Base64
9
9
  else
10
- # Ruby 1.9 doesn't provide base64, so we wrap this here
10
+ # Base64 provides utility methods for encoding and de-coding binary data
11
+ # using a base 64 representation. A base 64 representation of binary data
12
+ # consists entirely of printable US-ASCII characters. The Base64 module
13
+ # is included in Ruby 1.8, but has been removed in Ruby 1.9.
11
14
  module Base64
12
-
15
+ # Encodes a string to its base 64 representation. Each 60 characters of
16
+ # output is separated by a newline character.
17
+ #
18
+ # ActiveSupport::Base64.encode64("Original unencoded string")
19
+ # # => "T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw==\n"
13
20
  def self.encode64(data)
14
21
  [data].pack("m")
15
22
  end
16
23
 
24
+ # Decodes a base 64 encoded string to its original representation.
25
+ #
26
+ # ActiveSupport::Base64.decode64("T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw==")
27
+ # # => "Original unencoded string"
17
28
  def self.decode64(data)
18
29
  data.unpack("m").first
19
30
  end
@@ -7,7 +7,7 @@
7
7
  # barebones base class that emulates Builder::BlankSlate while still relying on
8
8
  # Ruby 1.9's BasicObject in Ruby 1.9.
9
9
  module ActiveSupport
10
- if RUBY_VERSION >= '1.9'
10
+ if defined? ::BasicObject
11
11
  class BasicObject < ::BasicObject
12
12
  undef_method :==
13
13
  undef_method :equal?
@@ -33,13 +33,12 @@ module ActiveSupport
33
33
 
34
34
  attr_accessor :level
35
35
  attr_reader :auto_flushing
36
- attr_reader :buffer
37
36
 
38
37
  def initialize(log, level = DEBUG)
39
38
  @level = level
40
- @buffer = []
39
+ @buffer = {}
41
40
  @auto_flushing = 1
42
- @no_block = false
41
+ @guard = Mutex.new
43
42
 
44
43
  if log.respond_to?(:write)
45
44
  @log = log
@@ -54,12 +53,6 @@ module ActiveSupport
54
53
  end
55
54
  end
56
55
 
57
- def set_non_blocking_io
58
- if !RUBY_PLATFORM.match(/java|mswin/) && !(@log == STDOUT) && @log.respond_to?(:write_nonblock)
59
- @no_block = true
60
- end
61
- end
62
-
63
56
  def add(severity, message = nil, progname = nil, &block)
64
57
  return if @level > severity
65
58
  message = (message || (block && block.call) || progname).to_s
@@ -98,11 +91,11 @@ module ActiveSupport
98
91
  end
99
92
 
100
93
  def flush
101
- unless buffer.empty?
102
- if @no_block
103
- @log.write_nonblock(buffer.slice!(0..-1).join)
104
- else
105
- @log.write(buffer.slice!(0..-1).join)
94
+ @guard.synchronize do
95
+ unless buffer.empty?
96
+ old_buffer = buffer
97
+ clear_buffer
98
+ @log.write(old_buffer.join)
106
99
  end
107
100
  end
108
101
  end
@@ -117,5 +110,13 @@ module ActiveSupport
117
110
  def auto_flush
118
111
  flush if buffer.size >= @auto_flushing
119
112
  end
113
+
114
+ def buffer
115
+ @buffer[Thread.current] ||= []
116
+ end
117
+
118
+ def clear_buffer
119
+ @buffer.delete(Thread.current)
120
+ end
120
121
  end
121
122
  end
@@ -1,7 +1,33 @@
1
1
  require 'benchmark'
2
2
 
3
3
  module ActiveSupport
4
+ # See ActiveSupport::Cache::Store for documentation.
4
5
  module Cache
6
+ # Creates a new CacheStore object according to the given options.
7
+ #
8
+ # If no arguments are passed to this method, then a new
9
+ # ActiveSupport::Cache::MemoryStore object will be returned.
10
+ #
11
+ # If you pass a Symbol as the first argument, then a corresponding cache
12
+ # store class under the ActiveSupport::Cache namespace will be created.
13
+ # For example:
14
+ #
15
+ # ActiveSupport::Cache.lookup_store(:memory_store)
16
+ # # => returns a new ActiveSupport::Cache::MemoryStore object
17
+ #
18
+ # ActiveSupport::Cache.lookup_store(:drb_store)
19
+ # # => returns a new ActiveSupport::Cache::DRbStore object
20
+ #
21
+ # Any additional arguments will be passed to the corresponding cache store
22
+ # class's constructor:
23
+ #
24
+ # ActiveSupport::Cache.lookup_store(:file_store, "/tmp/cache")
25
+ # # => same as: ActiveSupport::Cache::FileStore.new("/tmp/cache")
26
+ #
27
+ # If the first argument is not a Symbol, then it will simply be returned:
28
+ #
29
+ # ActiveSupport::Cache.lookup_store(MyOwnCacheStore.new)
30
+ # # => returns MyOwnCacheStore.new
5
31
  def self.lookup_store(*store_option)
6
32
  store, *parameters = *([ store_option ].flatten)
7
33
 
@@ -21,37 +47,84 @@ module ActiveSupport
21
47
  expanded_cache_key = namespace ? "#{namespace}/" : ""
22
48
 
23
49
  if ENV["RAILS_CACHE_ID"] || ENV["RAILS_APP_VERSION"]
24
- expanded_cache_key << "#{ENV["RAILS_CACHE_ID"] || ENV["RAILS_APP_VERSION"]}/"
50
+ expanded_cache_key << "#{ENV["RAILS_CACHE_ID"] || ENV["RAILS_APP_VERSION"]}/"
25
51
  end
26
52
 
27
53
  expanded_cache_key << case
28
- when key.respond_to?(:cache_key)
29
- key.cache_key
30
- when key.is_a?(Array)
31
- key.collect { |element| expand_cache_key(element) }.to_param
32
- when key.respond_to?(:to_param)
33
- key.to_param
34
- else
35
- key.to_s
36
- end
54
+ when key.respond_to?(:cache_key)
55
+ key.cache_key
56
+ when key.is_a?(Array)
57
+ key.collect { |element| expand_cache_key(element) }.to_param
58
+ when key
59
+ key.to_param
60
+ end.to_s
37
61
 
38
62
  expanded_cache_key
39
63
  end
40
64
 
41
-
65
+ # An abstract cache store class. There are multiple cache store
66
+ # implementations, each having its own additional features. See the classes
67
+ # under the ActiveSupport::Cache module, e.g.
68
+ # ActiveSupport::Cache::MemCacheStore. MemCacheStore is currently the most
69
+ # popular cache store for large production websites.
70
+ #
71
+ # ActiveSupport::Cache::Store is meant for caching strings. Some cache
72
+ # store implementations, like MemoryStore, are able to cache arbitrary
73
+ # Ruby objects, but don't count on every cache store to be able to do that.
74
+ #
75
+ # cache = ActiveSupport::Cache::MemoryStore.new
76
+ #
77
+ # cache.read("city") # => nil
78
+ # cache.write("city", "Duckburgh")
79
+ # cache.read("city") # => "Duckburgh"
42
80
  class Store
43
81
  cattr_accessor :logger
44
82
 
45
- def initialize
46
- end
47
-
48
- def threadsafe!
49
- @mutex = Mutex.new
50
- self.class.send :include, ThreadSafety
83
+ def silence!
84
+ @silence = true
51
85
  self
52
86
  end
53
87
 
54
- # Pass <tt>:force => true</tt> to force a cache miss.
88
+ # Fetches data from the cache, using the given key. If there is data in
89
+ # the cache with the given key, then that data is returned.
90
+ #
91
+ # If there is no such data in the cache (a cache miss occurred), then
92
+ # then nil will be returned. However, if a block has been passed, then
93
+ # that block will be run in the event of a cache miss. The return value
94
+ # of the block will be written to the cache under the given cache key,
95
+ # and that return value will be returned.
96
+ #
97
+ # cache.write("today", "Monday")
98
+ # cache.fetch("today") # => "Monday"
99
+ #
100
+ # cache.fetch("city") # => nil
101
+ # cache.fetch("city") do
102
+ # "Duckburgh"
103
+ # end
104
+ # cache.fetch("city") # => "Duckburgh"
105
+ #
106
+ # You may also specify additional options via the +options+ argument.
107
+ # Setting <tt>:force => true</tt> will force a cache miss:
108
+ #
109
+ # cache.write("today", "Monday")
110
+ # cache.fetch("today", :force => true) # => nil
111
+ #
112
+ # Other options will be handled by the specific cache store implementation.
113
+ # Internally, #fetch calls #read, and calls #write on a cache miss.
114
+ # +options+ will be passed to the #read and #write calls.
115
+ #
116
+ # For example, MemCacheStore's #write method supports the +:expires_in+
117
+ # option, which tells the memcached server to automatically expire the
118
+ # cache item after a certain period. We can use this option with #fetch
119
+ # too:
120
+ #
121
+ # cache = ActiveSupport::Cache::MemCacheStore.new
122
+ # cache.fetch("foo", :force => true, :expires_in => 5.seconds) do
123
+ # "bar"
124
+ # end
125
+ # cache.fetch("foo") # => "bar"
126
+ # sleep(6)
127
+ # cache.fetch("foo") # => nil
55
128
  def fetch(key, options = {})
56
129
  @logger_off = true
57
130
  if !options[:force] && value = read(key, options)
@@ -69,16 +142,38 @@ module ActiveSupport
69
142
  write(key, value, options)
70
143
  @logger_off = false
71
144
 
72
- log("write (will save #{'%.5f' % seconds})", key, nil)
145
+ log("write (will save #{'%.2f' % (seconds * 1000)}ms)", key, nil)
73
146
 
74
147
  value
75
148
  end
76
149
  end
77
150
 
151
+ # Fetches data from the cache, using the given key. If there is data in
152
+ # the cache with the given key, then that data is returned. Otherwise,
153
+ # nil is returned.
154
+ #
155
+ # You may also specify additional options via the +options+ argument.
156
+ # The specific cache store implementation will decide what to do with
157
+ # +options+.
78
158
  def read(key, options = nil)
79
159
  log("read", key, options)
80
160
  end
81
161
 
162
+ # Writes the given value to the cache, with the given key.
163
+ #
164
+ # You may also specify additional options via the +options+ argument.
165
+ # The specific cache store implementation will decide what to do with
166
+ # +options+.
167
+ #
168
+ # For example, MemCacheStore supports the +:expires_in+ option, which
169
+ # tells the memcached server to automatically expire the cache item after
170
+ # a certain period:
171
+ #
172
+ # cache = ActiveSupport::Cache::MemCacheStore.new
173
+ # cache.write("foo", "bar", :expires_in => 5.seconds)
174
+ # cache.read("foo") # => "bar"
175
+ # sleep(6)
176
+ # cache.read("foo") # => nil
82
177
  def write(key, value, options = nil)
83
178
  log("write", key, options)
84
179
  end
@@ -112,31 +207,12 @@ module ActiveSupport
112
207
  nil
113
208
  end
114
209
  end
115
-
210
+
116
211
  private
117
212
  def log(operation, key, options)
118
- logger.debug("Cache #{operation}: #{key}#{options ? " (#{options.inspect})" : ""}") if logger && !@logger_off
213
+ logger.debug("Cache #{operation}: #{key}#{options ? " (#{options.inspect})" : ""}") if logger && !@silence && !@logger_off
119
214
  end
120
215
  end
121
-
122
-
123
- module ThreadSafety #:nodoc:
124
- def read(key, options = nil) #:nodoc:
125
- @mutex.synchronize { super }
126
- end
127
-
128
- def write(key, value, options = nil) #:nodoc:
129
- @mutex.synchronize { super }
130
- end
131
-
132
- def delete(key, options = nil) #:nodoc:
133
- @mutex.synchronize { super }
134
- end
135
-
136
- def delete_matched(matcher, options = nil) #:nodoc:
137
- @mutex.synchronize { super }
138
- end
139
- end
140
216
  end
141
217
  end
142
218
 
@@ -3,12 +3,17 @@ module ActiveSupport
3
3
  class CompressedMemCacheStore < MemCacheStore
4
4
  def read(name, options = nil)
5
5
  if value = super(name, (options || {}).merge(:raw => true))
6
- Marshal.load(ActiveSupport::Gzip.decompress(value))
6
+ if raw?(options)
7
+ value
8
+ else
9
+ Marshal.load(ActiveSupport::Gzip.decompress(value))
10
+ end
7
11
  end
8
12
  end
9
13
 
10
14
  def write(name, value, options = nil)
11
- super(name, ActiveSupport::Gzip.compress(Marshal.dump(value)), (options || {}).merge(:raw => true))
15
+ value = ActiveSupport::Gzip.compress(Marshal.dump(value)) unless raw?(options)
16
+ super(name, value, (options || {}).merge(:raw => true))
12
17
  end
13
18
  end
14
19
  end
@@ -1,5 +1,6 @@
1
1
  module ActiveSupport
2
2
  module Cache
3
+ # A cache store implementation which stores everything on the filesystem.
3
4
  class FileStore < Store
4
5
  attr_reader :cache_path
5
6
 
@@ -9,15 +10,16 @@ module ActiveSupport
9
10
 
10
11
  def read(name, options = nil)
11
12
  super
12
- File.open(real_file_path(name), 'rb') { |f| f.read } rescue nil
13
+ File.open(real_file_path(name), 'rb') { |f| Marshal.load(f) } rescue nil
13
14
  end
14
15
 
15
16
  def write(name, value, options = nil)
16
17
  super
17
18
  ensure_cache_path(File.dirname(real_file_path(name)))
18
- File.open(real_file_path(name), "wb+") { |f| f.write(value) }
19
+ File.atomic_write(real_file_path(name), cache_path) { |f| Marshal.dump(value, f) }
20
+ value
19
21
  rescue => e
20
- RAILS_DEFAULT_LOGGER.error "Couldn't create cache directory: #{name} (#{e.message})" if RAILS_DEFAULT_LOGGER
22
+ logger.error "Couldn't create cache directory: #{name} (#{e.message})" if logger
21
23
  end
22
24
 
23
25
  def delete(name, options = nil)
@@ -65,6 +67,6 @@ module ActiveSupport
65
67
  end
66
68
  end
67
69
  end
68
- end
70
+ end
69
71
  end
70
- end
72
+ end