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,45 @@
|
|
|
1
|
+
module ActiveSupport #:nodoc:
|
|
2
|
+
module CoreExtensions #:nodoc:
|
|
3
|
+
module Integer #:nodoc:
|
|
4
|
+
# Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years.
|
|
5
|
+
#
|
|
6
|
+
# These methods use Time#advance for precise date calculations when using from_now, ago, etc.
|
|
7
|
+
# as well as adding or subtracting their results from a Time object. For example:
|
|
8
|
+
#
|
|
9
|
+
# # equivalent to Time.now.advance(:months => 1)
|
|
10
|
+
# 1.month.from_now
|
|
11
|
+
#
|
|
12
|
+
# # equivalent to Time.now.advance(:years => 2)
|
|
13
|
+
# 2.years.from_now
|
|
14
|
+
#
|
|
15
|
+
# # equivalent to Time.now.advance(:months => 4, :years => 5)
|
|
16
|
+
# (4.months + 5.years).from_now
|
|
17
|
+
#
|
|
18
|
+
# While these methods provide precise calculation when used as in the examples above, care
|
|
19
|
+
# should be taken to note that this is not true if the result of `months', `years', etc is
|
|
20
|
+
# converted before use:
|
|
21
|
+
#
|
|
22
|
+
# # equivalent to 30.days.to_i.from_now
|
|
23
|
+
# 1.month.to_i.from_now
|
|
24
|
+
#
|
|
25
|
+
# # equivalent to 365.25.days.to_f.from_now
|
|
26
|
+
# 1.year.to_f.from_now
|
|
27
|
+
#
|
|
28
|
+
# In such cases, Ruby's core
|
|
29
|
+
# Date[http://stdlib.rubyonrails.org/libdoc/date/rdoc/index.html] and
|
|
30
|
+
# Time[http://stdlib.rubyonrails.org/libdoc/time/rdoc/index.html] should be used for precision
|
|
31
|
+
# date and time arithmetic
|
|
32
|
+
module Time
|
|
33
|
+
def months
|
|
34
|
+
ActiveSupport::Duration.new(self * 30.days, [[:months, self]])
|
|
35
|
+
end
|
|
36
|
+
alias :month :months
|
|
37
|
+
|
|
38
|
+
def years
|
|
39
|
+
ActiveSupport::Duration.new(self * 365.25.days, [[:years, self]])
|
|
40
|
+
end
|
|
41
|
+
alias :year :years
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
require 'active_support/core_ext/integer/even_odd'
|
|
2
|
+
require 'active_support/core_ext/integer/inflections'
|
|
3
|
+
require 'active_support/core_ext/integer/time'
|
|
4
|
+
|
|
5
|
+
class Integer #:nodoc:
|
|
6
|
+
include ActiveSupport::CoreExtensions::Integer::EvenOdd
|
|
7
|
+
include ActiveSupport::CoreExtensions::Integer::Inflections
|
|
8
|
+
include ActiveSupport::CoreExtensions::Integer::Time
|
|
9
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
class Object
|
|
2
|
+
# Makes backticks behave (somewhat more) similarly on all platforms.
|
|
3
|
+
# On win32 `nonexistent_command` raises Errno::ENOENT; on Unix, the
|
|
4
|
+
# spawned shell prints a message to stderr and sets $?. We emulate
|
|
5
|
+
# Unix on the former but not the latter.
|
|
6
|
+
def `(command) #:nodoc:
|
|
7
|
+
super
|
|
8
|
+
rescue Errno::ENOENT => e
|
|
9
|
+
STDERR.puts "#$0: #{e}"
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Kernel
|
|
2
|
+
unless respond_to?(:debugger)
|
|
3
|
+
# Starts a debugging session if ruby-debug has been loaded (call script/server --debugger to do load it).
|
|
4
|
+
def debugger
|
|
5
|
+
Rails.logger.info "\n***** Debugger requested, but was not available: Start server with --debugger to enable *****\n"
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def breakpoint
|
|
10
|
+
Rails.logger.info "\n***** The 'breakpoint' command has been renamed 'debugger' -- please change *****\n"
|
|
11
|
+
debugger
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
module Kernel
|
|
2
|
+
# Sets $VERBOSE to nil for the duration of the block and back to its original value afterwards.
|
|
3
|
+
#
|
|
4
|
+
# silence_warnings do
|
|
5
|
+
# value = noisy_call # no warning voiced
|
|
6
|
+
# end
|
|
7
|
+
#
|
|
8
|
+
# noisy_call # warning voiced
|
|
9
|
+
def silence_warnings
|
|
10
|
+
old_verbose, $VERBOSE = $VERBOSE, nil
|
|
11
|
+
yield
|
|
12
|
+
ensure
|
|
13
|
+
$VERBOSE = old_verbose
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Sets $VERBOSE to true for the duration of the block and back to its original value afterwards.
|
|
17
|
+
def enable_warnings
|
|
18
|
+
old_verbose, $VERBOSE = $VERBOSE, true
|
|
19
|
+
yield
|
|
20
|
+
ensure
|
|
21
|
+
$VERBOSE = old_verbose
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# For compatibility
|
|
25
|
+
def silence_stderr #:nodoc:
|
|
26
|
+
silence_stream(STDERR) { yield }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Silences any stream for the duration of the block.
|
|
30
|
+
#
|
|
31
|
+
# silence_stream(STDOUT) do
|
|
32
|
+
# puts 'This will never be seen'
|
|
33
|
+
# end
|
|
34
|
+
#
|
|
35
|
+
# puts 'But this will'
|
|
36
|
+
def silence_stream(stream)
|
|
37
|
+
old_stream = stream.dup
|
|
38
|
+
stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
|
|
39
|
+
stream.sync = true
|
|
40
|
+
yield
|
|
41
|
+
ensure
|
|
42
|
+
stream.reopen(old_stream)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Blocks and ignores any exception passed as argument if raised within the block.
|
|
46
|
+
#
|
|
47
|
+
# suppress(ZeroDivisionError) do
|
|
48
|
+
# 1/0
|
|
49
|
+
# puts "This code is NOT reached"
|
|
50
|
+
# end
|
|
51
|
+
#
|
|
52
|
+
# puts "This code gets executed and nothing related to ZeroDivisionError was seen"
|
|
53
|
+
def suppress(*exception_classes)
|
|
54
|
+
begin yield
|
|
55
|
+
rescue Exception => e
|
|
56
|
+
raise unless exception_classes.any? { |cls| e.kind_of?(cls) }
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Kernel
|
|
2
|
+
# Require a library with fallback to RubyGems. Warnings during library
|
|
3
|
+
# loading are silenced to increase signal/noise for application warnings.
|
|
4
|
+
def require_library_or_gem(library_name)
|
|
5
|
+
silence_warnings do
|
|
6
|
+
begin
|
|
7
|
+
require library_name
|
|
8
|
+
rescue LoadError => cannot_require
|
|
9
|
+
# 1. Requiring the module is unsuccessful, maybe it's a gem and nobody required rubygems yet. Try.
|
|
10
|
+
begin
|
|
11
|
+
require 'rubygems'
|
|
12
|
+
rescue LoadError => rubygems_not_installed
|
|
13
|
+
raise cannot_require
|
|
14
|
+
end
|
|
15
|
+
# 2. Rubygems is installed and loaded. Try to load the library again
|
|
16
|
+
begin
|
|
17
|
+
require library_name
|
|
18
|
+
rescue LoadError => gem_not_installed
|
|
19
|
+
raise cannot_require
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
class MissingSourceFile < LoadError #:nodoc:
|
|
2
|
+
attr_reader :path
|
|
3
|
+
def initialize(message, path)
|
|
4
|
+
super(message)
|
|
5
|
+
@path = path
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def is_missing?(path)
|
|
9
|
+
path.gsub(/\.rb$/, '') == self.path.gsub(/\.rb$/, '')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.from_message(message)
|
|
13
|
+
REGEXPS.each do |regexp, capture|
|
|
14
|
+
match = regexp.match(message)
|
|
15
|
+
return MissingSourceFile.new(message, match[capture]) unless match.nil?
|
|
16
|
+
end
|
|
17
|
+
nil
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
REGEXPS = [
|
|
21
|
+
[/^no such file to load -- (.+)$/i, 1],
|
|
22
|
+
[/^Missing \w+ (file\s*)?([^\s]+.rb)$/i, 2],
|
|
23
|
+
[/^Missing API definition file in (.+)$/i, 1]
|
|
24
|
+
] unless defined?(REGEXPS)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
module ActiveSupport #:nodoc:
|
|
28
|
+
module CoreExtensions #:nodoc:
|
|
29
|
+
module LoadErrorExtensions #:nodoc:
|
|
30
|
+
module LoadErrorClassMethods #:nodoc:
|
|
31
|
+
def new(*args)
|
|
32
|
+
(self == LoadError && MissingSourceFile.from_message(args.first)) || super
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
::LoadError.extend(LoadErrorClassMethods)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Adds the 'around_level' method to Logger.
|
|
2
|
+
|
|
3
|
+
class Logger
|
|
4
|
+
def self.define_around_helper(level)
|
|
5
|
+
module_eval <<-end_eval
|
|
6
|
+
def around_#{level}(before_message, after_message, &block)
|
|
7
|
+
self.#{level}(before_message)
|
|
8
|
+
return_value = block.call(self)
|
|
9
|
+
self.#{level}(after_message)
|
|
10
|
+
return return_value
|
|
11
|
+
end
|
|
12
|
+
end_eval
|
|
13
|
+
end
|
|
14
|
+
[:debug, :info, :error, :fatal].each {|level| define_around_helper(level) }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
require 'logger'
|
|
19
|
+
|
|
20
|
+
# Extensions to the built in Ruby logger.
|
|
21
|
+
#
|
|
22
|
+
# If you want to use the default log formatter as defined in the Ruby core, then you
|
|
23
|
+
# will need to set the formatter for the logger as in:
|
|
24
|
+
#
|
|
25
|
+
# logger.formatter = Formatter.new
|
|
26
|
+
#
|
|
27
|
+
# You can then specify the datetime format, for example:
|
|
28
|
+
#
|
|
29
|
+
# logger.datetime_format = "%Y-%m-%d"
|
|
30
|
+
#
|
|
31
|
+
# Note: This logger is deprecated in favor of ActiveSupport::BufferedLogger
|
|
32
|
+
class Logger
|
|
33
|
+
# Set to false to disable the silencer
|
|
34
|
+
cattr_accessor :silencer
|
|
35
|
+
self.silencer = true
|
|
36
|
+
|
|
37
|
+
# Silences the logger for the duration of the block.
|
|
38
|
+
def silence(temporary_level = Logger::ERROR)
|
|
39
|
+
if silencer
|
|
40
|
+
begin
|
|
41
|
+
old_logger_level, self.level = level, temporary_level
|
|
42
|
+
yield self
|
|
43
|
+
ensure
|
|
44
|
+
self.level = old_logger_level
|
|
45
|
+
end
|
|
46
|
+
else
|
|
47
|
+
yield self
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
alias :old_datetime_format= :datetime_format=
|
|
52
|
+
# Logging date-time format (string passed to +strftime+). Ignored if the formatter
|
|
53
|
+
# does not respond to datetime_format=.
|
|
54
|
+
def datetime_format=(datetime_format)
|
|
55
|
+
formatter.datetime_format = datetime_format if formatter.respond_to?(:datetime_format=)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
alias :old_datetime_format :datetime_format
|
|
59
|
+
# Get the logging datetime format. Returns nil if the formatter does not support
|
|
60
|
+
# datetime formatting.
|
|
61
|
+
def datetime_format
|
|
62
|
+
formatter.datetime_format if formatter.respond_to?(:datetime_format)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
alias :old_formatter :formatter if method_defined?(:formatter)
|
|
66
|
+
# Get the current formatter. The default formatter is a SimpleFormatter which only
|
|
67
|
+
# displays the log message
|
|
68
|
+
def formatter
|
|
69
|
+
@formatter ||= SimpleFormatter.new
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
unless const_defined? :Formatter
|
|
73
|
+
class Formatter
|
|
74
|
+
Format = "%s, [%s#%d] %5s -- %s: %s\n"
|
|
75
|
+
|
|
76
|
+
attr_accessor :datetime_format
|
|
77
|
+
|
|
78
|
+
def initialize
|
|
79
|
+
@datetime_format = nil
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def call(severity, time, progname, msg)
|
|
83
|
+
Format % [severity[0..0], format_datetime(time), $$, severity, progname,
|
|
84
|
+
msg2str(msg)]
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
private
|
|
88
|
+
def format_datetime(time)
|
|
89
|
+
if @datetime_format.nil?
|
|
90
|
+
time.strftime("%Y-%m-%dT%H:%M:%S.") << "%06d " % time.usec
|
|
91
|
+
else
|
|
92
|
+
time.strftime(@datetime_format)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def msg2str(msg)
|
|
97
|
+
case msg
|
|
98
|
+
when ::String
|
|
99
|
+
msg
|
|
100
|
+
when ::Exception
|
|
101
|
+
"#{ msg.message } (#{ msg.class })\n" <<
|
|
102
|
+
(msg.backtrace || []).join("\n")
|
|
103
|
+
else
|
|
104
|
+
msg.inspect
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Simple formatter which only displays the message.
|
|
111
|
+
class SimpleFormatter < Logger::Formatter
|
|
112
|
+
# This method is invoked when a log event occurs
|
|
113
|
+
def call(severity, timestamp, progname, msg)
|
|
114
|
+
"#{String === msg ? msg : msg.inspect}\n"
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
private
|
|
119
|
+
alias old_format_message format_message
|
|
120
|
+
|
|
121
|
+
# Ruby 1.8.3 transposed the msg and progname arguments to format_message.
|
|
122
|
+
# We can't test RUBY_VERSION because some distributions don't keep Ruby
|
|
123
|
+
# and its standard library in sync, leading to installations of Ruby 1.8.2
|
|
124
|
+
# with Logger from 1.8.3 and vice versa.
|
|
125
|
+
if method_defined?(:formatter=)
|
|
126
|
+
def format_message(severity, timestamp, progname, msg)
|
|
127
|
+
formatter.call(severity, timestamp, progname, msg)
|
|
128
|
+
end
|
|
129
|
+
else
|
|
130
|
+
def format_message(severity, timestamp, msg, progname)
|
|
131
|
+
formatter.call(severity, timestamp, progname, msg)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
attr_writer :formatter
|
|
135
|
+
public :formatter=
|
|
136
|
+
|
|
137
|
+
alias old_format_datetime format_datetime
|
|
138
|
+
def format_datetime(datetime) datetime end
|
|
139
|
+
|
|
140
|
+
alias old_msg2str msg2str
|
|
141
|
+
def msg2str(msg) msg end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
module ActiveSupport
|
|
2
|
+
module CoreExtensions
|
|
3
|
+
module Module
|
|
4
|
+
# Encapsulates the common pattern of:
|
|
5
|
+
#
|
|
6
|
+
# alias_method :foo_without_feature, :foo
|
|
7
|
+
# alias_method :foo, :foo_with_feature
|
|
8
|
+
#
|
|
9
|
+
# With this, you simply do:
|
|
10
|
+
#
|
|
11
|
+
# alias_method_chain :foo, :feature
|
|
12
|
+
#
|
|
13
|
+
# And both aliases are set up for you.
|
|
14
|
+
#
|
|
15
|
+
# Query and bang methods (foo?, foo!) keep the same punctuation:
|
|
16
|
+
#
|
|
17
|
+
# alias_method_chain :foo?, :feature
|
|
18
|
+
#
|
|
19
|
+
# is equivalent to
|
|
20
|
+
#
|
|
21
|
+
# alias_method :foo_without_feature?, :foo?
|
|
22
|
+
# alias_method :foo?, :foo_with_feature?
|
|
23
|
+
#
|
|
24
|
+
# so you can safely chain foo, foo?, and foo! with the same feature.
|
|
25
|
+
def alias_method_chain(target, feature)
|
|
26
|
+
# Strip out punctuation on predicates or bang methods since
|
|
27
|
+
# e.g. target?_without_feature is not a valid method name.
|
|
28
|
+
aliased_target, punctuation = target.to_s.sub(/([?!=])$/, ''), $1
|
|
29
|
+
yield(aliased_target, punctuation) if block_given?
|
|
30
|
+
|
|
31
|
+
with_method, without_method = "#{aliased_target}_with_#{feature}#{punctuation}", "#{aliased_target}_without_#{feature}#{punctuation}"
|
|
32
|
+
|
|
33
|
+
alias_method without_method, target
|
|
34
|
+
alias_method target, with_method
|
|
35
|
+
|
|
36
|
+
case
|
|
37
|
+
when public_method_defined?(without_method)
|
|
38
|
+
public target
|
|
39
|
+
when protected_method_defined?(without_method)
|
|
40
|
+
protected target
|
|
41
|
+
when private_method_defined?(without_method)
|
|
42
|
+
private target
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Allows you to make aliases for attributes, which includes
|
|
47
|
+
# getter, setter, and query methods.
|
|
48
|
+
#
|
|
49
|
+
# Example:
|
|
50
|
+
#
|
|
51
|
+
# class Content < ActiveRecord::Base
|
|
52
|
+
# # has a title attribute
|
|
53
|
+
# end
|
|
54
|
+
#
|
|
55
|
+
# class Email < Content
|
|
56
|
+
# alias_attribute :subject, :title
|
|
57
|
+
# end
|
|
58
|
+
#
|
|
59
|
+
# e = Email.find(1)
|
|
60
|
+
# e.title # => "Superstars"
|
|
61
|
+
# e.subject # => "Superstars"
|
|
62
|
+
# e.subject? # => true
|
|
63
|
+
# e.subject = "Megastars"
|
|
64
|
+
# e.title # => "Megastars"
|
|
65
|
+
def alias_attribute(new_name, old_name)
|
|
66
|
+
module_eval <<-STR, __FILE__, __LINE__+1
|
|
67
|
+
def #{new_name}; self.#{old_name}; end
|
|
68
|
+
def #{new_name}?; self.#{old_name}?; end
|
|
69
|
+
def #{new_name}=(v); self.#{old_name} = v; end
|
|
70
|
+
STR
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/attr_accessor_with_default.rb
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
class Module
|
|
2
|
+
# Declare an attribute accessor with an initial default return value.
|
|
3
|
+
#
|
|
4
|
+
# To give attribute <tt>:age</tt> the initial value <tt>25</tt>:
|
|
5
|
+
#
|
|
6
|
+
# class Person
|
|
7
|
+
# attr_accessor_with_default :age, 25
|
|
8
|
+
# end
|
|
9
|
+
#
|
|
10
|
+
# some_person.age
|
|
11
|
+
# => 25
|
|
12
|
+
# some_person.age = 26
|
|
13
|
+
# some_person.age
|
|
14
|
+
# => 26
|
|
15
|
+
#
|
|
16
|
+
# To give attribute <tt>:element_name</tt> a dynamic default value, evaluated
|
|
17
|
+
# in scope of self:
|
|
18
|
+
#
|
|
19
|
+
# attr_accessor_with_default(:element_name) { name.underscore }
|
|
20
|
+
#
|
|
21
|
+
def attr_accessor_with_default(sym, default = nil, &block)
|
|
22
|
+
raise 'Default value or block required' unless !default.nil? || block
|
|
23
|
+
define_method(sym, block_given? ? block : Proc.new { default })
|
|
24
|
+
module_eval(<<-EVAL, __FILE__, __LINE__)
|
|
25
|
+
def #{sym}=(value)
|
|
26
|
+
class << self; attr_reader :#{sym} end
|
|
27
|
+
@#{sym} = value
|
|
28
|
+
end
|
|
29
|
+
EVAL
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
class Module
|
|
2
|
+
# Declares an attribute reader backed by an internally-named instance variable.
|
|
3
|
+
def attr_internal_reader(*attrs)
|
|
4
|
+
attrs.each do |attr|
|
|
5
|
+
module_eval "def #{attr}() #{attr_internal_ivar_name(attr)} end"
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# Declares an attribute writer backed by an internally-named instance variable.
|
|
10
|
+
def attr_internal_writer(*attrs)
|
|
11
|
+
attrs.each do |attr|
|
|
12
|
+
module_eval "def #{attr}=(v) #{attr_internal_ivar_name(attr)} = v end"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Declares an attribute reader and writer backed by an internally-named instance
|
|
17
|
+
# variable.
|
|
18
|
+
def attr_internal_accessor(*attrs)
|
|
19
|
+
attr_internal_reader(*attrs)
|
|
20
|
+
attr_internal_writer(*attrs)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
alias_method :attr_internal, :attr_internal_accessor
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
mattr_accessor :attr_internal_naming_format
|
|
27
|
+
self.attr_internal_naming_format = '@_%s'
|
|
28
|
+
|
|
29
|
+
def attr_internal_ivar_name(attr)
|
|
30
|
+
attr_internal_naming_format % attr
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Extends the module object with module and instance accessors for class attributes,
|
|
2
|
+
# just like the native attr* accessors for instance attributes.
|
|
3
|
+
#
|
|
4
|
+
# module AppConfiguration
|
|
5
|
+
# mattr_accessor :google_api_key
|
|
6
|
+
# self.google_api_key = "123456789"
|
|
7
|
+
#
|
|
8
|
+
# mattr_accessor :paypal_url
|
|
9
|
+
# self.paypal_url = "www.sandbox.paypal.com"
|
|
10
|
+
# end
|
|
11
|
+
#
|
|
12
|
+
# AppConfiguration.google_api_key = "overriding the api key!"
|
|
13
|
+
class Module
|
|
14
|
+
def mattr_reader(*syms)
|
|
15
|
+
syms.each do |sym|
|
|
16
|
+
next if sym.is_a?(Hash)
|
|
17
|
+
class_eval(<<-EOS, __FILE__, __LINE__)
|
|
18
|
+
unless defined? @@#{sym}
|
|
19
|
+
@@#{sym} = nil
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.#{sym}
|
|
23
|
+
@@#{sym}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def #{sym}
|
|
27
|
+
@@#{sym}
|
|
28
|
+
end
|
|
29
|
+
EOS
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def mattr_writer(*syms)
|
|
34
|
+
options = syms.extract_options!
|
|
35
|
+
syms.each do |sym|
|
|
36
|
+
class_eval(<<-EOS, __FILE__, __LINE__)
|
|
37
|
+
unless defined? @@#{sym}
|
|
38
|
+
@@#{sym} = nil
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def self.#{sym}=(obj)
|
|
42
|
+
@@#{sym} = obj
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
#{"
|
|
46
|
+
def #{sym}=(obj)
|
|
47
|
+
@@#{sym} = obj
|
|
48
|
+
end
|
|
49
|
+
" unless options[:instance_writer] == false }
|
|
50
|
+
EOS
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def mattr_accessor(*syms)
|
|
55
|
+
mattr_reader(*syms)
|
|
56
|
+
mattr_writer(*syms)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
class Module
|
|
2
|
+
# Provides a delegate class method to easily expose contained objects' methods
|
|
3
|
+
# as your own. Pass one or more methods (specified as symbols or strings)
|
|
4
|
+
# and the name of the target object as the final <tt>:to</tt> option (also a symbol
|
|
5
|
+
# or string). At least one method and the <tt>:to</tt> option are required.
|
|
6
|
+
#
|
|
7
|
+
# Delegation is particularly useful with Active Record associations:
|
|
8
|
+
#
|
|
9
|
+
# class Greeter < ActiveRecord::Base
|
|
10
|
+
# def hello() "hello" end
|
|
11
|
+
# def goodbye() "goodbye" end
|
|
12
|
+
# end
|
|
13
|
+
#
|
|
14
|
+
# class Foo < ActiveRecord::Base
|
|
15
|
+
# belongs_to :greeter
|
|
16
|
+
# delegate :hello, :to => :greeter
|
|
17
|
+
# end
|
|
18
|
+
#
|
|
19
|
+
# Foo.new.hello # => "hello"
|
|
20
|
+
# Foo.new.goodbye # => NoMethodError: undefined method `goodbye' for #<Foo:0x1af30c>
|
|
21
|
+
#
|
|
22
|
+
# Multiple delegates to the same target are allowed:
|
|
23
|
+
#
|
|
24
|
+
# class Foo < ActiveRecord::Base
|
|
25
|
+
# belongs_to :greeter
|
|
26
|
+
# delegate :hello, :goodbye, :to => :greeter
|
|
27
|
+
# end
|
|
28
|
+
#
|
|
29
|
+
# Foo.new.goodbye # => "goodbye"
|
|
30
|
+
#
|
|
31
|
+
# Methods can be delegated to instance variables, class variables, or constants
|
|
32
|
+
# by providing them as a symbols:
|
|
33
|
+
#
|
|
34
|
+
# class Foo
|
|
35
|
+
# CONSTANT_ARRAY = [0,1,2,3]
|
|
36
|
+
# @@class_array = [4,5,6,7]
|
|
37
|
+
#
|
|
38
|
+
# def initialize
|
|
39
|
+
# @instance_array = [8,9,10,11]
|
|
40
|
+
# end
|
|
41
|
+
# delegate :sum, :to => :CONSTANT_ARRAY
|
|
42
|
+
# delegate :min, :to => :@@class_array
|
|
43
|
+
# delegate :max, :to => :@instance_array
|
|
44
|
+
# end
|
|
45
|
+
#
|
|
46
|
+
# Foo.new.sum # => 6
|
|
47
|
+
# Foo.new.min # => 4
|
|
48
|
+
# Foo.new.max # => 11
|
|
49
|
+
#
|
|
50
|
+
# Delegates can optionally be prefixed using the <tt>:prefix</tt> option. If the value
|
|
51
|
+
# is <tt>true</tt>, the delegate methods are prefixed with the name of the object being
|
|
52
|
+
# delegated to.
|
|
53
|
+
#
|
|
54
|
+
# Person = Struct.new(:name, :address)
|
|
55
|
+
#
|
|
56
|
+
# class Invoice < Struct.new(:client)
|
|
57
|
+
# delegate :name, :address, :to => :client, :prefix => true
|
|
58
|
+
# end
|
|
59
|
+
#
|
|
60
|
+
# john_doe = Person.new("John Doe", "Vimmersvej 13")
|
|
61
|
+
# invoice = Invoice.new(john_doe)
|
|
62
|
+
# invoice.client_name # => "John Doe"
|
|
63
|
+
# invoice.client_address # => "Vimmersvej 13"
|
|
64
|
+
#
|
|
65
|
+
# It is also possible to supply a custom prefix.
|
|
66
|
+
#
|
|
67
|
+
# class Invoice < Struct.new(:client)
|
|
68
|
+
# delegate :name, :address, :to => :client, :prefix => :customer
|
|
69
|
+
# end
|
|
70
|
+
#
|
|
71
|
+
# invoice = Invoice.new(john_doe)
|
|
72
|
+
# invoice.customer_name # => "John Doe"
|
|
73
|
+
# invoice.customer_address # => "Vimmersvej 13"
|
|
74
|
+
#
|
|
75
|
+
def delegate(*methods)
|
|
76
|
+
options = methods.pop
|
|
77
|
+
unless options.is_a?(Hash) && to = options[:to]
|
|
78
|
+
raise ArgumentError, "Delegation needs a target. Supply an options hash with a :to key as the last argument (e.g. delegate :hello, :to => :greeter)."
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
if options[:prefix] == true && options[:to].to_s =~ /^[^a-z_]/
|
|
82
|
+
raise ArgumentError, "Can only automatically set the delegation prefix when delegating to a method."
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
prefix = options[:prefix] && "#{options[:prefix] == true ? to : options[:prefix]}_"
|
|
86
|
+
|
|
87
|
+
methods.each do |method|
|
|
88
|
+
module_eval(<<-EOS, "(__DELEGATION__)", 1)
|
|
89
|
+
def #{prefix}#{method}(*args, &block)
|
|
90
|
+
#{to}.__send__(#{method.inspect}, *args, &block)
|
|
91
|
+
end
|
|
92
|
+
EOS
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
class Module
|
|
2
|
+
# Returns the classes in the current ObjectSpace where this module has been
|
|
3
|
+
# mixed in according to Module#included_modules.
|
|
4
|
+
#
|
|
5
|
+
# module M
|
|
6
|
+
# end
|
|
7
|
+
#
|
|
8
|
+
# module N
|
|
9
|
+
# include M
|
|
10
|
+
# end
|
|
11
|
+
#
|
|
12
|
+
# class C
|
|
13
|
+
# include M
|
|
14
|
+
# end
|
|
15
|
+
#
|
|
16
|
+
# class D < C
|
|
17
|
+
# end
|
|
18
|
+
#
|
|
19
|
+
# p M.included_in_classes # => [C, D]
|
|
20
|
+
#
|
|
21
|
+
def included_in_classes
|
|
22
|
+
classes = []
|
|
23
|
+
ObjectSpace.each_object(Class) { |k| classes << k if k.included_modules.include?(self) }
|
|
24
|
+
|
|
25
|
+
classes.reverse.inject([]) do |unique_classes, klass|
|
|
26
|
+
unique_classes << klass unless unique_classes.collect { |k| k.to_s }.include?(klass.to_s)
|
|
27
|
+
unique_classes
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|