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.
- data/CHANGELOG +1 -100
- data/lib/active_support.rb +4 -38
- data/lib/active_support/autoload.rb +28 -0
- data/lib/active_support/backtrace_cleaner.rb +9 -31
- data/lib/active_support/benchmarkable.rb +0 -1
- data/lib/active_support/buffered_logger.rb +1 -0
- data/lib/active_support/cache.rb +81 -436
- data/lib/active_support/cache/compressed_mem_cache_store.rb +13 -6
- data/lib/active_support/cache/file_store.rb +41 -139
- data/lib/active_support/cache/mem_cache_store.rb +75 -120
- data/lib/active_support/cache/memory_store.rb +27 -127
- data/lib/active_support/cache/strategy/local_cache.rb +58 -111
- data/lib/active_support/cache/synchronized_memory_store.rb +38 -2
- data/lib/active_support/callbacks.rb +48 -87
- data/lib/active_support/configurable.rb +18 -19
- data/lib/active_support/core_ext/array.rb +0 -1
- data/lib/active_support/core_ext/array/access.rb +1 -1
- data/lib/active_support/core_ext/array/conversions.rb +54 -29
- data/lib/active_support/core_ext/array/extract_options.rb +1 -16
- data/lib/active_support/core_ext/array/random_access.rb +5 -19
- data/lib/active_support/core_ext/array/wrap.rb +9 -13
- data/lib/active_support/core_ext/benchmark.rb +12 -0
- data/lib/active_support/core_ext/boolean.rb +1 -0
- data/lib/active_support/core_ext/boolean/conversions.rb +11 -0
- data/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +0 -2
- data/lib/active_support/core_ext/class.rb +1 -1
- data/lib/active_support/core_ext/class/attribute_accessors.rb +27 -33
- data/lib/active_support/core_ext/class/delegating_attributes.rb +41 -35
- data/lib/active_support/core_ext/class/inheritable_attributes.rb +13 -22
- data/lib/active_support/core_ext/class/removal.rb +53 -0
- data/lib/active_support/core_ext/date.rb +7 -0
- data/lib/active_support/core_ext/date/calculations.rb +8 -30
- data/lib/active_support/core_ext/date/conversions.rb +2 -2
- data/lib/active_support/core_ext/date_time.rb +5 -0
- data/lib/active_support/core_ext/date_time/calculations.rb +1 -2
- data/lib/active_support/core_ext/date_time/conversions.rb +5 -23
- data/lib/active_support/core_ext/enumerable.rb +9 -5
- data/lib/active_support/core_ext/exception.rb +47 -0
- data/lib/active_support/core_ext/file.rb +0 -1
- data/lib/active_support/core_ext/file/atomic.rb +2 -3
- data/lib/active_support/core_ext/float/rounding.rb +2 -3
- data/lib/active_support/core_ext/hash/conversions.rb +145 -65
- data/lib/active_support/core_ext/hash/deep_merge.rb +7 -6
- data/lib/active_support/core_ext/hash/except.rb +0 -8
- data/lib/active_support/core_ext/hash/indifferent_access.rb +0 -5
- data/lib/active_support/core_ext/hash/keys.rb +11 -10
- data/lib/active_support/core_ext/hash/slice.rb +0 -6
- data/lib/active_support/core_ext/integer.rb +1 -1
- data/lib/active_support/core_ext/integer/even_odd.rb +16 -0
- data/lib/active_support/core_ext/kernel.rb +1 -1
- data/lib/active_support/core_ext/kernel/daemonizing.rb +7 -0
- data/lib/active_support/core_ext/kernel/debugger.rb +2 -3
- data/lib/active_support/core_ext/kernel/reporting.rb +1 -2
- data/lib/active_support/core_ext/load_error.rb +30 -17
- data/lib/active_support/core_ext/logger.rb +1 -1
- data/lib/active_support/core_ext/module.rb +3 -5
- data/lib/active_support/core_ext/module/aliasing.rb +1 -1
- data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +1 -1
- data/lib/active_support/core_ext/module/attr_internal.rb +2 -2
- data/lib/active_support/core_ext/module/attribute_accessors.rb +21 -25
- data/lib/active_support/core_ext/module/delegation.rb +10 -21
- data/lib/active_support/core_ext/module/inclusion.rb +30 -0
- data/lib/active_support/core_ext/module/introspection.rb +8 -8
- data/lib/active_support/core_ext/module/loading.rb +23 -0
- data/lib/active_support/core_ext/module/synchronization.rb +1 -2
- data/lib/active_support/core_ext/name_error.rb +1 -3
- data/lib/active_support/core_ext/nil.rb +1 -0
- data/lib/active_support/core_ext/nil/conversions.rb +5 -0
- data/lib/active_support/core_ext/object.rb +2 -6
- data/lib/active_support/core_ext/object/blank.rb +2 -20
- data/lib/active_support/core_ext/object/conversions.rb +16 -2
- data/lib/active_support/core_ext/object/duplicable.rb +1 -23
- data/lib/active_support/core_ext/object/extending.rb +77 -8
- data/lib/active_support/core_ext/object/instance_variables.rb +7 -0
- data/lib/active_support/core_ext/object/metaclass.rb +13 -0
- data/lib/active_support/core_ext/object/misc.rb +1 -0
- data/lib/active_support/core_ext/object/tap.rb +16 -0
- data/lib/active_support/core_ext/object/with_options.rb +0 -2
- data/lib/active_support/core_ext/proc.rb +4 -4
- data/lib/active_support/core_ext/regexp.rb +22 -0
- data/lib/active_support/core_ext/rexml.rb +1 -4
- data/lib/active_support/core_ext/string.rb +2 -3
- data/lib/active_support/core_ext/string/access.rb +2 -4
- data/lib/active_support/core_ext/string/bytesize.rb +5 -0
- data/lib/active_support/core_ext/string/conversions.rb +1 -36
- data/lib/active_support/core_ext/string/filters.rb +0 -29
- data/lib/active_support/core_ext/string/inflections.rb +12 -1
- data/lib/active_support/core_ext/string/interpolation.rb +92 -2
- data/lib/active_support/core_ext/string/iterators.rb +13 -0
- data/lib/active_support/core_ext/string/multibyte.rb +19 -16
- data/lib/active_support/core_ext/string/output_safety.rb +35 -101
- data/lib/active_support/core_ext/string/starts_ends_with.rb +14 -0
- data/lib/active_support/core_ext/string/xchar.rb +1 -1
- data/lib/active_support/core_ext/symbol.rb +1 -0
- data/lib/active_support/core_ext/symbol/to_proc.rb +14 -0
- data/lib/active_support/core_ext/time.rb +10 -0
- data/lib/active_support/core_ext/time/calculations.rb +7 -9
- data/lib/active_support/core_ext/time/conversions.rb +0 -1
- data/lib/active_support/core_ext/time/marshal_with_utc_flag.rb +22 -0
- data/lib/active_support/core_ext/uri.rb +4 -10
- data/lib/active_support/dependencies.rb +192 -179
- data/lib/active_support/deprecated_callbacks.rb +283 -0
- data/lib/active_support/deprecation/behaviors.rb +1 -1
- data/lib/active_support/deprecation/method_wrappers.rb +9 -10
- data/lib/active_support/deprecation/reporting.rb +1 -2
- data/lib/active_support/duration.rb +2 -6
- data/lib/active_support/hash_with_indifferent_access.rb +1 -9
- data/lib/active_support/inflections.rb +1 -1
- data/lib/active_support/inflector.rb +407 -4
- data/lib/active_support/json/backends/jsongem.rb +9 -12
- data/lib/active_support/json/decoding.rb +1 -16
- data/lib/active_support/json/encoding.rb +12 -42
- data/lib/active_support/locale/en.yml +1 -4
- data/lib/active_support/memoizable.rb +1 -1
- data/lib/active_support/message_encryptor.rb +0 -1
- data/lib/active_support/message_verifier.rb +5 -6
- data/lib/active_support/multibyte.rb +22 -7
- data/lib/active_support/multibyte/chars.rb +392 -164
- data/lib/active_support/multibyte/unicode_database.rb +71 -0
- data/lib/active_support/multibyte/utils.rb +7 -6
- data/lib/active_support/notifications.rb +113 -23
- data/lib/active_support/ordered_hash.rb +11 -35
- data/lib/active_support/ordered_options.rb +0 -6
- data/lib/active_support/rescuable.rb +4 -7
- data/lib/active_support/ruby/shim.rb +6 -4
- data/lib/active_support/test_case.rb +7 -2
- data/lib/active_support/testing/assertions.rb +0 -15
- data/lib/active_support/testing/declarative.rb +1 -1
- data/lib/active_support/testing/isolation.rb +19 -63
- data/lib/active_support/testing/performance.rb +337 -342
- data/lib/active_support/testing/setup_and_teardown.rb +29 -51
- data/lib/active_support/time.rb +3 -23
- data/lib/active_support/time_with_zone.rb +10 -5
- data/lib/active_support/values/time_zone.rb +84 -40
- data/lib/active_support/values/unicode_tables.dat +0 -0
- data/lib/active_support/vendor.rb +16 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/blankslate.rb +113 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder.rb +13 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/blankslate.rb +20 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/css.rb +250 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/xchar.rb +115 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlbase.rb +139 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlevents.rb +63 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlmarkup.rb +328 -0
- data/lib/active_support/vendor/i18n-0.1.3/MIT-LICENSE +20 -0
- data/lib/active_support/vendor/i18n-0.1.3/README.textile +20 -0
- data/lib/active_support/vendor/i18n-0.1.3/Rakefile +5 -0
- data/lib/active_support/vendor/i18n-0.1.3/i18n.gemspec +27 -0
- data/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb +204 -0
- data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb +215 -0
- data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/exceptions.rb +53 -0
- data/lib/active_support/vendor/i18n-0.1.3/test/all.rb +5 -0
- data/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb +99 -0
- data/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb +124 -0
- data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.rb +1 -0
- data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.yml +3 -0
- data/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb +567 -0
- data/lib/active_support/vendor/memcache-client-1.7.5/lib/memcache.rb +1133 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo.rb +33 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/data_timezone.rb +47 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/data_timezone_info.rb +228 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Algiers.rb +55 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Cairo.rb +219 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Casablanca.rb +42 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Harare.rb +18 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Johannesburg.rb +25 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Monrovia.rb +22 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Nairobi.rb +23 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +166 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Argentina/San_Juan.rb +86 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Bogota.rb +23 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Caracas.rb +23 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Chicago.rb +283 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Chihuahua.rb +136 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Denver.rb +204 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Godthab.rb +161 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Guatemala.rb +27 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Halifax.rb +274 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Indiana/Indianapolis.rb +149 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Juneau.rb +194 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/La_Paz.rb +22 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Lima.rb +35 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Los_Angeles.rb +232 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Mazatlan.rb +139 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Mexico_City.rb +144 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Monterrey.rb +131 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/New_York.rb +282 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Phoenix.rb +30 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Regina.rb +74 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Santiago.rb +205 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Sao_Paulo.rb +171 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/St_Johns.rb +288 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Tijuana.rb +196 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Almaty.rb +67 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Baghdad.rb +73 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Baku.rb +161 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Bangkok.rb +20 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Chongqing.rb +33 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Colombo.rb +30 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Dhaka.rb +27 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Hong_Kong.rb +87 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Irkutsk.rb +165 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Jakarta.rb +30 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Jerusalem.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kabul.rb +20 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kamchatka.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Karachi.rb +32 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kathmandu.rb +20 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kolkata.rb +25 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Krasnoyarsk.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kuala_Lumpur.rb +31 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kuwait.rb +18 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Magadan.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Muscat.rb +18 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Novosibirsk.rb +164 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Rangoon.rb +24 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Riyadh.rb +18 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Seoul.rb +34 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Shanghai.rb +35 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Singapore.rb +33 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Taipei.rb +59 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tashkent.rb +47 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tbilisi.rb +78 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tehran.rb +121 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tokyo.rb +30 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Ulaanbaatar.rb +65 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Urumqi.rb +33 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Vladivostok.rb +164 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yakutsk.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yekaterinburg.rb +165 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yerevan.rb +165 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/Azores.rb +270 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/Cape_Verde.rb +23 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/South_Georgia.rb +18 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Adelaide.rb +187 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Brisbane.rb +35 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Darwin.rb +29 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Hobart.rb +193 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Melbourne.rb +185 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Perth.rb +37 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Sydney.rb +185 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Etc/UTC.rb +16 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Amsterdam.rb +228 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Athens.rb +185 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Belgrade.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Berlin.rb +188 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Bratislava.rb +13 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Brussels.rb +232 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Bucharest.rb +181 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Budapest.rb +197 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Copenhagen.rb +179 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Dublin.rb +276 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Helsinki.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Istanbul.rb +218 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Kiev.rb +168 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Lisbon.rb +268 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Ljubljana.rb +13 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/London.rb +288 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Madrid.rb +211 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Minsk.rb +170 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Moscow.rb +181 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Paris.rb +232 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Prague.rb +187 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Riga.rb +176 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Rome.rb +215 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Sarajevo.rb +13 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Skopje.rb +13 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Sofia.rb +173 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Stockholm.rb +165 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Tallinn.rb +172 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Vienna.rb +183 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Vilnius.rb +170 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Warsaw.rb +212 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Zagreb.rb +13 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Auckland.rb +202 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Fiji.rb +23 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Guam.rb +22 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Honolulu.rb +28 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Majuro.rb +20 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Midway.rb +25 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Noumea.rb +25 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Pago_Pago.rb +26 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Port_Moresby.rb +20 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Tongatapu.rb +27 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/info_timezone.rb +52 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/linked_timezone.rb +51 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/linked_timezone_info.rb +44 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/offset_rationals.rb +98 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/ruby_core_support.rb +56 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/time_or_datetime.rb +292 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone.rb +508 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_definition.rb +56 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_info.rb +40 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_offset_info.rb +94 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_period.rb +198 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_transition_info.rb +129 -0
- data/lib/active_support/version.rb +2 -3
- data/lib/active_support/whiny_nil.rb +7 -9
- data/lib/active_support/xml_mini.rb +1 -126
- data/lib/active_support/xml_mini/jdom.rb +0 -2
- data/lib/active_support/xml_mini/libxml.rb +86 -24
- data/lib/active_support/xml_mini/nokogiri.rb +24 -27
- data/lib/active_support/xml_mini/rexml.rb +1 -7
- metadata +191 -49
- data/lib/active_support/builder.rb +0 -6
- data/lib/active_support/core_ext/array/uniq_by.rb +0 -17
- data/lib/active_support/core_ext/class/attribute.rb +0 -67
- data/lib/active_support/core_ext/class/subclasses.rb +0 -55
- data/lib/active_support/core_ext/file/path.rb +0 -5
- data/lib/active_support/core_ext/integer/multiple.rb +0 -6
- data/lib/active_support/core_ext/kernel/singleton_class.rb +0 -13
- data/lib/active_support/core_ext/module/anonymous.rb +0 -24
- data/lib/active_support/core_ext/module/method_names.rb +0 -14
- data/lib/active_support/core_ext/module/reachable.rb +0 -10
- data/lib/active_support/core_ext/module/remove_method.rb +0 -6
- data/lib/active_support/core_ext/object/to_param.rb +0 -49
- data/lib/active_support/core_ext/object/to_query.rb +0 -27
- data/lib/active_support/core_ext/string/encoding.rb +0 -11
- data/lib/active_support/core_ext/string/exclude.rb +0 -6
- data/lib/active_support/core_ext/time/marshal.rb +0 -56
- data/lib/active_support/dependencies/autoload.rb +0 -50
- data/lib/active_support/i18n.rb +0 -8
- data/lib/active_support/inflector/inflections.rb +0 -211
- data/lib/active_support/inflector/methods.rb +0 -141
- data/lib/active_support/inflector/transliterate.rb +0 -97
- data/lib/active_support/json/backends/yajl.rb +0 -40
- data/lib/active_support/lazy_load_hooks.rb +0 -27
- data/lib/active_support/multibyte/unicode.rb +0 -393
- data/lib/active_support/notifications/fanout.rb +0 -93
- data/lib/active_support/notifications/instrumenter.rb +0 -56
- data/lib/active_support/railtie.rb +0 -100
- data/lib/active_support/xml_mini/libxmlsax.rb +0 -85
- 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
|
@@ -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"] &&
|
21
|
+
!ENV["NO_FORK"] && RUBY_PLATFORM !~ /mswin|mingw|java/
|
38
22
|
end
|
39
23
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
30
|
+
yield(Test::Unit::TestCase::STARTED, name)
|
56
31
|
|
57
|
-
|
32
|
+
@_result = result
|
58
33
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
-
|
76
|
-
|
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
|
-
|
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
|
-
|
100
|
-
write.puts [Marshal.dump(
|
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
|
-
|
75
|
+
yield proxy
|
120
76
|
File.open(ENV["ISOLATION_OUTPUT"], "w") do |file|
|
121
|
-
file.puts [Marshal.dump(
|
77
|
+
file.puts [Marshal.dump(proxy)].pack("m")
|
122
78
|
end
|
123
79
|
exit!
|
124
80
|
else
|
@@ -1,455 +1,450 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
33
|
-
|
34
|
-
|
29
|
+
def full_test_name
|
30
|
+
"#{self.class.name}##{method_name}"
|
31
|
+
end
|
35
32
|
|
36
|
-
|
37
|
-
|
33
|
+
def run(result)
|
34
|
+
return if method_name =~ /^default_test$/
|
38
35
|
|
39
|
-
|
40
|
-
|
36
|
+
yield(self.class::STARTED, name)
|
37
|
+
@_result = result
|
41
38
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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
|
-
|
75
|
-
|
76
|
-
|
71
|
+
protected
|
72
|
+
def run_warmup
|
73
|
+
GC.start
|
77
74
|
|
78
|
-
|
79
|
-
|
80
|
-
|
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
|
-
|
83
|
-
|
79
|
+
GC.start
|
80
|
+
end
|
84
81
|
|
85
|
-
|
86
|
-
|
87
|
-
|
82
|
+
def run_profile(metric)
|
83
|
+
klass = profile_options[:benchmark] ? Benchmarker : Profiler
|
84
|
+
performer = klass.new(self, metric)
|
88
85
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
86
|
+
performer.run
|
87
|
+
puts performer.report
|
88
|
+
performer.record
|
89
|
+
end
|
93
90
|
|
94
|
-
|
95
|
-
|
91
|
+
class Performer
|
92
|
+
delegate :run_test, :profile_options, :full_test_name, :to => :@harness
|
96
93
|
|
97
|
-
|
98
|
-
|
99
|
-
|
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
|
-
|
102
|
-
|
103
|
-
|
103
|
+
protected
|
104
|
+
def output_filename
|
105
|
+
"#{profile_options[:output]}/#{full_test_name}_#{@metric.name}"
|
104
106
|
end
|
107
|
+
end
|
105
108
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
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
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
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
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
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
|
-
|
127
|
-
|
128
|
-
app = "#{$1}.#{$2}" if File.directory?('.git') && `git branch -v` =~ /^\* (\S+)\s+(\S+)/
|
140
|
+
@env
|
141
|
+
end
|
129
142
|
|
130
|
-
|
131
|
-
|
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
|
-
|
138
|
-
|
146
|
+
def with_output_file
|
147
|
+
fname = output_filename
|
139
148
|
|
140
|
-
|
149
|
+
if new = !File.exist?(fname)
|
150
|
+
FileUtils.mkdir_p(File.dirname(fname))
|
141
151
|
end
|
142
152
|
|
143
|
-
|
153
|
+
File.open(fname, 'ab') do |file|
|
154
|
+
file.puts(HEADER) if new
|
155
|
+
yield file
|
156
|
+
end
|
144
157
|
end
|
145
158
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
fname = output_filename
|
159
|
+
def output_filename
|
160
|
+
"#{super}.csv"
|
161
|
+
end
|
162
|
+
end
|
151
163
|
|
152
|
-
|
153
|
-
|
154
|
-
|
164
|
+
class Profiler < Performer
|
165
|
+
def initialize(*args)
|
166
|
+
super
|
167
|
+
@supported = @metric.measure_mode rescue false
|
168
|
+
end
|
155
169
|
|
156
|
-
|
157
|
-
|
158
|
-
yield file
|
159
|
-
end
|
160
|
-
end
|
170
|
+
def run
|
171
|
+
return unless @supported
|
161
172
|
|
162
|
-
|
163
|
-
|
164
|
-
|
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
|
-
|
168
|
-
|
181
|
+
def report
|
182
|
+
if @supported
|
169
183
|
super
|
170
|
-
|
184
|
+
else
|
185
|
+
'%20s: unsupported' % @metric.name
|
171
186
|
end
|
187
|
+
end
|
172
188
|
|
173
|
-
|
174
|
-
|
189
|
+
def record
|
190
|
+
return unless @supported
|
175
191
|
|
176
|
-
|
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
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
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
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
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
|
-
|
213
|
+
|
214
|
+
"#{super()}_#{suffix}"
|
204
215
|
end
|
216
|
+
end
|
205
217
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
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
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
225
|
+
class Base
|
226
|
+
attr_reader :total
|
227
|
+
|
228
|
+
def initialize
|
229
|
+
@total = 0
|
226
230
|
end
|
227
231
|
|
228
|
-
|
229
|
-
|
232
|
+
def name
|
233
|
+
@name ||= self.class.name.demodulize.underscore
|
234
|
+
end
|
230
235
|
|
231
|
-
|
232
|
-
|
233
|
-
|
236
|
+
def measure_mode
|
237
|
+
self.class::Mode
|
238
|
+
end
|
234
239
|
|
235
|
-
|
236
|
-
|
237
|
-
|
240
|
+
def measure
|
241
|
+
0
|
242
|
+
end
|
238
243
|
|
239
|
-
|
240
|
-
|
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
|
-
|
244
|
-
|
245
|
-
|
252
|
+
def profile
|
253
|
+
RubyProf.resume
|
254
|
+
yield
|
255
|
+
ensure
|
256
|
+
RubyProf.pause
|
257
|
+
end
|
246
258
|
|
247
|
-
|
248
|
-
|
249
|
-
|
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
|
-
|
256
|
-
|
257
|
-
|
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
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
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
|
-
|
302
|
-
|
298
|
+
class ProcessTime < Time
|
299
|
+
Mode = RubyProf::PROCESS_TIME
|
303
300
|
|
304
|
-
|
305
|
-
|
306
|
-
end
|
301
|
+
def measure
|
302
|
+
RubyProf.measure_process_time
|
307
303
|
end
|
304
|
+
end
|
308
305
|
|
309
|
-
|
310
|
-
|
306
|
+
class WallTime < Time
|
307
|
+
Mode = RubyProf::WALL_TIME
|
311
308
|
|
312
|
-
|
313
|
-
|
314
|
-
end
|
309
|
+
def measure
|
310
|
+
RubyProf.measure_wall_time
|
315
311
|
end
|
312
|
+
end
|
316
313
|
|
317
|
-
|
318
|
-
|
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
|
-
|
327
|
-
|
328
|
-
|
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
|
-
|
332
|
-
|
323
|
+
def measure
|
324
|
+
RubyProf.measure_cpu_time
|
325
|
+
end
|
326
|
+
end
|
333
327
|
|
334
|
-
|
335
|
-
|
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
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
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
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
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
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
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
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
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
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
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
|
-
|
376
|
-
|
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
|
-
|
381
|
-
|
372
|
+
def format(measurement)
|
373
|
+
'%.2f KB' % measurement
|
374
|
+
end
|
375
|
+
end
|
382
376
|
|
383
|
-
|
384
|
-
|
385
|
-
RubyProf.measure_allocations
|
386
|
-
end
|
377
|
+
class Objects < Base
|
378
|
+
Mode = RubyProf::ALLOCATIONS if RubyProf.const_defined?(:ALLOCATIONS)
|
387
379
|
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
end
|
380
|
+
if RubyProf.respond_to?(:measure_allocations)
|
381
|
+
def measure
|
382
|
+
RubyProf.measure_allocations
|
383
|
+
end
|
393
384
|
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
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
|
-
|
407
|
-
|
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
|
-
|
412
|
-
|
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
|
-
|
415
|
-
|
416
|
-
|
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
|
429
|
-
|
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
|
-
|
434
|
-
|
425
|
+
def format(measurement)
|
426
|
+
measurement.to_i.to_s
|
427
|
+
end
|
428
|
+
end
|
435
429
|
|
436
|
-
|
437
|
-
|
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
|
-
|
447
|
-
|
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
|
-
|
455
|
-
end
|
450
|
+
end
|