mack-active_record 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gems/activerecord-2.2.2/lib/active_record/aggregations.rb +261 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/association_preload.rb +374 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/association_collection.rb +453 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb +272 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/belongs_to_association.rb +58 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/belongs_to_polymorphic_association.rb +49 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/has_and_belongs_to_many_association.rb +121 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/has_many_association.rb +121 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/has_many_through_association.rb +256 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/has_one_association.rb +115 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/has_one_through_association.rb +31 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations.rb +2227 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/attribute_methods.rb +387 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/base.rb +2967 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/calculations.rb +299 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/callbacks.rb +331 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb +355 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb +136 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb +201 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb +94 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/quoting.rb +69 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/schema_definitions.rb +705 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/schema_statements.rb +434 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract_adapter.rb +210 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb +585 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb +1065 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/sqlite3_adapter.rb +34 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/sqlite_adapter.rb +418 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/dirty.rb +183 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/dynamic_finder_match.rb +41 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/fixtures.rb +998 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/i18n_interpolation_deprecation.rb +26 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/locale/en.yml +54 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/locking/optimistic.rb +148 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/locking/pessimistic.rb +77 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/migration.rb +560 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/named_scope.rb +181 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/observer.rb +197 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/query_cache.rb +21 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/reflection.rb +307 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/schema.rb +51 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/schema_dumper.rb +177 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/serialization.rb +98 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/serializers/json_serializer.rb +80 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/serializers/xml_serializer.rb +338 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/test_case.rb +60 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/timestamp.rb +41 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/transactions.rb +185 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/validations.rb +1061 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/version.rb +9 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record.rb +81 -0
- data/lib/gems/activerecord-2.2.2/lib/activerecord.rb +1 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/base64.rb +33 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/basic_object.rb +24 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/buffered_logger.rb +122 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/cache/compressed_mem_cache_store.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/cache/drb_store.rb +15 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/cache/file_store.rb +72 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/cache/mem_cache_store.rb +127 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/cache/memory_store.rb +52 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/cache/synchronized_memory_store.rb +47 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/cache.rb +223 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/callbacks.rb +280 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/array/access.rb +53 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/array/conversions.rb +183 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/array/extract_options.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/array/grouping.rb +106 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/array/random_access.rb +12 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/array.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/base64/encoding.rb +16 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/base64.rb +4 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/benchmark.rb +12 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/bigdecimal/conversions.rb +37 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/bigdecimal.rb +6 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/blank.rb +58 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +14 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/cgi.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/class/attribute_accessors.rb +54 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/class/delegating_attributes.rb +46 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/class/inheritable_attributes.rb +140 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/class/removal.rb +50 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/class.rb +4 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date/behavior.rb +42 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date/calculations.rb +230 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date/conversions.rb +107 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date.rb +10 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date_time/calculations.rb +126 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date_time/conversions.rb +96 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date_time.rb +12 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/duplicable.rb +43 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/enumerable.rb +107 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/exception.rb +41 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/file/atomic.rb +46 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/file.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/float/rounding.rb +24 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/float/time.rb +27 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/float.rb +7 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/conversions.rb +259 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/deep_merge.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/diff.rb +19 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/except.rb +25 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/indifferent_access.rb +137 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/keys.rb +52 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/reverse_merge.rb +35 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/slice.rb +33 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash.rb +14 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/integer/even_odd.rb +29 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/integer/inflections.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/integer/time.rb +45 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/integer.rb +9 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel/agnostics.rb +11 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel/daemonizing.rb +7 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel/debugger.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel/reporting.rb +59 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel/requires.rb +24 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/load_error.rb +38 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/logger.rb +143 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/aliasing.rb +74 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/attr_accessor_with_default.rb +31 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/attr_internal.rb +32 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/attribute_accessors.rb +58 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/delegation.rb +95 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/inclusion.rb +30 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/introspection.rb +90 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/loading.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/model_naming.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/synchronization.rb +39 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/name_error.rb +17 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/numeric/bytes.rb +44 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/numeric/conversions.rb +19 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/numeric/time.rb +81 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/numeric.rb +9 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/object/conversions.rb +14 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/object/extending.rb +80 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/object/instance_variables.rb +74 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/object/metaclass.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/object/misc.rb +74 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/object.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/pathname/clean_within.rb +14 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/pathname.rb +7 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/proc.rb +12 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/process/daemon.rb +25 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/process.rb +1 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/range/blockless_step.rb +32 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/range/conversions.rb +27 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/range/include_range.rb +30 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/range/overlaps.rb +15 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/range.rb +11 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/rexml.rb +36 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/access.rb +82 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/behavior.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/conversions.rb +28 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/filters.rb +26 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/inflections.rb +167 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/iterators.rb +21 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/multibyte.rb +81 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/starts_ends_with.rb +35 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/xchar.rb +11 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string.rb +22 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/symbol.rb +14 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/time/behavior.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/time/calculations.rb +303 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/time/conversions.rb +90 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/time/zones.rb +86 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/time.rb +42 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext.rb +4 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/dependencies.rb +621 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/deprecation.rb +243 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/duration.rb +96 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/gzip.rb +25 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/inflections.rb +55 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/inflector.rb +397 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/decoding.rb +63 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/date.rb +21 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/date_time.rb +21 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/enumerable.rb +12 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/false_class.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/hash.rb +47 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/nil_class.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/numeric.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/object.rb +6 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/regexp.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/string.rb +36 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/symbol.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/time.rb +21 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/true_class.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoding.rb +37 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/variable.rb +10 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/locale/en.yml +32 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/memoizable.rb +82 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/multibyte/chars.rb +679 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/multibyte/exceptions.rb +8 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/multibyte/unicode_database.rb +71 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/multibyte.rb +33 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/option_merger.rb +17 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/ordered_hash.rb +58 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/ordered_options.rb +19 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/rescuable.rb +108 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/secure_random.rb +197 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/string_inquirer.rb +21 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/test_case.rb +24 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/testing/core_ext/test/unit/assertions.rb +72 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/testing/core_ext/test.rb +6 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/testing/default.rb +9 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/testing/performance.rb +452 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb +120 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/time_with_zone.rb +328 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/values/time_zone.rb +403 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/values/unicode_tables.dat +0 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/blankslate.rb +113 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder/blankslate.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder/css.rb +250 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder/xchar.rb +115 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb +139 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb +63 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder/xmlmarkup.rb +328 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb +216 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/i18n-0.0.1/i18n/exceptions.rb +53 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/i18n-0.0.1/i18n.rb +194 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/memcache-client-1.5.1/memcache.rb +849 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone.rb +47 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone_info.rb +228 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Algiers.rb +55 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Cairo.rb +219 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Casablanca.rb +40 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Harare.rb +18 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Johannesburg.rb +25 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Monrovia.rb +22 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Nairobi.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +166 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/San_Juan.rb +86 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Bogota.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Caracas.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chicago.rb +283 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chihuahua.rb +136 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Denver.rb +204 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Godthab.rb +161 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Guatemala.rb +27 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Halifax.rb +274 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Indiana/Indianapolis.rb +149 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Juneau.rb +194 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/La_Paz.rb +22 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Lima.rb +35 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Los_Angeles.rb +232 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mazatlan.rb +139 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mexico_City.rb +144 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Monterrey.rb +131 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/New_York.rb +282 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Phoenix.rb +30 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Regina.rb +74 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Santiago.rb +205 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Sao_Paulo.rb +171 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/St_Johns.rb +288 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Tijuana.rb +196 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Almaty.rb +67 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baghdad.rb +73 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baku.rb +161 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Bangkok.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Chongqing.rb +33 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Colombo.rb +30 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Dhaka.rb +27 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Hong_Kong.rb +87 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Irkutsk.rb +165 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jakarta.rb +30 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jerusalem.rb +163 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kabul.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kamchatka.rb +163 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Karachi.rb +30 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Katmandu.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kolkata.rb +25 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Krasnoyarsk.rb +163 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuala_Lumpur.rb +31 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuwait.rb +18 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Magadan.rb +163 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Muscat.rb +18 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Novosibirsk.rb +164 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Rangoon.rb +24 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Riyadh.rb +18 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Seoul.rb +34 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Shanghai.rb +35 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Singapore.rb +33 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Taipei.rb +59 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tashkent.rb +47 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tbilisi.rb +78 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tehran.rb +121 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tokyo.rb +30 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Ulaanbaatar.rb +65 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Urumqi.rb +33 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Vladivostok.rb +164 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yakutsk.rb +163 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yekaterinburg.rb +165 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yerevan.rb +165 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Azores.rb +270 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Cape_Verde.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/South_Georgia.rb +18 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Adelaide.rb +187 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Brisbane.rb +35 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Darwin.rb +29 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Hobart.rb +193 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Melbourne.rb +185 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Perth.rb +37 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Sydney.rb +185 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Etc/UTC.rb +16 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Amsterdam.rb +228 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Athens.rb +185 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Belgrade.rb +163 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Berlin.rb +188 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bratislava.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Brussels.rb +232 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bucharest.rb +181 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Budapest.rb +197 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Copenhagen.rb +179 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Dublin.rb +276 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Helsinki.rb +163 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Istanbul.rb +218 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Kiev.rb +168 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Lisbon.rb +268 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Ljubljana.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/London.rb +288 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Madrid.rb +211 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Minsk.rb +170 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Moscow.rb +181 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Paris.rb +232 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Prague.rb +187 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Riga.rb +176 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Rome.rb +215 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sarajevo.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Skopje.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sofia.rb +173 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Stockholm.rb +165 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Tallinn.rb +172 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vienna.rb +183 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vilnius.rb +170 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Warsaw.rb +212 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Zagreb.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Auckland.rb +202 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Fiji.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Guam.rb +22 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Honolulu.rb +28 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Majuro.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Midway.rb +25 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Noumea.rb +25 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Pago_Pago.rb +26 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Port_Moresby.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Tongatapu.rb +27 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/info_timezone.rb +52 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone.rb +51 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone_info.rb +44 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/offset_rationals.rb +98 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/ruby_core_support.rb +56 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/time_or_datetime.rb +292 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone.rb +508 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_definition.rb +56 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_info.rb +40 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_offset_info.rb +94 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb +198 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_transition_info.rb +129 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo.rb +33 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/xml-simple-1.0.11/xmlsimple.rb +1021 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor.rb +34 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/version.rb +9 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/whiny_nil.rb +58 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support.rb +61 -0
- data/lib/gems/activesupport-2.2.2/lib/activesupport.rb +1 -0
- data/lib/gems.rb +13 -0
- data/lib/mack-active_record/database.rb +4 -4
- data/lib/mack-active_record/migration_generator/migration_generator.rb +6 -2
- data/lib/mack-active_record/model_generator/manifest.yml +3 -3
- data/lib/mack-active_record/model_generator/model_generator.rb +8 -1
- data/lib/mack-active_record/model_generator/templates/model.rb.template +1 -1
- data/lib/mack-active_record/model_generator/templates/rspec.rb.template +1 -1
- data/lib/mack-active_record/model_generator/templates/test.rb.template +1 -1
- data/lib/mack-active_record.rb +3 -1
- data/lib/mack-active_record_tasks.rb +3 -0
- metadata +457 -16
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'active_support/core_ext/string/inflections'
|
4
|
+
require 'active_support/core_ext/string/conversions'
|
5
|
+
require 'active_support/core_ext/string/access'
|
6
|
+
require 'active_support/core_ext/string/starts_ends_with'
|
7
|
+
require 'active_support/core_ext/string/iterators'
|
8
|
+
require 'active_support/core_ext/string/multibyte'
|
9
|
+
require 'active_support/core_ext/string/xchar'
|
10
|
+
require 'active_support/core_ext/string/filters'
|
11
|
+
require 'active_support/core_ext/string/behavior'
|
12
|
+
|
13
|
+
class String #:nodoc:
|
14
|
+
include ActiveSupport::CoreExtensions::String::Access
|
15
|
+
include ActiveSupport::CoreExtensions::String::Conversions
|
16
|
+
include ActiveSupport::CoreExtensions::String::Filters
|
17
|
+
include ActiveSupport::CoreExtensions::String::Inflections
|
18
|
+
include ActiveSupport::CoreExtensions::String::StartsEndsWith
|
19
|
+
include ActiveSupport::CoreExtensions::String::Iterators
|
20
|
+
include ActiveSupport::CoreExtensions::String::Behavior
|
21
|
+
include ActiveSupport::CoreExtensions::String::Multibyte
|
22
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
unless :to_proc.respond_to?(:to_proc)
|
2
|
+
class Symbol
|
3
|
+
# Turns the symbol into a simple proc, which is especially useful for enumerations. Examples:
|
4
|
+
#
|
5
|
+
# # The same as people.collect { |p| p.name }
|
6
|
+
# people.collect(&:name)
|
7
|
+
#
|
8
|
+
# # The same as people.select { |p| p.manager? }.collect { |p| p.salary }
|
9
|
+
# people.select(&:manager?).collect(&:salary)
|
10
|
+
def to_proc
|
11
|
+
Proc.new { |*args| args.shift.__send__(self, *args) }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module ActiveSupport #:nodoc:
|
2
|
+
module CoreExtensions #:nodoc:
|
3
|
+
module Time #:nodoc:
|
4
|
+
module Behavior
|
5
|
+
# Enable more predictable duck-typing on Time-like classes. See
|
6
|
+
# Object#acts_like?.
|
7
|
+
def acts_like_time?
|
8
|
+
true
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,303 @@
|
|
1
|
+
require 'active_support/duration'
|
2
|
+
|
3
|
+
module ActiveSupport #:nodoc:
|
4
|
+
module CoreExtensions #:nodoc:
|
5
|
+
module Time #:nodoc:
|
6
|
+
# Enables the use of time calculations within Time itself
|
7
|
+
module Calculations
|
8
|
+
def self.included(base) #:nodoc:
|
9
|
+
base.extend ClassMethods
|
10
|
+
|
11
|
+
base.class_eval do
|
12
|
+
alias_method :plus_without_duration, :+
|
13
|
+
alias_method :+, :plus_with_duration
|
14
|
+
|
15
|
+
alias_method :minus_without_duration, :-
|
16
|
+
alias_method :-, :minus_with_duration
|
17
|
+
|
18
|
+
alias_method :minus_without_coercion, :-
|
19
|
+
alias_method :-, :minus_with_coercion
|
20
|
+
|
21
|
+
alias_method :compare_without_coercion, :<=>
|
22
|
+
alias_method :<=>, :compare_with_coercion
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
COMMON_YEAR_DAYS_IN_MONTH = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
|
27
|
+
|
28
|
+
module ClassMethods
|
29
|
+
# Overriding case equality method so that it returns true for ActiveSupport::TimeWithZone instances
|
30
|
+
def ===(other)
|
31
|
+
other.is_a?(::Time)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Return the number of days in the given month.
|
35
|
+
# If no year is specified, it will use the current year.
|
36
|
+
def days_in_month(month, year = now.year)
|
37
|
+
return 29 if month == 2 && ::Date.gregorian_leap?(year)
|
38
|
+
COMMON_YEAR_DAYS_IN_MONTH[month]
|
39
|
+
end
|
40
|
+
|
41
|
+
# Returns a new Time if requested year can be accommodated by Ruby's Time class
|
42
|
+
# (i.e., if year is within either 1970..2038 or 1902..2038, depending on system architecture);
|
43
|
+
# otherwise returns a DateTime
|
44
|
+
def time_with_datetime_fallback(utc_or_local, year, month=1, day=1, hour=0, min=0, sec=0, usec=0)
|
45
|
+
::Time.send(utc_or_local, year, month, day, hour, min, sec, usec)
|
46
|
+
rescue
|
47
|
+
offset = utc_or_local.to_sym == :local ? ::DateTime.local_offset : 0
|
48
|
+
::DateTime.civil(year, month, day, hour, min, sec, offset)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Wraps class method +time_with_datetime_fallback+ with +utc_or_local+ set to <tt>:utc</tt>.
|
52
|
+
def utc_time(*args)
|
53
|
+
time_with_datetime_fallback(:utc, *args)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Wraps class method +time_with_datetime_fallback+ with +utc_or_local+ set to <tt>:local</tt>.
|
57
|
+
def local_time(*args)
|
58
|
+
time_with_datetime_fallback(:local, *args)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Tells whether the Time object's time lies in the past
|
63
|
+
def past?
|
64
|
+
self < ::Time.current
|
65
|
+
end
|
66
|
+
|
67
|
+
# Tells whether the Time object's time is today
|
68
|
+
def today?
|
69
|
+
self.to_date == ::Date.current
|
70
|
+
end
|
71
|
+
|
72
|
+
# Tells whether the Time object's time lies in the future
|
73
|
+
def future?
|
74
|
+
self > ::Time.current
|
75
|
+
end
|
76
|
+
|
77
|
+
# Seconds since midnight: Time.now.seconds_since_midnight
|
78
|
+
def seconds_since_midnight
|
79
|
+
self.to_i - self.change(:hour => 0).to_i + (self.usec/1.0e+6)
|
80
|
+
end
|
81
|
+
|
82
|
+
# Returns a new Time where one or more of the elements have been changed according to the +options+ parameter. The time options
|
83
|
+
# (hour, minute, sec, usec) reset cascadingly, so if only the hour is passed, then minute, sec, and usec is set to 0. If the hour and
|
84
|
+
# minute is passed, then sec and usec is set to 0.
|
85
|
+
def change(options)
|
86
|
+
::Time.send(
|
87
|
+
self.utc? ? :utc_time : :local_time,
|
88
|
+
options[:year] || self.year,
|
89
|
+
options[:month] || self.month,
|
90
|
+
options[:day] || self.day,
|
91
|
+
options[:hour] || self.hour,
|
92
|
+
options[:min] || (options[:hour] ? 0 : self.min),
|
93
|
+
options[:sec] || ((options[:hour] || options[:min]) ? 0 : self.sec),
|
94
|
+
options[:usec] || ((options[:hour] || options[:min] || options[:sec]) ? 0 : self.usec)
|
95
|
+
)
|
96
|
+
end
|
97
|
+
|
98
|
+
# Uses Date to provide precise Time calculations for years, months, and days.
|
99
|
+
# The +options+ parameter takes a hash with any of these keys: <tt>:years</tt>,
|
100
|
+
# <tt>:months</tt>, <tt>:weeks</tt>, <tt>:days</tt>, <tt>:hours</tt>,
|
101
|
+
# <tt>:minutes</tt>, <tt>:seconds</tt>.
|
102
|
+
def advance(options)
|
103
|
+
unless options[:weeks].nil?
|
104
|
+
options[:weeks], partial_weeks = options[:weeks].divmod(1)
|
105
|
+
options[:days] = (options[:days] || 0) + 7 * partial_weeks
|
106
|
+
end
|
107
|
+
|
108
|
+
unless options[:days].nil?
|
109
|
+
options[:days], partial_days = options[:days].divmod(1)
|
110
|
+
options[:hours] = (options[:hours] || 0) + 24 * partial_days
|
111
|
+
end
|
112
|
+
|
113
|
+
d = to_date.advance(options)
|
114
|
+
time_advanced_by_date = change(:year => d.year, :month => d.month, :day => d.day)
|
115
|
+
seconds_to_advance = (options[:seconds] || 0) + (options[:minutes] || 0) * 60 + (options[:hours] || 0) * 3600
|
116
|
+
seconds_to_advance == 0 ? time_advanced_by_date : time_advanced_by_date.since(seconds_to_advance)
|
117
|
+
end
|
118
|
+
|
119
|
+
# Returns a new Time representing the time a number of seconds ago, this is basically a wrapper around the Numeric extension
|
120
|
+
def ago(seconds)
|
121
|
+
self.since(-seconds)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Returns a new Time representing the time a number of seconds since the instance time, this is basically a wrapper around
|
125
|
+
# the Numeric extension.
|
126
|
+
def since(seconds)
|
127
|
+
f = seconds.since(self)
|
128
|
+
if ActiveSupport::Duration === seconds
|
129
|
+
f
|
130
|
+
else
|
131
|
+
initial_dst = self.dst? ? 1 : 0
|
132
|
+
final_dst = f.dst? ? 1 : 0
|
133
|
+
(seconds.abs >= 86400 && initial_dst != final_dst) ? f + (initial_dst - final_dst).hours : f
|
134
|
+
end
|
135
|
+
rescue
|
136
|
+
self.to_datetime.since(seconds)
|
137
|
+
end
|
138
|
+
alias :in :since
|
139
|
+
|
140
|
+
# Returns a new Time representing the time a number of specified months ago
|
141
|
+
def months_ago(months)
|
142
|
+
advance(:months => -months)
|
143
|
+
end
|
144
|
+
|
145
|
+
# Returns a new Time representing the time a number of specified months in the future
|
146
|
+
def months_since(months)
|
147
|
+
advance(:months => months)
|
148
|
+
end
|
149
|
+
|
150
|
+
# Returns a new Time representing the time a number of specified years ago
|
151
|
+
def years_ago(years)
|
152
|
+
advance(:years => -years)
|
153
|
+
end
|
154
|
+
|
155
|
+
# Returns a new Time representing the time a number of specified years in the future
|
156
|
+
def years_since(years)
|
157
|
+
advance(:years => years)
|
158
|
+
end
|
159
|
+
|
160
|
+
# Short-hand for years_ago(1)
|
161
|
+
def last_year
|
162
|
+
years_ago(1)
|
163
|
+
end
|
164
|
+
|
165
|
+
# Short-hand for years_since(1)
|
166
|
+
def next_year
|
167
|
+
years_since(1)
|
168
|
+
end
|
169
|
+
|
170
|
+
|
171
|
+
# Short-hand for months_ago(1)
|
172
|
+
def last_month
|
173
|
+
months_ago(1)
|
174
|
+
end
|
175
|
+
|
176
|
+
# Short-hand for months_since(1)
|
177
|
+
def next_month
|
178
|
+
months_since(1)
|
179
|
+
end
|
180
|
+
|
181
|
+
# Returns a new Time representing the "start" of this week (Monday, 0:00)
|
182
|
+
def beginning_of_week
|
183
|
+
days_to_monday = self.wday!=0 ? self.wday-1 : 6
|
184
|
+
(self - days_to_monday.days).midnight
|
185
|
+
end
|
186
|
+
alias :monday :beginning_of_week
|
187
|
+
alias :at_beginning_of_week :beginning_of_week
|
188
|
+
|
189
|
+
# Returns a new Time representing the end of this week (Sunday, 23:59:59)
|
190
|
+
def end_of_week
|
191
|
+
days_to_sunday = self.wday!=0 ? 7-self.wday : 0
|
192
|
+
(self + days_to_sunday.days).end_of_day
|
193
|
+
end
|
194
|
+
alias :at_end_of_week :end_of_week
|
195
|
+
|
196
|
+
# Returns a new Time representing the start of the given day in next week (default is Monday).
|
197
|
+
def next_week(day = :monday)
|
198
|
+
days_into_week = { :monday => 0, :tuesday => 1, :wednesday => 2, :thursday => 3, :friday => 4, :saturday => 5, :sunday => 6}
|
199
|
+
since(1.week).beginning_of_week.since(days_into_week[day].day).change(:hour => 0)
|
200
|
+
end
|
201
|
+
|
202
|
+
# Returns a new Time representing the start of the day (0:00)
|
203
|
+
def beginning_of_day
|
204
|
+
(self - self.seconds_since_midnight).change(:usec => 0)
|
205
|
+
end
|
206
|
+
alias :midnight :beginning_of_day
|
207
|
+
alias :at_midnight :beginning_of_day
|
208
|
+
alias :at_beginning_of_day :beginning_of_day
|
209
|
+
|
210
|
+
# Returns a new Time representing the end of the day (23:59:59)
|
211
|
+
def end_of_day
|
212
|
+
change(:hour => 23, :min => 59, :sec => 59)
|
213
|
+
end
|
214
|
+
|
215
|
+
# Returns a new Time representing the start of the month (1st of the month, 0:00)
|
216
|
+
def beginning_of_month
|
217
|
+
#self - ((self.mday-1).days + self.seconds_since_midnight)
|
218
|
+
change(:day => 1,:hour => 0, :min => 0, :sec => 0, :usec => 0)
|
219
|
+
end
|
220
|
+
alias :at_beginning_of_month :beginning_of_month
|
221
|
+
|
222
|
+
# Returns a new Time representing the end of the month (last day of the month, 0:00)
|
223
|
+
def end_of_month
|
224
|
+
#self - ((self.mday-1).days + self.seconds_since_midnight)
|
225
|
+
last_day = ::Time.days_in_month( self.month, self.year )
|
226
|
+
change(:day => last_day, :hour => 23, :min => 59, :sec => 59, :usec => 0)
|
227
|
+
end
|
228
|
+
alias :at_end_of_month :end_of_month
|
229
|
+
|
230
|
+
# Returns a new Time representing the start of the quarter (1st of january, april, july, october, 0:00)
|
231
|
+
def beginning_of_quarter
|
232
|
+
beginning_of_month.change(:month => [10, 7, 4, 1].detect { |m| m <= self.month })
|
233
|
+
end
|
234
|
+
alias :at_beginning_of_quarter :beginning_of_quarter
|
235
|
+
|
236
|
+
# Returns a new Time representing the end of the quarter (last day of march, june, september, december, 23:59:59)
|
237
|
+
def end_of_quarter
|
238
|
+
beginning_of_month.change(:month => [3, 6, 9, 12].detect { |m| m >= self.month }).end_of_month
|
239
|
+
end
|
240
|
+
alias :at_end_of_quarter :end_of_quarter
|
241
|
+
|
242
|
+
# Returns a new Time representing the start of the year (1st of january, 0:00)
|
243
|
+
def beginning_of_year
|
244
|
+
change(:month => 1,:day => 1,:hour => 0, :min => 0, :sec => 0, :usec => 0)
|
245
|
+
end
|
246
|
+
alias :at_beginning_of_year :beginning_of_year
|
247
|
+
|
248
|
+
# Returns a new Time representing the end of the year (31st of december, 23:59:59)
|
249
|
+
def end_of_year
|
250
|
+
change(:month => 12,:day => 31,:hour => 23, :min => 59, :sec => 59)
|
251
|
+
end
|
252
|
+
alias :at_end_of_year :end_of_year
|
253
|
+
|
254
|
+
# Convenience method which returns a new Time representing the time 1 day ago
|
255
|
+
def yesterday
|
256
|
+
advance(:days => -1)
|
257
|
+
end
|
258
|
+
|
259
|
+
# Convenience method which returns a new Time representing the time 1 day since the instance time
|
260
|
+
def tomorrow
|
261
|
+
advance(:days => 1)
|
262
|
+
end
|
263
|
+
|
264
|
+
def plus_with_duration(other) #:nodoc:
|
265
|
+
if ActiveSupport::Duration === other
|
266
|
+
other.since(self)
|
267
|
+
else
|
268
|
+
plus_without_duration(other)
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
def minus_with_duration(other) #:nodoc:
|
273
|
+
if ActiveSupport::Duration === other
|
274
|
+
other.until(self)
|
275
|
+
else
|
276
|
+
minus_without_duration(other)
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
# Time#- can also be used to determine the number of seconds between two Time instances.
|
281
|
+
# We're layering on additional behavior so that ActiveSupport::TimeWithZone instances
|
282
|
+
# are coerced into values that Time#- will recognize
|
283
|
+
def minus_with_coercion(other)
|
284
|
+
other = other.comparable_time if other.respond_to?(:comparable_time)
|
285
|
+
minus_without_coercion(other)
|
286
|
+
end
|
287
|
+
|
288
|
+
# Layers additional behavior on Time#<=> so that DateTime and ActiveSupport::TimeWithZone instances
|
289
|
+
# can be chronologically compared with a Time
|
290
|
+
def compare_with_coercion(other)
|
291
|
+
# if other is an ActiveSupport::TimeWithZone, coerce a Time instance from it so we can do <=> comparison
|
292
|
+
other = other.comparable_time if other.respond_to?(:comparable_time)
|
293
|
+
if other.acts_like?(:date)
|
294
|
+
# other is a Date/DateTime, so coerce self #to_datetime and hand off to DateTime#<=>
|
295
|
+
to_datetime.compare_without_coercion(other)
|
296
|
+
else
|
297
|
+
compare_without_coercion(other)
|
298
|
+
end
|
299
|
+
end
|
300
|
+
end
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module ActiveSupport #:nodoc:
|
2
|
+
module CoreExtensions #:nodoc:
|
3
|
+
module Time #:nodoc:
|
4
|
+
# Converting times to formatted strings, dates, and datetimes.
|
5
|
+
module Conversions
|
6
|
+
DATE_FORMATS = {
|
7
|
+
:db => "%Y-%m-%d %H:%M:%S",
|
8
|
+
:number => "%Y%m%d%H%M%S",
|
9
|
+
:time => "%H:%M",
|
10
|
+
:short => "%d %b %H:%M",
|
11
|
+
:long => "%B %d, %Y %H:%M",
|
12
|
+
:long_ordinal => lambda { |time| time.strftime("%B #{time.day.ordinalize}, %Y %H:%M") },
|
13
|
+
:rfc822 => "%a, %d %b %Y %H:%M:%S %z"
|
14
|
+
}
|
15
|
+
|
16
|
+
def self.included(base) #:nodoc:
|
17
|
+
base.class_eval do
|
18
|
+
alias_method :to_default_s, :to_s
|
19
|
+
alias_method :to_s, :to_formatted_s
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Converts to a formatted string. See DATE_FORMATS for builtin formats.
|
24
|
+
#
|
25
|
+
# This method is aliased to <tt>to_s</tt>.
|
26
|
+
#
|
27
|
+
# time = Time.now # => Thu Jan 18 06:10:17 CST 2007
|
28
|
+
#
|
29
|
+
# time.to_formatted_s(:time) # => "06:10:17"
|
30
|
+
# time.to_s(:time) # => "06:10:17"
|
31
|
+
#
|
32
|
+
# time.to_formatted_s(:db) # => "2007-01-18 06:10:17"
|
33
|
+
# time.to_formatted_s(:number) # => "20070118061017"
|
34
|
+
# time.to_formatted_s(:short) # => "18 Jan 06:10"
|
35
|
+
# time.to_formatted_s(:long) # => "January 18, 2007 06:10"
|
36
|
+
# time.to_formatted_s(:long_ordinal) # => "January 18th, 2007 06:10"
|
37
|
+
# time.to_formatted_s(:rfc822) # => "Thu, 18 Jan 2007 06:10:17 -0600"
|
38
|
+
#
|
39
|
+
# == Adding your own time formats to +to_formatted_s+
|
40
|
+
# You can add your own formats to the Time::DATE_FORMATS hash.
|
41
|
+
# Use the format name as the hash key and either a strftime string
|
42
|
+
# or Proc instance that takes a time argument as the value.
|
43
|
+
#
|
44
|
+
# # config/initializers/time_formats.rb
|
45
|
+
# Time::DATE_FORMATS[:month_and_year] = "%B %Y"
|
46
|
+
# Time::DATE_FORMATS[:short_ordinal] = lambda { |time| time.strftime("%B #{time.day.ordinalize}") }
|
47
|
+
def to_formatted_s(format = :default)
|
48
|
+
return to_default_s unless formatter = DATE_FORMATS[format]
|
49
|
+
formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Returns the UTC offset as an +HH:MM formatted string.
|
53
|
+
#
|
54
|
+
# Time.local(2000).formatted_offset # => "-06:00"
|
55
|
+
# Time.local(2000).formatted_offset(false) # => "-0600"
|
56
|
+
def formatted_offset(colon = true, alternate_utc_string = nil)
|
57
|
+
utc? && alternate_utc_string || utc_offset.to_utc_offset_s(colon)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Converts a Time object to a Date, dropping hour, minute, and second precision.
|
61
|
+
#
|
62
|
+
# my_time = Time.now # => Mon Nov 12 22:59:51 -0500 2007
|
63
|
+
# my_time.to_date # => Mon, 12 Nov 2007
|
64
|
+
#
|
65
|
+
# your_time = Time.parse("1/13/2009 1:13:03 P.M.") # => Tue Jan 13 13:13:03 -0500 2009
|
66
|
+
# your_time.to_date # => Tue, 13 Jan 2009
|
67
|
+
def to_date
|
68
|
+
::Date.new(year, month, day)
|
69
|
+
end
|
70
|
+
|
71
|
+
# A method to keep Time, Date and DateTime instances interchangeable on conversions.
|
72
|
+
# In this case, it simply returns +self+.
|
73
|
+
def to_time
|
74
|
+
self
|
75
|
+
end
|
76
|
+
|
77
|
+
# Converts a Time instance to a Ruby DateTime instance, preserving UTC offset.
|
78
|
+
#
|
79
|
+
# my_time = Time.now # => Mon Nov 12 23:04:21 -0500 2007
|
80
|
+
# my_time.to_datetime # => Mon, 12 Nov 2007 23:04:21 -0500
|
81
|
+
#
|
82
|
+
# your_time = Time.parse("1/13/2009 1:13:03 P.M.") # => Tue Jan 13 13:13:03 -0500 2009
|
83
|
+
# your_time.to_datetime # => Tue, 13 Jan 2009 13:13:03 -0500
|
84
|
+
def to_datetime
|
85
|
+
::DateTime.civil(year, month, day, hour, min, sec, Rational(utc_offset, 86400))
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module ActiveSupport #:nodoc:
|
2
|
+
module CoreExtensions #:nodoc:
|
3
|
+
module Time #:nodoc:
|
4
|
+
module Zones
|
5
|
+
def self.included(base) #:nodoc:
|
6
|
+
base.extend(ClassMethods) if base == ::Time # i.e., don't include class methods in DateTime
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
attr_accessor :zone_default
|
11
|
+
|
12
|
+
# Returns the TimeZone for the current request, if this has been set (via Time.zone=).
|
13
|
+
# If <tt>Time.zone</tt> has not been set for the current request, returns the TimeZone specified in <tt>config.time_zone</tt>.
|
14
|
+
def zone
|
15
|
+
Thread.current[:time_zone] || zone_default
|
16
|
+
end
|
17
|
+
|
18
|
+
# Sets <tt>Time.zone</tt> to a TimeZone object for the current request/thread.
|
19
|
+
#
|
20
|
+
# This method accepts any of the following:
|
21
|
+
#
|
22
|
+
# * A Rails TimeZone object.
|
23
|
+
# * An identifier for a Rails TimeZone object (e.g., "Eastern Time (US & Canada)", <tt>-5.hours</tt>).
|
24
|
+
# * A TZInfo::Timezone object.
|
25
|
+
# * An identifier for a TZInfo::Timezone object (e.g., "America/New_York").
|
26
|
+
#
|
27
|
+
# Here's an example of how you might set <tt>Time.zone</tt> on a per request basis -- <tt>current_user.time_zone</tt>
|
28
|
+
# just needs to return a string identifying the user's preferred TimeZone:
|
29
|
+
#
|
30
|
+
# class ApplicationController < ActionController::Base
|
31
|
+
# before_filter :set_time_zone
|
32
|
+
#
|
33
|
+
# def set_time_zone
|
34
|
+
# Time.zone = current_user.time_zone
|
35
|
+
# end
|
36
|
+
# end
|
37
|
+
def zone=(time_zone)
|
38
|
+
Thread.current[:time_zone] = get_zone(time_zone)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Allows override of <tt>Time.zone</tt> locally inside supplied block; resets <tt>Time.zone</tt> to existing value when done.
|
42
|
+
def use_zone(time_zone)
|
43
|
+
old_zone, ::Time.zone = ::Time.zone, get_zone(time_zone)
|
44
|
+
yield
|
45
|
+
ensure
|
46
|
+
::Time.zone = old_zone
|
47
|
+
end
|
48
|
+
|
49
|
+
# Returns <tt>Time.zone.now</tt> when <tt>config.time_zone</tt> is set, otherwise just returns <tt>Time.now</tt>.
|
50
|
+
def current
|
51
|
+
::Time.zone_default ? ::Time.zone.now : ::Time.now
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
def get_zone(time_zone)
|
56
|
+
return time_zone if time_zone.nil? || time_zone.is_a?(TimeZone)
|
57
|
+
# lookup timezone based on identifier (unless we've been passed a TZInfo::Timezone)
|
58
|
+
unless time_zone.respond_to?(:period_for_local)
|
59
|
+
time_zone = TimeZone[time_zone] || TZInfo::Timezone.get(time_zone) rescue nil
|
60
|
+
end
|
61
|
+
# Return if a TimeZone instance, or wrap in a TimeZone instance if a TZInfo::Timezone
|
62
|
+
if time_zone
|
63
|
+
time_zone.is_a?(TimeZone) ? time_zone : TimeZone.create(time_zone.name, nil, time_zone)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Returns the simultaneous time in <tt>Time.zone</tt>.
|
69
|
+
#
|
70
|
+
# Time.zone = 'Hawaii' # => 'Hawaii'
|
71
|
+
# Time.utc(2000).in_time_zone # => Fri, 31 Dec 1999 14:00:00 HST -10:00
|
72
|
+
#
|
73
|
+
# This method is similar to Time#localtime, except that it uses <tt>Time.zone</tt> as the local zone
|
74
|
+
# instead of the operating system's time zone.
|
75
|
+
#
|
76
|
+
# You can also pass in a TimeZone instance or string that identifies a TimeZone as an argument,
|
77
|
+
# and the conversion will be based on that zone instead of <tt>Time.zone</tt>.
|
78
|
+
#
|
79
|
+
# Time.utc(2000).in_time_zone('Alaska') # => Fri, 31 Dec 1999 15:00:00 AKST -09:00
|
80
|
+
def in_time_zone(zone = ::Time.zone)
|
81
|
+
ActiveSupport::TimeWithZone.new(utc? ? self : getutc, ::Time.__send__(:get_zone, zone))
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'time'
|
3
|
+
|
4
|
+
class Time
|
5
|
+
# Ruby 1.8-cvs and 1.9 define private Time#to_date
|
6
|
+
%w(to_date to_datetime).each do |method|
|
7
|
+
public method if private_instance_methods.include?(method)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Pre-1.9 versions of Ruby have a bug with marshaling Time instances, where utc instances are
|
11
|
+
# unmarshaled in the local zone, instead of utc. We're layering behavior on the _dump and _load
|
12
|
+
# methods so that utc instances can be flagged on dump, and coerced back to utc on load.
|
13
|
+
if RUBY_VERSION < '1.9'
|
14
|
+
class << self
|
15
|
+
alias_method :_original_load, :_load
|
16
|
+
def _load(marshaled_time)
|
17
|
+
time = _original_load(marshaled_time)
|
18
|
+
utc = time.instance_variable_get('@marshal_with_utc_coercion')
|
19
|
+
utc ? time.utc : time
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
alias_method :_original_dump, :_dump
|
24
|
+
def _dump(*args)
|
25
|
+
obj = self.frozen? ? self.dup : self
|
26
|
+
obj.instance_variable_set('@marshal_with_utc_coercion', utc?)
|
27
|
+
obj._original_dump(*args)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
require 'active_support/core_ext/time/behavior'
|
33
|
+
require 'active_support/core_ext/time/calculations'
|
34
|
+
require 'active_support/core_ext/time/conversions'
|
35
|
+
require 'active_support/core_ext/time/zones'
|
36
|
+
|
37
|
+
class Time#:nodoc:
|
38
|
+
include ActiveSupport::CoreExtensions::Time::Behavior
|
39
|
+
include ActiveSupport::CoreExtensions::Time::Calculations
|
40
|
+
include ActiveSupport::CoreExtensions::Time::Conversions
|
41
|
+
include ActiveSupport::CoreExtensions::Time::Zones
|
42
|
+
end
|