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
@@ -2,8 +2,19 @@ require 'memcache'
2
2
 
3
3
  module ActiveSupport
4
4
  module Cache
5
+ # A cache store implementation which stores data in Memcached:
6
+ # http://www.danga.com/memcached/
7
+ #
8
+ # This is currently the most popular cache store for production websites.
9
+ #
10
+ # Special features:
11
+ # - Clustering and load balancing. One can specify multiple memcached servers,
12
+ # and MemCacheStore will load balance between all available servers. If a
13
+ # server goes down, then MemCacheStore will ignore it until it goes back
14
+ # online.
15
+ # - Time-based expiry support. See #write and the +:expires_in+ option.
5
16
  class MemCacheStore < Store
6
- module Response
17
+ module Response # :nodoc:
7
18
  STORED = "STORED\r\n"
8
19
  NOT_STORED = "NOT_STORED\r\n"
9
20
  EXISTS = "EXISTS\r\n"
@@ -13,6 +24,14 @@ module ActiveSupport
13
24
 
14
25
  attr_reader :addresses
15
26
 
27
+ # Creates a new MemCacheStore object, with the given memcached server
28
+ # addresses. Each address is either a host name, or a host-with-port string
29
+ # in the form of "host_name:port". For example:
30
+ #
31
+ # ActiveSupport::Cache::MemCacheStore.new("localhost", "server-downstairs.localnetwork:8229")
32
+ #
33
+ # If no addresses are specified, then MemCacheStore will connect to
34
+ # localhost port 11211 (the default memcached port).
16
35
  def initialize(*addresses)
17
36
  addresses = addresses.flatten
18
37
  options = addresses.extract_options!
@@ -21,7 +40,7 @@ module ActiveSupport
21
40
  @data = MemCache.new(addresses, options)
22
41
  end
23
42
 
24
- def read(key, options = nil)
43
+ def read(key, options = nil) # :nodoc:
25
44
  super
26
45
  @data.get(key, raw?(options))
27
46
  rescue MemCache::MemCacheError => e
@@ -29,11 +48,19 @@ module ActiveSupport
29
48
  nil
30
49
  end
31
50
 
32
- # Set key = value. Pass :unless_exist => true if you don't
33
- # want to update the cache if the key is already set.
51
+ # Writes a value to the cache.
52
+ #
53
+ # Possible options:
54
+ # - +:unless_exist+ - set to true if you don't want to update the cache
55
+ # if the key is already set.
56
+ # - +:expires_in+ - the number of seconds that this value may stay in
57
+ # the cache. See ActiveSupport::Cache::Store#write for an example.
34
58
  def write(key, value, options = nil)
35
59
  super
36
60
  method = options && options[:unless_exist] ? :add : :set
61
+ # memcache-client will break the connection if you send it an integer
62
+ # in raw mode, so we convert it to a string to be sure it continues working.
63
+ value = value.to_s if raw?(options)
37
64
  response = @data.send(method, key, value, expires_in(options), raw?(options))
38
65
  response == Response::STORED
39
66
  rescue MemCache::MemCacheError => e
@@ -41,7 +68,7 @@ module ActiveSupport
41
68
  false
42
69
  end
43
70
 
44
- def delete(key, options = nil)
71
+ def delete(key, options = nil) # :nodoc:
45
72
  super
46
73
  response = @data.delete(key, expires_in(options))
47
74
  response == Response::DELETED
@@ -50,39 +77,39 @@ module ActiveSupport
50
77
  false
51
78
  end
52
79
 
53
- def exist?(key, options = nil)
80
+ def exist?(key, options = nil) # :nodoc:
54
81
  # Doesn't call super, cause exist? in memcache is in fact a read
55
82
  # But who cares? Reading is very fast anyway
56
83
  !read(key, options).nil?
57
84
  end
58
85
 
59
- def increment(key, amount = 1)
86
+ def increment(key, amount = 1) # :nodoc:
60
87
  log("incrementing", key, amount)
61
-
62
- response = @data.incr(key, amount)
88
+
89
+ response = @data.incr(key, amount)
63
90
  response == Response::NOT_FOUND ? nil : response
64
- rescue MemCache::MemCacheError
91
+ rescue MemCache::MemCacheError
65
92
  nil
66
93
  end
67
94
 
68
- def decrement(key, amount = 1)
95
+ def decrement(key, amount = 1) # :nodoc:
69
96
  log("decrement", key, amount)
70
-
71
- response = data.decr(key, amount)
97
+
98
+ response = @data.decr(key, amount)
72
99
  response == Response::NOT_FOUND ? nil : response
73
- rescue MemCache::MemCacheError
100
+ rescue MemCache::MemCacheError
74
101
  nil
75
- end
76
-
77
- def delete_matched(matcher, options = nil)
102
+ end
103
+
104
+ def delete_matched(matcher, options = nil) # :nodoc:
78
105
  super
79
106
  raise "Not supported by Memcache"
80
- end
81
-
107
+ end
108
+
82
109
  def clear
83
110
  @data.flush_all
84
- end
85
-
111
+ end
112
+
86
113
  def stats
87
114
  @data.stats
88
115
  end
@@ -1,5 +1,19 @@
1
1
  module ActiveSupport
2
2
  module Cache
3
+ # A cache store implementation which stores everything into memory in the
4
+ # same process. If you're running multiple Ruby on Rails server processes
5
+ # (which is the case if you're using mongrel_cluster or Phusion Passenger),
6
+ # then this means that your Rails server process instances won't be able
7
+ # to share cache data with each other. If your application never performs
8
+ # manual cache item expiry (e.g. when you're using generational cache keys),
9
+ # then using MemoryStore is ok. Otherwise, consider carefully whether you
10
+ # should be using this cache store.
11
+ #
12
+ # MemoryStore is not only able to store strings, but also arbitrary Ruby
13
+ # objects.
14
+ #
15
+ # MemoryStore is not thread-safe. Use SynchronizedMemoryStore instead
16
+ # if you need thread-safety.
3
17
  class MemoryStore < Store
4
18
  def initialize
5
19
  @data = {}
@@ -12,7 +26,7 @@ module ActiveSupport
12
26
 
13
27
  def write(name, value, options = nil)
14
28
  super
15
- @data[name] = value
29
+ @data[name] = value.freeze
16
30
  end
17
31
 
18
32
  def delete(name, options = nil)
@@ -35,4 +49,4 @@ module ActiveSupport
35
49
  end
36
50
  end
37
51
  end
38
- end
52
+ end
@@ -0,0 +1,47 @@
1
+ module ActiveSupport
2
+ module Cache
3
+ # Like MemoryStore, but thread-safe.
4
+ class SynchronizedMemoryStore < MemoryStore
5
+ def initialize
6
+ super
7
+ @guard = Monitor.new
8
+ end
9
+
10
+ def fetch(key, options = {})
11
+ @guard.synchronize { super }
12
+ end
13
+
14
+ def read(name, options = nil)
15
+ @guard.synchronize { super }
16
+ end
17
+
18
+ def write(name, value, options = nil)
19
+ @guard.synchronize { super }
20
+ end
21
+
22
+ def delete(name, options = nil)
23
+ @guard.synchronize { super }
24
+ end
25
+
26
+ def delete_matched(matcher, options = nil)
27
+ @guard.synchronize { super }
28
+ end
29
+
30
+ def exist?(name,options = nil)
31
+ @guard.synchronize { super }
32
+ end
33
+
34
+ def increment(key, amount = 1)
35
+ @guard.synchronize { super }
36
+ end
37
+
38
+ def decrement(key, amount = 1)
39
+ @guard.synchronize { super }
40
+ end
41
+
42
+ def clear
43
+ @guard.synchronize { super }
44
+ end
45
+ end
46
+ end
47
+ end
@@ -96,15 +96,12 @@ module ActiveSupport
96
96
  end
97
97
  end
98
98
 
99
- def |(chain)
100
- if chain.is_a?(CallbackChain)
101
- chain.each { |callback| self | callback }
99
+ # TODO: Decompose into more Array like behavior
100
+ def replace_or_append!(chain)
101
+ if index = index(chain)
102
+ self[index] = chain
102
103
  else
103
- if (found_callback = find(chain)) && (index = index(chain))
104
- self[index] = chain
105
- else
106
- self << chain
107
- end
104
+ self << chain
108
105
  end
109
106
  self
110
107
  end
@@ -157,6 +154,14 @@ module ActiveSupport
157
154
  self.class.new(@kind, @method, @options.dup)
158
155
  end
159
156
 
157
+ def hash
158
+ if @identifier
159
+ @identifier.hash
160
+ else
161
+ @method.hash
162
+ end
163
+ end
164
+
160
165
  def call(*args, &block)
161
166
  evaluate_method(method, *args, &block) if should_run_callback?(*args)
162
167
  rescue LocalJumpError
@@ -183,7 +188,7 @@ module ActiveSupport
183
188
  "Callbacks must be a symbol denoting the method to call, a string to be evaluated, " +
184
189
  "a block to be invoked, or an object responding to the callback method."
185
190
  end
186
- end
191
+ end
187
192
  end
188
193
 
189
194
  def should_run_callback?(*args)
@@ -8,6 +8,7 @@ module ActiveSupport #:nodoc:
8
8
  # %w( a b c d ).from(0) # => %w( a b c d )
9
9
  # %w( a b c d ).from(2) # => %w( c d )
10
10
  # %w( a b c d ).from(10) # => nil
11
+ # %w().from(0) # => nil
11
12
  def from(position)
12
13
  self[position..-1]
13
14
  end
@@ -17,9 +18,35 @@ module ActiveSupport #:nodoc:
17
18
  # %w( a b c d ).to(0) # => %w( a )
18
19
  # %w( a b c d ).to(2) # => %w( a b c )
19
20
  # %w( a b c d ).to(10) # => %w( a b c d )
21
+ # %w().to(0) # => %w()
20
22
  def to(position)
21
23
  self[0..position]
22
24
  end
25
+
26
+ # Equal to <tt>self[1]</tt>.
27
+ def second
28
+ self[1]
29
+ end
30
+
31
+ # Equal to <tt>self[2]</tt>.
32
+ def third
33
+ self[2]
34
+ end
35
+
36
+ # Equal to <tt>self[3]</tt>.
37
+ def fourth
38
+ self[3]
39
+ end
40
+
41
+ # Equal to <tt>self[4]</tt>.
42
+ def fifth
43
+ self[4]
44
+ end
45
+
46
+ # Equal to <tt>self[41]</tt>. Also known as accessing "the reddit".
47
+ def forty_two
48
+ self[41]
49
+ end
23
50
  end
24
51
  end
25
52
  end
@@ -6,10 +6,13 @@ module ActiveSupport #:nodoc:
6
6
  module Conversions
7
7
  # Converts the array to a comma-separated sentence where the last element is joined by the connector word. Options:
8
8
  # * <tt>:connector</tt> - The word used to join the last element in arrays with two or more elements (default: "and")
9
- # * <tt>:skip_last_comma</tt> - Set to true to return "a, b and c" instead of "a, b, and c".
10
- def to_sentence(options = {})
11
- options.assert_valid_keys(:connector, :skip_last_comma)
12
- options.reverse_merge! :connector => 'and', :skip_last_comma => false
9
+ # * <tt>:skip_last_comma</tt> - Set to true to return "a, b and c" instead of "a, b, and c".
10
+ def to_sentence(options = {})
11
+ options.assert_valid_keys(:connector, :skip_last_comma, :locale)
12
+
13
+ default = I18n.translate(:'support.array.sentence_connector', :locale => options[:locale])
14
+ default_skip_last_comma = I18n.translate(:'support.array.skip_last_comma', :locale => options[:locale])
15
+ options.reverse_merge! :connector => default, :skip_last_comma => default_skip_last_comma
13
16
  options[:connector] = "#{options[:connector]} " unless options[:connector].nil? || options[:connector].strip == ''
14
17
 
15
18
  case length
@@ -23,11 +26,12 @@ module ActiveSupport #:nodoc:
23
26
  "#{self[0...-1].join(', ')}#{options[:skip_last_comma] ? '' : ','} #{options[:connector]}#{self[-1]}"
24
27
  end
25
28
  end
29
+
26
30
 
27
31
  # Calls <tt>to_param</tt> on all its elements and joins the result with
28
32
  # slashes. This is used by <tt>url_for</tt> in Action Pack.
29
33
  def to_param
30
- map(&:to_param).join '/'
34
+ collect { |e| e.to_param }.join '/'
31
35
  end
32
36
 
33
37
  # Converts an array into a string suitable for use as a URL query string,
@@ -35,7 +39,8 @@ module ActiveSupport #:nodoc:
35
39
  #
36
40
  # ['Rails', 'coding'].to_query('hobbies') # => "hobbies%5B%5D=Rails&hobbies%5B%5D=coding"
37
41
  def to_query(key)
38
- collect { |value| value.to_query("#{key}[]") } * '&'
42
+ prefix = "#{key}[]"
43
+ collect { |value| value.to_query(prefix) }.join '&'
39
44
  end
40
45
 
41
46
  def self.included(base) #:nodoc:
@@ -167,7 +172,7 @@ module ActiveSupport #:nodoc:
167
172
  else
168
173
  xml.tag!(root, options[:skip_types] ? {} : {:type => "array"}) {
169
174
  yield xml if block_given?
170
- each { |e| e.to_xml(opts.merge!({ :skip_instruct => true })) }
175
+ each { |e| e.to_xml(opts.merge({ :skip_instruct => true })) }
171
176
  }
172
177
  end
173
178
  end
@@ -4,22 +4,22 @@ module ActiveSupport #:nodoc:
4
4
  module CoreExtensions #:nodoc:
5
5
  module Array #:nodoc:
6
6
  module Grouping
7
- # Iterates over the array in groups of size +number+, padding any remaining
8
- # slots with +fill_with+ unless it is +false+.
7
+ # Splits or iterates over the array in groups of size +number+,
8
+ # padding any remaining slots with +fill_with+ unless it is +false+.
9
9
  #
10
- # %w(1 2 3 4 5 6 7).in_groups_of(3) {|g| p g}
10
+ # %w(1 2 3 4 5 6 7).in_groups_of(3) {|group| p group}
11
11
  # ["1", "2", "3"]
12
12
  # ["4", "5", "6"]
13
13
  # ["7", nil, nil]
14
14
  #
15
- # %w(1 2 3).in_groups_of(2, '&nbsp;') {|g| p g}
15
+ # %w(1 2 3).in_groups_of(2, '&nbsp;') {|group| p group}
16
16
  # ["1", "2"]
17
17
  # ["3", "&nbsp;"]
18
18
  #
19
- # %w(1 2 3).in_groups_of(2, false) {|g| p g}
19
+ # %w(1 2 3).in_groups_of(2, false) {|group| p group}
20
20
  # ["1", "2"]
21
21
  # ["3"]
22
- def in_groups_of(number, fill_with = nil, &block)
22
+ def in_groups_of(number, fill_with = nil)
23
23
  if fill_with == false
24
24
  collection = self
25
25
  else
@@ -31,7 +31,7 @@ module ActiveSupport #:nodoc:
31
31
  end
32
32
 
33
33
  if block_given?
34
- collection.each_slice(number, &block)
34
+ collection.each_slice(number) { |slice| yield(slice) }
35
35
  else
36
36
  returning [] do |groups|
37
37
  collection.each_slice(number) { |group| groups << group }
@@ -39,16 +39,59 @@ module ActiveSupport #:nodoc:
39
39
  end
40
40
  end
41
41
 
42
+ # Splits or iterates over the array in +number+ of groups, padding any
43
+ # remaining slots with +fill_with+ unless it is +false+.
44
+ #
45
+ # %w(1 2 3 4 5 6 7 8 9 10).in_groups(3) {|group| p group}
46
+ # ["1", "2", "3", "4"]
47
+ # ["5", "6", "7", nil]
48
+ # ["8", "9", "10", nil]
49
+ #
50
+ # %w(1 2 3 4 5 6 7).in_groups(3, '&nbsp;') {|group| p group}
51
+ # ["1", "2", "3"]
52
+ # ["4", "5", "&nbsp;"]
53
+ # ["6", "7", "&nbsp;"]
54
+ #
55
+ # %w(1 2 3 4 5 6 7).in_groups(3, false) {|group| p group}
56
+ # ["1", "2", "3"]
57
+ # ["4", "5"]
58
+ # ["6", "7"]
59
+ def in_groups(number, fill_with = nil)
60
+ # size / number gives minor group size;
61
+ # size % number gives how many objects need extra accomodation;
62
+ # each group hold either division or division + 1 items.
63
+ division = size / number
64
+ modulo = size % number
65
+
66
+ # create a new array avoiding dup
67
+ groups = []
68
+ start = 0
69
+
70
+ number.times do |index|
71
+ length = division + (modulo > 0 && modulo > index ? 1 : 0)
72
+ padding = fill_with != false &&
73
+ modulo > 0 && length == division ? 1 : 0
74
+ groups << slice(start, length).concat([fill_with] * padding)
75
+ start += length
76
+ end
77
+
78
+ if block_given?
79
+ groups.each{|g| yield(g) }
80
+ else
81
+ groups
82
+ end
83
+ end
84
+
42
85
  # Divides the array into one or more subarrays based on a delimiting +value+
43
86
  # or the result of an optional block.
44
87
  #
45
88
  # [1, 2, 3, 4, 5].split(3) # => [[1, 2], [4, 5]]
46
89
  # (1..10).to_a.split { |i| i % 3 == 0 } # => [[1, 2], [4, 5], [7, 8], [10]]
47
- def split(value = nil, &block)
48
- block ||= Proc.new { |e| e == value }
90
+ def split(value = nil)
91
+ using_block = block_given?
49
92
 
50
93
  inject([[]]) do |results, element|
51
- if block.call(element)
94
+ if (using_block && yield(element)) || (value == element)
52
95
  results << []
53
96
  else
54
97
  results.last << element