activesupport 2.3.5 → 3.0.0.beta3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +66 -9
- data/lib/active_support/all.rb +2 -7
- data/lib/active_support/backtrace_cleaner.rb +31 -9
- data/lib/active_support/base64.rb +9 -0
- data/lib/active_support/basic_object.rb +7 -10
- data/lib/active_support/benchmarkable.rb +60 -0
- data/lib/active_support/buffered_logger.rb +14 -9
- data/lib/active_support/cache/compressed_mem_cache_store.rb +2 -0
- data/lib/active_support/cache/file_store.rb +35 -17
- data/lib/active_support/cache/mem_cache_store.rb +32 -23
- data/lib/active_support/cache/memory_store.rb +17 -10
- data/lib/active_support/cache/strategy/local_cache.rb +9 -1
- data/lib/active_support/cache.rb +75 -55
- data/lib/active_support/callbacks.rb +490 -169
- data/lib/active_support/concern.rb +29 -0
- data/lib/active_support/configurable.rb +35 -0
- data/lib/active_support/core_ext/array/access.rb +39 -46
- data/lib/active_support/core_ext/array/conversions.rb +145 -182
- data/lib/active_support/core_ext/array/extract_options.rb +26 -17
- data/lib/active_support/core_ext/array/grouping.rb +87 -93
- data/lib/active_support/core_ext/array/random_access.rb +4 -10
- data/lib/active_support/core_ext/array/uniq_by.rb +17 -0
- data/lib/active_support/core_ext/array/wrap.rb +22 -0
- data/lib/active_support/core_ext/array.rb +2 -10
- data/lib/active_support/core_ext/big_decimal/conversions.rb +27 -0
- data/lib/active_support/core_ext/big_decimal.rb +1 -0
- data/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +16 -20
- data/lib/active_support/core_ext/cgi.rb +0 -4
- data/lib/active_support/core_ext/class/attribute.rb +70 -0
- data/lib/active_support/core_ext/class/attribute_accessors.rb +40 -31
- data/lib/active_support/core_ext/class/delegating_attributes.rb +37 -40
- data/lib/active_support/core_ext/class/inheritable_attributes.rb +100 -11
- data/lib/active_support/core_ext/class/subclasses.rb +55 -0
- data/lib/active_support/core_ext/class.rb +1 -1
- data/lib/active_support/core_ext/date/acts_like.rb +8 -0
- data/lib/active_support/core_ext/date/calculations.rb +218 -228
- data/lib/active_support/core_ext/date/conversions.rb +87 -96
- data/lib/active_support/core_ext/date/freeze.rb +31 -0
- data/lib/active_support/core_ext/date_time/acts_like.rb +13 -0
- data/lib/active_support/core_ext/date_time/calculations.rb +97 -110
- data/lib/active_support/core_ext/date_time/conversions.rb +85 -85
- data/lib/active_support/core_ext/date_time/zones.rb +17 -0
- data/lib/active_support/core_ext/enumerable.rb +18 -13
- data/lib/active_support/core_ext/exception.rb +1 -43
- data/lib/active_support/core_ext/file/atomic.rb +35 -40
- data/lib/active_support/core_ext/file/path.rb +5 -0
- data/lib/active_support/core_ext/file.rb +0 -4
- data/lib/active_support/core_ext/float/rounding.rb +15 -20
- data/lib/active_support/core_ext/float.rb +0 -6
- data/lib/active_support/core_ext/hash/conversions.rb +255 -229
- data/lib/active_support/core_ext/hash/deep_merge.rb +12 -19
- data/lib/active_support/core_ext/hash/diff.rb +11 -17
- data/lib/active_support/core_ext/hash/except.rb +21 -22
- data/lib/active_support/core_ext/hash/indifferent_access.rb +8 -137
- data/lib/active_support/core_ext/hash/keys.rb +38 -45
- data/lib/active_support/core_ext/hash/reverse_merge.rb +25 -32
- data/lib/active_support/core_ext/hash/slice.rb +35 -37
- data/lib/active_support/core_ext/hash.rb +8 -14
- data/lib/active_support/core_ext/integer/inflections.rb +10 -16
- data/lib/active_support/core_ext/integer/multiple.rb +6 -0
- data/lib/active_support/core_ext/integer/time.rb +36 -42
- data/lib/active_support/core_ext/integer.rb +1 -7
- data/lib/active_support/core_ext/kernel/debugger.rb +1 -1
- data/lib/active_support/core_ext/kernel/reporting.rb +9 -7
- data/lib/active_support/core_ext/kernel/requires.rb +3 -1
- data/lib/active_support/core_ext/kernel/singleton_class.rb +13 -0
- data/lib/active_support/core_ext/kernel.rb +1 -1
- data/lib/active_support/core_ext/load_error.rb +16 -32
- data/lib/active_support/core_ext/logger.rb +3 -2
- data/lib/active_support/core_ext/module/aliasing.rb +64 -68
- data/lib/active_support/core_ext/module/anonymous.rb +24 -0
- data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +1 -1
- data/lib/active_support/core_ext/module/attr_internal.rb +4 -4
- data/lib/active_support/core_ext/module/attribute_accessors.rb +48 -42
- data/lib/active_support/core_ext/module/delegation.rb +22 -11
- data/lib/active_support/core_ext/module/deprecation.rb +9 -0
- data/lib/active_support/core_ext/module/introspection.rb +77 -79
- data/lib/active_support/core_ext/module/method_names.rb +14 -0
- data/lib/active_support/core_ext/module/reachable.rb +10 -0
- data/lib/active_support/core_ext/module/remove_method.rb +6 -0
- data/lib/active_support/core_ext/module/synchronization.rb +4 -1
- data/lib/active_support/core_ext/module.rb +7 -18
- data/lib/active_support/core_ext/name_error.rb +3 -4
- data/lib/active_support/core_ext/numeric/bytes.rb +35 -41
- data/lib/active_support/core_ext/numeric/time.rb +70 -74
- data/lib/active_support/core_ext/numeric.rb +1 -8
- data/lib/active_support/core_ext/object/acts_like.rb +10 -0
- data/lib/active_support/core_ext/object/blank.rb +20 -2
- data/lib/active_support/core_ext/object/conversions.rb +4 -15
- data/lib/active_support/core_ext/object/duplicable.rb +65 -0
- data/lib/active_support/core_ext/object/extending.rb +8 -77
- data/lib/active_support/core_ext/object/instance_variables.rb +0 -7
- data/lib/active_support/core_ext/object/misc.rb +2 -90
- data/lib/active_support/core_ext/object/returning.rb +42 -0
- data/lib/active_support/core_ext/object/to_param.rb +49 -0
- data/lib/active_support/core_ext/object/to_query.rb +27 -0
- data/lib/active_support/core_ext/{try.rb → object/try.rb} +4 -4
- data/lib/active_support/core_ext/object/with_options.rb +24 -0
- data/lib/active_support/core_ext/object.rb +10 -2
- data/lib/active_support/core_ext/proc.rb +3 -1
- data/lib/active_support/core_ext/process/daemon.rb +17 -19
- data/lib/active_support/core_ext/range/blockless_step.rb +24 -27
- data/lib/active_support/core_ext/range/conversions.rb +17 -23
- data/lib/active_support/core_ext/range/include_range.rb +18 -27
- data/lib/active_support/core_ext/range/overlaps.rb +6 -13
- data/lib/active_support/core_ext/range.rb +2 -9
- data/lib/active_support/core_ext/regexp.rb +5 -0
- data/lib/active_support/core_ext/rexml.rb +12 -7
- data/lib/active_support/core_ext/string/access.rb +88 -95
- data/lib/active_support/core_ext/string/behavior.rb +6 -12
- data/lib/active_support/core_ext/string/conversions.rb +20 -21
- data/lib/active_support/core_ext/string/exclude.rb +6 -0
- data/lib/active_support/core_ext/string/filters.rb +17 -23
- data/lib/active_support/core_ext/string/inflections.rb +147 -154
- data/lib/active_support/core_ext/string/interpolation.rb +1 -0
- data/lib/active_support/core_ext/string/multibyte.rb +68 -74
- data/lib/active_support/core_ext/string/output_safety.rb +105 -44
- data/lib/active_support/core_ext/string/starts_ends_with.rb +3 -34
- data/lib/active_support/core_ext/string/xchar.rb +10 -3
- data/lib/active_support/core_ext/string.rb +6 -20
- data/lib/active_support/core_ext/time/acts_like.rb +8 -0
- data/lib/active_support/core_ext/time/calculations.rb +276 -299
- data/lib/active_support/core_ext/time/conversions.rb +79 -84
- data/lib/active_support/core_ext/time/marshal.rb +56 -0
- data/lib/active_support/core_ext/time/publicize_conversion_methods.rb +10 -0
- data/lib/active_support/core_ext/time/zones.rb +73 -81
- data/lib/active_support/core_ext/uri.rb +2 -1
- data/lib/active_support/core_ext.rb +2 -7
- data/lib/active_support/dependencies/autoload.rb +50 -0
- data/lib/active_support/dependencies.rb +168 -197
- data/lib/active_support/deprecation/behaviors.rb +38 -0
- data/lib/active_support/deprecation/method_wrappers.rb +29 -0
- data/lib/active_support/deprecation/proxy_wrappers.rb +74 -0
- data/lib/active_support/deprecation/reporting.rb +56 -0
- data/lib/active_support/deprecation.rb +9 -187
- data/lib/active_support/duration.rb +6 -2
- data/lib/active_support/hash_with_indifferent_access.rb +141 -0
- data/lib/active_support/i18n.rb +3 -0
- data/lib/active_support/inflections.rb +1 -1
- data/lib/active_support/inflector/inflections.rb +211 -0
- data/lib/active_support/inflector/methods.rb +141 -0
- data/lib/active_support/inflector/transliterate.rb +77 -0
- data/lib/active_support/inflector.rb +4 -403
- data/lib/active_support/json/backends/jsongem.rb +16 -10
- data/lib/active_support/json/backends/yajl.rb +40 -0
- data/lib/active_support/json/backends/yaml.rb +14 -8
- data/lib/active_support/json/decoding.rb +17 -1
- data/lib/active_support/json/encoding.rb +164 -35
- data/lib/active_support/json/variable.rb +4 -3
- data/lib/active_support/lazy_load_hooks.rb +17 -0
- data/lib/active_support/memoizable.rb +8 -5
- data/lib/active_support/message_encryptor.rb +1 -0
- data/lib/active_support/message_verifier.rb +12 -29
- data/lib/active_support/multibyte/chars.rb +88 -31
- data/lib/active_support/multibyte/unicode_database.rb +5 -5
- data/lib/active_support/multibyte/utils.rb +6 -7
- data/lib/active_support/multibyte.rb +11 -6
- data/lib/active_support/notifications/fanout.rb +83 -0
- data/lib/active_support/notifications/instrumenter.rb +50 -0
- data/lib/active_support/notifications.rb +81 -0
- data/lib/active_support/option_merger.rb +2 -0
- data/lib/active_support/ordered_hash.rb +28 -11
- data/lib/active_support/ordered_options.rb +9 -1
- data/lib/active_support/railtie.rb +64 -0
- data/lib/active_support/rescuable.rb +11 -6
- data/lib/active_support/ruby/shim.rb +21 -0
- data/lib/active_support/test_case.rb +10 -8
- data/lib/active_support/testing/assertions.rb +17 -0
- data/lib/active_support/testing/declarative.rb +31 -12
- data/lib/active_support/testing/deprecation.rb +8 -10
- data/lib/active_support/testing/isolation.rb +153 -0
- data/lib/active_support/testing/pending.rb +48 -0
- data/lib/active_support/testing/performance.rb +342 -339
- data/lib/active_support/testing/setup_and_teardown.rb +48 -31
- data/lib/active_support/time/autoload.rb +5 -0
- data/lib/active_support/time.rb +34 -0
- data/lib/active_support/time_with_zone.rb +18 -12
- data/lib/active_support/values/time_zone.rb +51 -68
- data/lib/active_support/version.rb +5 -4
- data/lib/active_support/whiny_nil.rb +5 -9
- data/lib/active_support/xml_mini/jdom.rb +13 -7
- data/lib/active_support/xml_mini/libxml.rb +38 -91
- data/lib/active_support/xml_mini/libxmlsax.rb +85 -0
- data/lib/active_support/xml_mini/nokogiri.rb +40 -31
- data/lib/active_support/xml_mini/nokogirisax.rb +83 -0
- data/lib/active_support/xml_mini/rexml.rb +30 -9
- data/lib/active_support/xml_mini.rb +2 -0
- data/lib/active_support.rb +46 -30
- metadata +136 -215
- data/lib/active_support/cache/drb_store.rb +0 -14
- data/lib/active_support/core_ext/array/wrapper.rb +0 -24
- data/lib/active_support/core_ext/base64/encoding.rb +0 -16
- data/lib/active_support/core_ext/base64.rb +0 -4
- data/lib/active_support/core_ext/bigdecimal/conversions.rb +0 -37
- data/lib/active_support/core_ext/bigdecimal.rb +0 -6
- data/lib/active_support/core_ext/blank.rb +0 -2
- data/lib/active_support/core_ext/class/removal.rb +0 -50
- data/lib/active_support/core_ext/date/behavior.rb +0 -42
- data/lib/active_support/core_ext/date.rb +0 -10
- data/lib/active_support/core_ext/date_time.rb +0 -12
- data/lib/active_support/core_ext/duplicable.rb +0 -43
- data/lib/active_support/core_ext/float/time.rb +0 -27
- data/lib/active_support/core_ext/integer/even_odd.rb +0 -29
- data/lib/active_support/core_ext/kernel/daemonizing.rb +0 -7
- data/lib/active_support/core_ext/module/inclusion.rb +0 -30
- data/lib/active_support/core_ext/module/loading.rb +0 -23
- data/lib/active_support/core_ext/module/model_naming.rb +0 -25
- data/lib/active_support/core_ext/numeric/conversions.rb +0 -19
- data/lib/active_support/core_ext/object/metaclass.rb +0 -13
- data/lib/active_support/core_ext/pathname/clean_within.rb +0 -14
- data/lib/active_support/core_ext/pathname.rb +0 -7
- data/lib/active_support/core_ext/string/bytesize.rb +0 -5
- data/lib/active_support/core_ext/string/iterators.rb +0 -23
- data/lib/active_support/core_ext/symbol.rb +0 -14
- data/lib/active_support/core_ext/time/behavior.rb +0 -13
- data/lib/active_support/core_ext/time.rb +0 -42
- data/lib/active_support/json/encoders/date.rb +0 -22
- data/lib/active_support/json/encoders/date_time.rb +0 -22
- data/lib/active_support/json/encoders/enumerable.rb +0 -17
- data/lib/active_support/json/encoders/false_class.rb +0 -7
- data/lib/active_support/json/encoders/hash.rb +0 -56
- data/lib/active_support/json/encoders/nil_class.rb +0 -7
- data/lib/active_support/json/encoders/numeric.rb +0 -21
- data/lib/active_support/json/encoders/object.rb +0 -10
- data/lib/active_support/json/encoders/regexp.rb +0 -9
- data/lib/active_support/json/encoders/string.rb +0 -9
- data/lib/active_support/json/encoders/symbol.rb +0 -5
- data/lib/active_support/json/encoders/time.rb +0 -22
- data/lib/active_support/json/encoders/true_class.rb +0 -7
- data/lib/active_support/vendor/builder-2.1.2/blankslate.rb +0 -113
- data/lib/active_support/vendor/builder-2.1.2/builder/blankslate.rb +0 -20
- data/lib/active_support/vendor/builder-2.1.2/builder/css.rb +0 -250
- data/lib/active_support/vendor/builder-2.1.2/builder/xchar.rb +0 -115
- data/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb +0 -139
- data/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb +0 -63
- data/lib/active_support/vendor/builder-2.1.2/builder/xmlmarkup.rb +0 -328
- data/lib/active_support/vendor/builder-2.1.2/builder.rb +0 -13
- data/lib/active_support/vendor/i18n-0.1.3/MIT-LICENSE +0 -20
- data/lib/active_support/vendor/i18n-0.1.3/README.textile +0 -20
- data/lib/active_support/vendor/i18n-0.1.3/Rakefile +0 -5
- data/lib/active_support/vendor/i18n-0.1.3/i18n.gemspec +0 -27
- data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb +0 -214
- data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/exceptions.rb +0 -53
- data/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb +0 -199
- data/lib/active_support/vendor/i18n-0.1.3/test/all.rb +0 -5
- data/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb +0 -99
- data/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb +0 -124
- data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.rb +0 -1
- data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.yml +0 -3
- data/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb +0 -567
- data/lib/active_support/vendor/memcache-client-1.7.4/memcache.rb +0 -1107
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone.rb +0 -47
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone_info.rb +0 -228
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Algiers.rb +0 -55
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Cairo.rb +0 -219
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Casablanca.rb +0 -40
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Harare.rb +0 -18
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Johannesburg.rb +0 -25
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Monrovia.rb +0 -22
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Nairobi.rb +0 -23
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +0 -166
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/San_Juan.rb +0 -86
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Bogota.rb +0 -23
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Caracas.rb +0 -23
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chicago.rb +0 -283
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chihuahua.rb +0 -136
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Denver.rb +0 -204
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Godthab.rb +0 -161
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Guatemala.rb +0 -27
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Halifax.rb +0 -274
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Indiana/Indianapolis.rb +0 -149
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Juneau.rb +0 -194
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/La_Paz.rb +0 -22
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Lima.rb +0 -35
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Los_Angeles.rb +0 -232
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mazatlan.rb +0 -139
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mexico_City.rb +0 -144
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Monterrey.rb +0 -131
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/New_York.rb +0 -282
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Phoenix.rb +0 -30
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Regina.rb +0 -74
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Santiago.rb +0 -205
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Sao_Paulo.rb +0 -171
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/St_Johns.rb +0 -288
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Tijuana.rb +0 -196
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Almaty.rb +0 -67
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baghdad.rb +0 -73
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baku.rb +0 -161
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Bangkok.rb +0 -20
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Chongqing.rb +0 -33
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Colombo.rb +0 -30
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Dhaka.rb +0 -27
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Hong_Kong.rb +0 -87
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Irkutsk.rb +0 -165
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jakarta.rb +0 -30
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jerusalem.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kabul.rb +0 -20
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kamchatka.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Karachi.rb +0 -30
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Katmandu.rb +0 -20
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kolkata.rb +0 -25
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Krasnoyarsk.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuala_Lumpur.rb +0 -31
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuwait.rb +0 -18
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Magadan.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Muscat.rb +0 -18
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Novosibirsk.rb +0 -164
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Rangoon.rb +0 -24
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Riyadh.rb +0 -18
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Seoul.rb +0 -34
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Shanghai.rb +0 -35
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Singapore.rb +0 -33
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Taipei.rb +0 -59
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tashkent.rb +0 -47
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tbilisi.rb +0 -78
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tehran.rb +0 -121
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tokyo.rb +0 -30
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Ulaanbaatar.rb +0 -65
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Urumqi.rb +0 -33
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Vladivostok.rb +0 -164
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yakutsk.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yekaterinburg.rb +0 -165
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yerevan.rb +0 -165
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Azores.rb +0 -270
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Cape_Verde.rb +0 -23
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/South_Georgia.rb +0 -18
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Adelaide.rb +0 -187
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Brisbane.rb +0 -35
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Darwin.rb +0 -29
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Hobart.rb +0 -193
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Melbourne.rb +0 -185
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Perth.rb +0 -37
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Sydney.rb +0 -185
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Etc/UTC.rb +0 -16
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Amsterdam.rb +0 -228
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Athens.rb +0 -185
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Belgrade.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Berlin.rb +0 -188
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bratislava.rb +0 -13
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Brussels.rb +0 -232
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bucharest.rb +0 -181
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Budapest.rb +0 -197
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Copenhagen.rb +0 -179
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Dublin.rb +0 -276
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Helsinki.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Istanbul.rb +0 -218
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Kiev.rb +0 -168
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Lisbon.rb +0 -268
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Ljubljana.rb +0 -13
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/London.rb +0 -288
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Madrid.rb +0 -211
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Minsk.rb +0 -170
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Moscow.rb +0 -181
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Paris.rb +0 -232
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Prague.rb +0 -187
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Riga.rb +0 -176
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Rome.rb +0 -215
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sarajevo.rb +0 -13
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Skopje.rb +0 -13
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sofia.rb +0 -173
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Stockholm.rb +0 -165
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Tallinn.rb +0 -172
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vienna.rb +0 -183
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vilnius.rb +0 -170
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Warsaw.rb +0 -212
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Zagreb.rb +0 -13
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Auckland.rb +0 -202
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Fiji.rb +0 -23
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Guam.rb +0 -22
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Honolulu.rb +0 -28
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Majuro.rb +0 -20
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Midway.rb +0 -25
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Noumea.rb +0 -25
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Pago_Pago.rb +0 -26
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Port_Moresby.rb +0 -20
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Tongatapu.rb +0 -27
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/info_timezone.rb +0 -52
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone.rb +0 -51
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone_info.rb +0 -44
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/offset_rationals.rb +0 -98
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/ruby_core_support.rb +0 -56
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/time_or_datetime.rb +0 -292
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone.rb +0 -508
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_definition.rb +0 -56
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_info.rb +0 -40
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_offset_info.rb +0 -94
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb +0 -198
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_transition_info.rb +0 -129
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo.rb +0 -33
- data/lib/active_support/vendor.rb +0 -28
- data/lib/activesupport.rb +0 -2
data/CHANGELOG
CHANGED
|
@@ -1,23 +1,80 @@
|
|
|
1
|
-
*
|
|
1
|
+
*Rails 3.0.0 [beta 3] (April 13th, 2010)*
|
|
2
2
|
|
|
3
|
-
*
|
|
3
|
+
* Improve transliteration quality. #4374 [Norman Clarke]
|
|
4
4
|
|
|
5
|
-
*
|
|
5
|
+
* Speed up and add Ruby 1.9 support for ActiveSupport::Multibyte::Chars#tidy_bytes. #4350 [Norman Clarke]
|
|
6
6
|
|
|
7
|
-
* Ruby 1.9 Compatibility
|
|
8
7
|
|
|
9
|
-
*
|
|
8
|
+
*Rails 3.0.0 [beta 2] (April 1st, 2010)*
|
|
10
9
|
|
|
11
|
-
*
|
|
10
|
+
* Reduced load time by deferring configuration of classes using
|
|
11
|
+
ActiveSupport::on_load(:component_name) [YK]
|
|
12
12
|
|
|
13
|
-
*
|
|
13
|
+
* Rename #metaclass to #singleton_class now that ruby-core has decided [JK]
|
|
14
14
|
|
|
15
|
-
*
|
|
15
|
+
* New assertions assert_blank and assert_present. #4299 [Juanjo Bazan]
|
|
16
16
|
|
|
17
|
-
*
|
|
17
|
+
* Use Object#singleton_class instead of #metaclass. Prefer Ruby's choice. [Jeremy Kemper]
|
|
18
|
+
|
|
19
|
+
* JSON backend for YAJL. Preferred if available. #2666 [Brian Lopez]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
*Rails 3.0.0 [beta 1] (February 4, 2010)*
|
|
23
|
+
|
|
24
|
+
* Introduce class_attribute to declare inheritable class attributes. Writing an attribute on a subclass behaves just like overriding the superclass reader method. Unifies and replaces most usage of cattr_accessor, class_inheritable_attribute, superclass_delegating_attribute, and extlib_inheritable_attribute. [Jeremy Kemper, Yehuda Katz]
|
|
25
|
+
|
|
26
|
+
* Time#- with a DateTime argument behaves the same as with a Time argument, i.e. returns the difference between self and arg as a Float #3476 [Geoff Buesing]
|
|
27
|
+
|
|
28
|
+
* YAML serialization for OrderedHash. #3608 [Gregor Schmidt]
|
|
29
|
+
|
|
30
|
+
* Update bundled TZInfo to v0.3.16 [Geoff Buesing]
|
|
31
|
+
|
|
32
|
+
* Georgetown TimeZone is now mapped to "America/Guyana" instead of "America/Argentina/San_Juan" #1821 [Geoff Buesing, Reuben Sivan]
|
|
33
|
+
|
|
34
|
+
* Changed the default ActiveSupport.use_standard_json_time_format from false to true and
|
|
35
|
+
ActiveSupport.escape_html_entities_in_json from true to false to match previously announced Rails 3 defaults [DHH]
|
|
36
|
+
|
|
37
|
+
* Added Object#presence that returns the object if it's #present? otherwise returns nil [DHH/Colin Kelley]
|
|
38
|
+
|
|
39
|
+
* Add Enumerable#exclude? to bring parity to Enumerable#include? and avoid if !x.include?/else calls [DHH]
|
|
40
|
+
|
|
41
|
+
* Update Edinburgh TimeZone to use "Europe/London" instead of "Europe/Dublin" #3310 [Phil Ross]
|
|
42
|
+
|
|
43
|
+
* Update bundled TZInfo to v0.3.15 [Geoff Buesing]
|
|
44
|
+
|
|
45
|
+
* JSON: +Object#to_json+ calls +as_json+ to coerce itself into something natively encodable like +Hash+, +Integer+, or +String+. Override +as_json+ instead of +to_json+ so you're JSON library agnostic. [Jeremy Kemper]
|
|
46
|
+
|
|
47
|
+
* String #to_time and #to_datetime: handle fractional seconds #864 [Jason Frey]
|
|
48
|
+
|
|
49
|
+
* Update bundled TZInfo to v0.3.13 [Geoff Buesing]
|
|
18
50
|
|
|
19
51
|
* Allow MemCacheStore to be initialized with a MemCache-like object instead of addresses and options [Bryan Helmkamp]
|
|
20
52
|
|
|
53
|
+
* Change spelling of Kyev timezone to Kyiv #2613 [Alexander Dymo]
|
|
54
|
+
|
|
55
|
+
* Add ActiveSupport.parse_json_times to disable time parsing in JSON backends that don't support it or don't need it. [rick]
|
|
56
|
+
|
|
57
|
+
* Add pluggable JSON backends with support for the JSON gem. [rick]
|
|
58
|
+
Example: ActiveSupport::JSON.backend = "JSONGem"
|
|
59
|
+
|
|
60
|
+
All internal Rails JSON encoding is now handled by ActiveSupport::JSON.encode(). Use of #to_json is not recommended, as it may clash with other libraries that overwrite it. However, you can recover Rails specific functionality
|
|
61
|
+
if you really want to use #to_json.
|
|
62
|
+
|
|
63
|
+
gem 'json'
|
|
64
|
+
ActiveSupport::JSON.backend = "JSONGem"
|
|
65
|
+
|
|
66
|
+
class ActiveRecord::Base
|
|
67
|
+
alias to_json rails_to_json
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
* require 'active_support' no longer orders the whole menu of core extensions. Ask for just what you need: e.g. require 'active_support/core/time' to use timezones, durations, and stdlib date/time extensions. [Jeremy Kemper]
|
|
71
|
+
|
|
72
|
+
* Removed rarely-used DRb cache store. [Jeremy Kemper]
|
|
73
|
+
|
|
74
|
+
* TimeWithZone.name returns 'Time', to further thwart type checking [Geoff Buesing]
|
|
75
|
+
|
|
76
|
+
* Time.local instances: Adding 24.hours across the DST boundary adds 24 hours instead of one day #2066 [Michael Curtis]
|
|
77
|
+
|
|
21
78
|
|
|
22
79
|
*2.3.2 [Final] (March 15, 2009)*
|
|
23
80
|
|
data/lib/active_support/all.rb
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
# For forward compatibility with Rails 3.
|
|
2
|
-
#
|
|
3
|
-
# require 'active_support' loads a very bare minumum in Rails 3.
|
|
4
|
-
# require 'active_support/all' loads the whole suite like Rails 2 did.
|
|
5
|
-
#
|
|
6
|
-
# To prepare for Rails 3, switch to require 'active_support/all' now.
|
|
7
|
-
|
|
8
1
|
require 'active_support'
|
|
2
|
+
require 'active_support/time'
|
|
3
|
+
require 'active_support/core_ext'
|
|
@@ -4,12 +4,14 @@ module ActiveSupport
|
|
|
4
4
|
# context, so only the relevant lines are included.
|
|
5
5
|
#
|
|
6
6
|
# If you need to reconfigure an existing BacktraceCleaner, like the one in Rails, to show as much as possible, you can always
|
|
7
|
-
# call BacktraceCleaner#remove_silencers!
|
|
7
|
+
# call BacktraceCleaner#remove_silencers! Also, if you need to reconfigure an existing BacktraceCleaner so that it does not
|
|
8
|
+
# filter or modify the paths of any lines of the backtrace, you can call BacktraceCleaner#remove_filters! These two methods
|
|
9
|
+
# will give you a completely untouched backtrace.
|
|
8
10
|
#
|
|
9
11
|
# Example:
|
|
10
12
|
#
|
|
11
13
|
# bc = BacktraceCleaner.new
|
|
12
|
-
# bc.add_filter { |line| line.gsub(Rails.root, '') }
|
|
14
|
+
# bc.add_filter { |line| line.gsub(Rails.root, '') }
|
|
13
15
|
# bc.add_silencer { |line| line =~ /mongrel|rubygems/ }
|
|
14
16
|
# bc.clean(exception.backtrace) # will strip the Rails.root prefix and skip any lines from mongrel or rubygems
|
|
15
17
|
#
|
|
@@ -18,10 +20,19 @@ module ActiveSupport
|
|
|
18
20
|
def initialize
|
|
19
21
|
@filters, @silencers = [], []
|
|
20
22
|
end
|
|
21
|
-
|
|
23
|
+
|
|
22
24
|
# Returns the backtrace after all filters and silencers has been run against it. Filters run first, then silencers.
|
|
23
|
-
def clean(backtrace)
|
|
24
|
-
|
|
25
|
+
def clean(backtrace, kind = :silent)
|
|
26
|
+
filtered = filter(backtrace)
|
|
27
|
+
|
|
28
|
+
case kind
|
|
29
|
+
when :silent
|
|
30
|
+
silence(filtered)
|
|
31
|
+
when :noise
|
|
32
|
+
noise(filtered)
|
|
33
|
+
else
|
|
34
|
+
filtered
|
|
35
|
+
end
|
|
25
36
|
end
|
|
26
37
|
|
|
27
38
|
# Adds a filter from the block provided. Each line in the backtrace will be mapped against this filter.
|
|
@@ -51,21 +62,32 @@ module ActiveSupport
|
|
|
51
62
|
@silencers = []
|
|
52
63
|
end
|
|
53
64
|
|
|
54
|
-
|
|
65
|
+
def remove_filters!
|
|
66
|
+
@filters = []
|
|
67
|
+
end
|
|
68
|
+
|
|
55
69
|
private
|
|
56
70
|
def filter(backtrace)
|
|
57
71
|
@filters.each do |f|
|
|
58
72
|
backtrace = backtrace.map { |line| f.call(line) }
|
|
59
73
|
end
|
|
60
|
-
|
|
74
|
+
|
|
61
75
|
backtrace
|
|
62
76
|
end
|
|
63
|
-
|
|
77
|
+
|
|
64
78
|
def silence(backtrace)
|
|
65
79
|
@silencers.each do |s|
|
|
66
80
|
backtrace = backtrace.reject { |line| s.call(line) }
|
|
67
81
|
end
|
|
68
|
-
|
|
82
|
+
|
|
83
|
+
backtrace
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def noise(backtrace)
|
|
87
|
+
@silencers.each do |s|
|
|
88
|
+
backtrace = backtrace.select { |line| s.call(line) }
|
|
89
|
+
end
|
|
90
|
+
|
|
69
91
|
backtrace
|
|
70
92
|
end
|
|
71
93
|
end
|
|
@@ -30,4 +30,13 @@ module ActiveSupport
|
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
|
+
|
|
34
|
+
# Encodes the value as base64 without the newline breaks. This makes the base64 encoding readily usable as URL parameters
|
|
35
|
+
# or memcache keys without further processing.
|
|
36
|
+
#
|
|
37
|
+
# ActiveSupport::Base64.encode64s("Original unencoded string")
|
|
38
|
+
# # => "T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw=="
|
|
39
|
+
def Base64.encode64s(value)
|
|
40
|
+
encode64(value).gsub(/\n/, '')
|
|
41
|
+
end
|
|
33
42
|
end
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
# A base class with no predefined methods that tries to behave like Builder's
|
|
2
|
-
# BlankSlate in Ruby 1.9. In Ruby pre-1.9, this is actually the
|
|
3
|
-
# Builder::BlankSlate class.
|
|
4
|
-
#
|
|
5
|
-
# Ruby 1.9 introduces BasicObject which differs slightly from Builder's
|
|
6
|
-
# BlankSlate that has been used so far. ActiveSupport::BasicObject provides a
|
|
7
|
-
# barebones base class that emulates Builder::BlankSlate while still relying on
|
|
8
|
-
# Ruby 1.9's BasicObject in Ruby 1.9.
|
|
9
1
|
module ActiveSupport
|
|
10
2
|
if defined? ::BasicObject
|
|
3
|
+
# A class with no predefined methods that behaves similarly to Builder's
|
|
4
|
+
# BlankSlate. Used for proxy classes.
|
|
11
5
|
class BasicObject < ::BasicObject
|
|
12
6
|
undef_method :==
|
|
13
7
|
undef_method :equal?
|
|
@@ -18,7 +12,10 @@ module ActiveSupport
|
|
|
18
12
|
end
|
|
19
13
|
end
|
|
20
14
|
else
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
class BasicObject #:nodoc:
|
|
16
|
+
instance_methods.each do |m|
|
|
17
|
+
undef_method(m) if m.to_s !~ /(?:^__|^nil\?$|^send$|^object_id$)/
|
|
18
|
+
end
|
|
19
|
+
end
|
|
23
20
|
end
|
|
24
21
|
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require 'active_support/core_ext/benchmark'
|
|
2
|
+
require 'active_support/core_ext/hash/keys'
|
|
3
|
+
|
|
4
|
+
module ActiveSupport
|
|
5
|
+
module Benchmarkable
|
|
6
|
+
# Allows you to measure the execution time of a block
|
|
7
|
+
# in a template and records the result to the log. Wrap this block around
|
|
8
|
+
# expensive operations or possible bottlenecks to get a time reading
|
|
9
|
+
# for the operation. For example, let's say you thought your file
|
|
10
|
+
# processing method was taking too long; you could wrap it in a benchmark block.
|
|
11
|
+
#
|
|
12
|
+
# <% benchmark "Process data files" do %>
|
|
13
|
+
# <%= expensive_files_operation %>
|
|
14
|
+
# <% end %>
|
|
15
|
+
#
|
|
16
|
+
# That would add something like "Process data files (345.2ms)" to the log,
|
|
17
|
+
# which you can then use to compare timings when optimizing your code.
|
|
18
|
+
#
|
|
19
|
+
# You may give an optional logger level as the :level option.
|
|
20
|
+
# (:debug, :info, :warn, :error); the default value is :info.
|
|
21
|
+
#
|
|
22
|
+
# <% benchmark "Low-level files", :level => :debug do %>
|
|
23
|
+
# <%= lowlevel_files_operation %>
|
|
24
|
+
# <% end %>
|
|
25
|
+
#
|
|
26
|
+
# Finally, you can pass true as the third argument to silence all log activity
|
|
27
|
+
# inside the block. This is great for boiling down a noisy block to just a single statement:
|
|
28
|
+
#
|
|
29
|
+
# <% benchmark "Process data files", :level => :info, :silence => true do %>
|
|
30
|
+
# <%= expensive_and_chatty_files_operation %>
|
|
31
|
+
# <% end %>
|
|
32
|
+
def benchmark(message = "Benchmarking", options = {})
|
|
33
|
+
if logger
|
|
34
|
+
if options.is_a?(Symbol)
|
|
35
|
+
ActiveSupport::Deprecation.warn("use benchmark('#{message}', :level => :#{options}) instead", caller)
|
|
36
|
+
options = { :level => options, :silence => false }
|
|
37
|
+
else
|
|
38
|
+
options.assert_valid_keys(:level, :silence)
|
|
39
|
+
options[:level] ||= :info
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
result = nil
|
|
43
|
+
ms = Benchmark.ms { result = options[:silence] ? logger.silence { yield } : yield }
|
|
44
|
+
logger.send(options[:level], '%s (%.1fms)' % [ message, ms ])
|
|
45
|
+
result
|
|
46
|
+
else
|
|
47
|
+
yield
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Silence the logger during the execution of the block.
|
|
52
|
+
#
|
|
53
|
+
def silence
|
|
54
|
+
old_logger_level, logger.level = logger.level, ::Logger::ERROR if logger
|
|
55
|
+
yield
|
|
56
|
+
ensure
|
|
57
|
+
logger.level = old_logger_level if logger
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'active_support/core_ext/class/attribute_accessors'
|
|
2
|
+
|
|
1
3
|
module ActiveSupport
|
|
2
4
|
# Inspired by the buffered logger idea by Ezra
|
|
3
5
|
class BufferedLogger
|
|
@@ -51,7 +53,6 @@ module ActiveSupport
|
|
|
51
53
|
FileUtils.mkdir_p(File.dirname(log))
|
|
52
54
|
@log = open(log, (File::WRONLY | File::APPEND | File::CREAT))
|
|
53
55
|
@log.sync = true
|
|
54
|
-
@log.write("# Logfile created on %s" % [Time.now.to_s])
|
|
55
56
|
end
|
|
56
57
|
end
|
|
57
58
|
|
|
@@ -66,15 +67,19 @@ module ActiveSupport
|
|
|
66
67
|
message
|
|
67
68
|
end
|
|
68
69
|
|
|
70
|
+
# Dynamically add methods such as:
|
|
71
|
+
# def info
|
|
72
|
+
# def warn
|
|
73
|
+
# def debug
|
|
69
74
|
for severity in Severity.constants
|
|
70
|
-
class_eval <<-EOT, __FILE__, __LINE__
|
|
71
|
-
def #{severity.downcase}(message = nil, progname = nil, &block)
|
|
72
|
-
add(#{severity}, message, progname, &block)
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def #{severity.downcase}?
|
|
76
|
-
#{severity} >= @level
|
|
77
|
-
end
|
|
75
|
+
class_eval <<-EOT, __FILE__, __LINE__ + 1
|
|
76
|
+
def #{severity.downcase}(message = nil, progname = nil, &block) # def debug(message = nil, progname = nil, &block)
|
|
77
|
+
add(#{severity}, message, progname, &block) # add(DEBUG, message, progname, &block)
|
|
78
|
+
end # end
|
|
79
|
+
|
|
80
|
+
def #{severity.downcase}? # def debug?
|
|
81
|
+
#{severity} >= @level # DEBUG >= @level
|
|
82
|
+
end # end
|
|
78
83
|
EOT
|
|
79
84
|
end
|
|
80
85
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'active_support/core_ext/file/atomic'
|
|
2
|
+
|
|
1
3
|
module ActiveSupport
|
|
2
4
|
module Cache
|
|
3
5
|
# A cache store implementation which stores everything on the filesystem.
|
|
@@ -8,43 +10,59 @@ module ActiveSupport
|
|
|
8
10
|
@cache_path = cache_path
|
|
9
11
|
end
|
|
10
12
|
|
|
13
|
+
# Reads a value from the cache.
|
|
14
|
+
#
|
|
15
|
+
# Possible options:
|
|
16
|
+
# - +:expires_in+ - the number of seconds that this value may stay in
|
|
17
|
+
# the cache.
|
|
11
18
|
def read(name, options = nil)
|
|
12
|
-
super
|
|
13
|
-
|
|
19
|
+
super do
|
|
20
|
+
file_name = real_file_path(name)
|
|
21
|
+
expires = expires_in(options)
|
|
22
|
+
|
|
23
|
+
if File.exist?(file_name) && (expires <= 0 || Time.now - File.mtime(file_name) < expires)
|
|
24
|
+
File.open(file_name, 'rb') { |f| Marshal.load(f) }
|
|
25
|
+
end
|
|
26
|
+
end
|
|
14
27
|
end
|
|
15
28
|
|
|
29
|
+
# Writes a value to the cache.
|
|
16
30
|
def write(name, value, options = nil)
|
|
17
|
-
super
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
31
|
+
super do
|
|
32
|
+
ensure_cache_path(File.dirname(real_file_path(name)))
|
|
33
|
+
File.atomic_write(real_file_path(name), cache_path) { |f| Marshal.dump(value, f) }
|
|
34
|
+
value
|
|
35
|
+
end
|
|
21
36
|
rescue => e
|
|
22
37
|
logger.error "Couldn't create cache directory: #{name} (#{e.message})" if logger
|
|
23
38
|
end
|
|
24
39
|
|
|
25
40
|
def delete(name, options = nil)
|
|
26
|
-
super
|
|
27
|
-
|
|
41
|
+
super do
|
|
42
|
+
File.delete(real_file_path(name))
|
|
43
|
+
end
|
|
28
44
|
rescue SystemCallError => e
|
|
29
45
|
# If there's no cache, then there's nothing to complain about
|
|
30
46
|
end
|
|
31
47
|
|
|
32
48
|
def delete_matched(matcher, options = nil)
|
|
33
|
-
super
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
49
|
+
super do
|
|
50
|
+
search_dir(@cache_path) do |f|
|
|
51
|
+
if f =~ matcher
|
|
52
|
+
begin
|
|
53
|
+
File.delete(f)
|
|
54
|
+
rescue SystemCallError => e
|
|
55
|
+
# If there's no cache, then there's nothing to complain about
|
|
56
|
+
end
|
|
40
57
|
end
|
|
41
58
|
end
|
|
42
59
|
end
|
|
43
60
|
end
|
|
44
61
|
|
|
45
62
|
def exist?(name, options = nil)
|
|
46
|
-
super
|
|
47
|
-
|
|
63
|
+
super do
|
|
64
|
+
File.exist?(real_file_path(name))
|
|
65
|
+
end
|
|
48
66
|
end
|
|
49
67
|
|
|
50
68
|
private
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'memcache'
|
|
2
|
+
require 'active_support/core_ext/array/extract_options'
|
|
2
3
|
|
|
3
4
|
module ActiveSupport
|
|
4
5
|
module Cache
|
|
@@ -12,7 +13,7 @@ module ActiveSupport
|
|
|
12
13
|
# and MemCacheStore will load balance between all available servers. If a
|
|
13
14
|
# server goes down, then MemCacheStore will ignore it until it goes back
|
|
14
15
|
# online.
|
|
15
|
-
# - Time-based expiry support. See #write and the
|
|
16
|
+
# - Time-based expiry support. See #write and the <tt>:expires_in</tt> option.
|
|
16
17
|
# - Per-request in memory cache for all communication with the MemCache server(s).
|
|
17
18
|
class MemCacheStore < Store
|
|
18
19
|
module Response # :nodoc:
|
|
@@ -59,39 +60,42 @@ module ActiveSupport
|
|
|
59
60
|
end
|
|
60
61
|
|
|
61
62
|
def read(key, options = nil) # :nodoc:
|
|
62
|
-
super
|
|
63
|
-
|
|
63
|
+
super do
|
|
64
|
+
@data.get(key, raw?(options))
|
|
65
|
+
end
|
|
64
66
|
rescue MemCache::MemCacheError => e
|
|
65
|
-
logger.error("MemCacheError (#{e}): #{e.message}")
|
|
67
|
+
logger.error("MemCacheError (#{e}): #{e.message}") if logger
|
|
66
68
|
nil
|
|
67
69
|
end
|
|
68
70
|
|
|
69
71
|
# Writes a value to the cache.
|
|
70
72
|
#
|
|
71
73
|
# Possible options:
|
|
72
|
-
# -
|
|
74
|
+
# - <tt>:unless_exist</tt> - set to true if you don't want to update the cache
|
|
73
75
|
# if the key is already set.
|
|
74
|
-
# -
|
|
76
|
+
# - <tt>:expires_in</tt> - the number of seconds that this value may stay in
|
|
75
77
|
# the cache. See ActiveSupport::Cache::Store#write for an example.
|
|
76
78
|
def write(key, value, options = nil)
|
|
77
|
-
super
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
super do
|
|
80
|
+
method = options && options[:unless_exist] ? :add : :set
|
|
81
|
+
# memcache-client will break the connection if you send it an integer
|
|
82
|
+
# in raw mode, so we convert it to a string to be sure it continues working.
|
|
83
|
+
value = value.to_s if raw?(options)
|
|
84
|
+
response = @data.send(method, key, value, expires_in(options), raw?(options))
|
|
85
|
+
response == Response::STORED
|
|
86
|
+
end
|
|
84
87
|
rescue MemCache::MemCacheError => e
|
|
85
|
-
logger.error("MemCacheError (#{e}): #{e.message}")
|
|
88
|
+
logger.error("MemCacheError (#{e}): #{e.message}") if logger
|
|
86
89
|
false
|
|
87
90
|
end
|
|
88
91
|
|
|
89
92
|
def delete(key, options = nil) # :nodoc:
|
|
90
|
-
super
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
super do
|
|
94
|
+
response = @data.delete(key)
|
|
95
|
+
response == Response::DELETED
|
|
96
|
+
end
|
|
93
97
|
rescue MemCache::MemCacheError => e
|
|
94
|
-
logger.error("MemCacheError (#{e}): #{e.message}")
|
|
98
|
+
logger.error("MemCacheError (#{e}): #{e.message}") if logger
|
|
95
99
|
false
|
|
96
100
|
end
|
|
97
101
|
|
|
@@ -99,21 +103,26 @@ module ActiveSupport
|
|
|
99
103
|
# Doesn't call super, cause exist? in memcache is in fact a read
|
|
100
104
|
# But who cares? Reading is very fast anyway
|
|
101
105
|
# Local cache is checked first, if it doesn't know then memcache itself is read from
|
|
102
|
-
|
|
106
|
+
super do
|
|
107
|
+
!read(key, options).nil?
|
|
108
|
+
end
|
|
103
109
|
end
|
|
104
110
|
|
|
105
111
|
def increment(key, amount = 1) # :nodoc:
|
|
106
|
-
|
|
112
|
+
response = instrument(:increment, key, :amount => amount) do
|
|
113
|
+
@data.incr(key, amount)
|
|
114
|
+
end
|
|
107
115
|
|
|
108
|
-
response = @data.incr(key, amount)
|
|
109
116
|
response == Response::NOT_FOUND ? nil : response
|
|
110
117
|
rescue MemCache::MemCacheError
|
|
111
118
|
nil
|
|
112
119
|
end
|
|
113
120
|
|
|
114
121
|
def decrement(key, amount = 1) # :nodoc:
|
|
115
|
-
|
|
116
|
-
|
|
122
|
+
response = instrument(:decrement, key, :amount => amount) do
|
|
123
|
+
@data.decr(key, amount)
|
|
124
|
+
end
|
|
125
|
+
|
|
117
126
|
response == Response::NOT_FOUND ? nil : response
|
|
118
127
|
rescue MemCache::MemCacheError
|
|
119
128
|
nil
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'active_support/core_ext/object/duplicable'
|
|
2
|
+
|
|
1
3
|
module ActiveSupport
|
|
2
4
|
module Cache
|
|
3
5
|
# A cache store implementation which stores everything into memory in the
|
|
@@ -20,28 +22,33 @@ module ActiveSupport
|
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
def read(name, options = nil)
|
|
23
|
-
super
|
|
24
|
-
|
|
25
|
+
super do
|
|
26
|
+
@data[name]
|
|
27
|
+
end
|
|
25
28
|
end
|
|
26
29
|
|
|
27
30
|
def write(name, value, options = nil)
|
|
28
|
-
super
|
|
29
|
-
|
|
31
|
+
super do
|
|
32
|
+
@data[name] = (value.duplicable? ? value.dup : value).freeze
|
|
33
|
+
end
|
|
30
34
|
end
|
|
31
35
|
|
|
32
36
|
def delete(name, options = nil)
|
|
33
|
-
super
|
|
34
|
-
|
|
37
|
+
super do
|
|
38
|
+
@data.delete(name)
|
|
39
|
+
end
|
|
35
40
|
end
|
|
36
41
|
|
|
37
42
|
def delete_matched(matcher, options = nil)
|
|
38
|
-
super
|
|
39
|
-
|
|
43
|
+
super do
|
|
44
|
+
@data.delete_if { |k,v| k =~ matcher }
|
|
45
|
+
end
|
|
40
46
|
end
|
|
41
47
|
|
|
42
48
|
def exist?(name,options = nil)
|
|
43
|
-
super
|
|
44
|
-
|
|
49
|
+
super do
|
|
50
|
+
@data.has_key?(name)
|
|
51
|
+
end
|
|
45
52
|
end
|
|
46
53
|
|
|
47
54
|
def clear
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
require 'active_support/core_ext/object/duplicable'
|
|
2
|
+
require 'active_support/core_ext/string/inflections'
|
|
3
|
+
|
|
1
4
|
module ActiveSupport
|
|
2
5
|
module Cache
|
|
3
6
|
module Strategy
|
|
@@ -15,7 +18,7 @@ module ActiveSupport
|
|
|
15
18
|
def middleware
|
|
16
19
|
@middleware ||= begin
|
|
17
20
|
klass = Class.new
|
|
18
|
-
klass.class_eval(<<-EOS, __FILE__, __LINE__)
|
|
21
|
+
klass.class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
|
19
22
|
def initialize(app)
|
|
20
23
|
@app = app
|
|
21
24
|
end
|
|
@@ -27,6 +30,11 @@ module ActiveSupport
|
|
|
27
30
|
Thread.current[:#{thread_local_key}] = nil
|
|
28
31
|
end
|
|
29
32
|
EOS
|
|
33
|
+
|
|
34
|
+
def klass.to_s
|
|
35
|
+
"ActiveSupport::Cache::Strategy::LocalCache"
|
|
36
|
+
end
|
|
37
|
+
|
|
30
38
|
klass
|
|
31
39
|
end
|
|
32
40
|
end
|