activesupport 3.0.pre → 3.0.0.rc
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 +121 -1
- data/README.rdoc +33 -0
- data/lib/active_support.rb +42 -4
- data/lib/active_support/backtrace_cleaner.rb +31 -9
- data/lib/active_support/benchmarkable.rb +1 -0
- data/lib/active_support/buffered_logger.rb +5 -2
- data/lib/active_support/builder.rb +6 -0
- data/lib/active_support/cache.rb +454 -84
- data/lib/active_support/cache/compressed_mem_cache_store.rb +6 -13
- data/lib/active_support/cache/file_store.rb +140 -41
- data/lib/active_support/cache/mem_cache_store.rb +121 -76
- data/lib/active_support/cache/memory_store.rb +127 -27
- data/lib/active_support/cache/strategy/local_cache.rb +111 -58
- data/lib/active_support/cache/synchronized_memory_store.rb +2 -38
- data/lib/active_support/callbacks.rb +105 -76
- data/lib/active_support/configurable.rb +19 -18
- data/lib/active_support/core_ext/array.rb +1 -0
- data/lib/active_support/core_ext/array/access.rb +1 -1
- data/lib/active_support/core_ext/array/conversions.rb +29 -54
- data/lib/active_support/core_ext/array/extract_options.rb +16 -1
- data/lib/active_support/core_ext/array/grouping.rb +1 -1
- data/lib/active_support/core_ext/array/random_access.rb +26 -5
- data/lib/active_support/core_ext/array/uniq_by.rb +17 -0
- data/lib/active_support/core_ext/array/wrap.rb +13 -9
- data/lib/active_support/core_ext/benchmark.rb +0 -12
- data/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +2 -0
- data/lib/active_support/core_ext/class.rb +2 -1
- data/lib/active_support/core_ext/class/attribute.rb +67 -0
- data/lib/active_support/core_ext/class/attribute_accessors.rb +33 -27
- data/lib/active_support/core_ext/class/delegating_attributes.rb +35 -41
- data/lib/active_support/core_ext/class/inheritable_attributes.rb +23 -14
- data/lib/active_support/core_ext/class/subclasses.rb +50 -0
- data/lib/active_support/core_ext/date/calculations.rb +35 -12
- data/lib/active_support/core_ext/date/conversions.rb +5 -5
- data/lib/active_support/core_ext/date/zones.rb +14 -0
- data/lib/active_support/core_ext/date_time/calculations.rb +3 -1
- data/lib/active_support/core_ext/date_time/conversions.rb +24 -5
- data/lib/active_support/core_ext/date_time/zones.rb +4 -0
- data/lib/active_support/core_ext/enumerable.rb +5 -9
- data/lib/active_support/core_ext/exception.rb +0 -47
- data/lib/active_support/core_ext/file.rb +1 -0
- data/lib/active_support/core_ext/file/atomic.rb +3 -2
- data/lib/active_support/core_ext/file/path.rb +5 -0
- data/lib/active_support/core_ext/float/rounding.rb +3 -2
- data/lib/active_support/core_ext/hash/conversions.rb +65 -145
- data/lib/active_support/core_ext/hash/deep_merge.rb +6 -7
- data/lib/active_support/core_ext/hash/except.rb +8 -1
- data/lib/active_support/core_ext/hash/indifferent_access.rb +5 -0
- data/lib/active_support/core_ext/hash/keys.rb +10 -11
- data/lib/active_support/core_ext/hash/slice.rb +6 -0
- data/lib/active_support/core_ext/integer.rb +1 -1
- data/lib/active_support/core_ext/integer/multiple.rb +6 -0
- data/lib/active_support/core_ext/kernel.rb +1 -1
- data/lib/active_support/core_ext/kernel/debugger.rb +3 -2
- data/lib/active_support/core_ext/kernel/reporting.rb +2 -1
- data/lib/active_support/core_ext/kernel/requires.rb +2 -2
- data/lib/active_support/core_ext/kernel/singleton_class.rb +13 -0
- data/lib/active_support/core_ext/load_error.rb +17 -30
- data/lib/active_support/core_ext/logger.rb +2 -40
- data/lib/active_support/core_ext/module.rb +5 -3
- data/lib/active_support/core_ext/module/aliasing.rb +1 -1
- 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 +2 -2
- data/lib/active_support/core_ext/module/attribute_accessors.rb +20 -22
- data/lib/active_support/core_ext/module/delegation.rb +21 -10
- data/lib/active_support/core_ext/module/introspection.rb +8 -8
- 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 +11 -0
- data/lib/active_support/core_ext/module/synchronization.rb +2 -1
- data/lib/active_support/core_ext/name_error.rb +3 -1
- data/lib/active_support/core_ext/object.rb +5 -3
- data/lib/active_support/core_ext/object/blank.rb +20 -2
- data/lib/active_support/core_ext/object/conversions.rb +2 -16
- data/lib/active_support/core_ext/object/duplicable.rb +23 -1
- data/lib/active_support/core_ext/object/instance_variables.rb +0 -7
- data/lib/active_support/core_ext/object/to_json.rb +19 -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/object/with_options.rb +2 -0
- data/lib/active_support/core_ext/proc.rb +4 -4
- data/lib/active_support/core_ext/range/overlaps.rb +1 -1
- data/lib/active_support/core_ext/regexp.rb +0 -22
- data/lib/active_support/core_ext/rexml.rb +4 -1
- data/lib/active_support/core_ext/string.rb +3 -2
- data/lib/active_support/core_ext/string/access.rb +4 -2
- data/lib/active_support/core_ext/string/conversions.rb +28 -1
- data/lib/active_support/core_ext/string/encoding.rb +11 -0
- data/lib/active_support/core_ext/string/exclude.rb +6 -0
- data/lib/active_support/core_ext/string/filters.rb +29 -0
- data/lib/active_support/core_ext/string/inflections.rb +12 -12
- data/lib/active_support/core_ext/string/interpolation.rb +2 -92
- data/lib/active_support/core_ext/string/multibyte.rb +16 -19
- data/lib/active_support/core_ext/string/output_safety.rb +101 -35
- data/lib/active_support/core_ext/string/starts_ends_with.rb +0 -14
- data/lib/active_support/core_ext/string/xchar.rb +1 -1
- data/lib/active_support/core_ext/time/calculations.rb +14 -7
- data/lib/active_support/core_ext/time/conversions.rb +1 -0
- data/lib/active_support/core_ext/time/marshal.rb +56 -0
- data/lib/active_support/core_ext/time/zones.rb +2 -5
- data/lib/active_support/core_ext/uri.rb +10 -4
- data/lib/active_support/dependencies.rb +200 -197
- data/lib/active_support/dependencies/autoload.rb +50 -0
- data/lib/active_support/deprecation/behaviors.rb +13 -9
- data/lib/active_support/deprecation/method_wrappers.rb +10 -9
- data/lib/active_support/deprecation/proxy_wrappers.rb +7 -0
- data/lib/active_support/deprecation/reporting.rb +5 -3
- data/lib/active_support/descendants_tracker.rb +43 -0
- data/lib/active_support/duration.rb +8 -4
- data/lib/active_support/file_update_checker.rb +36 -0
- data/lib/active_support/hash_with_indifferent_access.rb +9 -1
- data/lib/active_support/i18n.rb +9 -0
- data/lib/active_support/i18n_railtie.rb +81 -0
- data/lib/active_support/inflections.rb +1 -1
- data/lib/active_support/inflector.rb +4 -407
- data/lib/active_support/inflector/inflections.rb +211 -0
- data/lib/active_support/inflector/methods.rb +151 -0
- data/lib/active_support/inflector/transliterate.rb +97 -0
- data/lib/active_support/json/backends/jsongem.rb +12 -9
- data/lib/active_support/json/backends/yajl.rb +40 -0
- data/lib/active_support/json/backends/yaml.rb +1 -1
- data/lib/active_support/json/decoding.rb +17 -2
- data/lib/active_support/json/encoding.rb +48 -31
- data/lib/active_support/json/variable.rb +2 -4
- data/lib/active_support/lazy_load_hooks.rb +27 -0
- data/lib/active_support/locale/en.yml +5 -2
- data/lib/active_support/log_subscriber.rb +123 -0
- data/lib/active_support/log_subscriber/test_helper.rb +99 -0
- data/lib/active_support/memoizable.rb +1 -1
- data/lib/active_support/message_encryptor.rb +1 -0
- data/lib/active_support/message_verifier.rb +2 -1
- data/lib/active_support/multibyte.rb +8 -23
- data/lib/active_support/multibyte/chars.rb +213 -446
- data/lib/active_support/multibyte/unicode.rb +392 -0
- data/lib/active_support/multibyte/utils.rb +6 -7
- data/lib/active_support/notifications.rb +29 -122
- data/lib/active_support/notifications/fanout.rb +61 -0
- data/lib/active_support/notifications/instrumenter.rb +54 -0
- data/lib/active_support/ordered_hash.rb +59 -14
- data/lib/active_support/ordered_options.rb +6 -0
- data/lib/active_support/railtie.rb +60 -0
- data/lib/active_support/rescuable.rb +7 -4
- data/lib/active_support/ruby/shim.rb +4 -6
- data/lib/active_support/test_case.rb +2 -7
- data/lib/active_support/testing/assertions.rb +15 -0
- data/lib/active_support/testing/declarative.rb +1 -1
- data/lib/active_support/testing/isolation.rb +64 -17
- data/lib/active_support/testing/performance.rb +306 -335
- data/lib/active_support/testing/setup_and_teardown.rb +51 -29
- data/lib/active_support/time.rb +24 -3
- data/lib/active_support/time_with_zone.rb +10 -14
- data/lib/active_support/values/time_zone.rb +192 -234
- data/lib/active_support/values/unicode_tables.dat +0 -0
- data/lib/active_support/version.rb +3 -2
- data/lib/active_support/whiny_nil.rb +9 -7
- data/lib/active_support/xml_mini.rb +130 -1
- data/lib/active_support/xml_mini/jdom.rb +2 -0
- data/lib/active_support/xml_mini/libxml.rb +23 -86
- data/lib/active_support/xml_mini/libxmlsax.rb +85 -0
- data/lib/active_support/xml_mini/nokogiri.rb +27 -24
- data/lib/active_support/xml_mini/nokogirisax.rb +83 -0
- data/lib/active_support/xml_mini/rexml.rb +8 -2
- metadata +62 -195
- data/README +0 -43
- data/lib/active_support/autoload.rb +0 -28
- data/lib/active_support/core_ext/boolean.rb +0 -1
- data/lib/active_support/core_ext/boolean/conversions.rb +0 -11
- data/lib/active_support/core_ext/class/removal.rb +0 -53
- data/lib/active_support/core_ext/date.rb +0 -7
- data/lib/active_support/core_ext/date_time.rb +0 -5
- data/lib/active_support/core_ext/integer/even_odd.rb +0 -16
- 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/nil.rb +0 -1
- data/lib/active_support/core_ext/nil/conversions.rb +0 -5
- data/lib/active_support/core_ext/object/extending.rb +0 -80
- data/lib/active_support/core_ext/object/metaclass.rb +0 -13
- data/lib/active_support/core_ext/object/misc.rb +0 -3
- data/lib/active_support/core_ext/object/returning.rb +0 -42
- data/lib/active_support/core_ext/object/tap.rb +0 -16
- data/lib/active_support/core_ext/string/bytesize.rb +0 -5
- data/lib/active_support/core_ext/string/iterators.rb +0 -13
- data/lib/active_support/core_ext/symbol.rb +0 -1
- data/lib/active_support/core_ext/symbol/to_proc.rb +0 -14
- data/lib/active_support/core_ext/time.rb +0 -10
- data/lib/active_support/core_ext/time/marshal_with_utc_flag.rb +0 -22
- data/lib/active_support/deprecated_callbacks.rb +0 -283
- data/lib/active_support/multibyte/unicode_database.rb +0 -71
- data/lib/active_support/vendor.rb +0 -16
- data/lib/active_support/vendor/builder-2.1.2/lib/blankslate.rb +0 -113
- data/lib/active_support/vendor/builder-2.1.2/lib/builder.rb +0 -13
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/blankslate.rb +0 -20
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/css.rb +0 -250
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/xchar.rb +0 -115
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlbase.rb +0 -139
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlevents.rb +0 -63
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlmarkup.rb +0 -328
- 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.rb +0 -204
- data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb +0 -215
- data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/exceptions.rb +0 -53
- 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.5/lib/memcache.rb +0 -1133
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo.rb +0 -33
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/data_timezone.rb +0 -47
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/data_timezone_info.rb +0 -228
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Algiers.rb +0 -55
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Cairo.rb +0 -219
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Casablanca.rb +0 -42
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Harare.rb +0 -18
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Johannesburg.rb +0 -25
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Monrovia.rb +0 -22
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Nairobi.rb +0 -23
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +0 -166
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Argentina/San_Juan.rb +0 -86
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Bogota.rb +0 -23
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Caracas.rb +0 -23
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Chicago.rb +0 -283
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Chihuahua.rb +0 -136
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Denver.rb +0 -204
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Godthab.rb +0 -161
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Guatemala.rb +0 -27
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Halifax.rb +0 -274
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Indiana/Indianapolis.rb +0 -149
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Juneau.rb +0 -194
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/La_Paz.rb +0 -22
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Lima.rb +0 -35
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Los_Angeles.rb +0 -232
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Mazatlan.rb +0 -139
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Mexico_City.rb +0 -144
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Monterrey.rb +0 -131
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/New_York.rb +0 -282
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Phoenix.rb +0 -30
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Regina.rb +0 -74
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Santiago.rb +0 -205
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Sao_Paulo.rb +0 -171
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/St_Johns.rb +0 -288
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Tijuana.rb +0 -196
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Almaty.rb +0 -67
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Baghdad.rb +0 -73
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Baku.rb +0 -161
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Bangkok.rb +0 -20
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Chongqing.rb +0 -33
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Colombo.rb +0 -30
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Dhaka.rb +0 -27
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Hong_Kong.rb +0 -87
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Irkutsk.rb +0 -165
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Jakarta.rb +0 -30
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Jerusalem.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kabul.rb +0 -20
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kamchatka.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Karachi.rb +0 -32
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kathmandu.rb +0 -20
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kolkata.rb +0 -25
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Krasnoyarsk.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kuala_Lumpur.rb +0 -31
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kuwait.rb +0 -18
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Magadan.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Muscat.rb +0 -18
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Novosibirsk.rb +0 -164
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Rangoon.rb +0 -24
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Riyadh.rb +0 -18
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Seoul.rb +0 -34
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Shanghai.rb +0 -35
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Singapore.rb +0 -33
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Taipei.rb +0 -59
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tashkent.rb +0 -47
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tbilisi.rb +0 -78
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tehran.rb +0 -121
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tokyo.rb +0 -30
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Ulaanbaatar.rb +0 -65
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Urumqi.rb +0 -33
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Vladivostok.rb +0 -164
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yakutsk.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yekaterinburg.rb +0 -165
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yerevan.rb +0 -165
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/Azores.rb +0 -270
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/Cape_Verde.rb +0 -23
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/South_Georgia.rb +0 -18
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Adelaide.rb +0 -187
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Brisbane.rb +0 -35
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Darwin.rb +0 -29
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Hobart.rb +0 -193
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Melbourne.rb +0 -185
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Perth.rb +0 -37
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Sydney.rb +0 -185
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Etc/UTC.rb +0 -16
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Amsterdam.rb +0 -228
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Athens.rb +0 -185
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Belgrade.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Berlin.rb +0 -188
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Bratislava.rb +0 -13
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Brussels.rb +0 -232
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Bucharest.rb +0 -181
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Budapest.rb +0 -197
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Copenhagen.rb +0 -179
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Dublin.rb +0 -276
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Helsinki.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Istanbul.rb +0 -218
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Kiev.rb +0 -168
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Lisbon.rb +0 -268
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Ljubljana.rb +0 -13
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/London.rb +0 -288
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Madrid.rb +0 -211
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Minsk.rb +0 -170
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Moscow.rb +0 -181
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Paris.rb +0 -232
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Prague.rb +0 -187
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Riga.rb +0 -176
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Rome.rb +0 -215
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Sarajevo.rb +0 -13
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Skopje.rb +0 -13
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Sofia.rb +0 -173
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Stockholm.rb +0 -165
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Tallinn.rb +0 -172
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Vienna.rb +0 -183
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Vilnius.rb +0 -170
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Warsaw.rb +0 -212
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Zagreb.rb +0 -13
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Auckland.rb +0 -202
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Fiji.rb +0 -23
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Guam.rb +0 -22
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Honolulu.rb +0 -28
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Majuro.rb +0 -20
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Midway.rb +0 -25
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Noumea.rb +0 -25
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Pago_Pago.rb +0 -26
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Port_Moresby.rb +0 -20
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Tongatapu.rb +0 -27
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/info_timezone.rb +0 -52
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/linked_timezone.rb +0 -51
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/linked_timezone_info.rb +0 -44
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/offset_rationals.rb +0 -98
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/ruby_core_support.rb +0 -56
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/time_or_datetime.rb +0 -292
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone.rb +0 -508
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_definition.rb +0 -56
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_info.rb +0 -40
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_offset_info.rb +0 -94
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_period.rb +0 -198
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_transition_info.rb +0 -129
@@ -1,16 +1,29 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
require 'active_support/callbacks'
|
3
|
+
|
1
4
|
module ActiveSupport
|
2
5
|
module Testing
|
3
6
|
module SetupAndTeardown
|
4
|
-
|
5
|
-
base.class_eval do
|
6
|
-
include ActiveSupport::DeprecatedCallbacks
|
7
|
-
define_callbacks :setup, :teardown
|
7
|
+
extend ActiveSupport::Concern
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
included do
|
10
|
+
include ActiveSupport::Callbacks
|
11
|
+
define_callbacks :setup, :teardown
|
12
|
+
|
13
|
+
if defined?(MiniTest::Assertions) && TestCase < MiniTest::Assertions
|
14
|
+
include ForMiniTest
|
15
|
+
else
|
16
|
+
include ForClassicTestUnit
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module ClassMethods
|
21
|
+
def setup(*args, &block)
|
22
|
+
set_callback(:setup, :before, *args, &block)
|
23
|
+
end
|
24
|
+
|
25
|
+
def teardown(*args, &block)
|
26
|
+
set_callback(:teardown, :after, *args, &block)
|
14
27
|
end
|
15
28
|
end
|
16
29
|
|
@@ -18,15 +31,16 @@ module ActiveSupport
|
|
18
31
|
def run(runner)
|
19
32
|
result = '.'
|
20
33
|
begin
|
21
|
-
|
22
|
-
|
34
|
+
_run_setup_callbacks do
|
35
|
+
result = super
|
36
|
+
end
|
23
37
|
rescue Exception => e
|
24
|
-
result = runner.puke(self.class,
|
38
|
+
result = runner.puke(self.class, method_name, e)
|
25
39
|
ensure
|
26
40
|
begin
|
27
|
-
|
41
|
+
_run_teardown_callbacks
|
28
42
|
rescue Exception => e
|
29
|
-
result = runner.puke(self.class,
|
43
|
+
result = runner.puke(self.class, method_name, e)
|
30
44
|
end
|
31
45
|
end
|
32
46
|
result
|
@@ -42,23 +56,17 @@ module ActiveSupport
|
|
42
56
|
def run(result)
|
43
57
|
return if @method_name.to_s == "default_test"
|
44
58
|
|
45
|
-
|
46
|
-
assertion_counter_klass = if defined?(Mocha::TestCaseAdapter::AssertionCounter)
|
47
|
-
Mocha::TestCaseAdapter::AssertionCounter
|
48
|
-
else
|
49
|
-
Mocha::Integration::TestUnit::AssertionCounter
|
50
|
-
end
|
51
|
-
assertion_counter = assertion_counter_klass.new(result)
|
52
|
-
end
|
53
|
-
|
59
|
+
mocha_counter = retrieve_mocha_counter(result)
|
54
60
|
yield(Test::Unit::TestCase::STARTED, name)
|
55
61
|
@_result = result
|
62
|
+
|
56
63
|
begin
|
57
64
|
begin
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
65
|
+
_run_setup_callbacks do
|
66
|
+
setup
|
67
|
+
__send__(@method_name)
|
68
|
+
mocha_verify(mocha_counter) if mocha_counter
|
69
|
+
end
|
62
70
|
rescue Mocha::ExpectationError => e
|
63
71
|
add_failure(e.message, e.backtrace)
|
64
72
|
rescue Test::Unit::AssertionFailedError => e
|
@@ -69,7 +77,7 @@ module ActiveSupport
|
|
69
77
|
ensure
|
70
78
|
begin
|
71
79
|
teardown
|
72
|
-
|
80
|
+
_run_teardown_callbacks
|
73
81
|
rescue Test::Unit::AssertionFailedError => e
|
74
82
|
add_failure(e.message, e.backtrace)
|
75
83
|
rescue Exception => e
|
@@ -78,12 +86,26 @@ module ActiveSupport
|
|
78
86
|
end
|
79
87
|
end
|
80
88
|
ensure
|
81
|
-
mocha_teardown if
|
89
|
+
mocha_teardown if mocha_counter
|
82
90
|
end
|
91
|
+
|
83
92
|
result.add_run
|
84
93
|
yield(Test::Unit::TestCase::FINISHED, name)
|
85
94
|
end
|
95
|
+
|
96
|
+
protected
|
97
|
+
|
98
|
+
def retrieve_mocha_counter(result) #:nodoc:
|
99
|
+
if respond_to?(:mocha_verify) # using mocha
|
100
|
+
if defined?(Mocha::TestCaseAdapter::AssertionCounter)
|
101
|
+
Mocha::TestCaseAdapter::AssertionCounter.new(result)
|
102
|
+
else
|
103
|
+
Mocha::Integration::TestUnit::AssertionCounter.new(result)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
86
107
|
end
|
108
|
+
|
87
109
|
end
|
88
110
|
end
|
89
111
|
end
|
data/lib/active_support/time.rb
CHANGED
@@ -1,7 +1,4 @@
|
|
1
1
|
require 'active_support'
|
2
|
-
require 'active_support/core_ext/time'
|
3
|
-
require 'active_support/core_ext/date'
|
4
|
-
require 'active_support/core_ext/date_time'
|
5
2
|
|
6
3
|
module ActiveSupport
|
7
4
|
autoload :Duration, 'active_support/duration'
|
@@ -12,3 +9,27 @@ module ActiveSupport
|
|
12
9
|
[Duration, TimeWithZone, TimeZone]
|
13
10
|
end
|
14
11
|
end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
require 'active_support/core_ext/time/publicize_conversion_methods'
|
17
|
+
require 'active_support/core_ext/time/marshal'
|
18
|
+
require 'active_support/core_ext/time/acts_like'
|
19
|
+
require 'active_support/core_ext/time/calculations'
|
20
|
+
require 'active_support/core_ext/time/conversions'
|
21
|
+
require 'active_support/core_ext/time/zones'
|
22
|
+
|
23
|
+
require 'active_support/core_ext/date/acts_like'
|
24
|
+
require 'active_support/core_ext/date/freeze'
|
25
|
+
require 'active_support/core_ext/date/calculations'
|
26
|
+
require 'active_support/core_ext/date/conversions'
|
27
|
+
require 'active_support/core_ext/date/zones'
|
28
|
+
|
29
|
+
require 'active_support/core_ext/date_time/acts_like'
|
30
|
+
require 'active_support/core_ext/date_time/calculations'
|
31
|
+
require 'active_support/core_ext/date_time/conversions'
|
32
|
+
require 'active_support/core_ext/date_time/zones'
|
33
|
+
|
34
|
+
require 'active_support/core_ext/integer/time'
|
35
|
+
require 'active_support/core_ext/numeric/time'
|
@@ -1,17 +1,13 @@
|
|
1
|
-
require
|
2
|
-
require 'active_support/core_ext/
|
3
|
-
require 'active_support/core_ext/integer/time'
|
4
|
-
require 'active_support/core_ext/time/conversions'
|
5
|
-
require 'active_support/core_ext/date/conversions'
|
6
|
-
require 'active_support/core_ext/date_time/conversions'
|
1
|
+
require "active_support/values/time_zone"
|
2
|
+
require 'active_support/core_ext/object/acts_like'
|
7
3
|
|
8
4
|
module ActiveSupport
|
9
5
|
# A Time-like class that can represent a time in any time zone. Necessary because standard Ruby Time instances are
|
10
6
|
# limited to UTC and the system's <tt>ENV['TZ']</tt> zone.
|
11
7
|
#
|
12
|
-
# You shouldn't ever need to create a TimeWithZone instance directly via <tt>new</tt>
|
13
|
-
# +local+, +parse+, +at+ and +now+ on TimeZone instances, and +in_time_zone+ on Time and DateTime instances
|
14
|
-
#
|
8
|
+
# You shouldn't ever need to create a TimeWithZone instance directly via <tt>new</tt> . Instead use methods
|
9
|
+
# +local+, +parse+, +at+ and +now+ on TimeZone instances, and +in_time_zone+ on Time and DateTime instances.
|
10
|
+
# Examples:
|
15
11
|
#
|
16
12
|
# Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)'
|
17
13
|
# Time.zone.local(2007, 2, 10, 15, 30, 45) # => Sat, 10 Feb 2007 15:30:45 EST -05:00
|
@@ -22,7 +18,8 @@ module ActiveSupport
|
|
22
18
|
#
|
23
19
|
# See Time and TimeZone for further documentation of these methods.
|
24
20
|
#
|
25
|
-
# TimeWithZone instances implement the same API as Ruby Time instances, so that Time and TimeWithZone instances are
|
21
|
+
# TimeWithZone instances implement the same API as Ruby Time instances, so that Time and TimeWithZone instances are interchangeable.
|
22
|
+
# Examples:
|
26
23
|
#
|
27
24
|
# t = Time.zone.now # => Sun, 18 May 2008 13:27:25 EDT -04:00
|
28
25
|
# t.hour # => 13
|
@@ -36,7 +33,6 @@ module ActiveSupport
|
|
36
33
|
# t.is_a?(Time) # => true
|
37
34
|
# t.is_a?(ActiveSupport::TimeWithZone) # => true
|
38
35
|
class TimeWithZone
|
39
|
-
|
40
36
|
def self.name
|
41
37
|
'Time' # Report class name as 'Time' to thwart type checking
|
42
38
|
end
|
@@ -118,9 +114,9 @@ module ActiveSupport
|
|
118
114
|
end
|
119
115
|
alias_method :iso8601, :xmlschema
|
120
116
|
|
121
|
-
# Coerces
|
122
|
-
#
|
123
|
-
#
|
117
|
+
# Coerces time to a string for JSON encoding. The default format is ISO 8601. You can get
|
118
|
+
# %Y/%m/%d %H:%M:%S +offset style by setting <tt>ActiveSupport::JSON::Encoding.use_standard_json_time_format</tt>
|
119
|
+
# to false.
|
124
120
|
#
|
125
121
|
# ==== Examples
|
126
122
|
#
|
@@ -1,6 +1,5 @@
|
|
1
|
-
require 'active_support/core_ext/
|
2
|
-
require 'active_support/core_ext/
|
3
|
-
require 'active_support/core_ext/date_time'
|
1
|
+
require 'active_support/core_ext/object/blank'
|
2
|
+
require 'active_support/core_ext/object/try'
|
4
3
|
|
5
4
|
# The TimeZone class serves as a wrapper around TZInfo::Timezone instances. It allows us to do the following:
|
6
5
|
#
|
@@ -9,10 +8,10 @@ require 'active_support/core_ext/date_time'
|
|
9
8
|
# * Lazily load TZInfo::Timezone instances only when they're needed.
|
10
9
|
# * Create ActiveSupport::TimeWithZone instances via TimeZone's +local+, +parse+, +at+ and +now+ methods.
|
11
10
|
#
|
12
|
-
# If you set <tt>config.time_zone</tt> in the Rails
|
11
|
+
# If you set <tt>config.time_zone</tt> in the Rails Application, you can access this TimeZone object via <tt>Time.zone</tt>:
|
13
12
|
#
|
14
|
-
# #
|
15
|
-
# Rails::
|
13
|
+
# # application.rb:
|
14
|
+
# class Application < Rails::Application
|
16
15
|
# config.time_zone = "Eastern Time (US & Canada)"
|
17
16
|
# end
|
18
17
|
#
|
@@ -25,156 +24,154 @@ require 'active_support/core_ext/date_time'
|
|
25
24
|
# (if a recent version of the gem is installed locally, this will be used instead of the bundled version.)
|
26
25
|
module ActiveSupport
|
27
26
|
class TimeZone
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
MAPPING.freeze
|
175
|
-
end
|
27
|
+
# Keys are Rails TimeZone names, values are TZInfo identifiers
|
28
|
+
MAPPING = {
|
29
|
+
"International Date Line West" => "Pacific/Midway",
|
30
|
+
"Midway Island" => "Pacific/Midway",
|
31
|
+
"Samoa" => "Pacific/Pago_Pago",
|
32
|
+
"Hawaii" => "Pacific/Honolulu",
|
33
|
+
"Alaska" => "America/Juneau",
|
34
|
+
"Pacific Time (US & Canada)" => "America/Los_Angeles",
|
35
|
+
"Tijuana" => "America/Tijuana",
|
36
|
+
"Mountain Time (US & Canada)" => "America/Denver",
|
37
|
+
"Arizona" => "America/Phoenix",
|
38
|
+
"Chihuahua" => "America/Chihuahua",
|
39
|
+
"Mazatlan" => "America/Mazatlan",
|
40
|
+
"Central Time (US & Canada)" => "America/Chicago",
|
41
|
+
"Saskatchewan" => "America/Regina",
|
42
|
+
"Guadalajara" => "America/Mexico_City",
|
43
|
+
"Mexico City" => "America/Mexico_City",
|
44
|
+
"Monterrey" => "America/Monterrey",
|
45
|
+
"Central America" => "America/Guatemala",
|
46
|
+
"Eastern Time (US & Canada)" => "America/New_York",
|
47
|
+
"Indiana (East)" => "America/Indiana/Indianapolis",
|
48
|
+
"Bogota" => "America/Bogota",
|
49
|
+
"Lima" => "America/Lima",
|
50
|
+
"Quito" => "America/Lima",
|
51
|
+
"Atlantic Time (Canada)" => "America/Halifax",
|
52
|
+
"Caracas" => "America/Caracas",
|
53
|
+
"La Paz" => "America/La_Paz",
|
54
|
+
"Santiago" => "America/Santiago",
|
55
|
+
"Newfoundland" => "America/St_Johns",
|
56
|
+
"Brasilia" => "America/Sao_Paulo",
|
57
|
+
"Buenos Aires" => "America/Argentina/Buenos_Aires",
|
58
|
+
"Georgetown" => "America/Guyana",
|
59
|
+
"Greenland" => "America/Godthab",
|
60
|
+
"Mid-Atlantic" => "Atlantic/South_Georgia",
|
61
|
+
"Azores" => "Atlantic/Azores",
|
62
|
+
"Cape Verde Is." => "Atlantic/Cape_Verde",
|
63
|
+
"Dublin" => "Europe/Dublin",
|
64
|
+
"Edinburgh" => "Europe/London",
|
65
|
+
"Lisbon" => "Europe/Lisbon",
|
66
|
+
"London" => "Europe/London",
|
67
|
+
"Casablanca" => "Africa/Casablanca",
|
68
|
+
"Monrovia" => "Africa/Monrovia",
|
69
|
+
"UTC" => "Etc/UTC",
|
70
|
+
"Belgrade" => "Europe/Belgrade",
|
71
|
+
"Bratislava" => "Europe/Bratislava",
|
72
|
+
"Budapest" => "Europe/Budapest",
|
73
|
+
"Ljubljana" => "Europe/Ljubljana",
|
74
|
+
"Prague" => "Europe/Prague",
|
75
|
+
"Sarajevo" => "Europe/Sarajevo",
|
76
|
+
"Skopje" => "Europe/Skopje",
|
77
|
+
"Warsaw" => "Europe/Warsaw",
|
78
|
+
"Zagreb" => "Europe/Zagreb",
|
79
|
+
"Brussels" => "Europe/Brussels",
|
80
|
+
"Copenhagen" => "Europe/Copenhagen",
|
81
|
+
"Madrid" => "Europe/Madrid",
|
82
|
+
"Paris" => "Europe/Paris",
|
83
|
+
"Amsterdam" => "Europe/Amsterdam",
|
84
|
+
"Berlin" => "Europe/Berlin",
|
85
|
+
"Bern" => "Europe/Berlin",
|
86
|
+
"Rome" => "Europe/Rome",
|
87
|
+
"Stockholm" => "Europe/Stockholm",
|
88
|
+
"Vienna" => "Europe/Vienna",
|
89
|
+
"West Central Africa" => "Africa/Algiers",
|
90
|
+
"Bucharest" => "Europe/Bucharest",
|
91
|
+
"Cairo" => "Africa/Cairo",
|
92
|
+
"Helsinki" => "Europe/Helsinki",
|
93
|
+
"Kyiv" => "Europe/Kiev",
|
94
|
+
"Riga" => "Europe/Riga",
|
95
|
+
"Sofia" => "Europe/Sofia",
|
96
|
+
"Tallinn" => "Europe/Tallinn",
|
97
|
+
"Vilnius" => "Europe/Vilnius",
|
98
|
+
"Athens" => "Europe/Athens",
|
99
|
+
"Istanbul" => "Europe/Istanbul",
|
100
|
+
"Minsk" => "Europe/Minsk",
|
101
|
+
"Jerusalem" => "Asia/Jerusalem",
|
102
|
+
"Harare" => "Africa/Harare",
|
103
|
+
"Pretoria" => "Africa/Johannesburg",
|
104
|
+
"Moscow" => "Europe/Moscow",
|
105
|
+
"St. Petersburg" => "Europe/Moscow",
|
106
|
+
"Volgograd" => "Europe/Moscow",
|
107
|
+
"Kuwait" => "Asia/Kuwait",
|
108
|
+
"Riyadh" => "Asia/Riyadh",
|
109
|
+
"Nairobi" => "Africa/Nairobi",
|
110
|
+
"Baghdad" => "Asia/Baghdad",
|
111
|
+
"Tehran" => "Asia/Tehran",
|
112
|
+
"Abu Dhabi" => "Asia/Muscat",
|
113
|
+
"Muscat" => "Asia/Muscat",
|
114
|
+
"Baku" => "Asia/Baku",
|
115
|
+
"Tbilisi" => "Asia/Tbilisi",
|
116
|
+
"Yerevan" => "Asia/Yerevan",
|
117
|
+
"Kabul" => "Asia/Kabul",
|
118
|
+
"Ekaterinburg" => "Asia/Yekaterinburg",
|
119
|
+
"Islamabad" => "Asia/Karachi",
|
120
|
+
"Karachi" => "Asia/Karachi",
|
121
|
+
"Tashkent" => "Asia/Tashkent",
|
122
|
+
"Chennai" => "Asia/Kolkata",
|
123
|
+
"Kolkata" => "Asia/Kolkata",
|
124
|
+
"Mumbai" => "Asia/Kolkata",
|
125
|
+
"New Delhi" => "Asia/Kolkata",
|
126
|
+
"Kathmandu" => "Asia/Kathmandu",
|
127
|
+
"Astana" => "Asia/Dhaka",
|
128
|
+
"Dhaka" => "Asia/Dhaka",
|
129
|
+
"Sri Jayawardenepura" => "Asia/Colombo",
|
130
|
+
"Almaty" => "Asia/Almaty",
|
131
|
+
"Novosibirsk" => "Asia/Novosibirsk",
|
132
|
+
"Rangoon" => "Asia/Rangoon",
|
133
|
+
"Bangkok" => "Asia/Bangkok",
|
134
|
+
"Hanoi" => "Asia/Bangkok",
|
135
|
+
"Jakarta" => "Asia/Jakarta",
|
136
|
+
"Krasnoyarsk" => "Asia/Krasnoyarsk",
|
137
|
+
"Beijing" => "Asia/Shanghai",
|
138
|
+
"Chongqing" => "Asia/Chongqing",
|
139
|
+
"Hong Kong" => "Asia/Hong_Kong",
|
140
|
+
"Urumqi" => "Asia/Urumqi",
|
141
|
+
"Kuala Lumpur" => "Asia/Kuala_Lumpur",
|
142
|
+
"Singapore" => "Asia/Singapore",
|
143
|
+
"Taipei" => "Asia/Taipei",
|
144
|
+
"Perth" => "Australia/Perth",
|
145
|
+
"Irkutsk" => "Asia/Irkutsk",
|
146
|
+
"Ulaan Bataar" => "Asia/Ulaanbaatar",
|
147
|
+
"Seoul" => "Asia/Seoul",
|
148
|
+
"Osaka" => "Asia/Tokyo",
|
149
|
+
"Sapporo" => "Asia/Tokyo",
|
150
|
+
"Tokyo" => "Asia/Tokyo",
|
151
|
+
"Yakutsk" => "Asia/Yakutsk",
|
152
|
+
"Darwin" => "Australia/Darwin",
|
153
|
+
"Adelaide" => "Australia/Adelaide",
|
154
|
+
"Canberra" => "Australia/Melbourne",
|
155
|
+
"Melbourne" => "Australia/Melbourne",
|
156
|
+
"Sydney" => "Australia/Sydney",
|
157
|
+
"Brisbane" => "Australia/Brisbane",
|
158
|
+
"Hobart" => "Australia/Hobart",
|
159
|
+
"Vladivostok" => "Asia/Vladivostok",
|
160
|
+
"Guam" => "Pacific/Guam",
|
161
|
+
"Port Moresby" => "Pacific/Port_Moresby",
|
162
|
+
"Magadan" => "Asia/Magadan",
|
163
|
+
"Solomon Is." => "Asia/Magadan",
|
164
|
+
"New Caledonia" => "Pacific/Noumea",
|
165
|
+
"Fiji" => "Pacific/Fiji",
|
166
|
+
"Kamchatka" => "Asia/Kamchatka",
|
167
|
+
"Marshall Is." => "Pacific/Majuro",
|
168
|
+
"Auckland" => "Pacific/Auckland",
|
169
|
+
"Wellington" => "Pacific/Auckland",
|
170
|
+
"Nuku'alofa" => "Pacific/Tongatapu"
|
171
|
+
}.each { |name, zone| name.freeze; zone.freeze }
|
172
|
+
MAPPING.freeze
|
176
173
|
|
177
|
-
UTC_OFFSET_WITH_COLON = '
|
174
|
+
UTC_OFFSET_WITH_COLON = '%s%02d:%02d'
|
178
175
|
UTC_OFFSET_WITHOUT_COLON = UTC_OFFSET_WITH_COLON.sub(':', '')
|
179
176
|
|
180
177
|
# Assumes self represents an offset from UTC in seconds (as returned from Time#utc_offset)
|
@@ -183,26 +180,40 @@ module ActiveSupport
|
|
183
180
|
# TimeZone.seconds_to_utc_offset(-21_600) # => "-06:00"
|
184
181
|
def self.seconds_to_utc_offset(seconds, colon = true)
|
185
182
|
format = colon ? UTC_OFFSET_WITH_COLON : UTC_OFFSET_WITHOUT_COLON
|
186
|
-
|
183
|
+
sign = (seconds < 0 ? '-' : '+')
|
184
|
+
hours = seconds.abs / 3600
|
187
185
|
minutes = (seconds.abs % 3600) / 60
|
188
|
-
format % [hours, minutes]
|
186
|
+
format % [sign, hours, minutes]
|
189
187
|
end
|
190
188
|
|
191
189
|
include Comparable
|
192
190
|
attr_reader :name
|
191
|
+
attr_reader :tzinfo
|
193
192
|
|
194
193
|
# Create a new TimeZone object with the given name and offset. The
|
195
194
|
# offset is the number of seconds that this time zone is offset from UTC
|
196
195
|
# (GMT). Seconds were chosen as the offset unit because that is the unit that
|
197
196
|
# Ruby uses to represent time zone offsets (see Time#utc_offset).
|
198
|
-
def initialize(name, utc_offset, tzinfo = nil)
|
197
|
+
def initialize(name, utc_offset = nil, tzinfo = nil)
|
198
|
+
begin
|
199
|
+
require 'tzinfo'
|
200
|
+
rescue LoadError => e
|
201
|
+
$stderr.puts "You don't have tzinfo installed in your application. Please add it to your Gemfile and run bundle install"
|
202
|
+
raise e
|
203
|
+
end
|
199
204
|
@name = name
|
200
205
|
@utc_offset = utc_offset
|
201
|
-
@tzinfo = tzinfo
|
206
|
+
@tzinfo = tzinfo || TimeZone.find_tzinfo(name)
|
207
|
+
@current_period = nil
|
202
208
|
end
|
203
209
|
|
204
210
|
def utc_offset
|
205
|
-
@utc_offset
|
211
|
+
if @utc_offset
|
212
|
+
@utc_offset
|
213
|
+
else
|
214
|
+
@current_period ||= tzinfo.try(:current_period)
|
215
|
+
@current_period.try(:utc_offset)
|
216
|
+
end
|
206
217
|
end
|
207
218
|
|
208
219
|
# Returns the offset of this time zone as a formatted string, of the
|
@@ -211,7 +222,7 @@ module ActiveSupport
|
|
211
222
|
utc_offset == 0 && alternate_utc_string || self.class.seconds_to_utc_offset(utc_offset, colon)
|
212
223
|
end
|
213
224
|
|
214
|
-
# Compare this time zone to the parameter. The two are
|
225
|
+
# Compare this time zone to the parameter. The two are compared first on
|
215
226
|
# their offsets, and then by name.
|
216
227
|
def <=>(zone)
|
217
228
|
result = (utc_offset <=> zone.utc_offset)
|
@@ -305,76 +316,9 @@ module ActiveSupport
|
|
305
316
|
end
|
306
317
|
|
307
318
|
# TODO: Preload instead of lazy load for thread safety
|
308
|
-
def
|
309
|
-
require 'tzinfo' unless defined?(TZInfo)
|
310
|
-
|
311
|
-
end
|
312
|
-
|
313
|
-
unless const_defined?(:ZONES)
|
314
|
-
ZONES = []
|
315
|
-
ZONES_MAP = {}
|
316
|
-
[[-39_600, "International Date Line West", "Midway Island", "Samoa" ],
|
317
|
-
[-36_000, "Hawaii" ],
|
318
|
-
[-32_400, "Alaska" ],
|
319
|
-
[-28_800, "Pacific Time (US & Canada)", "Tijuana" ],
|
320
|
-
[-25_200, "Mountain Time (US & Canada)", "Chihuahua", "Mazatlan",
|
321
|
-
"Arizona" ],
|
322
|
-
[-21_600, "Central Time (US & Canada)", "Saskatchewan", "Guadalajara",
|
323
|
-
"Mexico City", "Monterrey", "Central America" ],
|
324
|
-
[-18_000, "Eastern Time (US & Canada)", "Indiana (East)", "Bogota",
|
325
|
-
"Lima", "Quito" ],
|
326
|
-
[-16_200, "Caracas" ],
|
327
|
-
[-14_400, "Atlantic Time (Canada)", "La Paz", "Santiago" ],
|
328
|
-
[-12_600, "Newfoundland" ],
|
329
|
-
[-10_800, "Brasilia", "Buenos Aires", "Georgetown", "Greenland" ],
|
330
|
-
[ -7_200, "Mid-Atlantic" ],
|
331
|
-
[ -3_600, "Azores", "Cape Verde Is." ],
|
332
|
-
[ 0, "Dublin", "Edinburgh", "Lisbon", "London", "Casablanca",
|
333
|
-
"Monrovia", "UTC" ],
|
334
|
-
[ 3_600, "Belgrade", "Bratislava", "Budapest", "Ljubljana", "Prague",
|
335
|
-
"Sarajevo", "Skopje", "Warsaw", "Zagreb", "Brussels",
|
336
|
-
"Copenhagen", "Madrid", "Paris", "Amsterdam", "Berlin",
|
337
|
-
"Bern", "Rome", "Stockholm", "Vienna",
|
338
|
-
"West Central Africa" ],
|
339
|
-
[ 7_200, "Bucharest", "Cairo", "Helsinki", "Kyiv", "Riga", "Sofia",
|
340
|
-
"Tallinn", "Vilnius", "Athens", "Istanbul", "Minsk",
|
341
|
-
"Jerusalem", "Harare", "Pretoria" ],
|
342
|
-
[ 10_800, "Moscow", "St. Petersburg", "Volgograd", "Kuwait", "Riyadh",
|
343
|
-
"Nairobi", "Baghdad" ],
|
344
|
-
[ 12_600, "Tehran" ],
|
345
|
-
[ 14_400, "Abu Dhabi", "Muscat", "Baku", "Tbilisi", "Yerevan" ],
|
346
|
-
[ 16_200, "Kabul" ],
|
347
|
-
[ 18_000, "Ekaterinburg", "Islamabad", "Karachi", "Tashkent" ],
|
348
|
-
[ 19_800, "Chennai", "Kolkata", "Mumbai", "New Delhi", "Sri Jayawardenepura" ],
|
349
|
-
[ 20_700, "Kathmandu" ],
|
350
|
-
[ 21_600, "Astana", "Dhaka", "Almaty",
|
351
|
-
"Novosibirsk" ],
|
352
|
-
[ 23_400, "Rangoon" ],
|
353
|
-
[ 25_200, "Bangkok", "Hanoi", "Jakarta", "Krasnoyarsk" ],
|
354
|
-
[ 28_800, "Beijing", "Chongqing", "Hong Kong", "Urumqi",
|
355
|
-
"Kuala Lumpur", "Singapore", "Taipei", "Perth", "Irkutsk",
|
356
|
-
"Ulaan Bataar" ],
|
357
|
-
[ 32_400, "Seoul", "Osaka", "Sapporo", "Tokyo", "Yakutsk" ],
|
358
|
-
[ 34_200, "Darwin", "Adelaide" ],
|
359
|
-
[ 36_000, "Canberra", "Melbourne", "Sydney", "Brisbane", "Hobart",
|
360
|
-
"Vladivostok", "Guam", "Port Moresby" ],
|
361
|
-
[ 39_600, "Magadan", "Solomon Is.", "New Caledonia" ],
|
362
|
-
[ 43_200, "Fiji", "Kamchatka", "Marshall Is.", "Auckland",
|
363
|
-
"Wellington" ],
|
364
|
-
[ 46_800, "Nuku'alofa" ]].
|
365
|
-
each do |offset, *places|
|
366
|
-
places.sort.each do |place|
|
367
|
-
place.freeze
|
368
|
-
zone = new(place, offset)
|
369
|
-
ZONES << zone
|
370
|
-
ZONES_MAP[place] = zone
|
371
|
-
end
|
372
|
-
end
|
373
|
-
ZONES.freeze
|
374
|
-
ZONES_MAP.freeze
|
375
|
-
|
376
|
-
US_ZONES = ZONES.find_all { |z| z.name =~ /US|Arizona|Indiana|Hawaii|Alaska/ }
|
377
|
-
US_ZONES.freeze
|
319
|
+
def self.find_tzinfo(name)
|
320
|
+
require 'active_support/tzinfo' unless defined?(::TZInfo)
|
321
|
+
::TZInfo::TimezoneProxy.new(MAPPING[name] || name)
|
378
322
|
end
|
379
323
|
|
380
324
|
class << self
|
@@ -391,7 +335,11 @@ module ActiveSupport
|
|
391
335
|
# TimeZone objects per time zone, in many cases, to make it easier
|
392
336
|
# for users to find their own time zone.
|
393
337
|
def all
|
394
|
-
|
338
|
+
@zones ||= zones_map.values.sort
|
339
|
+
end
|
340
|
+
|
341
|
+
def zones_map
|
342
|
+
@zones_map ||= Hash[MAPPING.map { |place, _| [place, create(place)] }]
|
395
343
|
end
|
396
344
|
|
397
345
|
# Locate a specific time zone object. If the argument is a string, it
|
@@ -402,7 +350,11 @@ module ActiveSupport
|
|
402
350
|
def [](arg)
|
403
351
|
case arg
|
404
352
|
when String
|
405
|
-
|
353
|
+
begin
|
354
|
+
zones_map[arg] ||= lookup(arg).tap { |tz| tz.utc_offset }
|
355
|
+
rescue TZInfo::InvalidTimezoneIdentifier
|
356
|
+
nil
|
357
|
+
end
|
406
358
|
when Numeric, ActiveSupport::Duration
|
407
359
|
arg *= 3600 if arg.abs <= 13
|
408
360
|
all.find { |z| z.utc_offset == arg.to_i }
|
@@ -414,8 +366,14 @@ module ActiveSupport
|
|
414
366
|
# A convenience method for returning a collection of TimeZone objects
|
415
367
|
# for time zones in the USA.
|
416
368
|
def us_zones
|
417
|
-
|
369
|
+
@us_zones ||= all.find_all { |z| z.name =~ /US|Arizona|Indiana|Hawaii|Alaska/ }
|
418
370
|
end
|
371
|
+
|
372
|
+
private
|
373
|
+
|
374
|
+
def lookup(name)
|
375
|
+
(tzinfo = find_tzinfo(name)) && create(tzinfo.name.freeze)
|
376
|
+
end
|
419
377
|
end
|
420
378
|
end
|
421
379
|
end
|