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,259 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'cgi'
|
3
|
+
require 'builder'
|
4
|
+
require 'xmlsimple'
|
5
|
+
|
6
|
+
# Locked down XmlSimple#xml_in_string
|
7
|
+
class XmlSimple
|
8
|
+
# Same as xml_in but doesn't try to smartly shoot itself in the foot.
|
9
|
+
def xml_in_string(string, options = nil)
|
10
|
+
handle_options('in', options)
|
11
|
+
|
12
|
+
@doc = parse(string)
|
13
|
+
result = collapse(@doc.root)
|
14
|
+
|
15
|
+
if @options['keeproot']
|
16
|
+
merge({}, @doc.root.name, result)
|
17
|
+
else
|
18
|
+
result
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.xml_in_string(string, options = nil)
|
23
|
+
new.xml_in_string(string, options)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# This module exists to decorate files deserialized using Hash.from_xml with
|
28
|
+
# the <tt>original_filename</tt> and <tt>content_type</tt> methods.
|
29
|
+
module FileLike #:nodoc:
|
30
|
+
attr_writer :original_filename, :content_type
|
31
|
+
|
32
|
+
def original_filename
|
33
|
+
@original_filename || 'untitled'
|
34
|
+
end
|
35
|
+
|
36
|
+
def content_type
|
37
|
+
@content_type || 'application/octet-stream'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
module ActiveSupport #:nodoc:
|
42
|
+
module CoreExtensions #:nodoc:
|
43
|
+
module Hash #:nodoc:
|
44
|
+
module Conversions
|
45
|
+
|
46
|
+
XML_TYPE_NAMES = {
|
47
|
+
"Symbol" => "symbol",
|
48
|
+
"Fixnum" => "integer",
|
49
|
+
"Bignum" => "integer",
|
50
|
+
"BigDecimal" => "decimal",
|
51
|
+
"Float" => "float",
|
52
|
+
"Date" => "date",
|
53
|
+
"DateTime" => "datetime",
|
54
|
+
"Time" => "datetime",
|
55
|
+
"TrueClass" => "boolean",
|
56
|
+
"FalseClass" => "boolean"
|
57
|
+
} unless defined?(XML_TYPE_NAMES)
|
58
|
+
|
59
|
+
XML_FORMATTING = {
|
60
|
+
"symbol" => Proc.new { |symbol| symbol.to_s },
|
61
|
+
"date" => Proc.new { |date| date.to_s(:db) },
|
62
|
+
"datetime" => Proc.new { |time| time.xmlschema },
|
63
|
+
"binary" => Proc.new { |binary| ActiveSupport::Base64.encode64(binary) },
|
64
|
+
"yaml" => Proc.new { |yaml| yaml.to_yaml }
|
65
|
+
} unless defined?(XML_FORMATTING)
|
66
|
+
|
67
|
+
# TODO: use Time.xmlschema instead of Time.parse;
|
68
|
+
# use regexp instead of Date.parse
|
69
|
+
unless defined?(XML_PARSING)
|
70
|
+
XML_PARSING = {
|
71
|
+
"symbol" => Proc.new { |symbol| symbol.to_sym },
|
72
|
+
"date" => Proc.new { |date| ::Date.parse(date) },
|
73
|
+
"datetime" => Proc.new { |time| ::Time.parse(time).utc rescue ::DateTime.parse(time).utc },
|
74
|
+
"integer" => Proc.new { |integer| integer.to_i },
|
75
|
+
"float" => Proc.new { |float| float.to_f },
|
76
|
+
"decimal" => Proc.new { |number| BigDecimal(number) },
|
77
|
+
"boolean" => Proc.new { |boolean| %w(1 true).include?(boolean.strip) },
|
78
|
+
"string" => Proc.new { |string| string.to_s },
|
79
|
+
"yaml" => Proc.new { |yaml| YAML::load(yaml) rescue yaml },
|
80
|
+
"base64Binary" => Proc.new { |bin| ActiveSupport::Base64.decode64(bin) },
|
81
|
+
"file" => Proc.new do |file, entity|
|
82
|
+
f = StringIO.new(ActiveSupport::Base64.decode64(file))
|
83
|
+
f.extend(FileLike)
|
84
|
+
f.original_filename = entity['name']
|
85
|
+
f.content_type = entity['content_type']
|
86
|
+
f
|
87
|
+
end
|
88
|
+
}
|
89
|
+
|
90
|
+
XML_PARSING.update(
|
91
|
+
"double" => XML_PARSING["float"],
|
92
|
+
"dateTime" => XML_PARSING["datetime"]
|
93
|
+
)
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.included(klass)
|
97
|
+
klass.extend(ClassMethods)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Converts a hash into a string suitable for use as a URL query string. An optional <tt>namespace</tt> can be
|
101
|
+
# passed to enclose the param names (see example below).
|
102
|
+
#
|
103
|
+
# ==== Example:
|
104
|
+
# { :name => 'David', :nationality => 'Danish' }.to_query # => "name=David&nationality=Danish"
|
105
|
+
#
|
106
|
+
# { :name => 'David', :nationality => 'Danish' }.to_query('user') # => "user%5Bname%5D=David&user%5Bnationality%5D=Danish"
|
107
|
+
def to_query(namespace = nil)
|
108
|
+
collect do |key, value|
|
109
|
+
value.to_query(namespace ? "#{namespace}[#{key}]" : key)
|
110
|
+
end.sort * '&'
|
111
|
+
end
|
112
|
+
|
113
|
+
alias_method :to_param, :to_query
|
114
|
+
|
115
|
+
def to_xml(options = {})
|
116
|
+
options[:indent] ||= 2
|
117
|
+
options.reverse_merge!({ :builder => Builder::XmlMarkup.new(:indent => options[:indent]),
|
118
|
+
:root => "hash" })
|
119
|
+
options[:builder].instruct! unless options.delete(:skip_instruct)
|
120
|
+
dasherize = !options.has_key?(:dasherize) || options[:dasherize]
|
121
|
+
root = dasherize ? options[:root].to_s.dasherize : options[:root].to_s
|
122
|
+
|
123
|
+
options[:builder].__send__(:method_missing, root) do
|
124
|
+
each do |key, value|
|
125
|
+
case value
|
126
|
+
when ::Hash
|
127
|
+
value.to_xml(options.merge({ :root => key, :skip_instruct => true }))
|
128
|
+
when ::Array
|
129
|
+
value.to_xml(options.merge({ :root => key, :children => key.to_s.singularize, :skip_instruct => true}))
|
130
|
+
when ::Method, ::Proc
|
131
|
+
# If the Method or Proc takes two arguments, then
|
132
|
+
# pass the suggested child element name. This is
|
133
|
+
# used if the Method or Proc will be operating over
|
134
|
+
# multiple records and needs to create an containing
|
135
|
+
# element that will contain the objects being
|
136
|
+
# serialized.
|
137
|
+
if 1 == value.arity
|
138
|
+
value.call(options.merge({ :root => key, :skip_instruct => true }))
|
139
|
+
else
|
140
|
+
value.call(options.merge({ :root => key, :skip_instruct => true }), key.to_s.singularize)
|
141
|
+
end
|
142
|
+
else
|
143
|
+
if value.respond_to?(:to_xml)
|
144
|
+
value.to_xml(options.merge({ :root => key, :skip_instruct => true }))
|
145
|
+
else
|
146
|
+
type_name = XML_TYPE_NAMES[value.class.name]
|
147
|
+
|
148
|
+
key = dasherize ? key.to_s.dasherize : key.to_s
|
149
|
+
|
150
|
+
attributes = options[:skip_types] || value.nil? || type_name.nil? ? { } : { :type => type_name }
|
151
|
+
if value.nil?
|
152
|
+
attributes[:nil] = true
|
153
|
+
end
|
154
|
+
|
155
|
+
options[:builder].tag!(key,
|
156
|
+
XML_FORMATTING[type_name] ? XML_FORMATTING[type_name].call(value) : value,
|
157
|
+
attributes
|
158
|
+
)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
yield options[:builder] if block_given?
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
module ClassMethods
|
169
|
+
def from_xml(xml)
|
170
|
+
# TODO: Refactor this into something much cleaner that doesn't rely on XmlSimple
|
171
|
+
typecast_xml_value(undasherize_keys(XmlSimple.xml_in_string(xml,
|
172
|
+
'forcearray' => false,
|
173
|
+
'forcecontent' => true,
|
174
|
+
'keeproot' => true,
|
175
|
+
'contentkey' => '__content__')
|
176
|
+
))
|
177
|
+
end
|
178
|
+
|
179
|
+
private
|
180
|
+
def typecast_xml_value(value)
|
181
|
+
case value.class.to_s
|
182
|
+
when 'Hash'
|
183
|
+
if value['type'] == 'array'
|
184
|
+
child_key, entries = value.detect { |k,v| k != 'type' } # child_key is throwaway
|
185
|
+
if entries.nil? || (c = value['__content__'] && c.blank?)
|
186
|
+
[]
|
187
|
+
else
|
188
|
+
case entries.class.to_s # something weird with classes not matching here. maybe singleton methods breaking is_a?
|
189
|
+
when "Array"
|
190
|
+
entries.collect { |v| typecast_xml_value(v) }
|
191
|
+
when "Hash"
|
192
|
+
[typecast_xml_value(entries)]
|
193
|
+
else
|
194
|
+
raise "can't typecast #{entries.inspect}"
|
195
|
+
end
|
196
|
+
end
|
197
|
+
elsif value.has_key?("__content__")
|
198
|
+
content = value["__content__"]
|
199
|
+
if parser = XML_PARSING[value["type"]]
|
200
|
+
if parser.arity == 2
|
201
|
+
XML_PARSING[value["type"]].call(content, value)
|
202
|
+
else
|
203
|
+
XML_PARSING[value["type"]].call(content)
|
204
|
+
end
|
205
|
+
else
|
206
|
+
content
|
207
|
+
end
|
208
|
+
elsif value['type'] == 'string' && value['nil'] != 'true'
|
209
|
+
""
|
210
|
+
# blank or nil parsed values are represented by nil
|
211
|
+
elsif value.blank? || value['nil'] == 'true'
|
212
|
+
nil
|
213
|
+
# If the type is the only element which makes it then
|
214
|
+
# this still makes the value nil, except if type is
|
215
|
+
# a XML node(where type['value'] is a Hash)
|
216
|
+
elsif value['type'] && value.size == 1 && !value['type'].is_a?(::Hash)
|
217
|
+
nil
|
218
|
+
else
|
219
|
+
xml_value = value.inject({}) do |h,(k,v)|
|
220
|
+
h[k] = typecast_xml_value(v)
|
221
|
+
h
|
222
|
+
end
|
223
|
+
|
224
|
+
# Turn { :files => { :file => #<StringIO> } into { :files => #<StringIO> } so it is compatible with
|
225
|
+
# how multipart uploaded files from HTML appear
|
226
|
+
xml_value["file"].is_a?(StringIO) ? xml_value["file"] : xml_value
|
227
|
+
end
|
228
|
+
when 'Array'
|
229
|
+
value.map! { |i| typecast_xml_value(i) }
|
230
|
+
case value.length
|
231
|
+
when 0 then nil
|
232
|
+
when 1 then value.first
|
233
|
+
else value
|
234
|
+
end
|
235
|
+
when 'String'
|
236
|
+
value
|
237
|
+
else
|
238
|
+
raise "can't typecast #{value.class.name} - #{value.inspect}"
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
def undasherize_keys(params)
|
243
|
+
case params.class.to_s
|
244
|
+
when "Hash"
|
245
|
+
params.inject({}) do |h,(k,v)|
|
246
|
+
h[k.to_s.tr("-", "_")] = undasherize_keys(v)
|
247
|
+
h
|
248
|
+
end
|
249
|
+
when "Array"
|
250
|
+
params.map { |v| undasherize_keys(v) }
|
251
|
+
else
|
252
|
+
params
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ActiveSupport #:nodoc:
|
2
|
+
module CoreExtensions #:nodoc:
|
3
|
+
module Hash #:nodoc:
|
4
|
+
# Allows for deep merging
|
5
|
+
module DeepMerge
|
6
|
+
# Returns a new hash with +self+ and +other_hash+ merged recursively.
|
7
|
+
def deep_merge(other_hash)
|
8
|
+
self.merge(other_hash) do |key, oldval, newval|
|
9
|
+
oldval = oldval.to_hash if oldval.respond_to?(:to_hash)
|
10
|
+
newval = newval.to_hash if newval.respond_to?(:to_hash)
|
11
|
+
oldval.class.to_s == 'Hash' && newval.class.to_s == 'Hash' ? oldval.deep_merge(newval) : newval
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Returns a new hash with +self+ and +other_hash+ merged recursively.
|
16
|
+
# Modifies the receiver in place.
|
17
|
+
def deep_merge!(other_hash)
|
18
|
+
replace(deep_merge(other_hash))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ActiveSupport #:nodoc:
|
2
|
+
module CoreExtensions #:nodoc:
|
3
|
+
module Hash #:nodoc:
|
4
|
+
module Diff
|
5
|
+
# Returns a hash that represents the difference between two hashes.
|
6
|
+
#
|
7
|
+
# Examples:
|
8
|
+
#
|
9
|
+
# {1 => 2}.diff(1 => 2) # => {}
|
10
|
+
# {1 => 2}.diff(1 => 3) # => {1 => 2}
|
11
|
+
# {}.diff(1 => 2) # => {1 => 2}
|
12
|
+
# {1 => 2, 3 => 4}.diff(1 => 2) # => {3 => 4}
|
13
|
+
def diff(h2)
|
14
|
+
self.dup.delete_if { |k, v| h2[k] == v }.merge(h2.dup.delete_if { |k, v| self.has_key?(k) })
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
module ActiveSupport #:nodoc:
|
4
|
+
module CoreExtensions #:nodoc:
|
5
|
+
module Hash #:nodoc:
|
6
|
+
# Return a hash that includes everything but the given keys. This is useful for
|
7
|
+
# limiting a set of parameters to everything but a few known toggles:
|
8
|
+
#
|
9
|
+
# @person.update_attributes(params[:person].except(:admin))
|
10
|
+
module Except
|
11
|
+
# Returns a new hash without the given keys.
|
12
|
+
def except(*keys)
|
13
|
+
dup.except!(*keys)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Replaces the hash without the given keys.
|
17
|
+
def except!(*keys)
|
18
|
+
keys.map! { |key| convert_key(key) } if respond_to?(:convert_key)
|
19
|
+
keys.each { |key| delete(key) }
|
20
|
+
self
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
# This class has dubious semantics and we only have it so that
|
2
|
+
# people can write params[:key] instead of params['key']
|
3
|
+
# and they get the same value for both keys.
|
4
|
+
|
5
|
+
class HashWithIndifferentAccess < Hash
|
6
|
+
def initialize(constructor = {})
|
7
|
+
if constructor.is_a?(Hash)
|
8
|
+
super()
|
9
|
+
update(constructor)
|
10
|
+
else
|
11
|
+
super(constructor)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def default(key = nil)
|
16
|
+
if key.is_a?(Symbol) && include?(key = key.to_s)
|
17
|
+
self[key]
|
18
|
+
else
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
alias_method :regular_writer, :[]= unless method_defined?(:regular_writer)
|
24
|
+
alias_method :regular_update, :update unless method_defined?(:regular_update)
|
25
|
+
|
26
|
+
# Assigns a new value to the hash:
|
27
|
+
#
|
28
|
+
# hash = HashWithIndifferentAccess.new
|
29
|
+
# hash[:key] = "value"
|
30
|
+
#
|
31
|
+
def []=(key, value)
|
32
|
+
regular_writer(convert_key(key), convert_value(value))
|
33
|
+
end
|
34
|
+
|
35
|
+
# Updates the instantized hash with values from the second:
|
36
|
+
#
|
37
|
+
# hash_1 = HashWithIndifferentAccess.new
|
38
|
+
# hash_1[:key] = "value"
|
39
|
+
#
|
40
|
+
# hash_2 = HashWithIndifferentAccess.new
|
41
|
+
# hash_2[:key] = "New Value!"
|
42
|
+
#
|
43
|
+
# hash_1.update(hash_2) # => {"key"=>"New Value!"}
|
44
|
+
#
|
45
|
+
def update(other_hash)
|
46
|
+
other_hash.each_pair { |key, value| regular_writer(convert_key(key), convert_value(value)) }
|
47
|
+
self
|
48
|
+
end
|
49
|
+
|
50
|
+
alias_method :merge!, :update
|
51
|
+
|
52
|
+
# Checks the hash for a key matching the argument passed in:
|
53
|
+
#
|
54
|
+
# hash = HashWithIndifferentAccess.new
|
55
|
+
# hash["key"] = "value"
|
56
|
+
# hash.key? :key # => true
|
57
|
+
# hash.key? "key" # => true
|
58
|
+
#
|
59
|
+
def key?(key)
|
60
|
+
super(convert_key(key))
|
61
|
+
end
|
62
|
+
|
63
|
+
alias_method :include?, :key?
|
64
|
+
alias_method :has_key?, :key?
|
65
|
+
alias_method :member?, :key?
|
66
|
+
|
67
|
+
# Fetches the value for the specified key, same as doing hash[key]
|
68
|
+
def fetch(key, *extras)
|
69
|
+
super(convert_key(key), *extras)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Returns an array of the values at the specified indices:
|
73
|
+
#
|
74
|
+
# hash = HashWithIndifferentAccess.new
|
75
|
+
# hash[:a] = "x"
|
76
|
+
# hash[:b] = "y"
|
77
|
+
# hash.values_at("a", "b") # => ["x", "y"]
|
78
|
+
#
|
79
|
+
def values_at(*indices)
|
80
|
+
indices.collect {|key| self[convert_key(key)]}
|
81
|
+
end
|
82
|
+
|
83
|
+
# Returns an exact copy of the hash.
|
84
|
+
def dup
|
85
|
+
HashWithIndifferentAccess.new(self)
|
86
|
+
end
|
87
|
+
|
88
|
+
# Merges the instantized and the specified hashes together, giving precedence to the values from the second hash
|
89
|
+
# Does not overwrite the existing hash.
|
90
|
+
def merge(hash)
|
91
|
+
self.dup.update(hash)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Removes a specified key from the hash.
|
95
|
+
def delete(key)
|
96
|
+
super(convert_key(key))
|
97
|
+
end
|
98
|
+
|
99
|
+
def stringify_keys!; self end
|
100
|
+
def symbolize_keys!; self end
|
101
|
+
def to_options!; self end
|
102
|
+
|
103
|
+
# Convert to a Hash with String keys.
|
104
|
+
def to_hash
|
105
|
+
Hash.new(default).merge(self)
|
106
|
+
end
|
107
|
+
|
108
|
+
protected
|
109
|
+
def convert_key(key)
|
110
|
+
key.kind_of?(Symbol) ? key.to_s : key
|
111
|
+
end
|
112
|
+
|
113
|
+
def convert_value(value)
|
114
|
+
case value
|
115
|
+
when Hash
|
116
|
+
value.with_indifferent_access
|
117
|
+
when Array
|
118
|
+
value.collect { |e| e.is_a?(Hash) ? e.with_indifferent_access : e }
|
119
|
+
else
|
120
|
+
value
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
module ActiveSupport #:nodoc:
|
126
|
+
module CoreExtensions #:nodoc:
|
127
|
+
module Hash #:nodoc:
|
128
|
+
module IndifferentAccess #:nodoc:
|
129
|
+
def with_indifferent_access
|
130
|
+
hash = HashWithIndifferentAccess.new(self)
|
131
|
+
hash.default = self.default
|
132
|
+
hash
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module ActiveSupport #:nodoc:
|
2
|
+
module CoreExtensions #:nodoc:
|
3
|
+
module Hash #:nodoc:
|
4
|
+
module Keys
|
5
|
+
# Return a new hash with all keys converted to strings.
|
6
|
+
def stringify_keys
|
7
|
+
inject({}) do |options, (key, value)|
|
8
|
+
options[key.to_s] = value
|
9
|
+
options
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# Destructively convert all keys to strings.
|
14
|
+
def stringify_keys!
|
15
|
+
keys.each do |key|
|
16
|
+
self[key.to_s] = delete(key)
|
17
|
+
end
|
18
|
+
self
|
19
|
+
end
|
20
|
+
|
21
|
+
# Return a new hash with all keys converted to symbols.
|
22
|
+
def symbolize_keys
|
23
|
+
inject({}) do |options, (key, value)|
|
24
|
+
options[(key.to_sym rescue key) || key] = value
|
25
|
+
options
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Destructively convert all keys to symbols.
|
30
|
+
def symbolize_keys!
|
31
|
+
self.replace(self.symbolize_keys)
|
32
|
+
end
|
33
|
+
|
34
|
+
alias_method :to_options, :symbolize_keys
|
35
|
+
alias_method :to_options!, :symbolize_keys!
|
36
|
+
|
37
|
+
# Validate all keys in a hash match *valid keys, raising ArgumentError on a mismatch.
|
38
|
+
# Note that keys are NOT treated indifferently, meaning if you use strings for keys but assert symbols
|
39
|
+
# as keys, this will fail.
|
40
|
+
#
|
41
|
+
# ==== Examples:
|
42
|
+
# { :name => "Rob", :years => "28" }.assert_valid_keys(:name, :age) # => raises "ArgumentError: Unknown key(s): years"
|
43
|
+
# { :name => "Rob", :age => "28" }.assert_valid_keys("name", "age") # => raises "ArgumentError: Unknown key(s): name, age"
|
44
|
+
# { :name => "Rob", :age => "28" }.assert_valid_keys(:name, :age) # => passes, raises nothing
|
45
|
+
def assert_valid_keys(*valid_keys)
|
46
|
+
unknown_keys = keys - [valid_keys].flatten
|
47
|
+
raise(ArgumentError, "Unknown key(s): #{unknown_keys.join(", ")}") unless unknown_keys.empty?
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module ActiveSupport #:nodoc:
|
2
|
+
module CoreExtensions #:nodoc:
|
3
|
+
module Hash #:nodoc:
|
4
|
+
# Allows for reverse merging two hashes where the keys in the calling hash take precedence over those
|
5
|
+
# in the <tt>other_hash</tt>. This is particularly useful for initializing an option hash with default values:
|
6
|
+
#
|
7
|
+
# def setup(options = {})
|
8
|
+
# options.reverse_merge! :size => 25, :velocity => 10
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
# Using <tt>merge</tt>, the above example would look as follows:
|
12
|
+
#
|
13
|
+
# def setup(options = {})
|
14
|
+
# { :size => 25, :velocity => 10 }.merge(options)
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# The default <tt>:size</tt> and <tt>:velocity</tt> are only set if the +options+ hash passed in doesn't already
|
18
|
+
# have the respective key.
|
19
|
+
module ReverseMerge
|
20
|
+
# Performs the opposite of <tt>merge</tt>, with the keys and values from the first hash taking precedence over the second.
|
21
|
+
def reverse_merge(other_hash)
|
22
|
+
other_hash.merge(self)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Performs the opposite of <tt>merge</tt>, with the keys and values from the first hash taking precedence over the second.
|
26
|
+
# Modifies the receiver in place.
|
27
|
+
def reverse_merge!(other_hash)
|
28
|
+
replace(reverse_merge(other_hash))
|
29
|
+
end
|
30
|
+
|
31
|
+
alias_method :reverse_update, :reverse_merge!
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module ActiveSupport #:nodoc:
|
2
|
+
module CoreExtensions #:nodoc:
|
3
|
+
module Hash #:nodoc:
|
4
|
+
# Slice a hash to include only the given keys. This is useful for
|
5
|
+
# limiting an options hash to valid keys before passing to a method:
|
6
|
+
#
|
7
|
+
# def search(criteria = {})
|
8
|
+
# assert_valid_keys(:mass, :velocity, :time)
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
# search(options.slice(:mass, :velocity, :time))
|
12
|
+
#
|
13
|
+
# If you have an array of keys you want to limit to, you should splat them:
|
14
|
+
#
|
15
|
+
# valid_keys = [:mass, :velocity, :time]
|
16
|
+
# search(options.slice(*valid_keys))
|
17
|
+
module Slice
|
18
|
+
# Returns a new hash with only the given keys.
|
19
|
+
def slice(*keys)
|
20
|
+
keys = keys.map! { |key| convert_key(key) } if respond_to?(:convert_key)
|
21
|
+
hash = self.class.new
|
22
|
+
keys.each { |k| hash[k] = self[k] if has_key?(k) }
|
23
|
+
hash
|
24
|
+
end
|
25
|
+
|
26
|
+
# Replaces the hash with only the given keys.
|
27
|
+
def slice!(*keys)
|
28
|
+
replace(slice(*keys))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
%w(keys indifferent_access deep_merge reverse_merge conversions diff slice except).each do |ext|
|
2
|
+
require "active_support/core_ext/hash/#{ext}"
|
3
|
+
end
|
4
|
+
|
5
|
+
class Hash #:nodoc:
|
6
|
+
include ActiveSupport::CoreExtensions::Hash::Keys
|
7
|
+
include ActiveSupport::CoreExtensions::Hash::IndifferentAccess
|
8
|
+
include ActiveSupport::CoreExtensions::Hash::DeepMerge
|
9
|
+
include ActiveSupport::CoreExtensions::Hash::ReverseMerge
|
10
|
+
include ActiveSupport::CoreExtensions::Hash::Conversions
|
11
|
+
include ActiveSupport::CoreExtensions::Hash::Diff
|
12
|
+
include ActiveSupport::CoreExtensions::Hash::Slice
|
13
|
+
include ActiveSupport::CoreExtensions::Hash::Except
|
14
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module ActiveSupport #:nodoc:
|
2
|
+
module CoreExtensions #:nodoc:
|
3
|
+
module Integer #:nodoc:
|
4
|
+
# For checking if a fixnum is even or odd.
|
5
|
+
#
|
6
|
+
# 2.even? # => true
|
7
|
+
# 2.odd? # => false
|
8
|
+
# 1.even? # => false
|
9
|
+
# 1.odd? # => true
|
10
|
+
# 0.even? # => true
|
11
|
+
# 0.odd? # => false
|
12
|
+
# -1.even? # => false
|
13
|
+
# -1.odd? # => true
|
14
|
+
module EvenOdd
|
15
|
+
def multiple_of?(number)
|
16
|
+
self % number == 0
|
17
|
+
end
|
18
|
+
|
19
|
+
def even?
|
20
|
+
multiple_of? 2
|
21
|
+
end if RUBY_VERSION < '1.9'
|
22
|
+
|
23
|
+
def odd?
|
24
|
+
!even?
|
25
|
+
end if RUBY_VERSION < '1.9'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'active_support/inflector'
|
2
|
+
|
3
|
+
module ActiveSupport #:nodoc:
|
4
|
+
module CoreExtensions #:nodoc:
|
5
|
+
module Integer #:nodoc:
|
6
|
+
module Inflections
|
7
|
+
# Ordinalize turns a number into an ordinal string used to denote the
|
8
|
+
# position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
|
9
|
+
#
|
10
|
+
# 1.ordinalize # => "1st"
|
11
|
+
# 2.ordinalize # => "2nd"
|
12
|
+
# 1002.ordinalize # => "1002nd"
|
13
|
+
# 1003.ordinalize # => "1003rd"
|
14
|
+
def ordinalize
|
15
|
+
Inflector.ordinalize(self)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|