activesupport 3.0.0.beta4 → 3.0.pre

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

Potentially problematic release.


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

Files changed (333) hide show
  1. data/CHANGELOG +1 -100
  2. data/lib/active_support.rb +4 -38
  3. data/lib/active_support/autoload.rb +28 -0
  4. data/lib/active_support/backtrace_cleaner.rb +9 -31
  5. data/lib/active_support/benchmarkable.rb +0 -1
  6. data/lib/active_support/buffered_logger.rb +1 -0
  7. data/lib/active_support/cache.rb +81 -436
  8. data/lib/active_support/cache/compressed_mem_cache_store.rb +13 -6
  9. data/lib/active_support/cache/file_store.rb +41 -139
  10. data/lib/active_support/cache/mem_cache_store.rb +75 -120
  11. data/lib/active_support/cache/memory_store.rb +27 -127
  12. data/lib/active_support/cache/strategy/local_cache.rb +58 -111
  13. data/lib/active_support/cache/synchronized_memory_store.rb +38 -2
  14. data/lib/active_support/callbacks.rb +48 -87
  15. data/lib/active_support/configurable.rb +18 -19
  16. data/lib/active_support/core_ext/array.rb +0 -1
  17. data/lib/active_support/core_ext/array/access.rb +1 -1
  18. data/lib/active_support/core_ext/array/conversions.rb +54 -29
  19. data/lib/active_support/core_ext/array/extract_options.rb +1 -16
  20. data/lib/active_support/core_ext/array/random_access.rb +5 -19
  21. data/lib/active_support/core_ext/array/wrap.rb +9 -13
  22. data/lib/active_support/core_ext/benchmark.rb +12 -0
  23. data/lib/active_support/core_ext/boolean.rb +1 -0
  24. data/lib/active_support/core_ext/boolean/conversions.rb +11 -0
  25. data/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +0 -2
  26. data/lib/active_support/core_ext/class.rb +1 -1
  27. data/lib/active_support/core_ext/class/attribute_accessors.rb +27 -33
  28. data/lib/active_support/core_ext/class/delegating_attributes.rb +41 -35
  29. data/lib/active_support/core_ext/class/inheritable_attributes.rb +13 -22
  30. data/lib/active_support/core_ext/class/removal.rb +53 -0
  31. data/lib/active_support/core_ext/date.rb +7 -0
  32. data/lib/active_support/core_ext/date/calculations.rb +8 -30
  33. data/lib/active_support/core_ext/date/conversions.rb +2 -2
  34. data/lib/active_support/core_ext/date_time.rb +5 -0
  35. data/lib/active_support/core_ext/date_time/calculations.rb +1 -2
  36. data/lib/active_support/core_ext/date_time/conversions.rb +5 -23
  37. data/lib/active_support/core_ext/enumerable.rb +9 -5
  38. data/lib/active_support/core_ext/exception.rb +47 -0
  39. data/lib/active_support/core_ext/file.rb +0 -1
  40. data/lib/active_support/core_ext/file/atomic.rb +2 -3
  41. data/lib/active_support/core_ext/float/rounding.rb +2 -3
  42. data/lib/active_support/core_ext/hash/conversions.rb +145 -65
  43. data/lib/active_support/core_ext/hash/deep_merge.rb +7 -6
  44. data/lib/active_support/core_ext/hash/except.rb +0 -8
  45. data/lib/active_support/core_ext/hash/indifferent_access.rb +0 -5
  46. data/lib/active_support/core_ext/hash/keys.rb +11 -10
  47. data/lib/active_support/core_ext/hash/slice.rb +0 -6
  48. data/lib/active_support/core_ext/integer.rb +1 -1
  49. data/lib/active_support/core_ext/integer/even_odd.rb +16 -0
  50. data/lib/active_support/core_ext/kernel.rb +1 -1
  51. data/lib/active_support/core_ext/kernel/daemonizing.rb +7 -0
  52. data/lib/active_support/core_ext/kernel/debugger.rb +2 -3
  53. data/lib/active_support/core_ext/kernel/reporting.rb +1 -2
  54. data/lib/active_support/core_ext/load_error.rb +30 -17
  55. data/lib/active_support/core_ext/logger.rb +1 -1
  56. data/lib/active_support/core_ext/module.rb +3 -5
  57. data/lib/active_support/core_ext/module/aliasing.rb +1 -1
  58. data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +1 -1
  59. data/lib/active_support/core_ext/module/attr_internal.rb +2 -2
  60. data/lib/active_support/core_ext/module/attribute_accessors.rb +21 -25
  61. data/lib/active_support/core_ext/module/delegation.rb +10 -21
  62. data/lib/active_support/core_ext/module/inclusion.rb +30 -0
  63. data/lib/active_support/core_ext/module/introspection.rb +8 -8
  64. data/lib/active_support/core_ext/module/loading.rb +23 -0
  65. data/lib/active_support/core_ext/module/synchronization.rb +1 -2
  66. data/lib/active_support/core_ext/name_error.rb +1 -3
  67. data/lib/active_support/core_ext/nil.rb +1 -0
  68. data/lib/active_support/core_ext/nil/conversions.rb +5 -0
  69. data/lib/active_support/core_ext/object.rb +2 -6
  70. data/lib/active_support/core_ext/object/blank.rb +2 -20
  71. data/lib/active_support/core_ext/object/conversions.rb +16 -2
  72. data/lib/active_support/core_ext/object/duplicable.rb +1 -23
  73. data/lib/active_support/core_ext/object/extending.rb +77 -8
  74. data/lib/active_support/core_ext/object/instance_variables.rb +7 -0
  75. data/lib/active_support/core_ext/object/metaclass.rb +13 -0
  76. data/lib/active_support/core_ext/object/misc.rb +1 -0
  77. data/lib/active_support/core_ext/object/tap.rb +16 -0
  78. data/lib/active_support/core_ext/object/with_options.rb +0 -2
  79. data/lib/active_support/core_ext/proc.rb +4 -4
  80. data/lib/active_support/core_ext/regexp.rb +22 -0
  81. data/lib/active_support/core_ext/rexml.rb +1 -4
  82. data/lib/active_support/core_ext/string.rb +2 -3
  83. data/lib/active_support/core_ext/string/access.rb +2 -4
  84. data/lib/active_support/core_ext/string/bytesize.rb +5 -0
  85. data/lib/active_support/core_ext/string/conversions.rb +1 -36
  86. data/lib/active_support/core_ext/string/filters.rb +0 -29
  87. data/lib/active_support/core_ext/string/inflections.rb +12 -1
  88. data/lib/active_support/core_ext/string/interpolation.rb +92 -2
  89. data/lib/active_support/core_ext/string/iterators.rb +13 -0
  90. data/lib/active_support/core_ext/string/multibyte.rb +19 -16
  91. data/lib/active_support/core_ext/string/output_safety.rb +35 -101
  92. data/lib/active_support/core_ext/string/starts_ends_with.rb +14 -0
  93. data/lib/active_support/core_ext/string/xchar.rb +1 -1
  94. data/lib/active_support/core_ext/symbol.rb +1 -0
  95. data/lib/active_support/core_ext/symbol/to_proc.rb +14 -0
  96. data/lib/active_support/core_ext/time.rb +10 -0
  97. data/lib/active_support/core_ext/time/calculations.rb +7 -9
  98. data/lib/active_support/core_ext/time/conversions.rb +0 -1
  99. data/lib/active_support/core_ext/time/marshal_with_utc_flag.rb +22 -0
  100. data/lib/active_support/core_ext/uri.rb +4 -10
  101. data/lib/active_support/dependencies.rb +192 -179
  102. data/lib/active_support/deprecated_callbacks.rb +283 -0
  103. data/lib/active_support/deprecation/behaviors.rb +1 -1
  104. data/lib/active_support/deprecation/method_wrappers.rb +9 -10
  105. data/lib/active_support/deprecation/reporting.rb +1 -2
  106. data/lib/active_support/duration.rb +2 -6
  107. data/lib/active_support/hash_with_indifferent_access.rb +1 -9
  108. data/lib/active_support/inflections.rb +1 -1
  109. data/lib/active_support/inflector.rb +407 -4
  110. data/lib/active_support/json/backends/jsongem.rb +9 -12
  111. data/lib/active_support/json/decoding.rb +1 -16
  112. data/lib/active_support/json/encoding.rb +12 -42
  113. data/lib/active_support/locale/en.yml +1 -4
  114. data/lib/active_support/memoizable.rb +1 -1
  115. data/lib/active_support/message_encryptor.rb +0 -1
  116. data/lib/active_support/message_verifier.rb +5 -6
  117. data/lib/active_support/multibyte.rb +22 -7
  118. data/lib/active_support/multibyte/chars.rb +392 -164
  119. data/lib/active_support/multibyte/unicode_database.rb +71 -0
  120. data/lib/active_support/multibyte/utils.rb +7 -6
  121. data/lib/active_support/notifications.rb +113 -23
  122. data/lib/active_support/ordered_hash.rb +11 -35
  123. data/lib/active_support/ordered_options.rb +0 -6
  124. data/lib/active_support/rescuable.rb +4 -7
  125. data/lib/active_support/ruby/shim.rb +6 -4
  126. data/lib/active_support/test_case.rb +7 -2
  127. data/lib/active_support/testing/assertions.rb +0 -15
  128. data/lib/active_support/testing/declarative.rb +1 -1
  129. data/lib/active_support/testing/isolation.rb +19 -63
  130. data/lib/active_support/testing/performance.rb +337 -342
  131. data/lib/active_support/testing/setup_and_teardown.rb +29 -51
  132. data/lib/active_support/time.rb +3 -23
  133. data/lib/active_support/time_with_zone.rb +10 -5
  134. data/lib/active_support/values/time_zone.rb +84 -40
  135. data/lib/active_support/values/unicode_tables.dat +0 -0
  136. data/lib/active_support/vendor.rb +16 -0
  137. data/lib/active_support/vendor/builder-2.1.2/lib/blankslate.rb +113 -0
  138. data/lib/active_support/vendor/builder-2.1.2/lib/builder.rb +13 -0
  139. data/lib/active_support/vendor/builder-2.1.2/lib/builder/blankslate.rb +20 -0
  140. data/lib/active_support/vendor/builder-2.1.2/lib/builder/css.rb +250 -0
  141. data/lib/active_support/vendor/builder-2.1.2/lib/builder/xchar.rb +115 -0
  142. data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlbase.rb +139 -0
  143. data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlevents.rb +63 -0
  144. data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlmarkup.rb +328 -0
  145. data/lib/active_support/vendor/i18n-0.1.3/MIT-LICENSE +20 -0
  146. data/lib/active_support/vendor/i18n-0.1.3/README.textile +20 -0
  147. data/lib/active_support/vendor/i18n-0.1.3/Rakefile +5 -0
  148. data/lib/active_support/vendor/i18n-0.1.3/i18n.gemspec +27 -0
  149. data/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb +204 -0
  150. data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb +215 -0
  151. data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/exceptions.rb +53 -0
  152. data/lib/active_support/vendor/i18n-0.1.3/test/all.rb +5 -0
  153. data/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb +99 -0
  154. data/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb +124 -0
  155. data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.rb +1 -0
  156. data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.yml +3 -0
  157. data/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb +567 -0
  158. data/lib/active_support/vendor/memcache-client-1.7.5/lib/memcache.rb +1133 -0
  159. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo.rb +33 -0
  160. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/data_timezone.rb +47 -0
  161. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/data_timezone_info.rb +228 -0
  162. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Algiers.rb +55 -0
  163. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Cairo.rb +219 -0
  164. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Casablanca.rb +42 -0
  165. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Harare.rb +18 -0
  166. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Johannesburg.rb +25 -0
  167. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Monrovia.rb +22 -0
  168. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Nairobi.rb +23 -0
  169. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +166 -0
  170. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Argentina/San_Juan.rb +86 -0
  171. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Bogota.rb +23 -0
  172. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Caracas.rb +23 -0
  173. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Chicago.rb +283 -0
  174. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Chihuahua.rb +136 -0
  175. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Denver.rb +204 -0
  176. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Godthab.rb +161 -0
  177. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Guatemala.rb +27 -0
  178. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Halifax.rb +274 -0
  179. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Indiana/Indianapolis.rb +149 -0
  180. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Juneau.rb +194 -0
  181. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/La_Paz.rb +22 -0
  182. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Lima.rb +35 -0
  183. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Los_Angeles.rb +232 -0
  184. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Mazatlan.rb +139 -0
  185. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Mexico_City.rb +144 -0
  186. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Monterrey.rb +131 -0
  187. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/New_York.rb +282 -0
  188. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Phoenix.rb +30 -0
  189. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Regina.rb +74 -0
  190. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Santiago.rb +205 -0
  191. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Sao_Paulo.rb +171 -0
  192. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/St_Johns.rb +288 -0
  193. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Tijuana.rb +196 -0
  194. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Almaty.rb +67 -0
  195. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Baghdad.rb +73 -0
  196. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Baku.rb +161 -0
  197. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Bangkok.rb +20 -0
  198. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Chongqing.rb +33 -0
  199. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Colombo.rb +30 -0
  200. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Dhaka.rb +27 -0
  201. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Hong_Kong.rb +87 -0
  202. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Irkutsk.rb +165 -0
  203. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Jakarta.rb +30 -0
  204. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Jerusalem.rb +163 -0
  205. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kabul.rb +20 -0
  206. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kamchatka.rb +163 -0
  207. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Karachi.rb +32 -0
  208. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kathmandu.rb +20 -0
  209. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kolkata.rb +25 -0
  210. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Krasnoyarsk.rb +163 -0
  211. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kuala_Lumpur.rb +31 -0
  212. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kuwait.rb +18 -0
  213. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Magadan.rb +163 -0
  214. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Muscat.rb +18 -0
  215. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Novosibirsk.rb +164 -0
  216. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Rangoon.rb +24 -0
  217. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Riyadh.rb +18 -0
  218. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Seoul.rb +34 -0
  219. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Shanghai.rb +35 -0
  220. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Singapore.rb +33 -0
  221. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Taipei.rb +59 -0
  222. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tashkent.rb +47 -0
  223. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tbilisi.rb +78 -0
  224. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tehran.rb +121 -0
  225. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tokyo.rb +30 -0
  226. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Ulaanbaatar.rb +65 -0
  227. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Urumqi.rb +33 -0
  228. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Vladivostok.rb +164 -0
  229. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yakutsk.rb +163 -0
  230. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yekaterinburg.rb +165 -0
  231. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yerevan.rb +165 -0
  232. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/Azores.rb +270 -0
  233. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/Cape_Verde.rb +23 -0
  234. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/South_Georgia.rb +18 -0
  235. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Adelaide.rb +187 -0
  236. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Brisbane.rb +35 -0
  237. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Darwin.rb +29 -0
  238. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Hobart.rb +193 -0
  239. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Melbourne.rb +185 -0
  240. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Perth.rb +37 -0
  241. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Sydney.rb +185 -0
  242. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Etc/UTC.rb +16 -0
  243. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Amsterdam.rb +228 -0
  244. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Athens.rb +185 -0
  245. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Belgrade.rb +163 -0
  246. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Berlin.rb +188 -0
  247. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Bratislava.rb +13 -0
  248. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Brussels.rb +232 -0
  249. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Bucharest.rb +181 -0
  250. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Budapest.rb +197 -0
  251. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Copenhagen.rb +179 -0
  252. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Dublin.rb +276 -0
  253. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Helsinki.rb +163 -0
  254. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Istanbul.rb +218 -0
  255. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Kiev.rb +168 -0
  256. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Lisbon.rb +268 -0
  257. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Ljubljana.rb +13 -0
  258. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/London.rb +288 -0
  259. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Madrid.rb +211 -0
  260. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Minsk.rb +170 -0
  261. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Moscow.rb +181 -0
  262. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Paris.rb +232 -0
  263. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Prague.rb +187 -0
  264. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Riga.rb +176 -0
  265. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Rome.rb +215 -0
  266. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Sarajevo.rb +13 -0
  267. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Skopje.rb +13 -0
  268. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Sofia.rb +173 -0
  269. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Stockholm.rb +165 -0
  270. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Tallinn.rb +172 -0
  271. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Vienna.rb +183 -0
  272. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Vilnius.rb +170 -0
  273. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Warsaw.rb +212 -0
  274. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Zagreb.rb +13 -0
  275. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Auckland.rb +202 -0
  276. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Fiji.rb +23 -0
  277. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Guam.rb +22 -0
  278. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Honolulu.rb +28 -0
  279. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Majuro.rb +20 -0
  280. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Midway.rb +25 -0
  281. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Noumea.rb +25 -0
  282. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Pago_Pago.rb +26 -0
  283. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Port_Moresby.rb +20 -0
  284. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Tongatapu.rb +27 -0
  285. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/info_timezone.rb +52 -0
  286. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/linked_timezone.rb +51 -0
  287. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/linked_timezone_info.rb +44 -0
  288. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/offset_rationals.rb +98 -0
  289. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/ruby_core_support.rb +56 -0
  290. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/time_or_datetime.rb +292 -0
  291. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone.rb +508 -0
  292. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_definition.rb +56 -0
  293. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_info.rb +40 -0
  294. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_offset_info.rb +94 -0
  295. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_period.rb +198 -0
  296. data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_transition_info.rb +129 -0
  297. data/lib/active_support/version.rb +2 -3
  298. data/lib/active_support/whiny_nil.rb +7 -9
  299. data/lib/active_support/xml_mini.rb +1 -126
  300. data/lib/active_support/xml_mini/jdom.rb +0 -2
  301. data/lib/active_support/xml_mini/libxml.rb +86 -24
  302. data/lib/active_support/xml_mini/nokogiri.rb +24 -27
  303. data/lib/active_support/xml_mini/rexml.rb +1 -7
  304. metadata +191 -49
  305. data/lib/active_support/builder.rb +0 -6
  306. data/lib/active_support/core_ext/array/uniq_by.rb +0 -17
  307. data/lib/active_support/core_ext/class/attribute.rb +0 -67
  308. data/lib/active_support/core_ext/class/subclasses.rb +0 -55
  309. data/lib/active_support/core_ext/file/path.rb +0 -5
  310. data/lib/active_support/core_ext/integer/multiple.rb +0 -6
  311. data/lib/active_support/core_ext/kernel/singleton_class.rb +0 -13
  312. data/lib/active_support/core_ext/module/anonymous.rb +0 -24
  313. data/lib/active_support/core_ext/module/method_names.rb +0 -14
  314. data/lib/active_support/core_ext/module/reachable.rb +0 -10
  315. data/lib/active_support/core_ext/module/remove_method.rb +0 -6
  316. data/lib/active_support/core_ext/object/to_param.rb +0 -49
  317. data/lib/active_support/core_ext/object/to_query.rb +0 -27
  318. data/lib/active_support/core_ext/string/encoding.rb +0 -11
  319. data/lib/active_support/core_ext/string/exclude.rb +0 -6
  320. data/lib/active_support/core_ext/time/marshal.rb +0 -56
  321. data/lib/active_support/dependencies/autoload.rb +0 -50
  322. data/lib/active_support/i18n.rb +0 -8
  323. data/lib/active_support/inflector/inflections.rb +0 -211
  324. data/lib/active_support/inflector/methods.rb +0 -141
  325. data/lib/active_support/inflector/transliterate.rb +0 -97
  326. data/lib/active_support/json/backends/yajl.rb +0 -40
  327. data/lib/active_support/lazy_load_hooks.rb +0 -27
  328. data/lib/active_support/multibyte/unicode.rb +0 -393
  329. data/lib/active_support/notifications/fanout.rb +0 -93
  330. data/lib/active_support/notifications/instrumenter.rb +0 -56
  331. data/lib/active_support/railtie.rb +0 -100
  332. data/lib/active_support/xml_mini/libxmlsax.rb +0 -85
  333. data/lib/active_support/xml_mini/nokogirisax.rb +0 -83
@@ -1,5 +1,4 @@
1
1
  require 'active_support/core_ext/array/wrap'
2
- require 'active_support/core_ext/object/blank'
3
2
 
4
3
  module ActiveSupport
5
4
  module Testing
@@ -63,20 +62,6 @@ module ActiveSupport
63
62
  def assert_no_difference(expression, message = nil, &block)
64
63
  assert_difference expression, 0, message, &block
65
64
  end
66
-
67
- # Test if an expression is blank. Passes if object.blank? is true.
68
- #
69
- # assert_blank [] # => true
70
- def assert_blank(object)
71
- assert object.blank?, "#{object.inspect} is not blank"
72
- end
73
-
74
- # Test if an expression is not blank. Passes if object.present? is true.
75
- #
76
- # assert_present {:data => 'x' } # => true
77
- def assert_present(object)
78
- assert object.present?, "#{object.inspect} is blank"
79
- end
80
65
  end
81
66
  end
82
67
  end
@@ -7,7 +7,7 @@ module ActiveSupport
7
7
 
8
8
  unless method_defined?(:describe)
9
9
  def self.describe(text)
10
- class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
10
+ class_eval <<-RUBY_EVAL
11
11
  def self.name
12
12
  "#{text}"
13
13
  end
@@ -1,26 +1,10 @@
1
- require 'rbconfig'
2
1
  module ActiveSupport
3
2
  module Testing
4
- class RemoteError < StandardError
5
-
6
- attr_reader :message, :backtrace
7
-
8
- def initialize(exception)
9
- @message = "caught #{exception.class.name}: #{exception.message}"
10
- @backtrace = exception.backtrace
11
- end
12
- end
13
-
14
3
  class ProxyTestResult
15
4
  def initialize
16
5
  @calls = []
17
6
  end
18
7
 
19
- def add_error(e)
20
- e = Test::Unit::Error.new(e.test_name, RemoteError.new(e.exception))
21
- @calls << [:add_error, e]
22
- end
23
-
24
8
  def __replay__(result)
25
9
  @calls.each do |name, args|
26
10
  result.send(name, *args)
@@ -34,59 +18,31 @@ module ActiveSupport
34
18
 
35
19
  module Isolation
36
20
  def self.forking_env?
37
- !ENV["NO_FORK"] && ((Config::CONFIG['host_os'] !~ /mswin|mingw/) && (RUBY_PLATFORM !~ /java/))
21
+ !ENV["NO_FORK"] && RUBY_PLATFORM !~ /mswin|mingw|java/
38
22
  end
39
23
 
40
- def self.included(base)
41
- if defined?(::MiniTest) && base < ::MiniTest::Unit::TestCase
42
- base.send :include, MiniTest
43
- elsif defined?(Test::Unit)
44
- base.send :include, TestUnit
24
+ def run(result)
25
+ unless defined?(@@ran_class_setup)
26
+ self.class.setup if self.class.respond_to?(:setup)
27
+ @@ran_class_setup = true
45
28
  end
46
- end
47
-
48
- module TestUnit
49
- def run(result)
50
- unless defined?(@@ran_class_setup)
51
- self.class.setup if self.class.respond_to?(:setup)
52
- @@ran_class_setup = true
53
- end
54
29
 
55
- yield(Test::Unit::TestCase::STARTED, name)
30
+ yield(Test::Unit::TestCase::STARTED, name)
56
31
 
57
- @_result = result
32
+ @_result = result
58
33
 
59
- serialized = run_in_isolation do |proxy|
60
- begin
61
- super(proxy) { }
62
- rescue Exception => e
63
- proxy.add_error(Test::Unit::Error.new(name, e))
64
- end
34
+ serialized = run_in_isolation do |proxy|
35
+ begin
36
+ super(proxy) { }
37
+ rescue Exception => e
38
+ proxy.add_error(Test::Unit::Error.new(name, e))
65
39
  end
66
-
67
- retval, proxy = Marshal.load(serialized)
68
- proxy.__replay__(@_result)
69
-
70
- yield(Test::Unit::TestCase::FINISHED, name)
71
- retval
72
40
  end
73
- end
74
41
 
75
- module MiniTest
76
- def run(runner)
77
- unless defined?(@@ran_class_setup)
78
- self.class.setup if self.class.respond_to?(:setup)
79
- @@ran_class_setup = true
80
- end
81
-
82
- serialized = run_in_isolation do |isolated_runner|
83
- super(isolated_runner)
84
- end
42
+ proxy = Marshal.load(serialized)
43
+ proxy.__replay__(@_result)
85
44
 
86
- retval, proxy = Marshal.load(serialized)
87
- proxy.__replay__(runner)
88
- retval
89
- end
45
+ yield(Test::Unit::TestCase::FINISHED, name)
90
46
  end
91
47
 
92
48
  module Forking
@@ -96,8 +52,8 @@ module ActiveSupport
96
52
  pid = fork do
97
53
  read.close
98
54
  proxy = ProxyTestResult.new
99
- retval = yield proxy
100
- write.puts [Marshal.dump([retval, proxy])].pack("m")
55
+ yield proxy
56
+ write.puts [Marshal.dump(proxy)].pack("m")
101
57
  exit!
102
58
  end
103
59
 
@@ -116,9 +72,9 @@ module ActiveSupport
116
72
 
117
73
  if ENV["ISOLATION_TEST"]
118
74
  proxy = ProxyTestResult.new
119
- retval = yield proxy
75
+ yield proxy
120
76
  File.open(ENV["ISOLATION_OUTPUT"], "w") do |file|
121
- file.puts [Marshal.dump([retval, proxy])].pack("m")
77
+ file.puts [Marshal.dump(proxy)].pack("m")
122
78
  end
123
79
  exit!
124
80
  else
@@ -1,455 +1,450 @@
1
- begin
2
- require 'ruby-prof'
3
-
4
- require 'fileutils'
5
- require 'rails/version'
6
- require 'active_support/core_ext/class/delegating_attributes'
7
- require 'active_support/core_ext/string/inflections'
8
-
9
- module ActiveSupport
10
- module Testing
11
- module Performance
12
- DEFAULTS =
13
- if benchmark = ARGV.include?('--benchmark') # HAX for rake test
14
- { :benchmark => true,
15
- :runs => 4,
16
- :metrics => [:wall_time, :memory, :objects, :gc_runs, :gc_time],
17
- :output => 'tmp/performance' }
18
- else
19
- { :benchmark => false,
20
- :runs => 1,
21
- :min_percent => 0.01,
22
- :metrics => [:process_time, :memory, :objects],
23
- :formats => [:flat, :graph_html, :call_tree],
24
- :output => 'tmp/performance' }
25
- end.freeze
26
-
27
- def self.included(base)
28
- base.superclass_delegating_accessor :profile_options
29
- base.profile_options = DEFAULTS
30
- end
1
+ require 'ruby-prof'
2
+
3
+ require 'fileutils'
4
+ require 'rails/version'
5
+
6
+ module ActiveSupport
7
+ module Testing
8
+ module Performance
9
+ DEFAULTS =
10
+ if benchmark = ARGV.include?('--benchmark') # HAX for rake test
11
+ { :benchmark => true,
12
+ :runs => 4,
13
+ :metrics => [:wall_time, :memory, :objects, :gc_runs, :gc_time],
14
+ :output => 'tmp/performance' }
15
+ else
16
+ { :benchmark => false,
17
+ :runs => 1,
18
+ :min_percent => 0.01,
19
+ :metrics => [:process_time, :memory, :objects],
20
+ :formats => [:flat, :graph_html, :call_tree],
21
+ :output => 'tmp/performance' }
22
+ end.freeze
23
+
24
+ def self.included(base)
25
+ base.superclass_delegating_accessor :profile_options
26
+ base.profile_options = DEFAULTS
27
+ end
31
28
 
32
- def full_test_name
33
- "#{self.class.name}##{method_name}"
34
- end
29
+ def full_test_name
30
+ "#{self.class.name}##{method_name}"
31
+ end
35
32
 
36
- def run(result)
37
- return if method_name =~ /^default_test$/
33
+ def run(result)
34
+ return if method_name =~ /^default_test$/
38
35
 
39
- yield(self.class::STARTED, name)
40
- @_result = result
36
+ yield(self.class::STARTED, name)
37
+ @_result = result
41
38
 
42
- run_warmup
43
- if profile_options && metrics = profile_options[:metrics]
44
- metrics.each do |metric_name|
45
- if klass = Metrics[metric_name.to_sym]
46
- run_profile(klass.new)
47
- result.add_run
48
- end
39
+ run_warmup
40
+ if profile_options && metrics = profile_options[:metrics]
41
+ metrics.each do |metric_name|
42
+ if klass = Metrics[metric_name.to_sym]
43
+ run_profile(klass.new)
44
+ result.add_run
49
45
  end
50
46
  end
51
-
52
- yield(self.class::FINISHED, name)
53
47
  end
54
48
 
55
- def run_test(metric, mode)
56
- run_callbacks :setup
57
- setup
58
- metric.send(mode) { __send__ @method_name }
49
+ yield(self.class::FINISHED, name)
50
+ end
51
+
52
+ def run_test(metric, mode)
53
+ run_callbacks :setup
54
+ setup
55
+ metric.send(mode) { __send__ @method_name }
56
+ rescue ::Test::Unit::AssertionFailedError => e
57
+ add_failure(e.message, e.backtrace)
58
+ rescue StandardError, ScriptError
59
+ add_error($!)
60
+ ensure
61
+ begin
62
+ teardown
63
+ run_callbacks :teardown, :enumerator => :reverse_each
59
64
  rescue ::Test::Unit::AssertionFailedError => e
60
65
  add_failure(e.message, e.backtrace)
61
66
  rescue StandardError, ScriptError
62
67
  add_error($!)
63
- ensure
64
- begin
65
- teardown
66
- run_callbacks :teardown, :enumerator => :reverse_each
67
- rescue ::Test::Unit::AssertionFailedError => e
68
- add_failure(e.message, e.backtrace)
69
- rescue StandardError, ScriptError
70
- add_error($!)
71
- end
72
68
  end
69
+ end
73
70
 
74
- protected
75
- def run_warmup
76
- GC.start
71
+ protected
72
+ def run_warmup
73
+ GC.start
77
74
 
78
- time = Metrics::Time.new
79
- run_test(time, :benchmark)
80
- puts "%s (%s warmup)" % [full_test_name, time.format(time.total)]
75
+ time = Metrics::Time.new
76
+ run_test(time, :benchmark)
77
+ puts "%s (%s warmup)" % [full_test_name, time.format(time.total)]
81
78
 
82
- GC.start
83
- end
79
+ GC.start
80
+ end
84
81
 
85
- def run_profile(metric)
86
- klass = profile_options[:benchmark] ? Benchmarker : Profiler
87
- performer = klass.new(self, metric)
82
+ def run_profile(metric)
83
+ klass = profile_options[:benchmark] ? Benchmarker : Profiler
84
+ performer = klass.new(self, metric)
88
85
 
89
- performer.run
90
- puts performer.report
91
- performer.record
92
- end
86
+ performer.run
87
+ puts performer.report
88
+ performer.record
89
+ end
93
90
 
94
- class Performer
95
- delegate :run_test, :profile_options, :full_test_name, :to => :@harness
91
+ class Performer
92
+ delegate :run_test, :profile_options, :full_test_name, :to => :@harness
96
93
 
97
- def initialize(harness, metric)
98
- @harness, @metric = harness, metric
99
- end
94
+ def initialize(harness, metric)
95
+ @harness, @metric = harness, metric
96
+ end
97
+
98
+ def report
99
+ rate = @total / profile_options[:runs]
100
+ '%20s: %s' % [@metric.name, @metric.format(rate)]
101
+ end
100
102
 
101
- def report
102
- rate = @total / profile_options[:runs]
103
- '%20s: %s' % [@metric.name, @metric.format(rate)]
103
+ protected
104
+ def output_filename
105
+ "#{profile_options[:output]}/#{full_test_name}_#{@metric.name}"
104
106
  end
107
+ end
105
108
 
106
- protected
107
- def output_filename
108
- "#{profile_options[:output]}/#{full_test_name}_#{@metric.name}"
109
- end
109
+ class Benchmarker < Performer
110
+ def run
111
+ profile_options[:runs].to_i.times { run_test(@metric, :benchmark) }
112
+ @total = @metric.total
110
113
  end
111
114
 
112
- class Benchmarker < Performer
113
- def run
114
- profile_options[:runs].to_i.times { run_test(@metric, :benchmark) }
115
- @total = @metric.total
115
+ def record
116
+ avg = @metric.total / profile_options[:runs].to_i
117
+ now = Time.now.utc.xmlschema
118
+ with_output_file do |file|
119
+ file.puts "#{avg},#{now},#{environment}"
116
120
  end
121
+ end
117
122
 
118
- def record
119
- avg = @metric.total / profile_options[:runs].to_i
120
- now = Time.now.utc.xmlschema
121
- with_output_file do |file|
122
- file.puts "#{avg},#{now},#{environment}"
123
+ def environment
124
+ unless defined? @env
125
+ app = "#{$1}.#{$2}" if File.directory?('.git') && `git branch -v` =~ /^\* (\S+)\s+(\S+)/
126
+
127
+ rails = Rails::VERSION::STRING
128
+ if File.directory?('vendor/rails/.git')
129
+ Dir.chdir('vendor/rails') do
130
+ rails += ".#{$1}.#{$2}" if `git branch -v` =~ /^\* (\S+)\s+(\S+)/
131
+ end
123
132
  end
133
+
134
+ ruby = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
135
+ ruby += "-#{RUBY_VERSION}.#{RUBY_PATCHLEVEL}"
136
+
137
+ @env = [app, rails, ruby, RUBY_PLATFORM] * ','
124
138
  end
125
139
 
126
- def environment
127
- unless defined? @env
128
- app = "#{$1}.#{$2}" if File.directory?('.git') && `git branch -v` =~ /^\* (\S+)\s+(\S+)/
140
+ @env
141
+ end
129
142
 
130
- rails = Rails::VERSION::STRING
131
- if File.directory?('vendor/rails/.git')
132
- Dir.chdir('vendor/rails') do
133
- rails += ".#{$1}.#{$2}" if `git branch -v` =~ /^\* (\S+)\s+(\S+)/
134
- end
135
- end
143
+ protected
144
+ HEADER = 'measurement,created_at,app,rails,ruby,platform'
136
145
 
137
- ruby = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
138
- ruby += "-#{RUBY_VERSION}.#{RUBY_PATCHLEVEL}"
146
+ def with_output_file
147
+ fname = output_filename
139
148
 
140
- @env = [app, rails, ruby, RUBY_PLATFORM] * ','
149
+ if new = !File.exist?(fname)
150
+ FileUtils.mkdir_p(File.dirname(fname))
141
151
  end
142
152
 
143
- @env
153
+ File.open(fname, 'ab') do |file|
154
+ file.puts(HEADER) if new
155
+ yield file
156
+ end
144
157
  end
145
158
 
146
- protected
147
- HEADER = 'measurement,created_at,app,rails,ruby,platform'
148
-
149
- def with_output_file
150
- fname = output_filename
159
+ def output_filename
160
+ "#{super}.csv"
161
+ end
162
+ end
151
163
 
152
- if new = !File.exist?(fname)
153
- FileUtils.mkdir_p(File.dirname(fname))
154
- end
164
+ class Profiler < Performer
165
+ def initialize(*args)
166
+ super
167
+ @supported = @metric.measure_mode rescue false
168
+ end
155
169
 
156
- File.open(fname, 'ab') do |file|
157
- file.puts(HEADER) if new
158
- yield file
159
- end
160
- end
170
+ def run
171
+ return unless @supported
161
172
 
162
- def output_filename
163
- "#{super}.csv"
164
- end
173
+ RubyProf.measure_mode = @metric.measure_mode
174
+ RubyProf.start
175
+ RubyProf.pause
176
+ profile_options[:runs].to_i.times { run_test(@metric, :profile) }
177
+ @data = RubyProf.stop
178
+ @total = @data.threads.values.sum(0) { |method_infos| method_infos.sort.last.total_time }
165
179
  end
166
180
 
167
- class Profiler < Performer
168
- def initialize(*args)
181
+ def report
182
+ if @supported
169
183
  super
170
- @supported = @metric.measure_mode rescue false
184
+ else
185
+ '%20s: unsupported' % @metric.name
171
186
  end
187
+ end
172
188
 
173
- def run
174
- return unless @supported
189
+ def record
190
+ return unless @supported
175
191
 
176
- RubyProf.measure_mode = @metric.measure_mode
177
- RubyProf.start
178
- RubyProf.pause
179
- profile_options[:runs].to_i.times { run_test(@metric, :profile) }
180
- @data = RubyProf.stop
181
- @total = @data.threads.values.sum(0) { |method_infos| method_infos.sort.last.total_time }
182
- end
192
+ klasses = profile_options[:formats].map { |f| RubyProf.const_get("#{f.to_s.camelize}Printer") }.compact
183
193
 
184
- def report
185
- if @supported
186
- super
187
- else
188
- '%20s: unsupported' % @metric.name
194
+ klasses.each do |klass|
195
+ fname = output_filename(klass)
196
+ FileUtils.mkdir_p(File.dirname(fname))
197
+ File.open(fname, 'wb') do |file|
198
+ klass.new(@data).print(file, profile_options.slice(:min_percent))
189
199
  end
190
200
  end
201
+ end
191
202
 
192
- def record
193
- return unless @supported
194
-
195
- klasses = profile_options[:formats].map { |f| RubyProf.const_get("#{f.to_s.camelize}Printer") }.compact
196
-
197
- klasses.each do |klass|
198
- fname = output_filename(klass)
199
- FileUtils.mkdir_p(File.dirname(fname))
200
- File.open(fname, 'wb') do |file|
201
- klass.new(@data).print(file, profile_options.slice(:min_percent))
203
+ protected
204
+ def output_filename(printer_class)
205
+ suffix =
206
+ case printer_class.name.demodulize
207
+ when 'FlatPrinter'; 'flat.txt'
208
+ when 'GraphPrinter'; 'graph.txt'
209
+ when 'GraphHtmlPrinter'; 'graph.html'
210
+ when 'CallTreePrinter'; 'tree.txt'
211
+ else printer_class.name.sub(/Printer$/, '').underscore
202
212
  end
203
- end
213
+
214
+ "#{super()}_#{suffix}"
204
215
  end
216
+ end
205
217
 
206
- protected
207
- def output_filename(printer_class)
208
- suffix =
209
- case printer_class.name.demodulize
210
- when 'FlatPrinter'; 'flat.txt'
211
- when 'GraphPrinter'; 'graph.txt'
212
- when 'GraphHtmlPrinter'; 'graph.html'
213
- when 'CallTreePrinter'; 'tree.txt'
214
- else printer_class.name.sub(/Printer$/, '').underscore
215
- end
216
-
217
- "#{super()}_#{suffix}"
218
- end
218
+ module Metrics
219
+ def self.[](name)
220
+ const_get(name.to_s.camelize)
221
+ rescue NameError
222
+ nil
219
223
  end
220
224
 
221
- module Metrics
222
- def self.[](name)
223
- const_get(name.to_s.camelize)
224
- rescue NameError
225
- nil
225
+ class Base
226
+ attr_reader :total
227
+
228
+ def initialize
229
+ @total = 0
226
230
  end
227
231
 
228
- class Base
229
- attr_reader :total
232
+ def name
233
+ @name ||= self.class.name.demodulize.underscore
234
+ end
230
235
 
231
- def initialize
232
- @total = 0
233
- end
236
+ def measure_mode
237
+ self.class::Mode
238
+ end
234
239
 
235
- def name
236
- @name ||= self.class.name.demodulize.underscore
237
- end
240
+ def measure
241
+ 0
242
+ end
238
243
 
239
- def measure_mode
240
- self.class::Mode
244
+ def benchmark
245
+ with_gc_stats do
246
+ before = measure
247
+ yield
248
+ @total += (measure - before)
241
249
  end
250
+ end
242
251
 
243
- def measure
244
- 0
245
- end
252
+ def profile
253
+ RubyProf.resume
254
+ yield
255
+ ensure
256
+ RubyProf.pause
257
+ end
246
258
 
247
- def benchmark
248
- with_gc_stats do
249
- before = measure
259
+ protected
260
+ if GC.respond_to?(:enable_stats)
261
+ def with_gc_stats
262
+ GC.enable_stats
263
+ yield
264
+ ensure
265
+ GC.disable_stats
266
+ end
267
+ elsif defined?(GC::Profiler)
268
+ def with_gc_stats
269
+ GC.start
270
+ GC.disable
271
+ GC::Profiler.enable
272
+ yield
273
+ ensure
274
+ GC::Profiler.disable
275
+ GC.enable
276
+ end
277
+ else
278
+ def with_gc_stats
250
279
  yield
251
- @total += (measure - before)
252
280
  end
253
281
  end
282
+ end
254
283
 
255
- def profile
256
- RubyProf.resume
257
- yield
258
- ensure
259
- RubyProf.pause
260
- end
261
-
262
- protected
263
- if GC.respond_to?(:enable_stats)
264
- def with_gc_stats
265
- GC.enable_stats
266
- yield
267
- ensure
268
- GC.disable_stats
269
- end
270
- elsif defined?(GC::Profiler)
271
- def with_gc_stats
272
- GC.start
273
- GC.disable
274
- GC::Profiler.enable
275
- yield
276
- ensure
277
- GC::Profiler.disable
278
- GC.enable
279
- end
280
- else
281
- def with_gc_stats
282
- yield
283
- end
284
- end
284
+ class Time < Base
285
+ def measure
286
+ ::Time.now.to_f
285
287
  end
286
288
 
287
- class Time < Base
288
- def measure
289
- ::Time.now.to_f
290
- end
291
-
292
- def format(measurement)
293
- if measurement < 2
294
- '%d ms' % (measurement * 1000)
295
- else
296
- '%.2f sec' % measurement
297
- end
289
+ def format(measurement)
290
+ if measurement < 2
291
+ '%d ms' % (measurement * 1000)
292
+ else
293
+ '%.2f sec' % measurement
298
294
  end
299
295
  end
296
+ end
300
297
 
301
- class ProcessTime < Time
302
- Mode = RubyProf::PROCESS_TIME
298
+ class ProcessTime < Time
299
+ Mode = RubyProf::PROCESS_TIME
303
300
 
304
- def measure
305
- RubyProf.measure_process_time
306
- end
301
+ def measure
302
+ RubyProf.measure_process_time
307
303
  end
304
+ end
308
305
 
309
- class WallTime < Time
310
- Mode = RubyProf::WALL_TIME
306
+ class WallTime < Time
307
+ Mode = RubyProf::WALL_TIME
311
308
 
312
- def measure
313
- RubyProf.measure_wall_time
314
- end
309
+ def measure
310
+ RubyProf.measure_wall_time
315
311
  end
312
+ end
316
313
 
317
- class CpuTime < Time
318
- Mode = RubyProf::CPU_TIME if RubyProf.const_defined?(:CPU_TIME)
319
-
320
- def initialize(*args)
321
- # FIXME: yeah my CPU is 2.33 GHz
322
- RubyProf.cpu_frequency = 2.33e9
323
- super
324
- end
314
+ class CpuTime < Time
315
+ Mode = RubyProf::CPU_TIME if RubyProf.const_defined?(:CPU_TIME)
325
316
 
326
- def measure
327
- RubyProf.measure_cpu_time
328
- end
317
+ def initialize(*args)
318
+ # FIXME: yeah my CPU is 2.33 GHz
319
+ RubyProf.cpu_frequency = 2.33e9
320
+ super
329
321
  end
330
322
 
331
- class Memory < Base
332
- Mode = RubyProf::MEMORY if RubyProf.const_defined?(:MEMORY)
323
+ def measure
324
+ RubyProf.measure_cpu_time
325
+ end
326
+ end
333
327
 
334
- # ruby-prof wrapper
335
- if RubyProf.respond_to?(:measure_memory)
336
- def measure
337
- RubyProf.measure_memory / 1024.0
338
- end
328
+ class Memory < Base
329
+ Mode = RubyProf::MEMORY if RubyProf.const_defined?(:MEMORY)
339
330
 
340
- # Ruby 1.8 + railsbench patch
341
- elsif GC.respond_to?(:allocated_size)
342
- def measure
343
- GC.allocated_size / 1024.0
344
- end
331
+ # ruby-prof wrapper
332
+ if RubyProf.respond_to?(:measure_memory)
333
+ def measure
334
+ RubyProf.measure_memory / 1024.0
335
+ end
345
336
 
346
- # Ruby 1.8 + lloyd patch
347
- elsif GC.respond_to?(:heap_info)
348
- def measure
349
- GC.heap_info['heap_current_memory'] / 1024.0
350
- end
337
+ # Ruby 1.8 + railsbench patch
338
+ elsif GC.respond_to?(:allocated_size)
339
+ def measure
340
+ GC.allocated_size / 1024.0
341
+ end
351
342
 
352
- # Ruby 1.9 with total_malloc_allocated_size patch
353
- elsif GC.respond_to?(:malloc_total_allocated_size)
354
- def measure
355
- GC.total_malloc_allocated_size / 1024.0
356
- end
343
+ # Ruby 1.8 + lloyd patch
344
+ elsif GC.respond_to?(:heap_info)
345
+ def measure
346
+ GC.heap_info['heap_current_memory'] / 1024.0
347
+ end
357
348
 
358
- # Ruby 1.9 unpatched
359
- elsif GC.respond_to?(:malloc_allocated_size)
360
- def measure
361
- GC.malloc_allocated_size / 1024.0
362
- end
349
+ # Ruby 1.9 with total_malloc_allocated_size patch
350
+ elsif GC.respond_to?(:malloc_total_allocated_size)
351
+ def measure
352
+ GC.total_malloc_allocated_size / 1024.0
353
+ end
363
354
 
364
- # Ruby 1.9 + GC profiler patch
365
- elsif defined?(GC::Profiler)
366
- def measure
367
- GC.enable
368
- GC.start
369
- kb = GC::Profiler.data.last[:HEAP_USE_SIZE] / 1024.0
370
- GC.disable
371
- kb
372
- end
355
+ # Ruby 1.9 unpatched
356
+ elsif GC.respond_to?(:malloc_allocated_size)
357
+ def measure
358
+ GC.malloc_allocated_size / 1024.0
373
359
  end
374
360
 
375
- def format(measurement)
376
- '%.2f KB' % measurement
361
+ # Ruby 1.9 + GC profiler patch
362
+ elsif defined?(GC::Profiler)
363
+ def measure
364
+ GC.enable
365
+ GC.start
366
+ kb = GC::Profiler.data.last[:HEAP_USE_SIZE] / 1024.0
367
+ GC.disable
368
+ kb
377
369
  end
378
370
  end
379
371
 
380
- class Objects < Base
381
- Mode = RubyProf::ALLOCATIONS if RubyProf.const_defined?(:ALLOCATIONS)
372
+ def format(measurement)
373
+ '%.2f KB' % measurement
374
+ end
375
+ end
382
376
 
383
- if RubyProf.respond_to?(:measure_allocations)
384
- def measure
385
- RubyProf.measure_allocations
386
- end
377
+ class Objects < Base
378
+ Mode = RubyProf::ALLOCATIONS if RubyProf.const_defined?(:ALLOCATIONS)
387
379
 
388
- # Ruby 1.8 + railsbench patch
389
- elsif ObjectSpace.respond_to?(:allocated_objects)
390
- def measure
391
- ObjectSpace.allocated_objects
392
- end
380
+ if RubyProf.respond_to?(:measure_allocations)
381
+ def measure
382
+ RubyProf.measure_allocations
383
+ end
393
384
 
394
- # Ruby 1.9 + GC profiler patch
395
- elsif defined?(GC::Profiler)
396
- def measure
397
- GC.enable
398
- GC.start
399
- last = GC::Profiler.data.last
400
- count = last[:HEAP_LIVE_OBJECTS] + last[:HEAP_FREE_OBJECTS]
401
- GC.disable
402
- count
403
- end
385
+ # Ruby 1.8 + railsbench patch
386
+ elsif ObjectSpace.respond_to?(:allocated_objects)
387
+ def measure
388
+ ObjectSpace.allocated_objects
404
389
  end
405
390
 
406
- def format(measurement)
407
- measurement.to_i.to_s
391
+ # Ruby 1.9 + GC profiler patch
392
+ elsif defined?(GC::Profiler)
393
+ def measure
394
+ GC.enable
395
+ GC.start
396
+ last = GC::Profiler.data.last
397
+ count = last[:HEAP_LIVE_OBJECTS] + last[:HEAP_FREE_OBJECTS]
398
+ GC.disable
399
+ count
408
400
  end
409
401
  end
410
402
 
411
- class GcRuns < Base
412
- Mode = RubyProf::GC_RUNS if RubyProf.const_defined?(:GC_RUNS)
403
+ def format(measurement)
404
+ measurement.to_i.to_s
405
+ end
406
+ end
407
+
408
+ class GcRuns < Base
409
+ Mode = RubyProf::GC_RUNS if RubyProf.const_defined?(:GC_RUNS)
413
410
 
414
- if RubyProf.respond_to?(:measure_gc_runs)
415
- def measure
416
- RubyProf.measure_gc_runs
417
- end
418
- elsif GC.respond_to?(:collections)
419
- def measure
420
- GC.collections
421
- end
422
- elsif GC.respond_to?(:heap_info)
423
- def measure
424
- GC.heap_info['num_gc_passes']
425
- end
411
+ if RubyProf.respond_to?(:measure_gc_runs)
412
+ def measure
413
+ RubyProf.measure_gc_runs
426
414
  end
427
-
428
- def format(measurement)
429
- measurement.to_i.to_s
415
+ elsif GC.respond_to?(:collections)
416
+ def measure
417
+ GC.collections
418
+ end
419
+ elsif GC.respond_to?(:heap_info)
420
+ def measure
421
+ GC.heap_info['num_gc_passes']
430
422
  end
431
423
  end
432
424
 
433
- class GcTime < Base
434
- Mode = RubyProf::GC_TIME if RubyProf.const_defined?(:GC_TIME)
425
+ def format(measurement)
426
+ measurement.to_i.to_s
427
+ end
428
+ end
435
429
 
436
- if RubyProf.respond_to?(:measure_gc_time)
437
- def measure
438
- RubyProf.measure_gc_time
439
- end
440
- elsif GC.respond_to?(:time)
441
- def measure
442
- GC.time
443
- end
444
- end
430
+ class GcTime < Base
431
+ Mode = RubyProf::GC_TIME if RubyProf.const_defined?(:GC_TIME)
445
432
 
446
- def format(measurement)
447
- '%d ms' % (measurement / 1000)
433
+ if RubyProf.respond_to?(:measure_gc_time)
434
+ def measure
435
+ RubyProf.measure_gc_time
436
+ end
437
+ elsif GC.respond_to?(:time)
438
+ def measure
439
+ GC.time
448
440
  end
449
441
  end
442
+
443
+ def format(measurement)
444
+ '%d ms' % (measurement / 1000)
445
+ end
450
446
  end
451
447
  end
452
448
  end
453
449
  end
454
- rescue LoadError
455
- end
450
+ end