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,55 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/module/anonymous'
|
2
|
-
require 'active_support/core_ext/module/reachable'
|
3
|
-
|
4
|
-
class Class #:nodoc:
|
5
|
-
# Returns an array with the names of the subclasses of +self+ as strings.
|
6
|
-
#
|
7
|
-
# Integer.subclasses # => ["Bignum", "Fixnum"]
|
8
|
-
def subclasses
|
9
|
-
Class.subclasses_of(self).map { |o| o.to_s }
|
10
|
-
end
|
11
|
-
|
12
|
-
# Rubinius
|
13
|
-
if defined?(Class.__subclasses__)
|
14
|
-
def descendents
|
15
|
-
subclasses = []
|
16
|
-
__subclasses__.each {|k| subclasses << k; subclasses.concat k.descendents }
|
17
|
-
subclasses
|
18
|
-
end
|
19
|
-
else
|
20
|
-
# MRI
|
21
|
-
begin
|
22
|
-
ObjectSpace.each_object(Class.new) {}
|
23
|
-
|
24
|
-
def descendents
|
25
|
-
subclasses = []
|
26
|
-
ObjectSpace.each_object(class << self; self; end) do |k|
|
27
|
-
subclasses << k unless k == self
|
28
|
-
end
|
29
|
-
subclasses
|
30
|
-
end
|
31
|
-
# JRuby
|
32
|
-
rescue StandardError
|
33
|
-
def descendents
|
34
|
-
subclasses = []
|
35
|
-
ObjectSpace.each_object(Class) do |k|
|
36
|
-
subclasses << k if k < self
|
37
|
-
end
|
38
|
-
subclasses.uniq!
|
39
|
-
subclasses
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
# Exclude this class unless it's a subclass of our supers and is defined.
|
45
|
-
# We check defined? in case we find a removed class that has yet to be
|
46
|
-
# garbage collected. This also fails for anonymous classes -- please
|
47
|
-
# submit a patch if you have a workaround.
|
48
|
-
def self.subclasses_of(*superclasses) #:nodoc:
|
49
|
-
subclasses = []
|
50
|
-
superclasses.each do |klass|
|
51
|
-
subclasses.concat klass.descendents.select {|k| k.anonymous? || k.reachable?}
|
52
|
-
end
|
53
|
-
subclasses
|
54
|
-
end
|
55
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module Kernel
|
2
|
-
# Returns the object's singleton class.
|
3
|
-
def singleton_class
|
4
|
-
class << self
|
5
|
-
self
|
6
|
-
end
|
7
|
-
end unless respond_to?(:singleton_class) # exists in 1.9.2
|
8
|
-
|
9
|
-
# class_eval on an object acts like singleton_class.class_eval.
|
10
|
-
def class_eval(*args, &block)
|
11
|
-
singleton_class.class_eval(*args, &block)
|
12
|
-
end
|
13
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/object/blank'
|
2
|
-
|
3
|
-
class Module
|
4
|
-
# A module may or may not have a name.
|
5
|
-
#
|
6
|
-
# module M; end
|
7
|
-
# M.name # => "M"
|
8
|
-
#
|
9
|
-
# m = Module.new
|
10
|
-
# m.name # => ""
|
11
|
-
#
|
12
|
-
# A module gets a name when it is first assigned to a constant. Either
|
13
|
-
# via the +module+ or +class+ keyword or by an explicit assignment:
|
14
|
-
#
|
15
|
-
# m = Module.new # creates an anonymous module
|
16
|
-
# M = m # => m gets a name here as a side-effect
|
17
|
-
# m.name # => "M"
|
18
|
-
#
|
19
|
-
def anonymous?
|
20
|
-
# Uses blank? because the name of an anonymous class is an empty
|
21
|
-
# string in 1.8, and nil in 1.9.
|
22
|
-
name.blank?
|
23
|
-
end
|
24
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class Module
|
2
|
-
if instance_methods[0].is_a?(Symbol)
|
3
|
-
def instance_method_names(*args)
|
4
|
-
instance_methods(*args).map(&:to_s)
|
5
|
-
end
|
6
|
-
|
7
|
-
def method_names(*args)
|
8
|
-
methods(*args).map(&:to_s)
|
9
|
-
end
|
10
|
-
else
|
11
|
-
alias_method :instance_method_names, :instance_methods
|
12
|
-
alias_method :method_names, :methods
|
13
|
-
end
|
14
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class Object
|
4
|
-
# Alias of <tt>to_s</tt>.
|
5
|
-
def to_param
|
6
|
-
to_s
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
class NilClass
|
11
|
-
def to_param
|
12
|
-
self
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class TrueClass
|
17
|
-
def to_param
|
18
|
-
self
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class FalseClass
|
23
|
-
def to_param
|
24
|
-
self
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class Array
|
29
|
-
# Calls <tt>to_param</tt> on all its elements and joins the result with
|
30
|
-
# slashes. This is used by <tt>url_for</tt> in Action Pack.
|
31
|
-
def to_param
|
32
|
-
collect { |e| e.to_param }.join '/'
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
class Hash
|
37
|
-
# Converts a hash into a string suitable for use as a URL query string. An optional <tt>namespace</tt> can be
|
38
|
-
# passed to enclose the param names (see example below).
|
39
|
-
#
|
40
|
-
# ==== Examples
|
41
|
-
# { :name => 'David', :nationality => 'Danish' }.to_param # => "name=David&nationality=Danish"
|
42
|
-
#
|
43
|
-
# { :name => 'David', :nationality => 'Danish' }.to_param('user') # => "user[name]=David&user[nationality]=Danish"
|
44
|
-
def to_param(namespace = nil)
|
45
|
-
collect do |key, value|
|
46
|
-
value.to_query(namespace ? "#{namespace}[#{key}]" : key)
|
47
|
-
end.sort * '&'
|
48
|
-
end
|
49
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/object/to_param'
|
2
|
-
|
3
|
-
class Object
|
4
|
-
# Converts an object into a string suitable for use as a URL query string, using the given <tt>key</tt> as the
|
5
|
-
# param name.
|
6
|
-
#
|
7
|
-
# Note: This method is defined as a default implementation for all Objects for Hash#to_query to work.
|
8
|
-
def to_query(key)
|
9
|
-
require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
|
10
|
-
"#{CGI.escape(key.to_s).gsub(/%(5B|5D)/n) { [$1].pack('H*') }}=#{CGI.escape(to_param.to_s)}"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class Array
|
15
|
-
# Converts an array into a string suitable for use as a URL query string,
|
16
|
-
# using the given +key+ as the param name.
|
17
|
-
#
|
18
|
-
# ['Rails', 'coding'].to_query('hobbies') # => "hobbies[]=Rails&hobbies[]=coding"
|
19
|
-
def to_query(key)
|
20
|
-
prefix = "#{key}[]"
|
21
|
-
collect { |value| value.to_query(prefix) }.join '&'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
class Hash
|
26
|
-
alias_method :to_query, :to_param
|
27
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
# Pre-1.9 versions of Ruby have a bug with marshaling Time instances, where utc instances are
|
2
|
-
# unmarshalled in the local zone, instead of utc. We're layering behavior on the _dump and _load
|
3
|
-
# methods so that utc instances can be flagged on dump, and coerced back to utc on load.
|
4
|
-
if !Marshal.load(Marshal.dump(Time.now.utc)).utc?
|
5
|
-
class Time
|
6
|
-
class << self
|
7
|
-
alias_method :_load_without_utc_flag, :_load
|
8
|
-
def _load(marshaled_time)
|
9
|
-
time = _load_without_utc_flag(marshaled_time)
|
10
|
-
time.instance_eval do
|
11
|
-
if defined?(@marshal_with_utc_coercion)
|
12
|
-
val = remove_instance_variable("@marshal_with_utc_coercion")
|
13
|
-
end
|
14
|
-
val ? utc : self
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
alias_method :_dump_without_utc_flag, :_dump
|
20
|
-
def _dump(*args)
|
21
|
-
obj = dup
|
22
|
-
obj.instance_variable_set('@marshal_with_utc_coercion', utc?)
|
23
|
-
obj._dump_without_utc_flag(*args)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# Ruby 1.9.2 adds utc_offset and zone to Time, but marshaling only
|
29
|
-
# preserves utc_offset. Preserve zone also, even though it may not
|
30
|
-
# work in some edge cases.
|
31
|
-
if Time.local(2010).zone != Marshal.load(Marshal.dump(Time.local(2010))).zone
|
32
|
-
class Time
|
33
|
-
class << self
|
34
|
-
alias_method :_load_without_zone, :_load
|
35
|
-
def _load(marshaled_time)
|
36
|
-
time = _load_without_zone(marshaled_time)
|
37
|
-
time.instance_eval do
|
38
|
-
if zone = defined?(@_zone) && remove_instance_variable('@_zone')
|
39
|
-
ary = to_a
|
40
|
-
ary[-1] = zone
|
41
|
-
utc? ? Time.utc(*ary) : Time.local(*ary)
|
42
|
-
else
|
43
|
-
self
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
alias_method :_dump_without_zone, :_dump
|
50
|
-
def _dump(*args)
|
51
|
-
obj = dup
|
52
|
-
obj.instance_variable_set('@_zone', zone)
|
53
|
-
obj._dump_without_zone(*args)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require "active_support/inflector/methods"
|
2
|
-
require "active_support/lazy_load_hooks"
|
3
|
-
|
4
|
-
module ActiveSupport
|
5
|
-
module Autoload
|
6
|
-
@@autoloads = {}
|
7
|
-
@@under_path = nil
|
8
|
-
@@at_path = nil
|
9
|
-
@@eager_autoload = false
|
10
|
-
|
11
|
-
def autoload(const_name, path = @@at_path)
|
12
|
-
full = [self.name, @@under_path, const_name.to_s, path].compact.join("::")
|
13
|
-
location = path || Inflector.underscore(full)
|
14
|
-
|
15
|
-
if @@eager_autoload
|
16
|
-
@@autoloads[const_name] = location
|
17
|
-
end
|
18
|
-
super const_name, location
|
19
|
-
end
|
20
|
-
|
21
|
-
def autoload_under(path)
|
22
|
-
@@under_path, old_path = path, @@under_path
|
23
|
-
yield
|
24
|
-
ensure
|
25
|
-
@@under_path = old_path
|
26
|
-
end
|
27
|
-
|
28
|
-
def autoload_at(path)
|
29
|
-
@@at_path, old_path = path, @@at_path
|
30
|
-
yield
|
31
|
-
ensure
|
32
|
-
@@at_path = old_path
|
33
|
-
end
|
34
|
-
|
35
|
-
def eager_autoload
|
36
|
-
old_eager, @@eager_autoload = @@eager_autoload, true
|
37
|
-
yield
|
38
|
-
ensure
|
39
|
-
@@eager_autoload = old_eager
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.eager_autoload!
|
43
|
-
@@autoloads.values.each { |file| require file }
|
44
|
-
end
|
45
|
-
|
46
|
-
def autoloads
|
47
|
-
@@autoloads
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
data/lib/active_support/i18n.rb
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'i18n'
|
3
|
-
rescue LoadError => e
|
4
|
-
$stderr.puts "You don't have i18n installed in your application. Please add it to your Gemfile and run bundle install"
|
5
|
-
raise e
|
6
|
-
end
|
7
|
-
I18n.load_path << "#{File.dirname(__FILE__)}/locale/en.yml"
|
8
|
-
ActiveSupport.run_load_hooks(:i18n)
|
@@ -1,211 +0,0 @@
|
|
1
|
-
module ActiveSupport
|
2
|
-
module Inflector
|
3
|
-
# A singleton instance of this class is yielded by Inflector.inflections, which can then be used to specify additional
|
4
|
-
# inflection rules. Examples:
|
5
|
-
#
|
6
|
-
# ActiveSupport::Inflector.inflections do |inflect|
|
7
|
-
# inflect.plural /^(ox)$/i, '\1\2en'
|
8
|
-
# inflect.singular /^(ox)en/i, '\1'
|
9
|
-
#
|
10
|
-
# inflect.irregular 'octopus', 'octopi'
|
11
|
-
#
|
12
|
-
# inflect.uncountable "equipment"
|
13
|
-
# end
|
14
|
-
#
|
15
|
-
# New rules are added at the top. So in the example above, the irregular rule for octopus will now be the first of the
|
16
|
-
# pluralization and singularization rules that is runs. This guarantees that your rules run before any of the rules that may
|
17
|
-
# already have been loaded.
|
18
|
-
class Inflections
|
19
|
-
def self.instance
|
20
|
-
@__instance__ ||= new
|
21
|
-
end
|
22
|
-
|
23
|
-
attr_reader :plurals, :singulars, :uncountables, :humans
|
24
|
-
|
25
|
-
def initialize
|
26
|
-
@plurals, @singulars, @uncountables, @humans = [], [], [], []
|
27
|
-
end
|
28
|
-
|
29
|
-
# Specifies a new pluralization rule and its replacement. The rule can either be a string or a regular expression.
|
30
|
-
# The replacement should always be a string that may include references to the matched data from the rule.
|
31
|
-
def plural(rule, replacement)
|
32
|
-
@uncountables.delete(rule) if rule.is_a?(String)
|
33
|
-
@uncountables.delete(replacement)
|
34
|
-
@plurals.insert(0, [rule, replacement])
|
35
|
-
end
|
36
|
-
|
37
|
-
# Specifies a new singularization rule and its replacement. The rule can either be a string or a regular expression.
|
38
|
-
# The replacement should always be a string that may include references to the matched data from the rule.
|
39
|
-
def singular(rule, replacement)
|
40
|
-
@uncountables.delete(rule) if rule.is_a?(String)
|
41
|
-
@uncountables.delete(replacement)
|
42
|
-
@singulars.insert(0, [rule, replacement])
|
43
|
-
end
|
44
|
-
|
45
|
-
# Specifies a new irregular that applies to both pluralization and singularization at the same time. This can only be used
|
46
|
-
# for strings, not regular expressions. You simply pass the irregular in singular and plural form.
|
47
|
-
#
|
48
|
-
# Examples:
|
49
|
-
# irregular 'octopus', 'octopi'
|
50
|
-
# irregular 'person', 'people'
|
51
|
-
def irregular(singular, plural)
|
52
|
-
@uncountables.delete(singular)
|
53
|
-
@uncountables.delete(plural)
|
54
|
-
if singular[0,1].upcase == plural[0,1].upcase
|
55
|
-
plural(Regexp.new("(#{singular[0,1]})#{singular[1..-1]}$", "i"), '\1' + plural[1..-1])
|
56
|
-
plural(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"), '\1' + plural[1..-1])
|
57
|
-
singular(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"), '\1' + singular[1..-1])
|
58
|
-
else
|
59
|
-
plural(Regexp.new("#{singular[0,1].upcase}(?i)#{singular[1..-1]}$"), plural[0,1].upcase + plural[1..-1])
|
60
|
-
plural(Regexp.new("#{singular[0,1].downcase}(?i)#{singular[1..-1]}$"), plural[0,1].downcase + plural[1..-1])
|
61
|
-
plural(Regexp.new("#{plural[0,1].upcase}(?i)#{plural[1..-1]}$"), plural[0,1].upcase + plural[1..-1])
|
62
|
-
plural(Regexp.new("#{plural[0,1].downcase}(?i)#{plural[1..-1]}$"), plural[0,1].downcase + plural[1..-1])
|
63
|
-
singular(Regexp.new("#{plural[0,1].upcase}(?i)#{plural[1..-1]}$"), singular[0,1].upcase + singular[1..-1])
|
64
|
-
singular(Regexp.new("#{plural[0,1].downcase}(?i)#{plural[1..-1]}$"), singular[0,1].downcase + singular[1..-1])
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
# Add uncountable words that shouldn't be attempted inflected.
|
69
|
-
#
|
70
|
-
# Examples:
|
71
|
-
# uncountable "money"
|
72
|
-
# uncountable "money", "information"
|
73
|
-
# uncountable %w( money information rice )
|
74
|
-
def uncountable(*words)
|
75
|
-
(@uncountables << words).flatten!
|
76
|
-
end
|
77
|
-
|
78
|
-
# Specifies a humanized form of a string by a regular expression rule or by a string mapping.
|
79
|
-
# When using a regular expression based replacement, the normal humanize formatting is called after the replacement.
|
80
|
-
# When a string is used, the human form should be specified as desired (example: 'The name', not 'the_name')
|
81
|
-
#
|
82
|
-
# Examples:
|
83
|
-
# human /_cnt$/i, '\1_count'
|
84
|
-
# human "legacy_col_person_name", "Name"
|
85
|
-
def human(rule, replacement)
|
86
|
-
@humans.insert(0, [rule, replacement])
|
87
|
-
end
|
88
|
-
|
89
|
-
# Clears the loaded inflections within a given scope (default is <tt>:all</tt>).
|
90
|
-
# Give the scope as a symbol of the inflection type, the options are: <tt>:plurals</tt>,
|
91
|
-
# <tt>:singulars</tt>, <tt>:uncountables</tt>, <tt>:humans</tt>.
|
92
|
-
#
|
93
|
-
# Examples:
|
94
|
-
# clear :all
|
95
|
-
# clear :plurals
|
96
|
-
def clear(scope = :all)
|
97
|
-
case scope
|
98
|
-
when :all
|
99
|
-
@plurals, @singulars, @uncountables = [], [], []
|
100
|
-
else
|
101
|
-
instance_variable_set "@#{scope}", []
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
# Yields a singleton instance of Inflector::Inflections so you can specify additional
|
107
|
-
# inflector rules.
|
108
|
-
#
|
109
|
-
# Example:
|
110
|
-
# ActiveSupport::Inflector.inflections do |inflect|
|
111
|
-
# inflect.uncountable "rails"
|
112
|
-
# end
|
113
|
-
def inflections
|
114
|
-
if block_given?
|
115
|
-
yield Inflections.instance
|
116
|
-
else
|
117
|
-
Inflections.instance
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
# Returns the plural form of the word in the string.
|
122
|
-
#
|
123
|
-
# Examples:
|
124
|
-
# "post".pluralize # => "posts"
|
125
|
-
# "octopus".pluralize # => "octopi"
|
126
|
-
# "sheep".pluralize # => "sheep"
|
127
|
-
# "words".pluralize # => "words"
|
128
|
-
# "CamelOctopus".pluralize # => "CamelOctopi"
|
129
|
-
def pluralize(word)
|
130
|
-
result = word.to_s.dup
|
131
|
-
|
132
|
-
if word.empty? || inflections.uncountables.include?(result.downcase)
|
133
|
-
result
|
134
|
-
else
|
135
|
-
inflections.plurals.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
|
136
|
-
result
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
# The reverse of +pluralize+, returns the singular form of a word in a string.
|
141
|
-
#
|
142
|
-
# Examples:
|
143
|
-
# "posts".singularize # => "post"
|
144
|
-
# "octopi".singularize # => "octopus"
|
145
|
-
# "sheep".singularize # => "sheep"
|
146
|
-
# "word".singularize # => "word"
|
147
|
-
# "CamelOctopi".singularize # => "CamelOctopus"
|
148
|
-
def singularize(word)
|
149
|
-
result = word.to_s.dup
|
150
|
-
|
151
|
-
if inflections.uncountables.any? { |inflection| result =~ /#{inflection}\Z/i }
|
152
|
-
result
|
153
|
-
else
|
154
|
-
inflections.singulars.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
|
155
|
-
result
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
# Capitalizes the first word and turns underscores into spaces and strips a
|
160
|
-
# trailing "_id", if any. Like +titleize+, this is meant for creating pretty output.
|
161
|
-
#
|
162
|
-
# Examples:
|
163
|
-
# "employee_salary" # => "Employee salary"
|
164
|
-
# "author_id" # => "Author"
|
165
|
-
def humanize(lower_case_and_underscored_word)
|
166
|
-
result = lower_case_and_underscored_word.to_s.dup
|
167
|
-
|
168
|
-
inflections.humans.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
|
169
|
-
result.gsub(/_id$/, "").gsub(/_/, " ").capitalize
|
170
|
-
end
|
171
|
-
|
172
|
-
# Capitalizes all the words and replaces some characters in the string to create
|
173
|
-
# a nicer looking title. +titleize+ is meant for creating pretty output. It is not
|
174
|
-
# used in the Rails internals.
|
175
|
-
#
|
176
|
-
# +titleize+ is also aliased as as +titlecase+.
|
177
|
-
#
|
178
|
-
# Examples:
|
179
|
-
# "man from the boondocks".titleize # => "Man From The Boondocks"
|
180
|
-
# "x-men: the last stand".titleize # => "X Men: The Last Stand"
|
181
|
-
def titleize(word)
|
182
|
-
humanize(underscore(word)).gsub(/\b('?[a-z])/) { $1.capitalize }
|
183
|
-
end
|
184
|
-
|
185
|
-
# Create the name of a table like Rails does for models to table names. This method
|
186
|
-
# uses the +pluralize+ method on the last word in the string.
|
187
|
-
#
|
188
|
-
# Examples
|
189
|
-
# "RawScaledScorer".tableize # => "raw_scaled_scorers"
|
190
|
-
# "egg_and_ham".tableize # => "egg_and_hams"
|
191
|
-
# "fancyCategory".tableize # => "fancy_categories"
|
192
|
-
def tableize(class_name)
|
193
|
-
pluralize(underscore(class_name))
|
194
|
-
end
|
195
|
-
|
196
|
-
# Create a class name from a plural table name like Rails does for table names to models.
|
197
|
-
# Note that this returns a string and not a Class. (To convert to an actual class
|
198
|
-
# follow +classify+ with +constantize+.)
|
199
|
-
#
|
200
|
-
# Examples:
|
201
|
-
# "egg_and_hams".classify # => "EggAndHam"
|
202
|
-
# "posts".classify # => "Post"
|
203
|
-
#
|
204
|
-
# Singular names are not handled correctly:
|
205
|
-
# "business".classify # => "Busines"
|
206
|
-
def classify(table_name)
|
207
|
-
# strip out any leading schema name
|
208
|
-
camelize(singularize(table_name.to_s.sub(/.*\./, '')))
|
209
|
-
end
|
210
|
-
end
|
211
|
-
end
|