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,22 +1,18 @@
|
|
1
1
|
class Array
|
2
2
|
# Wraps the object in an Array unless it's an Array. Converts the
|
3
3
|
# object to an Array using #to_ary if it implements that.
|
4
|
-
#
|
5
|
-
# It differs with Array() in that it does not call +to_a+ on
|
6
|
-
# the argument:
|
7
|
-
#
|
8
|
-
# Array(:foo => :bar) # => [[:foo, :bar]]
|
9
|
-
# Array.wrap(:foo => :bar) # => [{:foo => :bar}]
|
10
|
-
#
|
11
|
-
# Array("foo\nbar") # => ["foo\n", "bar"], in Ruby 1.8
|
12
|
-
# Array.wrap("foo\nbar") # => ["foo\nbar"]
|
13
4
|
def self.wrap(object)
|
14
|
-
|
5
|
+
case object
|
6
|
+
when nil
|
15
7
|
[]
|
16
|
-
|
17
|
-
object
|
8
|
+
when self
|
9
|
+
object
|
18
10
|
else
|
19
|
-
|
11
|
+
if object.respond_to?(:to_ary)
|
12
|
+
object.to_ary
|
13
|
+
else
|
14
|
+
[object]
|
15
|
+
end
|
20
16
|
end
|
21
17
|
end
|
22
18
|
end
|
@@ -1,6 +1,18 @@
|
|
1
1
|
require 'benchmark'
|
2
2
|
|
3
3
|
class << Benchmark
|
4
|
+
# Earlier Ruby had a slower implementation.
|
5
|
+
if RUBY_VERSION < '1.8.7'
|
6
|
+
remove_method :realtime
|
7
|
+
|
8
|
+
def realtime
|
9
|
+
r0 = Time.now
|
10
|
+
yield
|
11
|
+
r1 = Time.now
|
12
|
+
r1.to_f - r0.to_f
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
4
16
|
def ms
|
5
17
|
1000 * realtime { yield }
|
6
18
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'active_support/core_ext/boolean/conversions'
|
@@ -1,4 +1,4 @@
|
|
1
1
|
require 'active_support/core_ext/class/attribute_accessors'
|
2
2
|
require 'active_support/core_ext/class/inheritable_attributes'
|
3
|
+
require 'active_support/core_ext/class/removal'
|
3
4
|
require 'active_support/core_ext/class/delegating_attributes'
|
4
|
-
require 'active_support/core_ext/class/subclasses'
|
@@ -10,48 +10,42 @@ require 'active_support/core_ext/array/extract_options'
|
|
10
10
|
# Person.hair_colors = [:brown, :black, :blonde, :red]
|
11
11
|
class Class
|
12
12
|
def cattr_reader(*syms)
|
13
|
-
|
14
|
-
|
13
|
+
syms.flatten.each do |sym|
|
14
|
+
next if sym.is_a?(Hash)
|
15
15
|
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
16
|
-
unless defined? @@#{sym}
|
17
|
-
@@#{sym} = nil
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.#{sym}
|
21
|
-
@@#{sym}
|
22
|
-
end
|
16
|
+
unless defined? @@#{sym} # unless defined? @@hair_colors
|
17
|
+
@@#{sym} = nil # @@hair_colors = nil
|
18
|
+
end # end
|
19
|
+
#
|
20
|
+
def self.#{sym} # def self.hair_colors
|
21
|
+
@@#{sym} # @@hair_colors
|
22
|
+
end # end
|
23
|
+
#
|
24
|
+
def #{sym} # def hair_colors
|
25
|
+
@@#{sym} # @@hair_colors
|
26
|
+
end # end
|
23
27
|
EOS
|
24
|
-
|
25
|
-
unless options[:instance_reader] == false
|
26
|
-
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
27
|
-
def #{sym}
|
28
|
-
@@#{sym}
|
29
|
-
end
|
30
|
-
EOS
|
31
|
-
end
|
32
28
|
end
|
33
29
|
end
|
34
30
|
|
35
31
|
def cattr_writer(*syms)
|
36
32
|
options = syms.extract_options!
|
37
|
-
syms.each do |sym|
|
33
|
+
syms.flatten.each do |sym|
|
38
34
|
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
39
|
-
unless defined? @@#{sym}
|
40
|
-
@@#{sym} = nil
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.#{sym}=(obj)
|
44
|
-
@@#{sym} = obj
|
45
|
-
end
|
35
|
+
unless defined? @@#{sym} # unless defined? @@hair_colors
|
36
|
+
@@#{sym} = nil # @@hair_colors = nil
|
37
|
+
end # end
|
38
|
+
#
|
39
|
+
def self.#{sym}=(obj) # def self.hair_colors=(obj)
|
40
|
+
@@#{sym} = obj # @@hair_colors = obj
|
41
|
+
end # end
|
42
|
+
#
|
43
|
+
#{" #
|
44
|
+
def #{sym}=(obj) # def hair_colors=(obj)
|
45
|
+
@@#{sym} = obj # @@hair_colors = obj
|
46
|
+
end # end
|
47
|
+
" unless options[:instance_writer] == false } # # instance writer above is generated unless options[:instance_writer] == false
|
46
48
|
EOS
|
47
|
-
|
48
|
-
unless options[:instance_writer] == false
|
49
|
-
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
50
|
-
def #{sym}=(obj)
|
51
|
-
@@#{sym} = obj
|
52
|
-
end
|
53
|
-
EOS
|
54
|
-
end
|
55
49
|
self.send("#{sym}=", yield) if block_given?
|
56
50
|
end
|
57
51
|
end
|
@@ -1,44 +1,50 @@
|
|
1
1
|
require 'active_support/core_ext/object/blank'
|
2
|
-
require 'active_support/core_ext/array/extract_options'
|
3
|
-
require 'active_support/core_ext/kernel/singleton_class'
|
4
|
-
require 'active_support/core_ext/module/remove_method'
|
5
2
|
|
6
3
|
class Class
|
7
|
-
def
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
def _stash_object_in_method(object, method, instance_reader = true)
|
31
|
-
singleton_class.remove_possible_method(method)
|
32
|
-
singleton_class.send(:define_method, method) { object }
|
33
|
-
remove_possible_method(method)
|
34
|
-
define_method(method) { object } if instance_reader
|
4
|
+
def superclass_delegating_reader(*names)
|
5
|
+
class_name_to_stop_searching_on = superclass.name.blank? ? "Object" : superclass.name
|
6
|
+
names.each do |name|
|
7
|
+
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
8
|
+
def self.#{name} # def self.only_reader
|
9
|
+
if defined?(@#{name}) # if defined?(@only_reader)
|
10
|
+
@#{name} # @only_reader
|
11
|
+
elsif superclass < #{class_name_to_stop_searching_on} && # elsif superclass < Object &&
|
12
|
+
superclass.respond_to?(:#{name}) # superclass.respond_to?(:only_reader)
|
13
|
+
superclass.#{name} # superclass.only_reader
|
14
|
+
end # end
|
15
|
+
end # end
|
16
|
+
def #{name} # def only_reader
|
17
|
+
self.class.#{name} # self.class.only_reader
|
18
|
+
end # end
|
19
|
+
def self.#{name}? # def self.only_reader?
|
20
|
+
!!#{name} # !!only_reader
|
21
|
+
end # end
|
22
|
+
def #{name}? # def only_reader?
|
23
|
+
!!#{name} # !!only_reader
|
24
|
+
end # end
|
25
|
+
EOS
|
26
|
+
end
|
35
27
|
end
|
36
28
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
29
|
+
def superclass_delegating_writer(*names, &block)
|
30
|
+
names.each do |name|
|
31
|
+
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
32
|
+
def self.#{name}=(value) # def self.property=(value)
|
33
|
+
@#{name} = value # @property = value
|
34
|
+
end # end
|
35
|
+
EOS
|
36
|
+
self.send("#{name}=", yield) if block_given?
|
40
37
|
end
|
41
|
-
send("#{name}=", nil)
|
42
38
|
end
|
43
39
|
|
40
|
+
# These class attributes behave something like the class
|
41
|
+
# inheritable accessors. But instead of copying the hash over at
|
42
|
+
# the time the subclass is first defined, the accessors simply
|
43
|
+
# delegate to their superclass unless they have been given a
|
44
|
+
# specific value. This stops the strange situation where values
|
45
|
+
# set after class definition don't get applied to subclasses.
|
46
|
+
def superclass_delegating_accessor(*names, &block)
|
47
|
+
superclass_delegating_reader(*names)
|
48
|
+
superclass_delegating_writer(*names, &block)
|
49
|
+
end
|
44
50
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'active_support/core_ext/object/duplicable'
|
2
|
-
require 'active_support/core_ext/array/extract_options'
|
3
2
|
|
4
3
|
# Retain for backward compatibility. Methods are now included in Class.
|
5
4
|
module ClassInheritableAttributes # :nodoc:
|
@@ -9,24 +8,18 @@ end
|
|
9
8
|
# their parents' attributes, instead of just a pointer to the same. This means that the child can add elements
|
10
9
|
# to, for example, an array without those additions being shared with either their parent, siblings, or
|
11
10
|
# children, which is unlike the regular class-level attributes that are shared across the entire hierarchy.
|
12
|
-
#
|
13
|
-
# The copies of inheritable parent attributes are added to subclasses when they are created, via the
|
14
|
-
# +inherited+ hook.
|
15
11
|
class Class # :nodoc:
|
16
12
|
def class_inheritable_reader(*syms)
|
17
|
-
options = syms.extract_options!
|
18
13
|
syms.each do |sym|
|
19
14
|
next if sym.is_a?(Hash)
|
20
15
|
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
21
|
-
def self.#{sym}
|
22
|
-
read_inheritable_attribute(:#{sym})
|
23
|
-
end
|
24
|
-
|
25
|
-
#{
|
26
|
-
|
27
|
-
|
28
|
-
end # end
|
29
|
-
" unless options[:instance_reader] == false } # # the reader above is generated unless options[:instance_reader] == false
|
16
|
+
def self.#{sym} # def self.after_add
|
17
|
+
read_inheritable_attribute(:#{sym}) # read_inheritable_attribute(:after_add)
|
18
|
+
end # end
|
19
|
+
|
20
|
+
def #{sym} # def after_add
|
21
|
+
self.class.#{sym} # self.class.after_add
|
22
|
+
end # end
|
30
23
|
EOS
|
31
24
|
end
|
32
25
|
end
|
@@ -162,8 +155,8 @@ class Class
|
|
162
155
|
# (error out or do the same as other methods above) instead of silently
|
163
156
|
# moving on). In particular, this makes the return value of this function
|
164
157
|
# less useful.
|
165
|
-
def extlib_inheritable_reader(*ivars
|
166
|
-
|
158
|
+
def extlib_inheritable_reader(*ivars)
|
159
|
+
instance_reader = ivars.pop[:reader] if ivars.last.is_a?(Hash)
|
167
160
|
|
168
161
|
ivars.each do |ivar|
|
169
162
|
self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
@@ -171,17 +164,16 @@ class Class
|
|
171
164
|
return @#{ivar} if self.object_id == #{self.object_id} || defined?(@#{ivar})
|
172
165
|
ivar = superclass.#{ivar}
|
173
166
|
return nil if ivar.nil? && !#{self}.instance_variable_defined?("@#{ivar}")
|
174
|
-
@#{ivar} = ivar.
|
167
|
+
@#{ivar} = ivar && !ivar.is_a?(Module) && !ivar.is_a?(Numeric) && !ivar.is_a?(TrueClass) && !ivar.is_a?(FalseClass) ? ivar.dup : ivar
|
175
168
|
end
|
176
169
|
RUBY
|
177
|
-
unless
|
170
|
+
unless instance_reader == false
|
178
171
|
self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
179
172
|
def #{ivar}
|
180
173
|
self.class.#{ivar}
|
181
174
|
end
|
182
175
|
RUBY
|
183
176
|
end
|
184
|
-
instance_variable_set(:"@#{ivar}", yield) if block_given?
|
185
177
|
end
|
186
178
|
end
|
187
179
|
|
@@ -198,15 +190,14 @@ class Class
|
|
198
190
|
# @todo We need a style for class_eval <<-HEREDOC. I'd like to make it
|
199
191
|
# class_eval(<<-RUBY, __FILE__, __LINE__), but we should codify it somewhere.
|
200
192
|
def extlib_inheritable_writer(*ivars)
|
201
|
-
|
202
|
-
|
193
|
+
instance_writer = ivars.pop[:writer] if ivars.last.is_a?(Hash)
|
203
194
|
ivars.each do |ivar|
|
204
195
|
self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
205
196
|
def self.#{ivar}=(obj)
|
206
197
|
@#{ivar} = obj
|
207
198
|
end
|
208
199
|
RUBY
|
209
|
-
unless
|
200
|
+
unless instance_writer == false
|
210
201
|
self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
211
202
|
def #{ivar}=(obj) self.class.#{ivar} = obj end
|
212
203
|
RUBY
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'active_support/core_ext/object/extending'
|
2
|
+
require 'active_support/core_ext/module/introspection'
|
3
|
+
|
4
|
+
class Class #:nodoc:
|
5
|
+
|
6
|
+
# Unassociates the class with its subclasses and removes the subclasses
|
7
|
+
# themselves.
|
8
|
+
#
|
9
|
+
# Integer.remove_subclasses # => [Bignum, Fixnum]
|
10
|
+
# Fixnum # => NameError: uninitialized constant Fixnum
|
11
|
+
def remove_subclasses
|
12
|
+
Object.remove_subclasses_of(self)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Returns an array with the names of the subclasses of +self+ as strings.
|
16
|
+
#
|
17
|
+
# Integer.subclasses # => ["Bignum", "Fixnum"]
|
18
|
+
def subclasses
|
19
|
+
Object.subclasses_of(self).map { |o| o.to_s }
|
20
|
+
end
|
21
|
+
|
22
|
+
# Removes the classes in +klasses+ from their parent module.
|
23
|
+
#
|
24
|
+
# Ordinary classes belong to some module via a constant. This method computes
|
25
|
+
# that constant name from the class name and removes it from the module it
|
26
|
+
# belongs to.
|
27
|
+
#
|
28
|
+
# Object.remove_class(Integer) # => [Integer]
|
29
|
+
# Integer # => NameError: uninitialized constant Integer
|
30
|
+
#
|
31
|
+
# Take into account that in general the class object could be still stored
|
32
|
+
# somewhere else.
|
33
|
+
#
|
34
|
+
# i = Integer # => Integer
|
35
|
+
# Object.remove_class(Integer) # => [Integer]
|
36
|
+
# Integer # => NameError: uninitialized constant Integer
|
37
|
+
# i.subclasses # => ["Bignum", "Fixnum"]
|
38
|
+
# Fixnum.superclass # => Integer
|
39
|
+
def remove_class(*klasses)
|
40
|
+
klasses.flatten.each do |klass|
|
41
|
+
# Skip this class if there is nothing bound to this name
|
42
|
+
next unless defined?(klass.name)
|
43
|
+
|
44
|
+
basename = klass.to_s.split("::").last
|
45
|
+
parent = klass.parent
|
46
|
+
|
47
|
+
# Skip this class if it does not match the current one bound to this name
|
48
|
+
next unless parent.const_defined?(basename) && klass = parent.const_get(basename)
|
49
|
+
|
50
|
+
parent.instance_eval { remove_const basename } unless parent == klass
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -1,36 +1,15 @@
|
|
1
|
-
require 'date'
|
2
1
|
require 'active_support/duration'
|
3
|
-
require 'active_support/core_ext/time/zones'
|
4
|
-
require 'active_support/core_ext/object/acts_like'
|
5
2
|
|
6
3
|
class Date
|
7
|
-
if RUBY_VERSION < '1.9'
|
8
|
-
undef :>>
|
9
|
-
|
10
|
-
# Backported from 1.9. The one in 1.8 leads to incorrect next_month and
|
11
|
-
# friends for dates where the calendar reform is involved. It additionally
|
12
|
-
# prevents an infinite loop fixed in r27013.
|
13
|
-
def >>(n)
|
14
|
-
y, m = (year * 12 + (mon - 1) + n).divmod(12)
|
15
|
-
m, = (m + 1) .divmod(1)
|
16
|
-
d = mday
|
17
|
-
until jd2 = self.class.valid_civil?(y, m, d, start)
|
18
|
-
d -= 1
|
19
|
-
raise ArgumentError, 'invalid date' unless d > 0
|
20
|
-
end
|
21
|
-
self + (jd2 - jd)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
4
|
class << self
|
26
5
|
# Returns a new Date representing the date 1 day ago (i.e. yesterday's date).
|
27
6
|
def yesterday
|
28
|
-
::Date.
|
7
|
+
::Date.today.yesterday
|
29
8
|
end
|
30
9
|
|
31
10
|
# Returns a new Date representing the date 1 day after today (i.e. tomorrow's date).
|
32
11
|
def tomorrow
|
33
|
-
::Date.
|
12
|
+
::Date.today.tomorrow
|
34
13
|
end
|
35
14
|
|
36
15
|
# Returns Time.zone.today when config.time_zone is set, otherwise just returns Date.today.
|
@@ -146,20 +125,20 @@ class Date
|
|
146
125
|
advance(:years => years)
|
147
126
|
end
|
148
127
|
|
149
|
-
#
|
150
|
-
def
|
128
|
+
# Short-hand for years_ago(1)
|
129
|
+
def last_year
|
151
130
|
years_ago(1)
|
152
|
-
end
|
131
|
+
end
|
153
132
|
|
154
133
|
# Short-hand for years_since(1)
|
155
134
|
def next_year
|
156
135
|
years_since(1)
|
157
136
|
end unless method_defined?(:next_year)
|
158
|
-
|
137
|
+
|
159
138
|
# Short-hand for months_ago(1)
|
160
|
-
def
|
139
|
+
def last_month
|
161
140
|
months_ago(1)
|
162
|
-
end
|
141
|
+
end
|
163
142
|
|
164
143
|
# Short-hand for months_since(1)
|
165
144
|
def next_month
|
@@ -181,7 +160,6 @@ class Date
|
|
181
160
|
result = self + days_to_sunday.days
|
182
161
|
self.acts_like?(:time) ? result.end_of_day : result
|
183
162
|
end
|
184
|
-
alias :sunday :end_of_week
|
185
163
|
alias :at_end_of_week :end_of_week
|
186
164
|
|
187
165
|
# Returns a new Date/DateTime representing the start of the given day in next week (default is Monday).
|