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
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'active_support/core_ext/string/multibyte'
|
2
|
-
|
3
1
|
class String
|
4
2
|
# Returns the string, first removing all whitespace on both ends of
|
5
3
|
# the string, and then changing remaining consecutive whitespace
|
@@ -19,31 +17,4 @@ class String
|
|
19
17
|
gsub!(/\s+/, ' ')
|
20
18
|
self
|
21
19
|
end
|
22
|
-
|
23
|
-
# Truncates a given +text+ after a given <tt>length</tt> if +text+ is longer than <tt>length</tt>:
|
24
|
-
#
|
25
|
-
# "Once upon a time in a world far far away".truncate(27)
|
26
|
-
# # => "Once upon a time in a wo..."
|
27
|
-
#
|
28
|
-
# The last characters will be replaced with the <tt>:omission</tt> string (defaults to "...")
|
29
|
-
# for a total length not exceeding <tt>:length</tt>:
|
30
|
-
#
|
31
|
-
# "Once upon a time in a world far far away".truncate(27, :separator => ' ')
|
32
|
-
# # => "Once upon a time in a..."
|
33
|
-
#
|
34
|
-
# Pass a <tt>:separator</tt> to truncate +text+ at a natural break:
|
35
|
-
#
|
36
|
-
# "And they found that many people were sleeping better.".truncate(25, :omission => "... (continued)")
|
37
|
-
# # => "And they f... (continued)"
|
38
|
-
def truncate(length, options = {})
|
39
|
-
text = self.dup
|
40
|
-
options[:omission] ||= "..."
|
41
|
-
|
42
|
-
length_with_room_for_omission = length - options[:omission].mb_chars.length
|
43
|
-
chars = text.mb_chars
|
44
|
-
stop = options[:separator] ?
|
45
|
-
(chars.rindex(options[:separator].mb_chars, length_with_room_for_omission) || length_with_room_for_omission) : length_with_room_for_omission
|
46
|
-
|
47
|
-
(chars.length > length ? chars[0...stop] + options[:omission] : text).to_s
|
48
|
-
end
|
49
20
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# For instance, you can figure out the name of a database from the name of a class.
|
3
3
|
#
|
4
4
|
# "ScaleScore".tableize # => "scale_scores"
|
5
|
-
|
5
|
+
|
6
6
|
class String
|
7
7
|
# Returns the plural form of the word in the string.
|
8
8
|
#
|
@@ -146,4 +146,15 @@ class String
|
|
146
146
|
def foreign_key(separate_class_name_and_id_with_underscore = true)
|
147
147
|
ActiveSupport::Inflector.foreign_key(self, separate_class_name_and_id_with_underscore)
|
148
148
|
end
|
149
|
+
|
150
|
+
# +constantize+ tries to find a declared constant with the name specified
|
151
|
+
# in the string. It raises a NameError when the name is not in CamelCase
|
152
|
+
# or is not initialized.
|
153
|
+
#
|
154
|
+
# Examples
|
155
|
+
# "Module".constantize # => Module
|
156
|
+
# "Class".constantize # => Class
|
157
|
+
def constantize
|
158
|
+
ActiveSupport::Inflector.constantize(self)
|
159
|
+
end
|
149
160
|
end
|
@@ -1,2 +1,92 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
=begin
|
2
|
+
heavily based on Masao Mutoh's gettext String interpolation extension
|
3
|
+
http://github.com/mutoh/gettext/blob/f6566738b981fe0952548c421042ad1e0cdfb31e/lib/gettext/core_ext/string.rb
|
4
|
+
Copyright (C) 2005-2009 Masao Mutoh
|
5
|
+
You may redistribute it and/or modify it under the same license terms as Ruby.
|
6
|
+
=end
|
7
|
+
|
8
|
+
if RUBY_VERSION < '1.9'
|
9
|
+
require 'active_support/core_ext/string/bytesize'
|
10
|
+
|
11
|
+
# KeyError is raised by String#% when the string contains a named placeholder
|
12
|
+
# that is not contained in the given arguments hash. Ruby 1.9 includes and
|
13
|
+
# raises this exception natively. We define it to mimic Ruby 1.9's behaviour
|
14
|
+
# in Ruby 1.8.x
|
15
|
+
|
16
|
+
class KeyError < IndexError
|
17
|
+
def initialize(message = nil)
|
18
|
+
super(message || "key not found")
|
19
|
+
end
|
20
|
+
end unless defined?(KeyError)
|
21
|
+
|
22
|
+
# Extension for String class. This feature is included in Ruby 1.9 or later but not occur TypeError.
|
23
|
+
#
|
24
|
+
# String#% method which accept "named argument". The translator can know
|
25
|
+
# the meaning of the msgids using "named argument" instead of %s/%d style.
|
26
|
+
|
27
|
+
class String
|
28
|
+
alias :interpolate_without_ruby_19_syntax :% # :nodoc:
|
29
|
+
|
30
|
+
INTERPOLATION_PATTERN = Regexp.union(
|
31
|
+
/%%/,
|
32
|
+
/%\{(\w+)\}/, # matches placeholders like "%{foo}"
|
33
|
+
/%<(\w+)>(.*?\d*\.?\d*[bBdiouxXeEfgGcps])/ # matches placeholders like "%<foo>.d"
|
34
|
+
)
|
35
|
+
|
36
|
+
# % uses self (i.e. the String) as a format specification and returns the
|
37
|
+
# result of applying it to the given arguments. In other words it interpolates
|
38
|
+
# the given arguments to the string according to the formats the string
|
39
|
+
# defines.
|
40
|
+
#
|
41
|
+
# There are three ways to use it:
|
42
|
+
#
|
43
|
+
# * Using a single argument or Array of arguments.
|
44
|
+
#
|
45
|
+
# This is the default behaviour of the String class. See Kernel#sprintf for
|
46
|
+
# more details about the format string.
|
47
|
+
#
|
48
|
+
# Example:
|
49
|
+
#
|
50
|
+
# "%d %s" % [1, "message"]
|
51
|
+
# # => "1 message"
|
52
|
+
#
|
53
|
+
# * Using a Hash as an argument and unformatted, named placeholders.
|
54
|
+
#
|
55
|
+
# When you pass a Hash as an argument and specify placeholders with %{foo}
|
56
|
+
# it will interpret the hash values as named arguments.
|
57
|
+
#
|
58
|
+
# Example:
|
59
|
+
#
|
60
|
+
# "%{firstname}, %{lastname}" % {:firstname => "Masao", :lastname => "Mutoh"}
|
61
|
+
# # => "Masao Mutoh"
|
62
|
+
#
|
63
|
+
# * Using a Hash as an argument and formatted, named placeholders.
|
64
|
+
#
|
65
|
+
# When you pass a Hash as an argument and specify placeholders with %<foo>d
|
66
|
+
# it will interpret the hash values as named arguments and format the value
|
67
|
+
# according to the formatting instruction appended to the closing >.
|
68
|
+
#
|
69
|
+
# Example:
|
70
|
+
#
|
71
|
+
# "%<integer>d, %<float>.1f" % { :integer => 10, :float => 43.4 }
|
72
|
+
# # => "10, 43.3"
|
73
|
+
def %(args)
|
74
|
+
if args.kind_of?(Hash)
|
75
|
+
dup.gsub(INTERPOLATION_PATTERN) do |match|
|
76
|
+
if match == '%%'
|
77
|
+
'%'
|
78
|
+
else
|
79
|
+
key = ($1 || $2).to_sym
|
80
|
+
raise KeyError unless args.has_key?(key)
|
81
|
+
$3 ? sprintf("%#{$3}", args[key]) : args[key]
|
82
|
+
end
|
83
|
+
end
|
84
|
+
elsif self =~ INTERPOLATION_PATTERN
|
85
|
+
raise ArgumentError.new('one hash required')
|
86
|
+
else
|
87
|
+
result = gsub(/%([{<])/, '%%\1')
|
88
|
+
result.send :'interpolate_without_ruby_19_syntax', args
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
unless '1.9'.respond_to?(:each_char)
|
2
|
+
class String
|
3
|
+
# Yields a single-character string for each character in the string.
|
4
|
+
# When $KCODE = 'UTF8', multi-byte characters are yielded appropriately.
|
5
|
+
def each_char
|
6
|
+
require 'strscan' unless defined? ::StringScanner
|
7
|
+
scanner, char = ::StringScanner.new(self), /./mu
|
8
|
+
while c = scanner.scan(char)
|
9
|
+
yield c
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
require 'active_support/multibyte'
|
3
3
|
|
4
4
|
class String
|
5
|
-
|
5
|
+
unless '1.9'.respond_to?(:force_encoding)
|
6
6
|
# == Multibyte proxy
|
7
7
|
#
|
8
8
|
# +mb_chars+ is a multibyte safe proxy for string methods.
|
@@ -37,13 +37,30 @@ class String
|
|
37
37
|
# For more information about the methods defined on the Chars proxy see ActiveSupport::Multibyte::Chars. For
|
38
38
|
# information about how to change the default Multibyte behaviour see ActiveSupport::Multibyte.
|
39
39
|
def mb_chars
|
40
|
-
if ActiveSupport::Multibyte.proxy_class.
|
40
|
+
if ActiveSupport::Multibyte.proxy_class.wants?(self)
|
41
41
|
ActiveSupport::Multibyte.proxy_class.new(self)
|
42
42
|
else
|
43
43
|
self
|
44
44
|
end
|
45
45
|
end
|
46
|
+
|
47
|
+
# Returns true if the string has UTF-8 semantics (a String used for purely byte resources is unlikely to have
|
48
|
+
# them), returns false otherwise.
|
49
|
+
def is_utf8?
|
50
|
+
ActiveSupport::Multibyte::Chars.consumes?(self)
|
51
|
+
end
|
46
52
|
|
53
|
+
unless '1.8.7 and later'.respond_to?(:chars)
|
54
|
+
def chars
|
55
|
+
ActiveSupport::Deprecation.warn('String#chars has been deprecated in favor of String#mb_chars.', caller)
|
56
|
+
mb_chars
|
57
|
+
end
|
58
|
+
end
|
59
|
+
else
|
60
|
+
def mb_chars #:nodoc
|
61
|
+
self
|
62
|
+
end
|
63
|
+
|
47
64
|
def is_utf8? #:nodoc
|
48
65
|
case encoding
|
49
66
|
when Encoding::UTF_8
|
@@ -54,19 +71,5 @@ class String
|
|
54
71
|
false
|
55
72
|
end
|
56
73
|
end
|
57
|
-
else
|
58
|
-
def mb_chars
|
59
|
-
if ActiveSupport::Multibyte.proxy_class.wants?(self)
|
60
|
-
ActiveSupport::Multibyte.proxy_class.new(self)
|
61
|
-
else
|
62
|
-
self
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
# Returns true if the string has UTF-8 semantics (a String used for purely byte resources is unlikely to have
|
67
|
-
# them), returns false otherwise.
|
68
|
-
def is_utf8?
|
69
|
-
ActiveSupport::Multibyte::Chars.consumes?(self)
|
70
|
-
end
|
71
74
|
end
|
72
75
|
end
|
@@ -1,109 +1,43 @@
|
|
1
|
-
|
2
|
-
require 'active_support/core_ext/kernel/singleton_class'
|
3
|
-
|
4
|
-
class ERB
|
5
|
-
module Util
|
6
|
-
HTML_ESCAPE = { '&' => '&', '>' => '>', '<' => '<', '"' => '"' }
|
7
|
-
JSON_ESCAPE = { '&' => '\u0026', '>' => '\u003E', '<' => '\u003C' }
|
8
|
-
|
9
|
-
# A utility method for escaping HTML tag characters.
|
10
|
-
# This method is also aliased as <tt>h</tt>.
|
11
|
-
#
|
12
|
-
# In your ERb templates, use this method to escape any unsafe content. For example:
|
13
|
-
# <%=h @person.name %>
|
14
|
-
#
|
15
|
-
# ==== Example:
|
16
|
-
# puts html_escape("is a > 0 & a < 10?")
|
17
|
-
# # => is a > 0 & a < 10?
|
18
|
-
def html_escape(s)
|
19
|
-
s = s.to_s
|
20
|
-
if s.html_safe?
|
21
|
-
s
|
22
|
-
else
|
23
|
-
s.gsub(/[&"><]/) { |special| HTML_ESCAPE[special] }.html_safe
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
remove_method(:h)
|
28
|
-
alias h html_escape
|
29
|
-
|
30
|
-
module_function :h
|
31
|
-
|
32
|
-
singleton_class.send(:remove_method, :html_escape)
|
33
|
-
module_function :html_escape
|
34
|
-
|
35
|
-
# A utility method for escaping HTML entities in JSON strings.
|
36
|
-
# This method is also aliased as <tt>j</tt>.
|
37
|
-
#
|
38
|
-
# In your ERb templates, use this method to escape any HTML entities:
|
39
|
-
# <%=j @person.to_json %>
|
40
|
-
#
|
41
|
-
# ==== Example:
|
42
|
-
# puts json_escape("is a > 0 & a < 10?")
|
43
|
-
# # => is a \u003E 0 \u0026 a \u003C 10?
|
44
|
-
def json_escape(s)
|
45
|
-
s.to_s.gsub(/[&"><]/) { |special| JSON_ESCAPE[special] }
|
46
|
-
end
|
47
|
-
|
48
|
-
alias j json_escape
|
49
|
-
module_function :j
|
50
|
-
module_function :json_escape
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
class Object
|
1
|
+
class String
|
55
2
|
def html_safe?
|
56
|
-
|
3
|
+
defined?(@_rails_html_safe) && @_rails_html_safe
|
57
4
|
end
|
58
|
-
end
|
59
5
|
|
60
|
-
|
61
|
-
|
62
|
-
|
6
|
+
def html_safe!
|
7
|
+
@_rails_html_safe = true
|
8
|
+
self
|
63
9
|
end
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
77
|
-
alias << concat
|
78
|
-
|
79
|
-
def +(other)
|
80
|
-
dup.concat(other)
|
81
|
-
end
|
82
|
-
|
83
|
-
def html_safe?
|
84
|
-
true
|
85
|
-
end
|
86
|
-
|
87
|
-
def html_safe
|
88
|
-
self
|
89
|
-
end
|
90
|
-
|
91
|
-
def to_s
|
92
|
-
self
|
93
|
-
end
|
94
|
-
|
95
|
-
def to_yaml(*args)
|
96
|
-
to_str.to_yaml(*args)
|
10
|
+
|
11
|
+
def html_safe
|
12
|
+
dup.html_safe!
|
13
|
+
end
|
14
|
+
|
15
|
+
alias original_plus +
|
16
|
+
def +(other)
|
17
|
+
result = original_plus(other)
|
18
|
+
if html_safe? && also_html_safe?(other)
|
19
|
+
result.html_safe!
|
20
|
+
else
|
21
|
+
result
|
97
22
|
end
|
98
23
|
end
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
24
|
+
|
25
|
+
alias original_concat <<
|
26
|
+
def <<(other)
|
27
|
+
result = original_concat(other)
|
28
|
+
unless html_safe? && also_html_safe?(other)
|
29
|
+
@_rails_html_safe = false
|
30
|
+
end
|
31
|
+
result
|
104
32
|
end
|
105
|
-
|
106
|
-
def
|
107
|
-
|
33
|
+
|
34
|
+
def concat(other)
|
35
|
+
self << other
|
108
36
|
end
|
109
|
-
|
37
|
+
|
38
|
+
private
|
39
|
+
def also_html_safe?(other)
|
40
|
+
other.respond_to?(:html_safe?) && other.html_safe?
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -1,4 +1,18 @@
|
|
1
1
|
class String
|
2
|
+
unless '1.8.7 and up'.respond_to?(:start_with?)
|
3
|
+
# Does the string start with the specified +prefix+?
|
4
|
+
def start_with?(prefix)
|
5
|
+
prefix = prefix.to_s
|
6
|
+
self[0, prefix.length] == prefix
|
7
|
+
end
|
8
|
+
|
9
|
+
# Does the string end with the specified +suffix+?
|
10
|
+
def end_with?(suffix)
|
11
|
+
suffix = suffix.to_s
|
12
|
+
self[-suffix.length, suffix.length] == suffix
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
2
16
|
alias_method :starts_with?, :start_with?
|
3
17
|
alias_method :ends_with?, :end_with?
|
4
18
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'active_support/core_ext/symbol/to_proc'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Symbol
|
2
|
+
# Turns the symbol into a simple proc, which is especially useful for enumerations. Examples:
|
3
|
+
#
|
4
|
+
# # The same as people.collect { |p| p.name }
|
5
|
+
# people.collect(&:name)
|
6
|
+
#
|
7
|
+
# # The same as people.select { |p| p.manager? }.collect { |p| p.salary }
|
8
|
+
# people.select(&:manager?).collect(&:salary)
|
9
|
+
#
|
10
|
+
# This is a builtin method in Ruby 1.8.7 and later.
|
11
|
+
def to_proc
|
12
|
+
Proc.new { |*args| args.shift.__send__(self, *args) }
|
13
|
+
end unless :to_proc.respond_to?(:to_proc)
|
14
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'time'
|
3
|
+
|
4
|
+
require 'active_support/core_ext/time/publicize_conversion_methods'
|
5
|
+
require 'active_support/core_ext/time/marshal_with_utc_flag'
|
6
|
+
|
7
|
+
require 'active_support/core_ext/time/acts_like'
|
8
|
+
require 'active_support/core_ext/time/calculations'
|
9
|
+
require 'active_support/core_ext/time/conversions'
|
10
|
+
require 'active_support/core_ext/time/zones'
|
@@ -1,7 +1,5 @@
|
|
1
1
|
require 'active_support/duration'
|
2
|
-
require 'active_support/core_ext/date/acts_like'
|
3
2
|
require 'active_support/core_ext/date/calculations'
|
4
|
-
require 'active_support/core_ext/date_time/conversions'
|
5
3
|
|
6
4
|
class Time
|
7
5
|
COMMON_YEAR_DAYS_IN_MONTH = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
|
@@ -24,11 +22,10 @@ class Time
|
|
24
22
|
# (i.e., if year is within either 1970..2038 or 1902..2038, depending on system architecture);
|
25
23
|
# otherwise returns a DateTime
|
26
24
|
def time_with_datetime_fallback(utc_or_local, year, month=1, day=1, hour=0, min=0, sec=0, usec=0)
|
27
|
-
|
28
|
-
# This check is needed because Time.utc(y) returns a time object in the 2000s for 0 <= y <= 138.
|
29
|
-
time.year == year ? time : ::DateTime.civil_from_format(utc_or_local, year, month, day, hour, min, sec)
|
25
|
+
::Time.send(utc_or_local, year, month, day, hour, min, sec, usec)
|
30
26
|
rescue
|
31
|
-
|
27
|
+
offset = utc_or_local.to_sym == :local ? ::DateTime.local_offset : 0
|
28
|
+
::DateTime.civil(year, month, day, hour, min, sec, offset)
|
32
29
|
end
|
33
30
|
|
34
31
|
# Wraps class method +time_with_datetime_fallback+ with +utc_or_local+ set to <tt>:utc</tt>.
|
@@ -133,7 +130,7 @@ class Time
|
|
133
130
|
end
|
134
131
|
|
135
132
|
# Short-hand for years_ago(1)
|
136
|
-
def
|
133
|
+
def last_year
|
137
134
|
years_ago(1)
|
138
135
|
end
|
139
136
|
|
@@ -142,8 +139,9 @@ class Time
|
|
142
139
|
years_since(1)
|
143
140
|
end
|
144
141
|
|
142
|
+
|
145
143
|
# Short-hand for months_ago(1)
|
146
|
-
def
|
144
|
+
def last_month
|
147
145
|
months_ago(1)
|
148
146
|
end
|
149
147
|
|
@@ -260,7 +258,7 @@ class Time
|
|
260
258
|
# are coerced into values that Time#- will recognize
|
261
259
|
def minus_with_coercion(other)
|
262
260
|
other = other.comparable_time if other.respond_to?(:comparable_time)
|
263
|
-
|
261
|
+
minus_without_coercion(other)
|
264
262
|
end
|
265
263
|
alias_method :minus_without_coercion, :-
|
266
264
|
alias_method :-, :minus_with_coercion
|