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
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ module ActiveSupport #:nodoc:
4
+ module Multibyte #:nodoc:
5
+ # Raised when a problem with the encoding was found.
6
+ class EncodingError < StandardError; end
7
+ end
8
+ end
@@ -0,0 +1,71 @@
1
+ # encoding: utf-8
2
+
3
+ module ActiveSupport #:nodoc:
4
+ module Multibyte #:nodoc:
5
+ # Holds data about a codepoint in the Unicode database
6
+ class Codepoint
7
+ attr_accessor :code, :combining_class, :decomp_type, :decomp_mapping, :uppercase_mapping, :lowercase_mapping
8
+ end
9
+
10
+ # Holds static data from the Unicode database
11
+ class UnicodeDatabase
12
+ ATTRIBUTES = :codepoints, :composition_exclusion, :composition_map, :boundary, :cp1252
13
+
14
+ attr_writer(*ATTRIBUTES)
15
+
16
+ def initialize
17
+ @codepoints = Hash.new(Codepoint.new)
18
+ @composition_exclusion = []
19
+ @composition_map = {}
20
+ @boundary = {}
21
+ @cp1252 = {}
22
+ end
23
+
24
+ # Lazy load the Unicode database so it's only loaded when it's actually used
25
+ ATTRIBUTES.each do |attr_name|
26
+ class_eval(<<-EOS, __FILE__, __LINE__)
27
+ def #{attr_name}
28
+ load
29
+ @#{attr_name}
30
+ end
31
+ EOS
32
+ end
33
+
34
+ # Loads the Unicode database and returns all the internal objects of UnicodeDatabase.
35
+ def load
36
+ begin
37
+ @codepoints, @composition_exclusion, @composition_map, @boundary, @cp1252 = File.open(self.class.filename, 'rb') { |f| Marshal.load f.read }
38
+ rescue Exception => e
39
+ raise IOError.new("Couldn't load the Unicode tables for UTF8Handler (#{e.message}), ActiveSupport::Multibyte is unusable")
40
+ end
41
+
42
+ # Redefine the === method so we can write shorter rules for grapheme cluster breaks
43
+ @boundary.each do |k,_|
44
+ @boundary[k].instance_eval do
45
+ def ===(other)
46
+ detect { |i| i === other } ? true : false
47
+ end
48
+ end if @boundary[k].kind_of?(Array)
49
+ end
50
+
51
+ # define attr_reader methods for the instance variables
52
+ class << self
53
+ attr_reader(*ATTRIBUTES)
54
+ end
55
+ end
56
+
57
+ # Returns the directory in which the data files are stored
58
+ def self.dirname
59
+ File.dirname(__FILE__) + '/../values/'
60
+ end
61
+
62
+ # Returns the filename for the data file for this version
63
+ def self.filename
64
+ File.expand_path File.join(dirname, "unicode_tables.dat")
65
+ end
66
+ end
67
+
68
+ # UniCode Database
69
+ UCD = UnicodeDatabase.new
70
+ end
71
+ end
@@ -10,16 +10,8 @@ module ActiveSupport
10
10
 
11
11
  private
12
12
  def method_missing(method, *arguments, &block)
13
- merge_argument_options! arguments
14
- @context.send!(method, *arguments, &block)
15
- end
16
-
17
- def merge_argument_options!(arguments)
18
- arguments << if arguments.last.respond_to? :to_hash
19
- @options.merge(arguments.pop)
20
- else
21
- @options.dup
22
- end
13
+ arguments << (arguments.last.respond_to?(:to_hash) ? @options.deep_merge(arguments.pop) : @options.dup)
14
+ @context.__send__(method, *arguments, &block)
23
15
  end
24
16
  end
25
17
  end
@@ -12,6 +12,7 @@ module ActiveSupport
12
12
  else
13
13
  self << [key, value]
14
14
  end
15
+ value
15
16
  end
16
17
 
17
18
  def [](key)
@@ -38,6 +39,20 @@ module ActiveSupport
38
39
  each { |array| hash[array[0]] = array[1] }
39
40
  end
40
41
  end
42
+
43
+ def has_key?(k)
44
+ !assoc(k).nil?
45
+ end
46
+
47
+ alias_method :key?, :has_key?
48
+ alias_method :include?, :has_key?
49
+ alias_method :member?, :has_key?
50
+
51
+ def has_value?(v)
52
+ any? { |key, value| value == v }
53
+ end
54
+
55
+ alias_method :value?, :has_value?
41
56
  end
42
57
  end
43
58
  end
@@ -0,0 +1,108 @@
1
+ module ActiveSupport
2
+ # Rescuable module adds support for easier exception handling.
3
+ module Rescuable
4
+ def self.included(base) # :nodoc:
5
+ base.class_inheritable_accessor :rescue_handlers
6
+ base.rescue_handlers = []
7
+
8
+ base.extend(ClassMethods)
9
+ end
10
+
11
+ module ClassMethods
12
+ # Rescue exceptions raised in controller actions.
13
+ #
14
+ # <tt>rescue_from</tt> receives a series of exception classes or class
15
+ # names, and a trailing <tt>:with</tt> option with the name of a method
16
+ # or a Proc object to be called to handle them. Alternatively a block can
17
+ # be given.
18
+ #
19
+ # Handlers that take one argument will be called with the exception, so
20
+ # that the exception can be inspected when dealing with it.
21
+ #
22
+ # Handlers are inherited. They are searched from right to left, from
23
+ # bottom to top, and up the hierarchy. The handler of the first class for
24
+ # which <tt>exception.is_a?(klass)</tt> holds true is the one invoked, if
25
+ # any.
26
+ #
27
+ # class ApplicationController < ActionController::Base
28
+ # rescue_from User::NotAuthorized, :with => :deny_access # self defined exception
29
+ # rescue_from ActiveRecord::RecordInvalid, :with => :show_errors
30
+ #
31
+ # rescue_from 'MyAppError::Base' do |exception|
32
+ # render :xml => exception, :status => 500
33
+ # end
34
+ #
35
+ # protected
36
+ # def deny_access
37
+ # ...
38
+ # end
39
+ #
40
+ # def show_errors(exception)
41
+ # exception.record.new_record? ? ...
42
+ # end
43
+ # end
44
+ def rescue_from(*klasses, &block)
45
+ options = klasses.extract_options!
46
+
47
+ unless options.has_key?(:with)
48
+ if block_given?
49
+ options[:with] = block
50
+ else
51
+ raise ArgumentError, "Need a handler. Supply an options hash that has a :with key as the last argument."
52
+ end
53
+ end
54
+
55
+ klasses.each do |klass|
56
+ key = if klass.is_a?(Class) && klass <= Exception
57
+ klass.name
58
+ elsif klass.is_a?(String)
59
+ klass
60
+ else
61
+ raise ArgumentError, "#{klass} is neither an Exception nor a String"
62
+ end
63
+
64
+ # put the new handler at the end because the list is read in reverse
65
+ rescue_handlers << [key, options[:with]]
66
+ end
67
+ end
68
+ end
69
+
70
+ # Tries to rescue the exception by looking up and calling a registered handler.
71
+ def rescue_with_handler(exception)
72
+ if handler = handler_for_rescue(exception)
73
+ handler.arity != 0 ? handler.call(exception) : handler.call
74
+ true # don't rely on the return value of the handler
75
+ end
76
+ end
77
+
78
+ def handler_for_rescue(exception)
79
+ # We go from right to left because pairs are pushed onto rescue_handlers
80
+ # as rescue_from declarations are found.
81
+ _, rescuer = Array(rescue_handlers).reverse.detect do |klass_name, handler|
82
+ # The purpose of allowing strings in rescue_from is to support the
83
+ # declaration of handler associations for exception classes whose
84
+ # definition is yet unknown.
85
+ #
86
+ # Since this loop needs the constants it would be inconsistent to
87
+ # assume they should exist at this point. An early raised exception
88
+ # could trigger some other handler and the array could include
89
+ # precisely a string whose corresponding constant has not yet been
90
+ # seen. This is why we are tolerant to unknown constants.
91
+ #
92
+ # Note that this tolerance only matters if the exception was given as
93
+ # a string, otherwise a NameError will be raised by the interpreter
94
+ # itself when rescue_from CONSTANT is executed.
95
+ klass = self.class.const_get(klass_name) rescue nil
96
+ klass ||= klass_name.constantize rescue nil
97
+ exception.is_a?(klass) if klass
98
+ end
99
+
100
+ case rescuer
101
+ when Symbol
102
+ method(rescuer)
103
+ when Proc
104
+ rescuer.bind(self)
105
+ end
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,197 @@
1
+ begin
2
+ require 'openssl'
3
+ rescue LoadError
4
+ end
5
+
6
+ begin
7
+ require 'securerandom'
8
+ rescue LoadError
9
+ end
10
+
11
+ module ActiveSupport
12
+ if defined?(::SecureRandom)
13
+ # Use Ruby 1.9's SecureRandom library whenever possible.
14
+ SecureRandom = ::SecureRandom # :nodoc:
15
+ else
16
+ # = Secure random number generator interface.
17
+ #
18
+ # This library is an interface for secure random number generator which is
19
+ # suitable for generating session key in HTTP cookies, etc.
20
+ #
21
+ # It supports following secure random number generators.
22
+ #
23
+ # * openssl
24
+ # * /dev/urandom
25
+ # * Win32
26
+ #
27
+ # *Note*: This module is based on the SecureRandom library from Ruby 1.9,
28
+ # revision 18786, August 23 2008. It's 100% interface-compatible with Ruby 1.9's
29
+ # SecureRandom library.
30
+ #
31
+ # == Example
32
+ #
33
+ # # random hexadecimal string.
34
+ # p SecureRandom.hex(10) #=> "52750b30ffbc7de3b362"
35
+ # p SecureRandom.hex(10) #=> "92b15d6c8dc4beb5f559"
36
+ # p SecureRandom.hex(11) #=> "6aca1b5c58e4863e6b81b8"
37
+ # p SecureRandom.hex(12) #=> "94b2fff3e7fd9b9c391a2306"
38
+ # p SecureRandom.hex(13) #=> "39b290146bea6ce975c37cfc23"
39
+ # ...
40
+ #
41
+ # # random base64 string.
42
+ # p SecureRandom.base64(10) #=> "EcmTPZwWRAozdA=="
43
+ # p SecureRandom.base64(10) #=> "9b0nsevdwNuM/w=="
44
+ # p SecureRandom.base64(10) #=> "KO1nIU+p9DKxGg=="
45
+ # p SecureRandom.base64(11) #=> "l7XEiFja+8EKEtY="
46
+ # p SecureRandom.base64(12) #=> "7kJSM/MzBJI+75j8"
47
+ # p SecureRandom.base64(13) #=> "vKLJ0tXBHqQOuIcSIg=="
48
+ # ...
49
+ #
50
+ # # random binary string.
51
+ # p SecureRandom.random_bytes(10) #=> "\016\t{\370g\310pbr\301"
52
+ # p SecureRandom.random_bytes(10) #=> "\323U\030TO\234\357\020\a\337"
53
+ # ...
54
+ module SecureRandom
55
+ # SecureRandom.random_bytes generates a random binary string.
56
+ #
57
+ # The argument n specifies the length of the result string.
58
+ #
59
+ # If n is not specified, 16 is assumed.
60
+ # It may be larger in future.
61
+ #
62
+ # If secure random number generator is not available,
63
+ # NotImplementedError is raised.
64
+ def self.random_bytes(n=nil)
65
+ n ||= 16
66
+
67
+ if defined? OpenSSL::Random
68
+ return OpenSSL::Random.random_bytes(n)
69
+ end
70
+
71
+ if !defined?(@has_urandom) || @has_urandom
72
+ flags = File::RDONLY
73
+ flags |= File::NONBLOCK if defined? File::NONBLOCK
74
+ flags |= File::NOCTTY if defined? File::NOCTTY
75
+ flags |= File::NOFOLLOW if defined? File::NOFOLLOW
76
+ begin
77
+ File.open("/dev/urandom", flags) {|f|
78
+ unless f.stat.chardev?
79
+ raise Errno::ENOENT
80
+ end
81
+ @has_urandom = true
82
+ ret = f.readpartial(n)
83
+ if ret.length != n
84
+ raise NotImplementedError, "Unexpected partial read from random device"
85
+ end
86
+ return ret
87
+ }
88
+ rescue Errno::ENOENT
89
+ @has_urandom = false
90
+ end
91
+ end
92
+
93
+ if !defined?(@has_win32)
94
+ begin
95
+ require 'Win32API'
96
+
97
+ crypt_acquire_context = Win32API.new("advapi32", "CryptAcquireContext", 'PPPII', 'L')
98
+ @crypt_gen_random = Win32API.new("advapi32", "CryptGenRandom", 'LIP', 'L')
99
+
100
+ hProvStr = " " * 4
101
+ prov_rsa_full = 1
102
+ crypt_verifycontext = 0xF0000000
103
+
104
+ if crypt_acquire_context.call(hProvStr, nil, nil, prov_rsa_full, crypt_verifycontext) == 0
105
+ raise SystemCallError, "CryptAcquireContext failed: #{lastWin32ErrorMessage}"
106
+ end
107
+ @hProv, = hProvStr.unpack('L')
108
+
109
+ @has_win32 = true
110
+ rescue LoadError
111
+ @has_win32 = false
112
+ end
113
+ end
114
+ if @has_win32
115
+ bytes = " " * n
116
+ if @crypt_gen_random.call(@hProv, bytes.size, bytes) == 0
117
+ raise SystemCallError, "CryptGenRandom failed: #{lastWin32ErrorMessage}"
118
+ end
119
+ return bytes
120
+ end
121
+
122
+ raise NotImplementedError, "No random device"
123
+ end
124
+
125
+ # SecureRandom.hex generates a random hex string.
126
+ #
127
+ # The argument n specifies the length of the random length.
128
+ # The length of the result string is twice of n.
129
+ #
130
+ # If n is not specified, 16 is assumed.
131
+ # It may be larger in future.
132
+ #
133
+ # If secure random number generator is not available,
134
+ # NotImplementedError is raised.
135
+ def self.hex(n=nil)
136
+ random_bytes(n).unpack("H*")[0]
137
+ end
138
+
139
+ # SecureRandom.base64 generates a random base64 string.
140
+ #
141
+ # The argument n specifies the length of the random length.
142
+ # The length of the result string is about 4/3 of n.
143
+ #
144
+ # If n is not specified, 16 is assumed.
145
+ # It may be larger in future.
146
+ #
147
+ # If secure random number generator is not available,
148
+ # NotImplementedError is raised.
149
+ def self.base64(n=nil)
150
+ [random_bytes(n)].pack("m*").delete("\n")
151
+ end
152
+
153
+ # SecureRandom.random_number generates a random number.
154
+ #
155
+ # If an positive integer is given as n,
156
+ # SecureRandom.random_number returns an integer:
157
+ # 0 <= SecureRandom.random_number(n) < n.
158
+ #
159
+ # If 0 is given or an argument is not given,
160
+ # SecureRandom.random_number returns an float:
161
+ # 0.0 <= SecureRandom.random_number() < 1.0.
162
+ def self.random_number(n=0)
163
+ if 0 < n
164
+ hex = n.to_s(16)
165
+ hex = '0' + hex if (hex.length & 1) == 1
166
+ bin = [hex].pack("H*")
167
+ mask = bin[0]
168
+ mask |= mask >> 1
169
+ mask |= mask >> 2
170
+ mask |= mask >> 4
171
+ begin
172
+ rnd = SecureRandom.random_bytes(bin.length)
173
+ rnd[0] = rnd[0] & mask
174
+ end until rnd < bin
175
+ rnd.unpack("H*")[0].hex
176
+ else
177
+ # assumption: Float::MANT_DIG <= 64
178
+ i64 = SecureRandom.random_bytes(8).unpack("Q")[0]
179
+ Math.ldexp(i64 >> (64-Float::MANT_DIG), -Float::MANT_DIG)
180
+ end
181
+ end
182
+
183
+ # Following code is based on David Garamond's GUID library for Ruby.
184
+ def self.lastWin32ErrorMessage # :nodoc:
185
+ get_last_error = Win32API.new("kernel32", "GetLastError", '', 'L')
186
+ format_message = Win32API.new("kernel32", "FormatMessageA", 'LPLLPLPPPPPPPP', 'L')
187
+ format_message_ignore_inserts = 0x00000200
188
+ format_message_from_system = 0x00001000
189
+
190
+ code = get_last_error.call
191
+ msg = "\0" * 1024
192
+ len = format_message.call(format_message_ignore_inserts + format_message_from_system, 0, code, 0, msg, 1024, nil, nil, nil, nil, nil, nil, nil, nil)
193
+ msg[0, len].tr("\r", '').chomp
194
+ end
195
+ end
196
+ end
197
+ end
@@ -1,7 +1,17 @@
1
1
  module ActiveSupport
2
+ # Wrapping a string in this class gives you a prettier way to test
3
+ # for equality. The value returned by <tt>Rails.env</tt> is wrapped
4
+ # in a StringInquirer object so instead of calling this:
5
+ #
6
+ # Rails.env == "production"
7
+ #
8
+ # you can call this:
9
+ #
10
+ # Rails.env.production?
11
+ #
2
12
  class StringInquirer < String
3
13
  def method_missing(method_name, *arguments)
4
- if method_name.to_s.ends_with?("?")
14
+ if method_name.to_s[-1,1] == "?"
5
15
  self == method_name.to_s[0..-2]
6
16
  else
7
17
  super