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
@@ -1,13 +1,24 @@
1
1
  require 'test/unit/testcase'
2
- require 'active_support/testing/setup_and_teardown'
3
2
  require 'active_support/testing/default'
3
+ require 'active_support/testing/core_ext/test'
4
4
 
5
- # TODO: move to core_ext
6
- class Test::Unit::TestCase #:nodoc:
7
- include ActiveSupport::Testing::SetupAndTeardown
8
- end
9
5
 
10
6
  module ActiveSupport
11
7
  class TestCase < Test::Unit::TestCase
8
+ # test "verify something" do
9
+ # ...
10
+ # end
11
+ def self.test(name, &block)
12
+ test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
13
+ defined = instance_method(test_name) rescue false
14
+ raise "#{test_name} is already defined in #{self}" if defined
15
+ if block_given?
16
+ define_method(test_name, &block)
17
+ else
18
+ define_method(test_name) do
19
+ flunk "No implementation provided for #{name}"
20
+ end
21
+ end
22
+ end
12
23
  end
13
24
  end
@@ -0,0 +1,6 @@
1
+ require 'active_support/testing/core_ext/test/unit/assertions'
2
+ require 'active_support/testing/setup_and_teardown'
3
+
4
+ class Test::Unit::TestCase #:nodoc:
5
+ include ActiveSupport::Testing::SetupAndTeardown
6
+ end
@@ -1,9 +1,10 @@
1
- module Test
2
- module Unit
1
+ require 'test/unit/assertions'
2
+ module Test
3
+ module Unit
3
4
  #--
4
5
  # FIXME: no Proc#binding in Ruby 2, must change this API
5
6
  #++
6
- module Assertions
7
+ module Assertions
7
8
  # Test numeric difference between the return value of an expression as a result of what is evaluated
8
9
  # in the yielded block.
9
10
  #
@@ -35,12 +36,19 @@ module Test
35
36
  # post :delete, :id => ...
36
37
  # end
37
38
  def assert_difference(expressions, difference = 1, message = nil, &block)
38
- expression_evaluations = Array(expressions).collect{ |expression| lambda { eval(expression, block.send!(:binding)) } }
39
+ expression_evaluations = Array(expressions).map do |expression|
40
+ [expression, lambda do
41
+ eval(expression, block.__send__(:binding))
42
+ end]
43
+ end
39
44
 
40
- original_values = expression_evaluations.inject([]) { |memo, expression| memo << expression.call }
45
+ original_values = expression_evaluations.inject([]) { |memo, expression| memo << expression[1].call }
41
46
  yield
42
47
  expression_evaluations.each_with_index do |expression, i|
43
- assert_equal original_values[i] + difference, expression.call, message
48
+ full_message = ""
49
+ full_message << "#{message}.\n" if message
50
+ full_message << "<#{expression[0]}> was the expression that failed"
51
+ assert_equal original_values[i] + difference, expression[1].call, full_message
44
52
  end
45
53
  end
46
54
 
@@ -0,0 +1,452 @@
1
+ require 'rubygems'
2
+ gem 'ruby-prof', '>= 0.6.1'
3
+ require 'ruby-prof'
4
+
5
+ require 'fileutils'
6
+ require 'rails/version'
7
+
8
+ module ActiveSupport
9
+ module Testing
10
+ module Performance
11
+ DEFAULTS =
12
+ if benchmark = ARGV.include?('--benchmark') # HAX for rake test
13
+ { :benchmark => true,
14
+ :runs => 4,
15
+ :metrics => [:process_time, :memory, :objects, :gc_runs, :gc_time],
16
+ :output => 'tmp/performance' }
17
+ else
18
+ { :benchmark => false,
19
+ :runs => 1,
20
+ :min_percent => 0.01,
21
+ :metrics => [:process_time, :memory, :objects],
22
+ :formats => [:flat, :graph_html, :call_tree],
23
+ :output => 'tmp/performance' }
24
+ end.freeze
25
+
26
+ def self.included(base)
27
+ base.superclass_delegating_accessor :profile_options
28
+ base.profile_options = DEFAULTS
29
+ end
30
+
31
+ def full_test_name
32
+ "#{self.class.name}##{method_name}"
33
+ end
34
+
35
+ def run(result)
36
+ return if method_name =~ /^default_test$/
37
+
38
+ yield(self.class::STARTED, name)
39
+ @_result = result
40
+
41
+ run_warmup
42
+ if profile_options && metrics = profile_options[:metrics]
43
+ metrics.each do |metric_name|
44
+ if klass = Metrics[metric_name.to_sym]
45
+ run_profile(klass.new)
46
+ result.add_run
47
+ end
48
+ end
49
+ end
50
+
51
+ yield(self.class::FINISHED, name)
52
+ end
53
+
54
+ def run_test(metric, mode)
55
+ run_callbacks :setup
56
+ setup
57
+ metric.send(mode) { __send__ @method_name }
58
+ rescue ::Test::Unit::AssertionFailedError => e
59
+ add_failure(e.message, e.backtrace)
60
+ rescue StandardError, ScriptError
61
+ add_error($!)
62
+ ensure
63
+ begin
64
+ teardown
65
+ run_callbacks :teardown, :enumerator => :reverse_each
66
+ rescue ::Test::Unit::AssertionFailedError => e
67
+ add_failure(e.message, e.backtrace)
68
+ rescue StandardError, ScriptError
69
+ add_error($!)
70
+ end
71
+ end
72
+
73
+ protected
74
+ def run_warmup
75
+ GC.start
76
+
77
+ time = Metrics::Time.new
78
+ run_test(time, :benchmark)
79
+ puts "%s (%s warmup)" % [full_test_name, time.format(time.total)]
80
+
81
+ GC.start
82
+ end
83
+
84
+ def run_profile(metric)
85
+ klass = profile_options[:benchmark] ? Benchmarker : Profiler
86
+ performer = klass.new(self, metric)
87
+
88
+ performer.run
89
+ puts performer.report
90
+ performer.record
91
+ end
92
+
93
+ class Performer
94
+ delegate :run_test, :profile_options, :full_test_name, :to => :@harness
95
+
96
+ def initialize(harness, metric)
97
+ @harness, @metric = harness, metric
98
+ end
99
+
100
+ def report
101
+ rate = @total / profile_options[:runs]
102
+ '%20s: %s' % [@metric.name, @metric.format(rate)]
103
+ end
104
+
105
+ protected
106
+ def output_filename
107
+ "#{profile_options[:output]}/#{full_test_name}_#{@metric.name}"
108
+ end
109
+ end
110
+
111
+ class Benchmarker < Performer
112
+ def run
113
+ profile_options[:runs].to_i.times { run_test(@metric, :benchmark) }
114
+ @total = @metric.total
115
+ end
116
+
117
+ def record
118
+ avg = @metric.total / profile_options[:runs].to_i
119
+ now = Time.now.utc.xmlschema
120
+ with_output_file do |file|
121
+ file.puts "#{avg},#{now},#{environment}"
122
+ end
123
+ end
124
+
125
+ def environment
126
+ unless defined? @env
127
+ app = "#{$1}.#{$2}" if File.directory?('.git') && `git branch -v` =~ /^\* (\S+)\s+(\S+)/
128
+
129
+ rails = Rails::VERSION::STRING
130
+ if File.directory?('vendor/rails/.git')
131
+ Dir.chdir('vendor/rails') do
132
+ rails += ".#{$1}.#{$2}" if `git branch -v` =~ /^\* (\S+)\s+(\S+)/
133
+ end
134
+ end
135
+
136
+ ruby = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
137
+ ruby += "-#{RUBY_VERSION}.#{RUBY_PATCHLEVEL}"
138
+
139
+ @env = [app, rails, ruby, RUBY_PLATFORM] * ','
140
+ end
141
+
142
+ @env
143
+ end
144
+
145
+ protected
146
+ HEADER = 'measurement,created_at,app,rails,ruby,platform'
147
+
148
+ def with_output_file
149
+ fname = output_filename
150
+
151
+ if new = !File.exist?(fname)
152
+ FileUtils.mkdir_p(File.dirname(fname))
153
+ end
154
+
155
+ File.open(fname, 'ab') do |file|
156
+ file.puts(HEADER) if new
157
+ yield file
158
+ end
159
+ end
160
+
161
+ def output_filename
162
+ "#{super}.csv"
163
+ end
164
+ end
165
+
166
+ class Profiler < Performer
167
+ def initialize(*args)
168
+ super
169
+ @supported = @metric.measure_mode rescue false
170
+ end
171
+
172
+ def run
173
+ return unless @supported
174
+
175
+ RubyProf.measure_mode = @metric.measure_mode
176
+ RubyProf.start
177
+ RubyProf.pause
178
+ profile_options[:runs].to_i.times { run_test(@metric, :profile) }
179
+ @data = RubyProf.stop
180
+ @total = @data.threads.values.sum(0) { |method_infos| method_infos.sort.last.total_time }
181
+ end
182
+
183
+ def report
184
+ if @supported
185
+ super
186
+ else
187
+ '%20s: unsupported' % @metric.name
188
+ end
189
+ end
190
+
191
+ def record
192
+ return unless @supported
193
+
194
+ klasses = profile_options[:formats].map { |f| RubyProf.const_get("#{f.to_s.camelize}Printer") }.compact
195
+
196
+ klasses.each do |klass|
197
+ fname = output_filename(klass)
198
+ FileUtils.mkdir_p(File.dirname(fname))
199
+ File.open(fname, 'wb') do |file|
200
+ klass.new(@data).print(file, profile_options.slice(:min_percent))
201
+ end
202
+ end
203
+ end
204
+
205
+ protected
206
+ def output_filename(printer_class)
207
+ suffix =
208
+ case printer_class.name.demodulize
209
+ when 'FlatPrinter'; 'flat.txt'
210
+ when 'GraphPrinter'; 'graph.txt'
211
+ when 'GraphHtmlPrinter'; 'graph.html'
212
+ when 'CallTreePrinter'; 'tree.txt'
213
+ else printer_class.name.sub(/Printer$/, '').underscore
214
+ end
215
+
216
+ "#{super()}_#{suffix}"
217
+ end
218
+ end
219
+
220
+ module Metrics
221
+ def self.[](name)
222
+ const_get(name.to_s.camelize)
223
+ rescue NameError
224
+ nil
225
+ end
226
+
227
+ class Base
228
+ attr_reader :total
229
+
230
+ def initialize
231
+ @total = 0
232
+ end
233
+
234
+ def name
235
+ @name ||= self.class.name.demodulize.underscore
236
+ end
237
+
238
+ def measure_mode
239
+ self.class::Mode
240
+ end
241
+
242
+ def measure
243
+ 0
244
+ end
245
+
246
+ def benchmark
247
+ with_gc_stats do
248
+ before = measure
249
+ yield
250
+ @total += (measure - before)
251
+ end
252
+ end
253
+
254
+ def profile
255
+ RubyProf.resume
256
+ yield
257
+ ensure
258
+ RubyProf.pause
259
+ end
260
+
261
+ protected
262
+ if GC.respond_to?(:enable_stats)
263
+ def with_gc_stats
264
+ GC.enable_stats
265
+ yield
266
+ ensure
267
+ GC.disable_stats
268
+ end
269
+ elsif defined?(GC::Profiler)
270
+ def with_gc_stats
271
+ GC.start
272
+ GC.disable
273
+ GC::Profiler.enable
274
+ yield
275
+ ensure
276
+ GC::Profiler.disable
277
+ GC.enable
278
+ end
279
+ else
280
+ def with_gc_stats
281
+ yield
282
+ end
283
+ end
284
+ end
285
+
286
+ class Time < Base
287
+ def measure
288
+ ::Time.now.to_f
289
+ end
290
+
291
+ def format(measurement)
292
+ if measurement < 2
293
+ '%d ms' % (measurement * 1000)
294
+ else
295
+ '%.2f sec' % measurement
296
+ end
297
+ end
298
+ end
299
+
300
+ class ProcessTime < Time
301
+ Mode = RubyProf::PROCESS_TIME
302
+
303
+ def measure
304
+ RubyProf.measure_process_time
305
+ end
306
+ end
307
+
308
+ class WallTime < Time
309
+ Mode = RubyProf::WALL_TIME
310
+
311
+ def measure
312
+ RubyProf.measure_wall_time
313
+ end
314
+ end
315
+
316
+ class CpuTime < Time
317
+ Mode = RubyProf::CPU_TIME if RubyProf.const_defined?(:CPU_TIME)
318
+
319
+ def initialize(*args)
320
+ # FIXME: yeah my CPU is 2.33 GHz
321
+ RubyProf.cpu_frequency = 2.33e9
322
+ super
323
+ end
324
+
325
+ def measure
326
+ RubyProf.measure_cpu_time
327
+ end
328
+ end
329
+
330
+ class Memory < Base
331
+ Mode = RubyProf::MEMORY if RubyProf.const_defined?(:MEMORY)
332
+
333
+ # ruby-prof wrapper
334
+ if RubyProf.respond_to?(:measure_memory)
335
+ def measure
336
+ RubyProf.measure_memory / 1024.0
337
+ end
338
+
339
+ # Ruby 1.8 + railsbench patch
340
+ elsif GC.respond_to?(:allocated_size)
341
+ def measure
342
+ GC.allocated_size / 1024.0
343
+ end
344
+
345
+ # Ruby 1.8 + lloyd patch
346
+ elsif GC.respond_to?(:heap_info)
347
+ def measure
348
+ GC.heap_info['heap_current_memory'] / 1024.0
349
+ end
350
+
351
+ # Ruby 1.9 with total_malloc_allocated_size patch
352
+ elsif GC.respond_to?(:malloc_total_allocated_size)
353
+ def measure
354
+ GC.total_malloc_allocated_size / 1024.0
355
+ end
356
+
357
+ # Ruby 1.9 unpatched
358
+ elsif GC.respond_to?(:malloc_allocated_size)
359
+ def measure
360
+ GC.malloc_allocated_size / 1024.0
361
+ end
362
+
363
+ # Ruby 1.9 + GC profiler patch
364
+ elsif defined?(GC::Profiler)
365
+ def measure
366
+ GC.enable
367
+ GC.start
368
+ kb = GC::Profiler.data.last[:HEAP_USE_SIZE] / 1024.0
369
+ GC.disable
370
+ kb
371
+ end
372
+ end
373
+
374
+ def format(measurement)
375
+ '%.2f KB' % measurement
376
+ end
377
+ end
378
+
379
+ class Objects < Base
380
+ Mode = RubyProf::ALLOCATIONS if RubyProf.const_defined?(:ALLOCATIONS)
381
+
382
+ if RubyProf.respond_to?(:measure_allocations)
383
+ def measure
384
+ RubyProf.measure_allocations
385
+ end
386
+
387
+ # Ruby 1.8 + railsbench patch
388
+ elsif ObjectSpace.respond_to?(:allocated_objects)
389
+ def measure
390
+ ObjectSpace.allocated_objects
391
+ end
392
+
393
+ # Ruby 1.9 + GC profiler patch
394
+ elsif defined?(GC::Profiler)
395
+ def measure
396
+ GC.enable
397
+ GC.start
398
+ last = GC::Profiler.data.last
399
+ count = last[:HEAP_LIVE_OBJECTS] + last[:HEAP_FREE_OBJECTS]
400
+ GC.disable
401
+ count
402
+ end
403
+ end
404
+
405
+ def format(measurement)
406
+ measurement.to_i.to_s
407
+ end
408
+ end
409
+
410
+ class GcRuns < Base
411
+ Mode = RubyProf::GC_RUNS if RubyProf.const_defined?(:GC_RUNS)
412
+
413
+ if RubyProf.respond_to?(:measure_gc_runs)
414
+ def measure
415
+ RubyProf.measure_gc_runs
416
+ end
417
+ elsif GC.respond_to?(:collections)
418
+ def measure
419
+ GC.collections
420
+ end
421
+ elsif GC.respond_to?(:heap_info)
422
+ def measure
423
+ GC.heap_info['num_gc_passes']
424
+ end
425
+ end
426
+
427
+ def format(measurement)
428
+ measurement.to_i.to_s
429
+ end
430
+ end
431
+
432
+ class GcTime < Base
433
+ Mode = RubyProf::GC_TIME if RubyProf.const_defined?(:GC_TIME)
434
+
435
+ if RubyProf.respond_to?(:measure_gc_time)
436
+ def measure
437
+ RubyProf.measure_gc_time
438
+ end
439
+ elsif GC.respond_to?(:time)
440
+ def measure
441
+ GC.time
442
+ end
443
+ end
444
+
445
+ def format(measurement)
446
+ '%d ms' % (measurement / 1000)
447
+ end
448
+ end
449
+ end
450
+ end
451
+ end
452
+ end