mack-active_record 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/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,397 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require 'singleton'
|
|
3
|
+
require 'iconv'
|
|
4
|
+
|
|
5
|
+
module ActiveSupport
|
|
6
|
+
# The Inflector transforms words from singular to plural, class names to table names, modularized class names to ones without,
|
|
7
|
+
# and class names to foreign keys. The default inflections for pluralization, singularization, and uncountable words are kept
|
|
8
|
+
# in inflections.rb.
|
|
9
|
+
#
|
|
10
|
+
# The Rails core team has stated patches for the inflections library will not be accepted
|
|
11
|
+
# in order to avoid breaking legacy applications which may be relying on errant inflections.
|
|
12
|
+
# If you discover an incorrect inflection and require it for your application, you'll need
|
|
13
|
+
# to correct it yourself (explained below).
|
|
14
|
+
module Inflector
|
|
15
|
+
extend self
|
|
16
|
+
|
|
17
|
+
# A singleton instance of this class is yielded by Inflector.inflections, which can then be used to specify additional
|
|
18
|
+
# inflection rules. Examples:
|
|
19
|
+
#
|
|
20
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
|
21
|
+
# inflect.plural /^(ox)$/i, '\1\2en'
|
|
22
|
+
# inflect.singular /^(ox)en/i, '\1'
|
|
23
|
+
#
|
|
24
|
+
# inflect.irregular 'octopus', 'octopi'
|
|
25
|
+
#
|
|
26
|
+
# inflect.uncountable "equipment"
|
|
27
|
+
# end
|
|
28
|
+
#
|
|
29
|
+
# New rules are added at the top. So in the example above, the irregular rule for octopus will now be the first of the
|
|
30
|
+
# pluralization and singularization rules that is runs. This guarantees that your rules run before any of the rules that may
|
|
31
|
+
# already have been loaded.
|
|
32
|
+
class Inflections
|
|
33
|
+
include Singleton
|
|
34
|
+
|
|
35
|
+
attr_reader :plurals, :singulars, :uncountables, :humans
|
|
36
|
+
|
|
37
|
+
def initialize
|
|
38
|
+
@plurals, @singulars, @uncountables, @humans = [], [], [], []
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Specifies a new pluralization rule and its replacement. The rule can either be a string or a regular expression.
|
|
42
|
+
# The replacement should always be a string that may include references to the matched data from the rule.
|
|
43
|
+
def plural(rule, replacement)
|
|
44
|
+
@uncountables.delete(rule) if rule.is_a?(String)
|
|
45
|
+
@uncountables.delete(replacement)
|
|
46
|
+
@plurals.insert(0, [rule, replacement])
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Specifies a new singularization rule and its replacement. The rule can either be a string or a regular expression.
|
|
50
|
+
# The replacement should always be a string that may include references to the matched data from the rule.
|
|
51
|
+
def singular(rule, replacement)
|
|
52
|
+
@uncountables.delete(rule) if rule.is_a?(String)
|
|
53
|
+
@uncountables.delete(replacement)
|
|
54
|
+
@singulars.insert(0, [rule, replacement])
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Specifies a new irregular that applies to both pluralization and singularization at the same time. This can only be used
|
|
58
|
+
# for strings, not regular expressions. You simply pass the irregular in singular and plural form.
|
|
59
|
+
#
|
|
60
|
+
# Examples:
|
|
61
|
+
# irregular 'octopus', 'octopi'
|
|
62
|
+
# irregular 'person', 'people'
|
|
63
|
+
def irregular(singular, plural)
|
|
64
|
+
@uncountables.delete(singular)
|
|
65
|
+
@uncountables.delete(plural)
|
|
66
|
+
if singular[0,1].upcase == plural[0,1].upcase
|
|
67
|
+
plural(Regexp.new("(#{singular[0,1]})#{singular[1..-1]}$", "i"), '\1' + plural[1..-1])
|
|
68
|
+
singular(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"), '\1' + singular[1..-1])
|
|
69
|
+
else
|
|
70
|
+
plural(Regexp.new("#{singular[0,1].upcase}(?i)#{singular[1..-1]}$"), plural[0,1].upcase + plural[1..-1])
|
|
71
|
+
plural(Regexp.new("#{singular[0,1].downcase}(?i)#{singular[1..-1]}$"), plural[0,1].downcase + plural[1..-1])
|
|
72
|
+
singular(Regexp.new("#{plural[0,1].upcase}(?i)#{plural[1..-1]}$"), singular[0,1].upcase + singular[1..-1])
|
|
73
|
+
singular(Regexp.new("#{plural[0,1].downcase}(?i)#{plural[1..-1]}$"), singular[0,1].downcase + singular[1..-1])
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Add uncountable words that shouldn't be attempted inflected.
|
|
78
|
+
#
|
|
79
|
+
# Examples:
|
|
80
|
+
# uncountable "money"
|
|
81
|
+
# uncountable "money", "information"
|
|
82
|
+
# uncountable %w( money information rice )
|
|
83
|
+
def uncountable(*words)
|
|
84
|
+
(@uncountables << words).flatten!
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Specifies a humanized form of a string by a regular expression rule or by a string mapping.
|
|
88
|
+
# When using a regular expression based replacement, the normal humanize formatting is called after the replacement.
|
|
89
|
+
# When a string is used, the human form should be specified as desired (example: 'The name', not 'the_name')
|
|
90
|
+
#
|
|
91
|
+
# Examples:
|
|
92
|
+
# human /_cnt$/i, '\1_count'
|
|
93
|
+
# human "legacy_col_person_name", "Name"
|
|
94
|
+
def human(rule, replacement)
|
|
95
|
+
@humans.insert(0, [rule, replacement])
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Clears the loaded inflections within a given scope (default is <tt>:all</tt>).
|
|
99
|
+
# Give the scope as a symbol of the inflection type, the options are: <tt>:plurals</tt>,
|
|
100
|
+
# <tt>:singulars</tt>, <tt>:uncountables</tt>, <tt>:humans</tt>.
|
|
101
|
+
#
|
|
102
|
+
# Examples:
|
|
103
|
+
# clear :all
|
|
104
|
+
# clear :plurals
|
|
105
|
+
def clear(scope = :all)
|
|
106
|
+
case scope
|
|
107
|
+
when :all
|
|
108
|
+
@plurals, @singulars, @uncountables = [], [], []
|
|
109
|
+
else
|
|
110
|
+
instance_variable_set "@#{scope}", []
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Yields a singleton instance of Inflector::Inflections so you can specify additional
|
|
116
|
+
# inflector rules.
|
|
117
|
+
#
|
|
118
|
+
# Example:
|
|
119
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
|
120
|
+
# inflect.uncountable "rails"
|
|
121
|
+
# end
|
|
122
|
+
def inflections
|
|
123
|
+
if block_given?
|
|
124
|
+
yield Inflections.instance
|
|
125
|
+
else
|
|
126
|
+
Inflections.instance
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# Returns the plural form of the word in the string.
|
|
131
|
+
#
|
|
132
|
+
# Examples:
|
|
133
|
+
# "post".pluralize # => "posts"
|
|
134
|
+
# "octopus".pluralize # => "octopi"
|
|
135
|
+
# "sheep".pluralize # => "sheep"
|
|
136
|
+
# "words".pluralize # => "words"
|
|
137
|
+
# "CamelOctopus".pluralize # => "CamelOctopi"
|
|
138
|
+
def pluralize(word)
|
|
139
|
+
result = word.to_s.dup
|
|
140
|
+
|
|
141
|
+
if word.empty? || inflections.uncountables.include?(result.downcase)
|
|
142
|
+
result
|
|
143
|
+
else
|
|
144
|
+
inflections.plurals.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
|
|
145
|
+
result
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# The reverse of +pluralize+, returns the singular form of a word in a string.
|
|
150
|
+
#
|
|
151
|
+
# Examples:
|
|
152
|
+
# "posts".singularize # => "post"
|
|
153
|
+
# "octopi".singularize # => "octopus"
|
|
154
|
+
# "sheep".singluarize # => "sheep"
|
|
155
|
+
# "word".singularize # => "word"
|
|
156
|
+
# "CamelOctopi".singularize # => "CamelOctopus"
|
|
157
|
+
def singularize(word)
|
|
158
|
+
result = word.to_s.dup
|
|
159
|
+
|
|
160
|
+
if inflections.uncountables.include?(result.downcase)
|
|
161
|
+
result
|
|
162
|
+
else
|
|
163
|
+
inflections.singulars.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
|
|
164
|
+
result
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# By default, +camelize+ converts strings to UpperCamelCase. If the argument to +camelize+
|
|
169
|
+
# is set to <tt>:lower</tt> then +camelize+ produces lowerCamelCase.
|
|
170
|
+
#
|
|
171
|
+
# +camelize+ will also convert '/' to '::' which is useful for converting paths to namespaces.
|
|
172
|
+
#
|
|
173
|
+
# Examples:
|
|
174
|
+
# "active_record".camelize # => "ActiveRecord"
|
|
175
|
+
# "active_record".camelize(:lower) # => "activeRecord"
|
|
176
|
+
# "active_record/errors".camelize # => "ActiveRecord::Errors"
|
|
177
|
+
# "active_record/errors".camelize(:lower) # => "activeRecord::Errors"
|
|
178
|
+
def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true)
|
|
179
|
+
if first_letter_in_uppercase
|
|
180
|
+
lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
|
|
181
|
+
else
|
|
182
|
+
lower_case_and_underscored_word.first.downcase + camelize(lower_case_and_underscored_word)[1..-1]
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# Capitalizes all the words and replaces some characters in the string to create
|
|
187
|
+
# a nicer looking title. +titleize+ is meant for creating pretty output. It is not
|
|
188
|
+
# used in the Rails internals.
|
|
189
|
+
#
|
|
190
|
+
# +titleize+ is also aliased as as +titlecase+.
|
|
191
|
+
#
|
|
192
|
+
# Examples:
|
|
193
|
+
# "man from the boondocks".titleize # => "Man From The Boondocks"
|
|
194
|
+
# "x-men: the last stand".titleize # => "X Men: The Last Stand"
|
|
195
|
+
def titleize(word)
|
|
196
|
+
humanize(underscore(word)).gsub(/\b('?[a-z])/) { $1.capitalize }
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# The reverse of +camelize+. Makes an underscored, lowercase form from the expression in the string.
|
|
200
|
+
#
|
|
201
|
+
# Changes '::' to '/' to convert namespaces to paths.
|
|
202
|
+
#
|
|
203
|
+
# Examples:
|
|
204
|
+
# "ActiveRecord".underscore # => "active_record"
|
|
205
|
+
# "ActiveRecord::Errors".underscore # => active_record/errors
|
|
206
|
+
def underscore(camel_cased_word)
|
|
207
|
+
camel_cased_word.to_s.gsub(/::/, '/').
|
|
208
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
|
209
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
|
210
|
+
tr("-", "_").
|
|
211
|
+
downcase
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# Replaces underscores with dashes in the string.
|
|
215
|
+
#
|
|
216
|
+
# Example:
|
|
217
|
+
# "puni_puni" # => "puni-puni"
|
|
218
|
+
def dasherize(underscored_word)
|
|
219
|
+
underscored_word.gsub(/_/, '-')
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
# Capitalizes the first word and turns underscores into spaces and strips a
|
|
223
|
+
# trailing "_id", if any. Like +titleize+, this is meant for creating pretty output.
|
|
224
|
+
#
|
|
225
|
+
# Examples:
|
|
226
|
+
# "employee_salary" # => "Employee salary"
|
|
227
|
+
# "author_id" # => "Author"
|
|
228
|
+
def humanize(lower_case_and_underscored_word)
|
|
229
|
+
result = lower_case_and_underscored_word.to_s.dup
|
|
230
|
+
|
|
231
|
+
inflections.humans.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
|
|
232
|
+
result.gsub(/_id$/, "").gsub(/_/, " ").capitalize
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
# Removes the module part from the expression in the string.
|
|
236
|
+
#
|
|
237
|
+
# Examples:
|
|
238
|
+
# "ActiveRecord::CoreExtensions::String::Inflections".demodulize # => "Inflections"
|
|
239
|
+
# "Inflections".demodulize # => "Inflections"
|
|
240
|
+
def demodulize(class_name_in_module)
|
|
241
|
+
class_name_in_module.to_s.gsub(/^.*::/, '')
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
# Replaces special characters in a string so that it may be used as part of a 'pretty' URL.
|
|
245
|
+
#
|
|
246
|
+
# ==== Examples
|
|
247
|
+
#
|
|
248
|
+
# class Person
|
|
249
|
+
# def to_param
|
|
250
|
+
# "#{id}-#{name.parameterize}"
|
|
251
|
+
# end
|
|
252
|
+
# end
|
|
253
|
+
#
|
|
254
|
+
# @person = Person.find(1)
|
|
255
|
+
# # => #<Person id: 1, name: "Donald E. Knuth">
|
|
256
|
+
#
|
|
257
|
+
# <%= link_to(@person.name, person_path %>
|
|
258
|
+
# # => <a href="/person/1-donald-e-knuth">Donald E. Knuth</a>
|
|
259
|
+
def parameterize(string, sep = '-')
|
|
260
|
+
re_sep = Regexp.escape(sep)
|
|
261
|
+
# replace accented chars with ther ascii equivalents
|
|
262
|
+
parameterized_string = transliterate(string)
|
|
263
|
+
# Turn unwanted chars into the seperator
|
|
264
|
+
parameterized_string.gsub!(/[^a-z0-9\-_\+]+/i, sep)
|
|
265
|
+
# No more than one of the separator in a row.
|
|
266
|
+
parameterized_string.squeeze!(sep)
|
|
267
|
+
# Remove leading/trailing separator.
|
|
268
|
+
parameterized_string.gsub!(/^#{re_sep}|#{re_sep}$/i, '')
|
|
269
|
+
parameterized_string.downcase
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
# Replaces accented characters with their ascii equivalents.
|
|
274
|
+
def transliterate(string)
|
|
275
|
+
Iconv.iconv('ascii//ignore//translit', 'utf-8', string).to_s
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
# The iconv transliteration code doesn't function correctly
|
|
279
|
+
# on some platforms, but it's very fast where it does function.
|
|
280
|
+
if "foo" != Inflector.transliterate("föö")
|
|
281
|
+
undef_method :transliterate
|
|
282
|
+
def transliterate(string)
|
|
283
|
+
string.mb_chars.normalize(:kd). # Decompose accented characters
|
|
284
|
+
gsub(/[^\x00-\x7F]+/, '') # Remove anything non-ASCII entirely (e.g. diacritics).
|
|
285
|
+
end
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
# Create the name of a table like Rails does for models to table names. This method
|
|
289
|
+
# uses the +pluralize+ method on the last word in the string.
|
|
290
|
+
#
|
|
291
|
+
# Examples
|
|
292
|
+
# "RawScaledScorer".tableize # => "raw_scaled_scorers"
|
|
293
|
+
# "egg_and_ham".tableize # => "egg_and_hams"
|
|
294
|
+
# "fancyCategory".tableize # => "fancy_categories"
|
|
295
|
+
def tableize(class_name)
|
|
296
|
+
pluralize(underscore(class_name))
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
# Create a class name from a plural table name like Rails does for table names to models.
|
|
300
|
+
# Note that this returns a string and not a Class. (To convert to an actual class
|
|
301
|
+
# follow +classify+ with +constantize+.)
|
|
302
|
+
#
|
|
303
|
+
# Examples:
|
|
304
|
+
# "egg_and_hams".classify # => "EggAndHam"
|
|
305
|
+
# "posts".classify # => "Post"
|
|
306
|
+
#
|
|
307
|
+
# Singular names are not handled correctly:
|
|
308
|
+
# "business".classify # => "Busines"
|
|
309
|
+
def classify(table_name)
|
|
310
|
+
# strip out any leading schema name
|
|
311
|
+
camelize(singularize(table_name.to_s.sub(/.*\./, '')))
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
# Creates a foreign key name from a class name.
|
|
315
|
+
# +separate_class_name_and_id_with_underscore+ sets whether
|
|
316
|
+
# the method should put '_' between the name and 'id'.
|
|
317
|
+
#
|
|
318
|
+
# Examples:
|
|
319
|
+
# "Message".foreign_key # => "message_id"
|
|
320
|
+
# "Message".foreign_key(false) # => "messageid"
|
|
321
|
+
# "Admin::Post".foreign_key # => "post_id"
|
|
322
|
+
def foreign_key(class_name, separate_class_name_and_id_with_underscore = true)
|
|
323
|
+
underscore(demodulize(class_name)) + (separate_class_name_and_id_with_underscore ? "_id" : "id")
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
# Ruby 1.9 introduces an inherit argument for Module#const_get and
|
|
327
|
+
# #const_defined? and changes their default behavior.
|
|
328
|
+
if Module.method(:const_get).arity == 1
|
|
329
|
+
# Tries to find a constant with the name specified in the argument string:
|
|
330
|
+
#
|
|
331
|
+
# "Module".constantize # => Module
|
|
332
|
+
# "Test::Unit".constantize # => Test::Unit
|
|
333
|
+
#
|
|
334
|
+
# The name is assumed to be the one of a top-level constant, no matter whether
|
|
335
|
+
# it starts with "::" or not. No lexical context is taken into account:
|
|
336
|
+
#
|
|
337
|
+
# C = 'outside'
|
|
338
|
+
# module M
|
|
339
|
+
# C = 'inside'
|
|
340
|
+
# C # => 'inside'
|
|
341
|
+
# "C".constantize # => 'outside', same as ::C
|
|
342
|
+
# end
|
|
343
|
+
#
|
|
344
|
+
# NameError is raised when the name is not in CamelCase or the constant is
|
|
345
|
+
# unknown.
|
|
346
|
+
def constantize(camel_cased_word)
|
|
347
|
+
names = camel_cased_word.split('::')
|
|
348
|
+
names.shift if names.empty? || names.first.empty?
|
|
349
|
+
|
|
350
|
+
constant = Object
|
|
351
|
+
names.each do |name|
|
|
352
|
+
constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
|
|
353
|
+
end
|
|
354
|
+
constant
|
|
355
|
+
end
|
|
356
|
+
else
|
|
357
|
+
def constantize(camel_cased_word) #:nodoc:
|
|
358
|
+
names = camel_cased_word.split('::')
|
|
359
|
+
names.shift if names.empty? || names.first.empty?
|
|
360
|
+
|
|
361
|
+
constant = Object
|
|
362
|
+
names.each do |name|
|
|
363
|
+
constant = constant.const_get(name, false) || constant.const_missing(name)
|
|
364
|
+
end
|
|
365
|
+
constant
|
|
366
|
+
end
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
# Turns a number into an ordinal string used to denote the position in an
|
|
370
|
+
# ordered sequence such as 1st, 2nd, 3rd, 4th.
|
|
371
|
+
#
|
|
372
|
+
# Examples:
|
|
373
|
+
# ordinalize(1) # => "1st"
|
|
374
|
+
# ordinalize(2) # => "2nd"
|
|
375
|
+
# ordinalize(1002) # => "1002nd"
|
|
376
|
+
# ordinalize(1003) # => "1003rd"
|
|
377
|
+
def ordinalize(number)
|
|
378
|
+
if (11..13).include?(number.to_i % 100)
|
|
379
|
+
"#{number}th"
|
|
380
|
+
else
|
|
381
|
+
case number.to_i % 10
|
|
382
|
+
when 1; "#{number}st"
|
|
383
|
+
when 2; "#{number}nd"
|
|
384
|
+
when 3; "#{number}rd"
|
|
385
|
+
else "#{number}th"
|
|
386
|
+
end
|
|
387
|
+
end
|
|
388
|
+
end
|
|
389
|
+
end
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
# in case active_support/inflector is required without the rest of active_support
|
|
393
|
+
require 'active_support/inflections'
|
|
394
|
+
require 'active_support/core_ext/string/inflections'
|
|
395
|
+
unless String.included_modules.include?(ActiveSupport::CoreExtensions::String::Inflections)
|
|
396
|
+
String.send :include, ActiveSupport::CoreExtensions::String::Inflections
|
|
397
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require 'yaml'
|
|
2
|
+
require 'strscan'
|
|
3
|
+
|
|
4
|
+
module ActiveSupport
|
|
5
|
+
module JSON
|
|
6
|
+
class ParseError < StandardError
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
class << self
|
|
10
|
+
# Converts a JSON string into a Ruby object.
|
|
11
|
+
def decode(json)
|
|
12
|
+
YAML.load(convert_json_to_yaml(json))
|
|
13
|
+
rescue ArgumentError => e
|
|
14
|
+
raise ParseError, "Invalid JSON string"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
protected
|
|
18
|
+
# matches YAML-formatted dates
|
|
19
|
+
DATE_REGEX = /^\d{4}-\d{2}-\d{2}|\d{4}-\d{1,2}-\d{1,2}[ \t]+\d{1,2}:\d{2}:\d{2}(\.[0-9]*)?(([ \t]*)Z|[-+]\d{2}?(:\d{2})?)?$/
|
|
20
|
+
|
|
21
|
+
# Ensure that ":" and "," are always followed by a space
|
|
22
|
+
def convert_json_to_yaml(json) #:nodoc:
|
|
23
|
+
scanner, quoting, marks, pos, times = StringScanner.new(json), false, [], nil, []
|
|
24
|
+
while scanner.scan_until(/(\\['"]|['":,\\]|\\.)/)
|
|
25
|
+
case char = scanner[1]
|
|
26
|
+
when '"', "'"
|
|
27
|
+
if !quoting
|
|
28
|
+
quoting = char
|
|
29
|
+
pos = scanner.pos
|
|
30
|
+
elsif quoting == char
|
|
31
|
+
if json[pos..scanner.pos-2] =~ DATE_REGEX
|
|
32
|
+
# found a date, track the exact positions of the quotes so we can remove them later.
|
|
33
|
+
# oh, and increment them for each current mark, each one is an extra padded space that bumps
|
|
34
|
+
# the position in the final YAML output
|
|
35
|
+
total_marks = marks.size
|
|
36
|
+
times << pos+total_marks << scanner.pos+total_marks
|
|
37
|
+
end
|
|
38
|
+
quoting = false
|
|
39
|
+
end
|
|
40
|
+
when ":",","
|
|
41
|
+
marks << scanner.pos - 1 unless quoting
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
if marks.empty?
|
|
46
|
+
json.gsub(/\\\//, '/')
|
|
47
|
+
else
|
|
48
|
+
left_pos = [-1].push(*marks)
|
|
49
|
+
right_pos = marks << json.length
|
|
50
|
+
output = []
|
|
51
|
+
left_pos.each_with_index do |left, i|
|
|
52
|
+
output << json[left.succ..right_pos[i]]
|
|
53
|
+
end
|
|
54
|
+
output = output * " "
|
|
55
|
+
|
|
56
|
+
times.each { |i| output[i-1] = ' ' }
|
|
57
|
+
output.gsub!(/\\\//, '/')
|
|
58
|
+
output
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
class Date
|
|
2
|
+
# Returns a JSON string representing the date. If ActiveSupport.use_standard_json_time_format is set to true, the
|
|
3
|
+
# ISO 8601 format is used.
|
|
4
|
+
#
|
|
5
|
+
# ==== Examples:
|
|
6
|
+
#
|
|
7
|
+
# # With ActiveSupport.use_standard_json_time_format = true
|
|
8
|
+
# Date.new(2005,2,1).to_json
|
|
9
|
+
# # => "2005-02-01"
|
|
10
|
+
#
|
|
11
|
+
# # With ActiveSupport.use_standard_json_time_format = false
|
|
12
|
+
# Date.new(2005,2,1).to_json
|
|
13
|
+
# # => "2005/02/01"
|
|
14
|
+
def to_json(options = nil)
|
|
15
|
+
if ActiveSupport.use_standard_json_time_format
|
|
16
|
+
%("#{strftime("%Y-%m-%d")}")
|
|
17
|
+
else
|
|
18
|
+
%("#{strftime("%Y/%m/%d")}")
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
class DateTime
|
|
2
|
+
# Returns a JSON string representing the datetime. If ActiveSupport.use_standard_json_time_format is set to true, the
|
|
3
|
+
# ISO 8601 format is used.
|
|
4
|
+
#
|
|
5
|
+
# ==== Examples:
|
|
6
|
+
#
|
|
7
|
+
# # With ActiveSupport.use_standard_json_time_format = true
|
|
8
|
+
# DateTime.civil(2005,2,1,15,15,10).to_json
|
|
9
|
+
# # => "2005-02-01T15:15:10+00:00"
|
|
10
|
+
#
|
|
11
|
+
# # With ActiveSupport.use_standard_json_time_format = false
|
|
12
|
+
# DateTime.civil(2005,2,1,15,15,10).to_json
|
|
13
|
+
# # => "2005/02/01 15:15:10 +0000"
|
|
14
|
+
def to_json(options = nil)
|
|
15
|
+
if ActiveSupport.use_standard_json_time_format
|
|
16
|
+
xmlschema.inspect
|
|
17
|
+
else
|
|
18
|
+
strftime('"%Y/%m/%d %H:%M:%S %z"')
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module Enumerable
|
|
2
|
+
# Returns a JSON string representing the enumerable. Any +options+
|
|
3
|
+
# given will be passed on to its elements. For example:
|
|
4
|
+
#
|
|
5
|
+
# users = User.find(:all)
|
|
6
|
+
# # => users.to_json(:only => :name)
|
|
7
|
+
#
|
|
8
|
+
# will pass the <tt>:only => :name</tt> option to each user.
|
|
9
|
+
def to_json(options = {}) #:nodoc:
|
|
10
|
+
"[#{map { |value| ActiveSupport::JSON.encode(value, options) } * ', '}]"
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
class Hash
|
|
2
|
+
# Returns a JSON string representing the hash.
|
|
3
|
+
#
|
|
4
|
+
# Without any +options+, the returned JSON string will include all
|
|
5
|
+
# the hash keys. For example:
|
|
6
|
+
#
|
|
7
|
+
# { :name => "Konata Izumi", 'age' => 16, 1 => 2 }.to_json
|
|
8
|
+
# # => {"name": "Konata Izumi", 1: 2, "age": 16}
|
|
9
|
+
#
|
|
10
|
+
# The keys in the JSON string are unordered due to the nature of hashes.
|
|
11
|
+
#
|
|
12
|
+
# The <tt>:only</tt> and <tt>:except</tt> options can be used to limit the
|
|
13
|
+
# attributes included, and will accept 1 or more hash keys to include/exclude.
|
|
14
|
+
#
|
|
15
|
+
# { :name => "Konata Izumi", 'age' => 16, 1 => 2 }.to_json(:only => [:name, 'age'])
|
|
16
|
+
# # => {"name": "Konata Izumi", "age": 16}
|
|
17
|
+
#
|
|
18
|
+
# { :name => "Konata Izumi", 'age' => 16, 1 => 2 }.to_json(:except => 1)
|
|
19
|
+
# # => {"name": "Konata Izumi", "age": 16}
|
|
20
|
+
#
|
|
21
|
+
# The +options+ also filter down to any hash values. This is particularly
|
|
22
|
+
# useful for converting hashes containing ActiveRecord objects or any object
|
|
23
|
+
# that responds to options in their <tt>to_json</tt> method. For example:
|
|
24
|
+
#
|
|
25
|
+
# users = User.find(:all)
|
|
26
|
+
# { :users => users, :count => users.size }.to_json(:include => :posts)
|
|
27
|
+
#
|
|
28
|
+
# would pass the <tt>:include => :posts</tt> option to <tt>users</tt>,
|
|
29
|
+
# allowing the posts association in the User model to be converted to JSON
|
|
30
|
+
# as well.
|
|
31
|
+
def to_json(options = {}) #:nodoc:
|
|
32
|
+
hash_keys = self.keys
|
|
33
|
+
|
|
34
|
+
if options[:except]
|
|
35
|
+
hash_keys = hash_keys - Array(options[:except])
|
|
36
|
+
elsif options[:only]
|
|
37
|
+
hash_keys = hash_keys & Array(options[:only])
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
returning result = '{' do
|
|
41
|
+
result << hash_keys.map do |key|
|
|
42
|
+
"#{ActiveSupport::JSON.encode(key)}: #{ActiveSupport::JSON.encode(self[key], options)}"
|
|
43
|
+
end * ', '
|
|
44
|
+
result << '}'
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module ActiveSupport
|
|
2
|
+
module JSON
|
|
3
|
+
module Encoding
|
|
4
|
+
mattr_accessor :escape_regex
|
|
5
|
+
|
|
6
|
+
ESCAPED_CHARS = {
|
|
7
|
+
"\010" => '\b',
|
|
8
|
+
"\f" => '\f',
|
|
9
|
+
"\n" => '\n',
|
|
10
|
+
"\r" => '\r',
|
|
11
|
+
"\t" => '\t',
|
|
12
|
+
'"' => '\"',
|
|
13
|
+
'\\' => '\\\\',
|
|
14
|
+
'>' => '\u003E',
|
|
15
|
+
'<' => '\u003C',
|
|
16
|
+
'&' => '\u0026'
|
|
17
|
+
}
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
ActiveSupport.escape_html_entities_in_json = true
|
|
23
|
+
|
|
24
|
+
class String
|
|
25
|
+
def to_json(options = nil) #:nodoc:
|
|
26
|
+
json = '"' + gsub(ActiveSupport::JSON::Encoding.escape_regex) { |s|
|
|
27
|
+
ActiveSupport::JSON::Encoding::ESCAPED_CHARS[s]
|
|
28
|
+
}
|
|
29
|
+
json.force_encoding('ascii-8bit') if respond_to?(:force_encoding)
|
|
30
|
+
json.gsub(/([\xC0-\xDF][\x80-\xBF]|
|
|
31
|
+
[\xE0-\xEF][\x80-\xBF]{2}|
|
|
32
|
+
[\xF0-\xF7][\x80-\xBF]{3})+/nx) { |s|
|
|
33
|
+
s.unpack("U*").pack("n*").unpack("H*")[0].gsub(/.{4}/, '\\\\u\&')
|
|
34
|
+
} + '"'
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
class Time
|
|
2
|
+
# Returns a JSON string representing the time. If ActiveSupport.use_standard_json_time_format is set to true, the
|
|
3
|
+
# ISO 8601 format is used.
|
|
4
|
+
#
|
|
5
|
+
# ==== Examples:
|
|
6
|
+
#
|
|
7
|
+
# # With ActiveSupport.use_standard_json_time_format = true
|
|
8
|
+
# Time.utc(2005,2,1,15,15,10).to_json
|
|
9
|
+
# # => "2005-02-01T15:15:10Z"
|
|
10
|
+
#
|
|
11
|
+
# # With ActiveSupport.use_standard_json_time_format = false
|
|
12
|
+
# Time.utc(2005,2,1,15,15,10).to_json
|
|
13
|
+
# # => "2005/02/01 15:15:10 +0000"
|
|
14
|
+
def to_json(options = nil)
|
|
15
|
+
if ActiveSupport.use_standard_json_time_format
|
|
16
|
+
xmlschema.inspect
|
|
17
|
+
else
|
|
18
|
+
%("#{strftime("%Y/%m/%d %H:%M:%S")} #{formatted_offset(false)}")
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|