activesupport 3.0.0.beta4 → 3.0.pre
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activesupport might be problematic. Click here for more details.
- data/CHANGELOG +1 -100
- data/lib/active_support.rb +4 -38
- data/lib/active_support/autoload.rb +28 -0
- data/lib/active_support/backtrace_cleaner.rb +9 -31
- data/lib/active_support/benchmarkable.rb +0 -1
- data/lib/active_support/buffered_logger.rb +1 -0
- data/lib/active_support/cache.rb +81 -436
- data/lib/active_support/cache/compressed_mem_cache_store.rb +13 -6
- data/lib/active_support/cache/file_store.rb +41 -139
- data/lib/active_support/cache/mem_cache_store.rb +75 -120
- data/lib/active_support/cache/memory_store.rb +27 -127
- data/lib/active_support/cache/strategy/local_cache.rb +58 -111
- data/lib/active_support/cache/synchronized_memory_store.rb +38 -2
- data/lib/active_support/callbacks.rb +48 -87
- data/lib/active_support/configurable.rb +18 -19
- data/lib/active_support/core_ext/array.rb +0 -1
- data/lib/active_support/core_ext/array/access.rb +1 -1
- data/lib/active_support/core_ext/array/conversions.rb +54 -29
- data/lib/active_support/core_ext/array/extract_options.rb +1 -16
- data/lib/active_support/core_ext/array/random_access.rb +5 -19
- data/lib/active_support/core_ext/array/wrap.rb +9 -13
- data/lib/active_support/core_ext/benchmark.rb +12 -0
- data/lib/active_support/core_ext/boolean.rb +1 -0
- data/lib/active_support/core_ext/boolean/conversions.rb +11 -0
- data/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +0 -2
- data/lib/active_support/core_ext/class.rb +1 -1
- data/lib/active_support/core_ext/class/attribute_accessors.rb +27 -33
- data/lib/active_support/core_ext/class/delegating_attributes.rb +41 -35
- data/lib/active_support/core_ext/class/inheritable_attributes.rb +13 -22
- data/lib/active_support/core_ext/class/removal.rb +53 -0
- data/lib/active_support/core_ext/date.rb +7 -0
- data/lib/active_support/core_ext/date/calculations.rb +8 -30
- data/lib/active_support/core_ext/date/conversions.rb +2 -2
- data/lib/active_support/core_ext/date_time.rb +5 -0
- data/lib/active_support/core_ext/date_time/calculations.rb +1 -2
- data/lib/active_support/core_ext/date_time/conversions.rb +5 -23
- data/lib/active_support/core_ext/enumerable.rb +9 -5
- data/lib/active_support/core_ext/exception.rb +47 -0
- data/lib/active_support/core_ext/file.rb +0 -1
- data/lib/active_support/core_ext/file/atomic.rb +2 -3
- data/lib/active_support/core_ext/float/rounding.rb +2 -3
- data/lib/active_support/core_ext/hash/conversions.rb +145 -65
- data/lib/active_support/core_ext/hash/deep_merge.rb +7 -6
- data/lib/active_support/core_ext/hash/except.rb +0 -8
- data/lib/active_support/core_ext/hash/indifferent_access.rb +0 -5
- data/lib/active_support/core_ext/hash/keys.rb +11 -10
- data/lib/active_support/core_ext/hash/slice.rb +0 -6
- data/lib/active_support/core_ext/integer.rb +1 -1
- data/lib/active_support/core_ext/integer/even_odd.rb +16 -0
- data/lib/active_support/core_ext/kernel.rb +1 -1
- data/lib/active_support/core_ext/kernel/daemonizing.rb +7 -0
- data/lib/active_support/core_ext/kernel/debugger.rb +2 -3
- data/lib/active_support/core_ext/kernel/reporting.rb +1 -2
- data/lib/active_support/core_ext/load_error.rb +30 -17
- data/lib/active_support/core_ext/logger.rb +1 -1
- data/lib/active_support/core_ext/module.rb +3 -5
- data/lib/active_support/core_ext/module/aliasing.rb +1 -1
- data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +1 -1
- data/lib/active_support/core_ext/module/attr_internal.rb +2 -2
- data/lib/active_support/core_ext/module/attribute_accessors.rb +21 -25
- data/lib/active_support/core_ext/module/delegation.rb +10 -21
- data/lib/active_support/core_ext/module/inclusion.rb +30 -0
- data/lib/active_support/core_ext/module/introspection.rb +8 -8
- data/lib/active_support/core_ext/module/loading.rb +23 -0
- data/lib/active_support/core_ext/module/synchronization.rb +1 -2
- data/lib/active_support/core_ext/name_error.rb +1 -3
- data/lib/active_support/core_ext/nil.rb +1 -0
- data/lib/active_support/core_ext/nil/conversions.rb +5 -0
- data/lib/active_support/core_ext/object.rb +2 -6
- data/lib/active_support/core_ext/object/blank.rb +2 -20
- data/lib/active_support/core_ext/object/conversions.rb +16 -2
- data/lib/active_support/core_ext/object/duplicable.rb +1 -23
- data/lib/active_support/core_ext/object/extending.rb +77 -8
- data/lib/active_support/core_ext/object/instance_variables.rb +7 -0
- data/lib/active_support/core_ext/object/metaclass.rb +13 -0
- data/lib/active_support/core_ext/object/misc.rb +1 -0
- data/lib/active_support/core_ext/object/tap.rb +16 -0
- data/lib/active_support/core_ext/object/with_options.rb +0 -2
- data/lib/active_support/core_ext/proc.rb +4 -4
- data/lib/active_support/core_ext/regexp.rb +22 -0
- data/lib/active_support/core_ext/rexml.rb +1 -4
- data/lib/active_support/core_ext/string.rb +2 -3
- data/lib/active_support/core_ext/string/access.rb +2 -4
- data/lib/active_support/core_ext/string/bytesize.rb +5 -0
- data/lib/active_support/core_ext/string/conversions.rb +1 -36
- data/lib/active_support/core_ext/string/filters.rb +0 -29
- data/lib/active_support/core_ext/string/inflections.rb +12 -1
- data/lib/active_support/core_ext/string/interpolation.rb +92 -2
- data/lib/active_support/core_ext/string/iterators.rb +13 -0
- data/lib/active_support/core_ext/string/multibyte.rb +19 -16
- data/lib/active_support/core_ext/string/output_safety.rb +35 -101
- data/lib/active_support/core_ext/string/starts_ends_with.rb +14 -0
- data/lib/active_support/core_ext/string/xchar.rb +1 -1
- data/lib/active_support/core_ext/symbol.rb +1 -0
- data/lib/active_support/core_ext/symbol/to_proc.rb +14 -0
- data/lib/active_support/core_ext/time.rb +10 -0
- data/lib/active_support/core_ext/time/calculations.rb +7 -9
- data/lib/active_support/core_ext/time/conversions.rb +0 -1
- data/lib/active_support/core_ext/time/marshal_with_utc_flag.rb +22 -0
- data/lib/active_support/core_ext/uri.rb +4 -10
- data/lib/active_support/dependencies.rb +192 -179
- data/lib/active_support/deprecated_callbacks.rb +283 -0
- data/lib/active_support/deprecation/behaviors.rb +1 -1
- data/lib/active_support/deprecation/method_wrappers.rb +9 -10
- data/lib/active_support/deprecation/reporting.rb +1 -2
- data/lib/active_support/duration.rb +2 -6
- data/lib/active_support/hash_with_indifferent_access.rb +1 -9
- data/lib/active_support/inflections.rb +1 -1
- data/lib/active_support/inflector.rb +407 -4
- data/lib/active_support/json/backends/jsongem.rb +9 -12
- data/lib/active_support/json/decoding.rb +1 -16
- data/lib/active_support/json/encoding.rb +12 -42
- data/lib/active_support/locale/en.yml +1 -4
- data/lib/active_support/memoizable.rb +1 -1
- data/lib/active_support/message_encryptor.rb +0 -1
- data/lib/active_support/message_verifier.rb +5 -6
- data/lib/active_support/multibyte.rb +22 -7
- data/lib/active_support/multibyte/chars.rb +392 -164
- data/lib/active_support/multibyte/unicode_database.rb +71 -0
- data/lib/active_support/multibyte/utils.rb +7 -6
- data/lib/active_support/notifications.rb +113 -23
- data/lib/active_support/ordered_hash.rb +11 -35
- data/lib/active_support/ordered_options.rb +0 -6
- data/lib/active_support/rescuable.rb +4 -7
- data/lib/active_support/ruby/shim.rb +6 -4
- data/lib/active_support/test_case.rb +7 -2
- data/lib/active_support/testing/assertions.rb +0 -15
- data/lib/active_support/testing/declarative.rb +1 -1
- data/lib/active_support/testing/isolation.rb +19 -63
- data/lib/active_support/testing/performance.rb +337 -342
- data/lib/active_support/testing/setup_and_teardown.rb +29 -51
- data/lib/active_support/time.rb +3 -23
- data/lib/active_support/time_with_zone.rb +10 -5
- data/lib/active_support/values/time_zone.rb +84 -40
- data/lib/active_support/values/unicode_tables.dat +0 -0
- data/lib/active_support/vendor.rb +16 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/blankslate.rb +113 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder.rb +13 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/blankslate.rb +20 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/css.rb +250 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/xchar.rb +115 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlbase.rb +139 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlevents.rb +63 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlmarkup.rb +328 -0
- data/lib/active_support/vendor/i18n-0.1.3/MIT-LICENSE +20 -0
- data/lib/active_support/vendor/i18n-0.1.3/README.textile +20 -0
- data/lib/active_support/vendor/i18n-0.1.3/Rakefile +5 -0
- data/lib/active_support/vendor/i18n-0.1.3/i18n.gemspec +27 -0
- data/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb +204 -0
- data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb +215 -0
- data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/exceptions.rb +53 -0
- data/lib/active_support/vendor/i18n-0.1.3/test/all.rb +5 -0
- data/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb +99 -0
- data/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb +124 -0
- data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.rb +1 -0
- data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.yml +3 -0
- data/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb +567 -0
- data/lib/active_support/vendor/memcache-client-1.7.5/lib/memcache.rb +1133 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo.rb +33 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/data_timezone.rb +47 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/data_timezone_info.rb +228 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Algiers.rb +55 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Cairo.rb +219 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Casablanca.rb +42 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Harare.rb +18 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Johannesburg.rb +25 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Monrovia.rb +22 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Nairobi.rb +23 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +166 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Argentina/San_Juan.rb +86 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Bogota.rb +23 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Caracas.rb +23 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Chicago.rb +283 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Chihuahua.rb +136 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Denver.rb +204 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Godthab.rb +161 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Guatemala.rb +27 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Halifax.rb +274 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Indiana/Indianapolis.rb +149 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Juneau.rb +194 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/La_Paz.rb +22 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Lima.rb +35 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Los_Angeles.rb +232 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Mazatlan.rb +139 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Mexico_City.rb +144 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Monterrey.rb +131 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/New_York.rb +282 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Phoenix.rb +30 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Regina.rb +74 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Santiago.rb +205 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Sao_Paulo.rb +171 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/St_Johns.rb +288 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Tijuana.rb +196 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Almaty.rb +67 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Baghdad.rb +73 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Baku.rb +161 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Bangkok.rb +20 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Chongqing.rb +33 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Colombo.rb +30 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Dhaka.rb +27 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Hong_Kong.rb +87 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Irkutsk.rb +165 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Jakarta.rb +30 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Jerusalem.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kabul.rb +20 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kamchatka.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Karachi.rb +32 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kathmandu.rb +20 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kolkata.rb +25 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Krasnoyarsk.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kuala_Lumpur.rb +31 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kuwait.rb +18 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Magadan.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Muscat.rb +18 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Novosibirsk.rb +164 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Rangoon.rb +24 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Riyadh.rb +18 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Seoul.rb +34 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Shanghai.rb +35 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Singapore.rb +33 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Taipei.rb +59 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tashkent.rb +47 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tbilisi.rb +78 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tehran.rb +121 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tokyo.rb +30 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Ulaanbaatar.rb +65 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Urumqi.rb +33 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Vladivostok.rb +164 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yakutsk.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yekaterinburg.rb +165 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yerevan.rb +165 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/Azores.rb +270 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/Cape_Verde.rb +23 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/South_Georgia.rb +18 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Adelaide.rb +187 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Brisbane.rb +35 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Darwin.rb +29 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Hobart.rb +193 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Melbourne.rb +185 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Perth.rb +37 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Sydney.rb +185 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Etc/UTC.rb +16 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Amsterdam.rb +228 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Athens.rb +185 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Belgrade.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Berlin.rb +188 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Bratislava.rb +13 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Brussels.rb +232 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Bucharest.rb +181 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Budapest.rb +197 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Copenhagen.rb +179 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Dublin.rb +276 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Helsinki.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Istanbul.rb +218 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Kiev.rb +168 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Lisbon.rb +268 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Ljubljana.rb +13 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/London.rb +288 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Madrid.rb +211 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Minsk.rb +170 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Moscow.rb +181 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Paris.rb +232 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Prague.rb +187 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Riga.rb +176 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Rome.rb +215 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Sarajevo.rb +13 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Skopje.rb +13 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Sofia.rb +173 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Stockholm.rb +165 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Tallinn.rb +172 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Vienna.rb +183 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Vilnius.rb +170 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Warsaw.rb +212 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Zagreb.rb +13 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Auckland.rb +202 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Fiji.rb +23 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Guam.rb +22 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Honolulu.rb +28 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Majuro.rb +20 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Midway.rb +25 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Noumea.rb +25 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Pago_Pago.rb +26 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Port_Moresby.rb +20 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Tongatapu.rb +27 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/info_timezone.rb +52 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/linked_timezone.rb +51 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/linked_timezone_info.rb +44 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/offset_rationals.rb +98 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/ruby_core_support.rb +56 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/time_or_datetime.rb +292 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone.rb +508 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_definition.rb +56 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_info.rb +40 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_offset_info.rb +94 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_period.rb +198 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_transition_info.rb +129 -0
- data/lib/active_support/version.rb +2 -3
- data/lib/active_support/whiny_nil.rb +7 -9
- data/lib/active_support/xml_mini.rb +1 -126
- data/lib/active_support/xml_mini/jdom.rb +0 -2
- data/lib/active_support/xml_mini/libxml.rb +86 -24
- data/lib/active_support/xml_mini/nokogiri.rb +24 -27
- data/lib/active_support/xml_mini/rexml.rb +1 -7
- metadata +191 -49
- data/lib/active_support/builder.rb +0 -6
- data/lib/active_support/core_ext/array/uniq_by.rb +0 -17
- data/lib/active_support/core_ext/class/attribute.rb +0 -67
- data/lib/active_support/core_ext/class/subclasses.rb +0 -55
- data/lib/active_support/core_ext/file/path.rb +0 -5
- data/lib/active_support/core_ext/integer/multiple.rb +0 -6
- data/lib/active_support/core_ext/kernel/singleton_class.rb +0 -13
- data/lib/active_support/core_ext/module/anonymous.rb +0 -24
- data/lib/active_support/core_ext/module/method_names.rb +0 -14
- data/lib/active_support/core_ext/module/reachable.rb +0 -10
- data/lib/active_support/core_ext/module/remove_method.rb +0 -6
- data/lib/active_support/core_ext/object/to_param.rb +0 -49
- data/lib/active_support/core_ext/object/to_query.rb +0 -27
- data/lib/active_support/core_ext/string/encoding.rb +0 -11
- data/lib/active_support/core_ext/string/exclude.rb +0 -6
- data/lib/active_support/core_ext/time/marshal.rb +0 -56
- data/lib/active_support/dependencies/autoload.rb +0 -50
- data/lib/active_support/i18n.rb +0 -8
- data/lib/active_support/inflector/inflections.rb +0 -211
- data/lib/active_support/inflector/methods.rb +0 -141
- data/lib/active_support/inflector/transliterate.rb +0 -97
- data/lib/active_support/json/backends/yajl.rb +0 -40
- data/lib/active_support/lazy_load_hooks.rb +0 -27
- data/lib/active_support/multibyte/unicode.rb +0 -393
- data/lib/active_support/notifications/fanout.rb +0 -93
- data/lib/active_support/notifications/instrumenter.rb +0 -56
- data/lib/active_support/railtie.rb +0 -100
- data/lib/active_support/xml_mini/libxmlsax.rb +0 -85
- data/lib/active_support/xml_mini/nokogirisax.rb +0 -83
@@ -3,14 +3,6 @@ class Hash
|
|
3
3
|
# limiting a set of parameters to everything but a few known toggles:
|
4
4
|
#
|
5
5
|
# @person.update_attributes(params[:person].except(:admin))
|
6
|
-
#
|
7
|
-
# If the receiver responds to +convert_key+, the method is called on each of the
|
8
|
-
# arguments. This allows +except+ to play nice with hashes with indifferent access
|
9
|
-
# for instance:
|
10
|
-
#
|
11
|
-
# {:a => 1}.with_indifferent_access.except(:a) # => {}
|
12
|
-
# {:a => 1}.with_indifferent_access.except("a") # => {}
|
13
|
-
#
|
14
6
|
def except(*keys)
|
15
7
|
dup.except!(*keys)
|
16
8
|
end
|
@@ -1,11 +1,6 @@
|
|
1
1
|
require 'active_support/hash_with_indifferent_access'
|
2
2
|
|
3
3
|
class Hash
|
4
|
-
|
5
|
-
# Returns an +ActiveSupport::HashWithIndifferentAccess+ out of its receiver:
|
6
|
-
#
|
7
|
-
# {:a => 1}.with_indifferent_access["a"] # => 1
|
8
|
-
#
|
9
4
|
def with_indifferent_access
|
10
5
|
hash = ActiveSupport::HashWithIndifferentAccess.new(self)
|
11
6
|
hash.default = self.default
|
@@ -1,7 +1,10 @@
|
|
1
1
|
class Hash
|
2
2
|
# Return a new hash with all keys converted to strings.
|
3
3
|
def stringify_keys
|
4
|
-
|
4
|
+
inject({}) do |options, (key, value)|
|
5
|
+
options[key.to_s] = value
|
6
|
+
options
|
7
|
+
end
|
5
8
|
end
|
6
9
|
|
7
10
|
# Destructively convert all keys to strings.
|
@@ -12,19 +15,17 @@ class Hash
|
|
12
15
|
self
|
13
16
|
end
|
14
17
|
|
15
|
-
# Return a new hash with all keys converted to symbols
|
16
|
-
# they respond to +to_sym+.
|
18
|
+
# Return a new hash with all keys converted to symbols.
|
17
19
|
def symbolize_keys
|
18
|
-
|
20
|
+
inject({}) do |options, (key, value)|
|
21
|
+
options[(key.to_sym rescue key) || key] = value
|
22
|
+
options
|
23
|
+
end
|
19
24
|
end
|
20
25
|
|
21
|
-
# Destructively convert all keys to symbols
|
22
|
-
# to +to_sym+.
|
26
|
+
# Destructively convert all keys to symbols.
|
23
27
|
def symbolize_keys!
|
24
|
-
|
25
|
-
self[(key.to_sym rescue key) || key] = delete(key)
|
26
|
-
end
|
27
|
-
self
|
28
|
+
self.replace(self.symbolize_keys)
|
28
29
|
end
|
29
30
|
|
30
31
|
alias_method :to_options, :symbolize_keys
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Integer
|
2
|
+
# Check whether the integer is evenly divisible by the argument.
|
3
|
+
def multiple_of?(number)
|
4
|
+
self % number == 0
|
5
|
+
end
|
6
|
+
|
7
|
+
# Is the integer a multiple of 2?
|
8
|
+
def even?
|
9
|
+
multiple_of? 2
|
10
|
+
end unless method_defined?(:even?)
|
11
|
+
|
12
|
+
# Is the integer not a multiple of 2?
|
13
|
+
def odd?
|
14
|
+
!even?
|
15
|
+
end unless method_defined?(:odd?)
|
16
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
+
require 'active_support/core_ext/kernel/daemonizing'
|
1
2
|
require 'active_support/core_ext/kernel/reporting'
|
2
3
|
require 'active_support/core_ext/kernel/agnostics'
|
3
4
|
require 'active_support/core_ext/kernel/requires'
|
4
5
|
require 'active_support/core_ext/kernel/debugger'
|
5
|
-
require 'active_support/core_ext/kernel/singleton_class'
|
@@ -1,13 +1,12 @@
|
|
1
1
|
module Kernel
|
2
2
|
unless respond_to?(:debugger)
|
3
|
-
# Starts a debugging session if ruby-debug has been loaded (call
|
3
|
+
# Starts a debugging session if ruby-debug has been loaded (call script/server --debugger to do load it).
|
4
4
|
def debugger
|
5
|
-
message = "\n***** Debugger requested, but was not available
|
5
|
+
message = "\n***** Debugger requested, but was not available: Start server with --debugger to enable *****\n"
|
6
6
|
defined?(Rails) ? Rails.logger.info(message) : $stderr.puts(message)
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
undef :breakpoint if respond_to?(:breakpoint)
|
11
10
|
def breakpoint
|
12
11
|
message = "\n***** The 'breakpoint' command has been renamed 'debugger' -- please change *****\n"
|
13
12
|
defined?(Rails) ? Rails.logger.info(message) : $stderr.puts(message)
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'rbconfig'
|
2
1
|
module Kernel
|
3
2
|
# Sets $VERBOSE to nil for the duration of the block and back to its original value afterwards.
|
4
3
|
#
|
@@ -38,7 +37,7 @@ module Kernel
|
|
38
37
|
# puts 'But this will'
|
39
38
|
def silence_stream(stream)
|
40
39
|
old_stream = stream.dup
|
41
|
-
stream.reopen(
|
40
|
+
stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
|
42
41
|
stream.sync = true
|
43
42
|
yield
|
44
43
|
ensure
|
@@ -1,23 +1,36 @@
|
|
1
|
-
class LoadError
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
]
|
1
|
+
class MissingSourceFile < LoadError #:nodoc:
|
2
|
+
attr_reader :path
|
3
|
+
def initialize(message, path)
|
4
|
+
super(message)
|
5
|
+
@path = path
|
6
|
+
end
|
8
7
|
|
9
|
-
def path
|
10
|
-
|
11
|
-
REGEXPS.find do |regex|
|
12
|
-
message =~ regex
|
13
|
-
end
|
14
|
-
$1
|
15
|
-
end
|
8
|
+
def is_missing?(path)
|
9
|
+
path.gsub(/\.rb$/, '') == self.path.gsub(/\.rb$/, '')
|
16
10
|
end
|
17
11
|
|
18
|
-
def
|
19
|
-
|
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
|
20
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
|
+
[/win32/, 0]
|
25
|
+
] unless defined?(REGEXPS)
|
21
26
|
end
|
22
27
|
|
23
|
-
|
28
|
+
class LoadError
|
29
|
+
def self.new(*args)
|
30
|
+
if self == LoadError
|
31
|
+
MissingSourceFile.from_message(args.first)
|
32
|
+
else
|
33
|
+
super
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -3,7 +3,7 @@ require 'active_support/core_ext/class/attribute_accessors'
|
|
3
3
|
# Adds the 'around_level' method to Logger.
|
4
4
|
class Logger #:nodoc:
|
5
5
|
def self.define_around_helper(level)
|
6
|
-
module_eval <<-end_eval
|
6
|
+
module_eval <<-end_eval
|
7
7
|
def around_#{level}(before_message, after_message, &block) # def around_debug(before_message, after_message, &block)
|
8
8
|
self.#{level}(before_message) # self.debug(before_message)
|
9
9
|
return_value = block.call(self) # return_value = block.call(self)
|
@@ -1,12 +1,10 @@
|
|
1
1
|
require 'active_support/core_ext/module/aliasing'
|
2
2
|
require 'active_support/core_ext/module/introspection'
|
3
|
-
|
4
|
-
require 'active_support/core_ext/module/
|
3
|
+
|
4
|
+
require 'active_support/core_ext/module/inclusion'
|
5
5
|
require 'active_support/core_ext/module/attribute_accessors'
|
6
6
|
require 'active_support/core_ext/module/attr_internal'
|
7
7
|
require 'active_support/core_ext/module/attr_accessor_with_default'
|
8
8
|
require 'active_support/core_ext/module/delegation'
|
9
|
+
require 'active_support/core_ext/module/loading'
|
9
10
|
require 'active_support/core_ext/module/synchronization'
|
10
|
-
require 'active_support/core_ext/module/deprecation'
|
11
|
-
require 'active_support/core_ext/module/remove_method'
|
12
|
-
require 'active_support/core_ext/module/method_names'
|
@@ -61,7 +61,7 @@ class Module
|
|
61
61
|
# e.subject = "Megastars"
|
62
62
|
# e.title # => "Megastars"
|
63
63
|
def alias_attribute(new_name, old_name)
|
64
|
-
module_eval <<-STR, __FILE__, __LINE__
|
64
|
+
module_eval <<-STR, __FILE__, __LINE__+1
|
65
65
|
def #{new_name}; self.#{old_name}; end # def subject; self.title; end
|
66
66
|
def #{new_name}?; self.#{old_name}?; end # def subject?; self.title?; end
|
67
67
|
def #{new_name}=(v); self.#{old_name} = v; end # def subject=(v); self.title = v; end
|
@@ -21,7 +21,7 @@ class Module
|
|
21
21
|
def attr_accessor_with_default(sym, default = nil, &block)
|
22
22
|
raise 'Default value or block required' unless !default.nil? || block
|
23
23
|
define_method(sym, block_given? ? block : Proc.new { default })
|
24
|
-
module_eval(<<-EVAL, __FILE__, __LINE__
|
24
|
+
module_eval(<<-EVAL, __FILE__, __LINE__)
|
25
25
|
def #{sym}=(value) # def age=(value)
|
26
26
|
class << self; attr_reader :#{sym} end # class << self; attr_reader :age end
|
27
27
|
@#{sym} = value # @age = value
|
@@ -2,14 +2,14 @@ class Module
|
|
2
2
|
# Declares an attribute reader backed by an internally-named instance variable.
|
3
3
|
def attr_internal_reader(*attrs)
|
4
4
|
attrs.each do |attr|
|
5
|
-
module_eval "def #{attr}() #{attr_internal_ivar_name(attr)} end"
|
5
|
+
module_eval "def #{attr}() #{attr_internal_ivar_name(attr)} end"
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
9
|
# Declares an attribute writer backed by an internally-named instance variable.
|
10
10
|
def attr_internal_writer(*attrs)
|
11
11
|
attrs.each do |attr|
|
12
|
-
module_eval "def #{attr}=(v) #{attr_internal_ivar_name(attr)} = v end"
|
12
|
+
module_eval "def #{attr}=(v) #{attr_internal_ivar_name(attr)} = v end"
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -2,25 +2,21 @@ require 'active_support/core_ext/array/extract_options'
|
|
2
2
|
|
3
3
|
class Module
|
4
4
|
def mattr_reader(*syms)
|
5
|
-
|
5
|
+
syms.extract_options!
|
6
6
|
syms.each do |sym|
|
7
7
|
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
8
|
-
unless defined? @@#{sym}
|
9
|
-
@@#{sym} = nil
|
10
|
-
end
|
8
|
+
unless defined? @@#{sym} # unless defined? @@pagination_options
|
9
|
+
@@#{sym} = nil # @@pagination_options = nil
|
10
|
+
end # end
|
11
|
+
|
12
|
+
def self.#{sym} # def self.pagination_options
|
13
|
+
@@#{sym} # @@pagination_options
|
14
|
+
end # end
|
11
15
|
|
12
|
-
def
|
13
|
-
@@#{sym}
|
14
|
-
end
|
16
|
+
def #{sym} # def pagination_options
|
17
|
+
@@#{sym} # @@pagination_options
|
18
|
+
end # end
|
15
19
|
EOS
|
16
|
-
|
17
|
-
unless options[:instance_reader] == false
|
18
|
-
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
19
|
-
def #{sym}
|
20
|
-
@@#{sym}
|
21
|
-
end
|
22
|
-
EOS
|
23
|
-
end
|
24
20
|
end
|
25
21
|
end
|
26
22
|
|
@@ -28,20 +24,20 @@ class Module
|
|
28
24
|
options = syms.extract_options!
|
29
25
|
syms.each do |sym|
|
30
26
|
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
31
|
-
unless defined? @@#{sym}
|
32
|
-
@@#{sym} = nil
|
33
|
-
end
|
27
|
+
unless defined? @@#{sym} # unless defined? @@pagination_options
|
28
|
+
@@#{sym} = nil # @@pagination_options = nil
|
29
|
+
end # end
|
34
30
|
|
35
|
-
def self.#{sym}=(obj)
|
36
|
-
@@#{sym} = obj
|
37
|
-
end
|
31
|
+
def self.#{sym}=(obj) # def self.pagination_options=(obj)
|
32
|
+
@@#{sym} = obj # @@pagination_options = obj
|
33
|
+
end # end
|
38
34
|
EOS
|
39
35
|
|
40
36
|
unless options[:instance_writer] == false
|
41
|
-
class_eval(<<-EOS, __FILE__, __LINE__
|
42
|
-
def #{sym}=(obj)
|
43
|
-
@@#{sym} = obj
|
44
|
-
end
|
37
|
+
class_eval(<<-EOS, __FILE__, __LINE__)
|
38
|
+
def #{sym}=(obj) # def pagination_options=(obj)
|
39
|
+
@@#{sym} = obj # @@pagination_options = obj
|
40
|
+
end # end
|
45
41
|
EOS
|
46
42
|
end
|
47
43
|
end
|
@@ -1,21 +1,14 @@
|
|
1
|
-
require "active_support/core_ext/module/remove_method"
|
2
|
-
|
3
1
|
class Module
|
4
2
|
# Provides a delegate class method to easily expose contained objects' methods
|
5
3
|
# as your own. Pass one or more methods (specified as symbols or strings)
|
6
|
-
# and the name of the target object
|
7
|
-
# or string).
|
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.
|
8
6
|
#
|
9
7
|
# Delegation is particularly useful with Active Record associations:
|
10
8
|
#
|
11
9
|
# class Greeter < ActiveRecord::Base
|
12
|
-
# def hello
|
13
|
-
#
|
14
|
-
# end
|
15
|
-
#
|
16
|
-
# def goodbye
|
17
|
-
# "goodbye"
|
18
|
-
# end
|
10
|
+
# def hello() "hello" end
|
11
|
+
# def goodbye() "goodbye" end
|
19
12
|
# end
|
20
13
|
#
|
21
14
|
# class Foo < ActiveRecord::Base
|
@@ -41,7 +34,7 @@ class Module
|
|
41
34
|
# class Foo
|
42
35
|
# CONSTANT_ARRAY = [0,1,2,3]
|
43
36
|
# @@class_array = [4,5,6,7]
|
44
|
-
#
|
37
|
+
#
|
45
38
|
# def initialize
|
46
39
|
# @instance_array = [8,9,10,11]
|
47
40
|
# end
|
@@ -79,9 +72,9 @@ class Module
|
|
79
72
|
# invoice.customer_name # => "John Doe"
|
80
73
|
# invoice.customer_address # => "Vimmersvej 13"
|
81
74
|
#
|
82
|
-
# If the delegate
|
83
|
-
#
|
84
|
-
#
|
75
|
+
# If the object to which you delegate can be nil, you may want to use the
|
76
|
+
# :allow_nil option. In that case, it returns nil instead of raising a
|
77
|
+
# NoMethodError exception:
|
85
78
|
#
|
86
79
|
# class Foo
|
87
80
|
# attr_accessor :bar
|
@@ -126,16 +119,12 @@ class Module
|
|
126
119
|
%(raise "#{self}##{prefix}#{method} delegated to #{to}.#{method}, but #{to} is nil: \#{self.inspect}")
|
127
120
|
end
|
128
121
|
|
129
|
-
module_eval(<<-EOS, file, line
|
130
|
-
if instance_methods(false).map(&:to_s).include?("#{prefix}#{method}")
|
131
|
-
remove_possible_method("#{prefix}#{method}")
|
132
|
-
end
|
133
|
-
|
122
|
+
module_eval(<<-EOS, file, line)
|
134
123
|
def #{prefix}#{method}(*args, &block) # def customer_name(*args, &block)
|
135
124
|
#{to}.__send__(#{method.inspect}, *args, &block) # client.__send__(:name, *args, &block)
|
136
125
|
rescue NoMethodError # rescue NoMethodError
|
137
126
|
if #{to}.nil? # if client.nil?
|
138
|
-
#{on_nil}
|
127
|
+
#{on_nil}
|
139
128
|
else # else
|
140
129
|
raise # raise
|
141
130
|
end # 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
|
@@ -3,7 +3,7 @@ require 'active_support/inflector'
|
|
3
3
|
class Module
|
4
4
|
# Returns the name of the module containing this one.
|
5
5
|
#
|
6
|
-
# M::N.parent_name # => "M"
|
6
|
+
# p M::N.parent_name # => "M"
|
7
7
|
def parent_name
|
8
8
|
unless defined? @parent_name
|
9
9
|
@parent_name = name =~ /::[^:]+\Z/ ? $`.freeze : nil
|
@@ -19,13 +19,13 @@ class Module
|
|
19
19
|
# end
|
20
20
|
# X = M::N
|
21
21
|
#
|
22
|
-
# M::N.parent # => M
|
23
|
-
# X.parent # => M
|
22
|
+
# p M::N.parent # => M
|
23
|
+
# p X.parent # => M
|
24
24
|
#
|
25
25
|
# The parent of top-level and anonymous modules is Object.
|
26
26
|
#
|
27
|
-
# M.parent # => Object
|
28
|
-
# Module.new.parent # => Object
|
27
|
+
# p M.parent # => Object
|
28
|
+
# p Module.new.parent # => Object
|
29
29
|
#
|
30
30
|
def parent
|
31
31
|
parent_name ? ActiveSupport::Inflector.constantize(parent_name) : Object
|
@@ -40,9 +40,9 @@ class Module
|
|
40
40
|
# end
|
41
41
|
# X = M::N
|
42
42
|
#
|
43
|
-
# M.parents # => [Object]
|
44
|
-
# M::N.parents # => [M, Object]
|
45
|
-
# X.parents # => [M, Object]
|
43
|
+
# p M.parents # => [Object]
|
44
|
+
# p M::N.parents # => [M, Object]
|
45
|
+
# p X.parents # => [M, Object]
|
46
46
|
#
|
47
47
|
def parents
|
48
48
|
parents = []
|