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,6 +1,4 @@
|
|
1
1
|
require 'active_support/inflector'
|
2
|
-
require 'active_support/core_ext/time/conversions'
|
3
|
-
require 'active_support/core_ext/date_time/calculations'
|
4
2
|
|
5
3
|
class DateTime
|
6
4
|
# Ruby 1.9 has DateTime#to_time which internally relies on Time. We define our own #to_time which allows
|
@@ -60,7 +58,7 @@ class DateTime
|
|
60
58
|
# Converts self to a Ruby Date object; time portion is discarded
|
61
59
|
def to_date
|
62
60
|
::Date.new(year, month, day)
|
63
|
-
end unless
|
61
|
+
end unless method_defined?(:to_date)
|
64
62
|
|
65
63
|
# Attempts to convert self to a Ruby Time object; returns self if out of range of Ruby Time class
|
66
64
|
# If self has an offset other than 0, self will just be returned unaltered, since there's no clean way to map it to a Time
|
@@ -71,32 +69,16 @@ class DateTime
|
|
71
69
|
# To be able to keep Times, Dates and DateTimes interchangeable on conversions
|
72
70
|
def to_datetime
|
73
71
|
self
|
74
|
-
end unless
|
75
|
-
|
76
|
-
def self.civil_from_format(utc_or_local, year, month=1, day=1, hour=0, min=0, sec=0)
|
77
|
-
offset = utc_or_local.to_sym == :local ? local_offset : 0
|
78
|
-
civil(year, month, day, hour, min, sec, offset)
|
79
|
-
end
|
72
|
+
end unless method_defined?(:to_datetime)
|
80
73
|
|
81
74
|
# Converts datetime to an appropriate format for use in XML
|
82
75
|
def xmlschema
|
83
76
|
strftime("%Y-%m-%dT%H:%M:%S%Z")
|
84
|
-
end unless
|
77
|
+
end unless method_defined?(:xmlschema)
|
85
78
|
|
86
79
|
# Converts self to a floating-point number of seconds since the Unix epoch
|
87
80
|
def to_f
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
# Converts self to an integer number of seconds since the Unix epoch
|
92
|
-
def to_i
|
93
|
-
seconds_since_unix_epoch.to_i
|
94
|
-
end
|
95
|
-
|
96
|
-
private
|
97
|
-
|
98
|
-
def seconds_since_unix_epoch
|
99
|
-
seconds_per_day = 86_400
|
100
|
-
(self - ::DateTime.civil(1970)) * seconds_per_day
|
81
|
+
days_since_unix_epoch = self - ::DateTime.civil(1970)
|
82
|
+
(days_since_unix_epoch * 86_400).to_f
|
101
83
|
end
|
102
84
|
end
|
@@ -101,11 +101,15 @@ module Enumerable
|
|
101
101
|
size = block_given? ? select(&block).size : self.size
|
102
102
|
size > 1
|
103
103
|
end
|
104
|
-
|
105
|
-
#
|
106
|
-
|
107
|
-
|
108
|
-
|
104
|
+
|
105
|
+
# Returns true if none of the elements match the given block.
|
106
|
+
#
|
107
|
+
# success = responses.none? {|r| r.status / 100 == 5 }
|
108
|
+
#
|
109
|
+
# This is a builtin method in Ruby 1.8.7 and later.
|
110
|
+
def none?(&block)
|
111
|
+
!any?(&block)
|
112
|
+
end unless [].respond_to?(:none?)
|
109
113
|
end
|
110
114
|
|
111
115
|
class Range #:nodoc:
|
@@ -1,3 +1,50 @@
|
|
1
1
|
module ActiveSupport
|
2
2
|
FrozenObjectError = RUBY_VERSION < '1.9' ? TypeError : RuntimeError
|
3
3
|
end
|
4
|
+
|
5
|
+
# TODO: Turn all this into using the BacktraceCleaner.
|
6
|
+
class Exception # :nodoc:
|
7
|
+
# Clean the paths contained in the message.
|
8
|
+
def self.clean_paths(string)
|
9
|
+
require 'pathname' unless defined? Pathname
|
10
|
+
string.gsub(%r{[\w. ]+(/[\w. ]+)+(\.rb)?(\b|$)}) do |path|
|
11
|
+
Pathname.new(path).cleanpath
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def clean_message
|
16
|
+
Exception.clean_paths(message)
|
17
|
+
end
|
18
|
+
|
19
|
+
TraceSubstitutions = []
|
20
|
+
FrameworkStart = /action_controller\/dispatcher\.rb/.freeze
|
21
|
+
FrameworkRegexp = /generated|vendor|dispatch|ruby|script\/\w+/.freeze
|
22
|
+
|
23
|
+
def clean_backtrace
|
24
|
+
backtrace.collect do |line|
|
25
|
+
substituted = TraceSubstitutions.inject(line) do |result, (regexp, sub)|
|
26
|
+
result.gsub regexp, sub
|
27
|
+
end
|
28
|
+
Exception.clean_paths(substituted)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def application_backtrace
|
33
|
+
before_framework_frame = nil
|
34
|
+
before_application_frame = true
|
35
|
+
|
36
|
+
trace = clean_backtrace.reject do |line|
|
37
|
+
before_framework_frame ||= (line =~ FrameworkStart)
|
38
|
+
non_app_frame = (line =~ FrameworkRegexp)
|
39
|
+
before_application_frame = false unless non_app_frame
|
40
|
+
before_framework_frame || (non_app_frame && !before_application_frame)
|
41
|
+
end
|
42
|
+
|
43
|
+
# If we didn't find any application frames, return an empty app trace.
|
44
|
+
before_application_frame ? [] : trace
|
45
|
+
end
|
46
|
+
|
47
|
+
def framework_backtrace
|
48
|
+
clean_backtrace.grep FrameworkRegexp
|
49
|
+
end
|
50
|
+
end
|
@@ -9,12 +9,11 @@ class File
|
|
9
9
|
# If your temp directory is not on the same filesystem as the file you're
|
10
10
|
# trying to write, you can provide a different temporary directory.
|
11
11
|
#
|
12
|
-
# File.atomic_write("/data/something.important", "/data/tmp") do |
|
12
|
+
# File.atomic_write("/data/something.important", "/data/tmp") do |f|
|
13
13
|
# file.write("hello")
|
14
14
|
# end
|
15
15
|
def self.atomic_write(file_name, temp_dir = Dir.tmpdir)
|
16
16
|
require 'tempfile' unless defined?(Tempfile)
|
17
|
-
require 'fileutils' unless defined?(FileUtils)
|
18
17
|
|
19
18
|
temp_file = Tempfile.new(basename(file_name), temp_dir)
|
20
19
|
yield temp_file
|
@@ -32,7 +31,7 @@ class File
|
|
32
31
|
end
|
33
32
|
|
34
33
|
# Overwrite original file with temp file
|
35
|
-
|
34
|
+
rename(temp_file.path, file_name)
|
36
35
|
|
37
36
|
# Set correct permissions on new file
|
38
37
|
chown(old_stat.uid, old_stat.gid, file_name)
|
@@ -1,6 +1,5 @@
|
|
1
1
|
class Float
|
2
|
-
|
3
|
-
private :precisionless_round
|
2
|
+
remove_method :round
|
4
3
|
|
5
4
|
# Rounds the float with the specified precision.
|
6
5
|
#
|
@@ -13,7 +12,7 @@ class Float
|
|
13
12
|
magnitude = 10.0 ** precision
|
14
13
|
(self * magnitude).round / magnitude
|
15
14
|
else
|
16
|
-
|
15
|
+
super()
|
17
16
|
end
|
18
17
|
end
|
19
18
|
end
|
@@ -1,76 +1,148 @@
|
|
1
|
-
require 'active_support/xml_mini'
|
2
1
|
require 'active_support/time'
|
3
|
-
require 'active_support/core_ext/
|
2
|
+
require 'active_support/core_ext/object/conversions'
|
3
|
+
require 'active_support/core_ext/array/conversions'
|
4
4
|
require 'active_support/core_ext/hash/reverse_merge'
|
5
|
-
require 'active_support/core_ext/object/blank'
|
6
|
-
require 'active_support/core_ext/string/inflections'
|
7
5
|
|
8
6
|
class Hash
|
9
|
-
#
|
10
|
-
#
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
7
|
+
# This module exists to decorate files deserialized using Hash.from_xml with
|
8
|
+
# the <tt>original_filename</tt> and <tt>content_type</tt> methods.
|
9
|
+
module FileLike #:nodoc:
|
10
|
+
attr_writer :original_filename, :content_type
|
11
|
+
|
12
|
+
def original_filename
|
13
|
+
@original_filename || 'untitled'
|
14
|
+
end
|
15
|
+
|
16
|
+
def content_type
|
17
|
+
@content_type || 'application/octet-stream'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
XML_TYPE_NAMES = {
|
22
|
+
"Symbol" => "symbol",
|
23
|
+
"Fixnum" => "integer",
|
24
|
+
"Bignum" => "integer",
|
25
|
+
"BigDecimal" => "decimal",
|
26
|
+
"Float" => "float",
|
27
|
+
"TrueClass" => "boolean",
|
28
|
+
"FalseClass" => "boolean",
|
29
|
+
"Date" => "date",
|
30
|
+
"DateTime" => "datetime",
|
31
|
+
"Time" => "datetime"
|
32
|
+
} unless defined?(XML_TYPE_NAMES)
|
33
|
+
|
34
|
+
XML_FORMATTING = {
|
35
|
+
"symbol" => Proc.new { |symbol| symbol.to_s },
|
36
|
+
"date" => Proc.new { |date| date.to_s(:db) },
|
37
|
+
"datetime" => Proc.new { |time| time.xmlschema },
|
38
|
+
"binary" => Proc.new { |binary| ActiveSupport::Base64.encode64(binary) },
|
39
|
+
"yaml" => Proc.new { |yaml| yaml.to_yaml }
|
40
|
+
} unless defined?(XML_FORMATTING)
|
41
|
+
|
42
|
+
# TODO: use Time.xmlschema instead of Time.parse;
|
43
|
+
# use regexp instead of Date.parse
|
44
|
+
unless defined?(XML_PARSING)
|
45
|
+
XML_PARSING = {
|
46
|
+
"symbol" => Proc.new { |symbol| symbol.to_sym },
|
47
|
+
"date" => Proc.new { |date| ::Date.parse(date) },
|
48
|
+
"datetime" => Proc.new { |time| ::Time.parse(time).utc rescue ::DateTime.parse(time).utc },
|
49
|
+
"integer" => Proc.new { |integer| integer.to_i },
|
50
|
+
"float" => Proc.new { |float| float.to_f },
|
51
|
+
"decimal" => Proc.new { |number| BigDecimal(number) },
|
52
|
+
"boolean" => Proc.new { |boolean| %w(1 true).include?(boolean.strip) },
|
53
|
+
"string" => Proc.new { |string| string.to_s },
|
54
|
+
"yaml" => Proc.new { |yaml| YAML::load(yaml) rescue yaml },
|
55
|
+
"base64Binary" => Proc.new { |bin| ActiveSupport::Base64.decode64(bin) },
|
56
|
+
"file" => Proc.new do |file, entity|
|
57
|
+
f = StringIO.new(ActiveSupport::Base64.decode64(file))
|
58
|
+
f.extend(FileLike)
|
59
|
+
f.original_filename = entity['name']
|
60
|
+
f.content_type = entity['content_type']
|
61
|
+
f
|
62
|
+
end
|
63
|
+
}
|
64
|
+
|
65
|
+
XML_PARSING.update(
|
66
|
+
"double" => XML_PARSING["float"],
|
67
|
+
"dateTime" => XML_PARSING["datetime"]
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Converts a hash into a string suitable for use as a URL query string. An optional <tt>namespace</tt> can be
|
72
|
+
# passed to enclose the param names (see example below).
|
38
73
|
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
#
|
52
|
-
# By default the root node is "hash", but that's configurable via the <tt>:root</tt> option.
|
53
|
-
#
|
54
|
-
# The default XML builder is a fresh instance of <tt>Builder::XmlMarkup</tt>. You can
|
55
|
-
# configure your own builder with the <tt>:builder</tt> option. The method also accepts
|
56
|
-
# options like <tt>:dasherize</tt> and friends, they are forwarded to the builder.
|
74
|
+
# ==== Examples
|
75
|
+
# { :name => 'David', :nationality => 'Danish' }.to_query # => "name=David&nationality=Danish"
|
76
|
+
#
|
77
|
+
# { :name => 'David', :nationality => 'Danish' }.to_query('user') # => "user%5Bname%5D=David&user%5Bnationality%5D=Danish"
|
78
|
+
def to_query(namespace = nil)
|
79
|
+
collect do |key, value|
|
80
|
+
value.to_query(namespace ? "#{namespace}[#{key}]" : key)
|
81
|
+
end.sort * '&'
|
82
|
+
end
|
83
|
+
|
84
|
+
alias_method :to_param, :to_query
|
85
|
+
|
57
86
|
def to_xml(options = {})
|
58
|
-
require '
|
87
|
+
require 'builder' unless defined?(Builder)
|
59
88
|
|
60
89
|
options = options.dup
|
61
|
-
options[:indent]
|
62
|
-
options[:
|
63
|
-
|
90
|
+
options[:indent] ||= 2
|
91
|
+
options.reverse_merge!({ :builder => Builder::XmlMarkup.new(:indent => options[:indent]),
|
92
|
+
:root => "hash" })
|
93
|
+
options[:builder].instruct! unless options.delete(:skip_instruct)
|
94
|
+
root = rename_key(options[:root].to_s, options)
|
64
95
|
|
65
|
-
|
66
|
-
|
96
|
+
options[:builder].__send__(:method_missing, root) do
|
97
|
+
each do |key, value|
|
98
|
+
case value
|
99
|
+
when ::Hash
|
100
|
+
value.to_xml(options.merge({ :root => key, :skip_instruct => true }))
|
101
|
+
when ::Array
|
102
|
+
value.to_xml(options.merge({ :root => key, :children => key.to_s.singularize, :skip_instruct => true}))
|
103
|
+
when ::Method, ::Proc
|
104
|
+
# If the Method or Proc takes two arguments, then
|
105
|
+
# pass the suggested child element name. This is
|
106
|
+
# used if the Method or Proc will be operating over
|
107
|
+
# multiple records and needs to create an containing
|
108
|
+
# element that will contain the objects being
|
109
|
+
# serialized.
|
110
|
+
if 1 == value.arity
|
111
|
+
value.call(options.merge({ :root => key, :skip_instruct => true }))
|
112
|
+
else
|
113
|
+
value.call(options.merge({ :root => key, :skip_instruct => true }), key.to_s.singularize)
|
114
|
+
end
|
115
|
+
else
|
116
|
+
if value.respond_to?(:to_xml)
|
117
|
+
value.to_xml(options.merge({ :root => key, :skip_instruct => true }))
|
118
|
+
else
|
119
|
+
type_name = XML_TYPE_NAMES[value.class.name]
|
67
120
|
|
68
|
-
|
121
|
+
key = rename_key(key.to_s, options)
|
69
122
|
|
70
|
-
|
71
|
-
|
72
|
-
|
123
|
+
attributes = options[:skip_types] || value.nil? || type_name.nil? ? { } : { :type => type_name }
|
124
|
+
if value.nil?
|
125
|
+
attributes[:nil] = true
|
126
|
+
end
|
127
|
+
|
128
|
+
options[:builder].tag!(key,
|
129
|
+
XML_FORMATTING[type_name] ? XML_FORMATTING[type_name].call(value) : value,
|
130
|
+
attributes
|
131
|
+
)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
yield options[:builder] if block_given?
|
73
137
|
end
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
def rename_key(key, options = {})
|
142
|
+
camelize = options.has_key?(:camelize) && options[:camelize]
|
143
|
+
dasherize = !options.has_key?(:dasherize) || options[:dasherize]
|
144
|
+
key = key.camelize if camelize
|
145
|
+
dasherize ? key.dasherize : key
|
74
146
|
end
|
75
147
|
|
76
148
|
class << self
|
@@ -83,7 +155,7 @@ class Hash
|
|
83
155
|
case value.class.to_s
|
84
156
|
when 'Hash'
|
85
157
|
if value['type'] == 'array'
|
86
|
-
child_key, entries =
|
158
|
+
child_key, entries = value.detect { |k,v| k != 'type' } # child_key is throwaway
|
87
159
|
if entries.nil? || (c = value['__content__'] && c.blank?)
|
88
160
|
[]
|
89
161
|
else
|
@@ -98,8 +170,12 @@ class Hash
|
|
98
170
|
end
|
99
171
|
elsif value.has_key?("__content__")
|
100
172
|
content = value["__content__"]
|
101
|
-
if parser =
|
102
|
-
parser.arity ==
|
173
|
+
if parser = XML_PARSING[value["type"]]
|
174
|
+
if parser.arity == 2
|
175
|
+
XML_PARSING[value["type"]].call(content, value)
|
176
|
+
else
|
177
|
+
XML_PARSING[value["type"]].call(content)
|
178
|
+
end
|
103
179
|
else
|
104
180
|
content
|
105
181
|
end
|
@@ -125,7 +201,11 @@ class Hash
|
|
125
201
|
end
|
126
202
|
when 'Array'
|
127
203
|
value.map! { |i| typecast_xml_value(i) }
|
128
|
-
value.length
|
204
|
+
case value.length
|
205
|
+
when 0 then nil
|
206
|
+
when 1 then value.first
|
207
|
+
else value
|
208
|
+
end
|
129
209
|
when 'String'
|
130
210
|
value
|
131
211
|
else
|
@@ -1,16 +1,17 @@
|
|
1
1
|
class Hash
|
2
2
|
# Returns a new hash with +self+ and +other_hash+ merged recursively.
|
3
3
|
def deep_merge(other_hash)
|
4
|
-
dup
|
4
|
+
target = dup
|
5
|
+
other_hash.each_pair do |k,v|
|
6
|
+
tv = target[k]
|
7
|
+
target[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_merge(v) : v
|
8
|
+
end
|
9
|
+
target
|
5
10
|
end
|
6
11
|
|
7
12
|
# Returns a new hash with +self+ and +other_hash+ merged recursively.
|
8
13
|
# Modifies the receiver in place.
|
9
14
|
def deep_merge!(other_hash)
|
10
|
-
other_hash
|
11
|
-
tv = self[k]
|
12
|
-
self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_merge(v) : v
|
13
|
-
end
|
14
|
-
self
|
15
|
+
replace(deep_merge(other_hash))
|
15
16
|
end
|
16
17
|
end
|