activesupport 2.1.2 → 2.2.2
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 +64 -5
- data/lib/active_support.rb +6 -6
- data/lib/active_support/base64.rb +13 -2
- data/lib/active_support/basic_object.rb +1 -1
- data/lib/active_support/buffered_logger.rb +15 -14
- data/lib/active_support/cache.rb +116 -40
- data/lib/active_support/cache/compressed_mem_cache_store.rb +7 -2
- data/lib/active_support/cache/file_store.rb +7 -5
- data/lib/active_support/cache/mem_cache_store.rb +48 -21
- data/lib/active_support/cache/memory_store.rb +16 -2
- data/lib/active_support/cache/synchronized_memory_store.rb +47 -0
- data/lib/active_support/callbacks.rb +14 -9
- data/lib/active_support/core_ext/array/access.rb +27 -0
- data/lib/active_support/core_ext/array/conversions.rb +12 -7
- data/lib/active_support/core_ext/array/grouping.rb +53 -10
- data/lib/active_support/core_ext/base64/encoding.rb +3 -0
- data/lib/active_support/core_ext/bigdecimal/conversions.rb +18 -22
- data/lib/active_support/core_ext/blank.rb +5 -0
- data/lib/active_support/core_ext/class/inheritable_attributes.rb +5 -5
- data/lib/active_support/core_ext/date/behavior.rb +3 -0
- data/lib/active_support/core_ext/date/calculations.rb +24 -9
- data/lib/active_support/core_ext/date_time/calculations.rb +19 -5
- data/lib/active_support/core_ext/duplicable.rb +6 -0
- data/lib/active_support/core_ext/enumerable.rb +42 -4
- data/lib/active_support/core_ext/file.rb +4 -20
- data/lib/active_support/core_ext/file/atomic.rb +46 -0
- data/lib/active_support/core_ext/float.rb +2 -0
- data/lib/active_support/core_ext/float/time.rb +27 -0
- data/lib/active_support/core_ext/hash.rb +2 -1
- data/lib/active_support/core_ext/hash/conversions.rb +1 -1
- data/lib/active_support/core_ext/hash/deep_merge.rb +23 -0
- data/lib/active_support/core_ext/hash/except.rb +1 -1
- data/lib/active_support/core_ext/hash/reverse_merge.rb +12 -5
- data/lib/active_support/core_ext/hash/slice.rb +7 -4
- data/lib/active_support/core_ext/integer.rb +2 -0
- data/lib/active_support/core_ext/integer/time.rb +45 -0
- data/lib/active_support/core_ext/kernel/debugger.rb +4 -4
- data/lib/active_support/core_ext/logger.rb +128 -1
- data/lib/active_support/core_ext/module.rb +11 -1
- data/lib/active_support/core_ext/module/aliasing.rb +71 -67
- data/lib/active_support/core_ext/module/delegation.rb +32 -1
- data/lib/active_support/core_ext/module/introspection.rb +81 -66
- data/lib/active_support/core_ext/module/model_naming.rb +8 -7
- data/lib/active_support/core_ext/module/synchronization.rb +39 -0
- data/lib/active_support/core_ext/numeric/time.rb +0 -10
- data/lib/active_support/core_ext/object.rb +1 -0
- data/lib/active_support/core_ext/object/extending.rb +29 -7
- data/lib/active_support/core_ext/object/instance_variables.rb +1 -1
- data/lib/active_support/core_ext/object/metaclass.rb +13 -0
- data/lib/active_support/core_ext/object/misc.rb +36 -21
- data/lib/active_support/core_ext/rexml.rb +2 -2
- data/lib/active_support/core_ext/string.rb +6 -2
- data/lib/active_support/core_ext/string/access.rb +5 -5
- data/lib/active_support/core_ext/string/behavior.rb +13 -0
- data/lib/active_support/core_ext/string/inflections.rb +21 -2
- data/lib/active_support/core_ext/string/multibyte.rb +81 -0
- data/lib/active_support/core_ext/time/calculations.rb +39 -12
- data/lib/active_support/core_ext/time/conversions.rb +1 -0
- data/lib/active_support/core_ext/time/zones.rb +1 -1
- data/lib/active_support/dependencies.rb +178 -110
- data/lib/active_support/deprecation.rb +24 -4
- data/lib/active_support/inflector.rb +122 -38
- data/lib/active_support/json.rb +1 -1
- data/lib/active_support/json/encoders/date.rb +9 -2
- data/lib/active_support/json/encoders/date_time.rb +9 -2
- data/lib/active_support/json/encoders/time.rb +10 -3
- data/lib/active_support/locale/en.yml +32 -0
- data/lib/active_support/memoizable.rb +82 -0
- data/lib/active_support/multibyte.rb +31 -7
- data/lib/active_support/multibyte/chars.rb +664 -122
- data/lib/active_support/multibyte/exceptions.rb +8 -0
- data/lib/active_support/multibyte/unicode_database.rb +71 -0
- data/lib/active_support/option_merger.rb +2 -10
- data/lib/active_support/ordered_hash.rb +15 -0
- data/lib/active_support/rescuable.rb +108 -0
- data/lib/active_support/secure_random.rb +197 -0
- data/lib/active_support/string_inquirer.rb +11 -1
- data/lib/active_support/test_case.rb +16 -5
- data/lib/active_support/testing/core_ext/test.rb +6 -0
- data/lib/active_support/{core_ext → testing/core_ext}/test/unit/assertions.rb +14 -6
- data/lib/active_support/testing/performance.rb +452 -0
- data/lib/active_support/testing/setup_and_teardown.rb +34 -7
- data/lib/active_support/time_with_zone.rb +66 -42
- data/lib/active_support/values/time_zone.rb +11 -4
- data/lib/active_support/values/unicode_tables.dat +0 -0
- data/lib/active_support/vendor.rb +13 -5
- data/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb +1 -1
- data/lib/active_support/vendor/i18n-0.0.1/i18n.rb +194 -0
- data/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb +216 -0
- data/lib/active_support/vendor/i18n-0.0.1/i18n/exceptions.rb +53 -0
- data/lib/active_support/vendor/{memcache-client-1.5.0 → memcache-client-1.5.1}/memcache.rb +5 -5
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/data_timezone.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/data_timezone_info.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Algiers.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Cairo.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Casablanca.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Harare.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Johannesburg.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Monrovia.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Nairobi.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +0 -0
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/San_Juan.rb +86 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Bogota.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Caracas.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Chicago.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Chihuahua.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Denver.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Godthab.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Guatemala.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Halifax.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Indiana/Indianapolis.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Juneau.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/La_Paz.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Lima.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Los_Angeles.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Mazatlan.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Mexico_City.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Monterrey.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/New_York.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Phoenix.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Regina.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Santiago.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Sao_Paulo.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/St_Johns.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Tijuana.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Almaty.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Baghdad.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Baku.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Bangkok.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Chongqing.rb +0 -0
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Colombo.rb +30 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Dhaka.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Hong_Kong.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Irkutsk.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Jakarta.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Jerusalem.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kabul.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kamchatka.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Karachi.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Katmandu.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kolkata.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Krasnoyarsk.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kuala_Lumpur.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kuwait.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Magadan.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Muscat.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Novosibirsk.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Rangoon.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Riyadh.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Seoul.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Shanghai.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Singapore.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Taipei.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Tashkent.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Tbilisi.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Tehran.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Tokyo.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Ulaanbaatar.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Urumqi.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Vladivostok.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Yakutsk.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Yekaterinburg.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Yerevan.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Atlantic/Azores.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Atlantic/Cape_Verde.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Atlantic/South_Georgia.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Adelaide.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Brisbane.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Darwin.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Hobart.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Melbourne.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Perth.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Sydney.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Etc/UTC.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Amsterdam.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Athens.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Belgrade.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Berlin.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Bratislava.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Brussels.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Bucharest.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Budapest.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Copenhagen.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Dublin.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Helsinki.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Istanbul.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Kiev.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Lisbon.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Ljubljana.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/London.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Madrid.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Minsk.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Moscow.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Paris.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Prague.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Riga.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Rome.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Sarajevo.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Skopje.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Sofia.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Stockholm.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Tallinn.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Vienna.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Vilnius.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Warsaw.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Zagreb.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Auckland.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Fiji.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Guam.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Honolulu.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Majuro.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Midway.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Noumea.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Pago_Pago.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Port_Moresby.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Tongatapu.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/info_timezone.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/linked_timezone.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/linked_timezone_info.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/offset_rationals.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/ruby_core_support.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/time_or_datetime.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_definition.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_info.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_offset_info.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_period.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_transition_info.rb +0 -0
- data/lib/active_support/vendor/xml-simple-1.0.11/xmlsimple.rb +3 -3
- data/lib/active_support/version.rb +1 -1
- metadata +185 -167
- data/lib/active_support/clean_logger.rb +0 -127
- data/lib/active_support/core_ext/string/unicode.rb +0 -66
- data/lib/active_support/core_ext/test.rb +0 -1
- data/lib/active_support/multibyte/generators/generate_tables.rb +0 -149
- data/lib/active_support/multibyte/handlers/passthru_handler.rb +0 -9
- data/lib/active_support/multibyte/handlers/utf8_handler.rb +0 -564
- data/lib/active_support/multibyte/handlers/utf8_handler_proc.rb +0 -43
- data/lib/active_support/vendor/tzinfo-0.3.11/tzinfo/definitions/America/Argentina/San_Juan.rb +0 -170
@@ -0,0 +1,71 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module ActiveSupport #:nodoc:
|
4
|
+
module Multibyte #:nodoc:
|
5
|
+
# Holds data about a codepoint in the Unicode database
|
6
|
+
class Codepoint
|
7
|
+
attr_accessor :code, :combining_class, :decomp_type, :decomp_mapping, :uppercase_mapping, :lowercase_mapping
|
8
|
+
end
|
9
|
+
|
10
|
+
# Holds static data from the Unicode database
|
11
|
+
class UnicodeDatabase
|
12
|
+
ATTRIBUTES = :codepoints, :composition_exclusion, :composition_map, :boundary, :cp1252
|
13
|
+
|
14
|
+
attr_writer(*ATTRIBUTES)
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@codepoints = Hash.new(Codepoint.new)
|
18
|
+
@composition_exclusion = []
|
19
|
+
@composition_map = {}
|
20
|
+
@boundary = {}
|
21
|
+
@cp1252 = {}
|
22
|
+
end
|
23
|
+
|
24
|
+
# Lazy load the Unicode database so it's only loaded when it's actually used
|
25
|
+
ATTRIBUTES.each do |attr_name|
|
26
|
+
class_eval(<<-EOS, __FILE__, __LINE__)
|
27
|
+
def #{attr_name}
|
28
|
+
load
|
29
|
+
@#{attr_name}
|
30
|
+
end
|
31
|
+
EOS
|
32
|
+
end
|
33
|
+
|
34
|
+
# Loads the Unicode database and returns all the internal objects of UnicodeDatabase.
|
35
|
+
def load
|
36
|
+
begin
|
37
|
+
@codepoints, @composition_exclusion, @composition_map, @boundary, @cp1252 = File.open(self.class.filename, 'rb') { |f| Marshal.load f.read }
|
38
|
+
rescue Exception => e
|
39
|
+
raise IOError.new("Couldn't load the Unicode tables for UTF8Handler (#{e.message}), ActiveSupport::Multibyte is unusable")
|
40
|
+
end
|
41
|
+
|
42
|
+
# Redefine the === method so we can write shorter rules for grapheme cluster breaks
|
43
|
+
@boundary.each do |k,_|
|
44
|
+
@boundary[k].instance_eval do
|
45
|
+
def ===(other)
|
46
|
+
detect { |i| i === other } ? true : false
|
47
|
+
end
|
48
|
+
end if @boundary[k].kind_of?(Array)
|
49
|
+
end
|
50
|
+
|
51
|
+
# define attr_reader methods for the instance variables
|
52
|
+
class << self
|
53
|
+
attr_reader(*ATTRIBUTES)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Returns the directory in which the data files are stored
|
58
|
+
def self.dirname
|
59
|
+
File.dirname(__FILE__) + '/../values/'
|
60
|
+
end
|
61
|
+
|
62
|
+
# Returns the filename for the data file for this version
|
63
|
+
def self.filename
|
64
|
+
File.expand_path File.join(dirname, "unicode_tables.dat")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# UniCode Database
|
69
|
+
UCD = UnicodeDatabase.new
|
70
|
+
end
|
71
|
+
end
|
@@ -10,16 +10,8 @@ module ActiveSupport
|
|
10
10
|
|
11
11
|
private
|
12
12
|
def method_missing(method, *arguments, &block)
|
13
|
-
|
14
|
-
@context.
|
15
|
-
end
|
16
|
-
|
17
|
-
def merge_argument_options!(arguments)
|
18
|
-
arguments << if arguments.last.respond_to? :to_hash
|
19
|
-
@options.merge(arguments.pop)
|
20
|
-
else
|
21
|
-
@options.dup
|
22
|
-
end
|
13
|
+
arguments << (arguments.last.respond_to?(:to_hash) ? @options.deep_merge(arguments.pop) : @options.dup)
|
14
|
+
@context.__send__(method, *arguments, &block)
|
23
15
|
end
|
24
16
|
end
|
25
17
|
end
|
@@ -12,6 +12,7 @@ module ActiveSupport
|
|
12
12
|
else
|
13
13
|
self << [key, value]
|
14
14
|
end
|
15
|
+
value
|
15
16
|
end
|
16
17
|
|
17
18
|
def [](key)
|
@@ -38,6 +39,20 @@ module ActiveSupport
|
|
38
39
|
each { |array| hash[array[0]] = array[1] }
|
39
40
|
end
|
40
41
|
end
|
42
|
+
|
43
|
+
def has_key?(k)
|
44
|
+
!assoc(k).nil?
|
45
|
+
end
|
46
|
+
|
47
|
+
alias_method :key?, :has_key?
|
48
|
+
alias_method :include?, :has_key?
|
49
|
+
alias_method :member?, :has_key?
|
50
|
+
|
51
|
+
def has_value?(v)
|
52
|
+
any? { |key, value| value == v }
|
53
|
+
end
|
54
|
+
|
55
|
+
alias_method :value?, :has_value?
|
41
56
|
end
|
42
57
|
end
|
43
58
|
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
module ActiveSupport
|
2
|
+
# Rescuable module adds support for easier exception handling.
|
3
|
+
module Rescuable
|
4
|
+
def self.included(base) # :nodoc:
|
5
|
+
base.class_inheritable_accessor :rescue_handlers
|
6
|
+
base.rescue_handlers = []
|
7
|
+
|
8
|
+
base.extend(ClassMethods)
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
# Rescue exceptions raised in controller actions.
|
13
|
+
#
|
14
|
+
# <tt>rescue_from</tt> receives a series of exception classes or class
|
15
|
+
# names, and a trailing <tt>:with</tt> option with the name of a method
|
16
|
+
# or a Proc object to be called to handle them. Alternatively a block can
|
17
|
+
# be given.
|
18
|
+
#
|
19
|
+
# Handlers that take one argument will be called with the exception, so
|
20
|
+
# that the exception can be inspected when dealing with it.
|
21
|
+
#
|
22
|
+
# Handlers are inherited. They are searched from right to left, from
|
23
|
+
# bottom to top, and up the hierarchy. The handler of the first class for
|
24
|
+
# which <tt>exception.is_a?(klass)</tt> holds true is the one invoked, if
|
25
|
+
# any.
|
26
|
+
#
|
27
|
+
# class ApplicationController < ActionController::Base
|
28
|
+
# rescue_from User::NotAuthorized, :with => :deny_access # self defined exception
|
29
|
+
# rescue_from ActiveRecord::RecordInvalid, :with => :show_errors
|
30
|
+
#
|
31
|
+
# rescue_from 'MyAppError::Base' do |exception|
|
32
|
+
# render :xml => exception, :status => 500
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# protected
|
36
|
+
# def deny_access
|
37
|
+
# ...
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
# def show_errors(exception)
|
41
|
+
# exception.record.new_record? ? ...
|
42
|
+
# end
|
43
|
+
# end
|
44
|
+
def rescue_from(*klasses, &block)
|
45
|
+
options = klasses.extract_options!
|
46
|
+
|
47
|
+
unless options.has_key?(:with)
|
48
|
+
if block_given?
|
49
|
+
options[:with] = block
|
50
|
+
else
|
51
|
+
raise ArgumentError, "Need a handler. Supply an options hash that has a :with key as the last argument."
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
klasses.each do |klass|
|
56
|
+
key = if klass.is_a?(Class) && klass <= Exception
|
57
|
+
klass.name
|
58
|
+
elsif klass.is_a?(String)
|
59
|
+
klass
|
60
|
+
else
|
61
|
+
raise ArgumentError, "#{klass} is neither an Exception nor a String"
|
62
|
+
end
|
63
|
+
|
64
|
+
# put the new handler at the end because the list is read in reverse
|
65
|
+
rescue_handlers << [key, options[:with]]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Tries to rescue the exception by looking up and calling a registered handler.
|
71
|
+
def rescue_with_handler(exception)
|
72
|
+
if handler = handler_for_rescue(exception)
|
73
|
+
handler.arity != 0 ? handler.call(exception) : handler.call
|
74
|
+
true # don't rely on the return value of the handler
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def handler_for_rescue(exception)
|
79
|
+
# We go from right to left because pairs are pushed onto rescue_handlers
|
80
|
+
# as rescue_from declarations are found.
|
81
|
+
_, rescuer = Array(rescue_handlers).reverse.detect do |klass_name, handler|
|
82
|
+
# The purpose of allowing strings in rescue_from is to support the
|
83
|
+
# declaration of handler associations for exception classes whose
|
84
|
+
# definition is yet unknown.
|
85
|
+
#
|
86
|
+
# Since this loop needs the constants it would be inconsistent to
|
87
|
+
# assume they should exist at this point. An early raised exception
|
88
|
+
# could trigger some other handler and the array could include
|
89
|
+
# precisely a string whose corresponding constant has not yet been
|
90
|
+
# seen. This is why we are tolerant to unknown constants.
|
91
|
+
#
|
92
|
+
# Note that this tolerance only matters if the exception was given as
|
93
|
+
# a string, otherwise a NameError will be raised by the interpreter
|
94
|
+
# itself when rescue_from CONSTANT is executed.
|
95
|
+
klass = self.class.const_get(klass_name) rescue nil
|
96
|
+
klass ||= klass_name.constantize rescue nil
|
97
|
+
exception.is_a?(klass) if klass
|
98
|
+
end
|
99
|
+
|
100
|
+
case rescuer
|
101
|
+
when Symbol
|
102
|
+
method(rescuer)
|
103
|
+
when Proc
|
104
|
+
rescuer.bind(self)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,197 @@
|
|
1
|
+
begin
|
2
|
+
require 'openssl'
|
3
|
+
rescue LoadError
|
4
|
+
end
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'securerandom'
|
8
|
+
rescue LoadError
|
9
|
+
end
|
10
|
+
|
11
|
+
module ActiveSupport
|
12
|
+
if defined?(::SecureRandom)
|
13
|
+
# Use Ruby 1.9's SecureRandom library whenever possible.
|
14
|
+
SecureRandom = ::SecureRandom # :nodoc:
|
15
|
+
else
|
16
|
+
# = Secure random number generator interface.
|
17
|
+
#
|
18
|
+
# This library is an interface for secure random number generator which is
|
19
|
+
# suitable for generating session key in HTTP cookies, etc.
|
20
|
+
#
|
21
|
+
# It supports following secure random number generators.
|
22
|
+
#
|
23
|
+
# * openssl
|
24
|
+
# * /dev/urandom
|
25
|
+
# * Win32
|
26
|
+
#
|
27
|
+
# *Note*: This module is based on the SecureRandom library from Ruby 1.9,
|
28
|
+
# revision 18786, August 23 2008. It's 100% interface-compatible with Ruby 1.9's
|
29
|
+
# SecureRandom library.
|
30
|
+
#
|
31
|
+
# == Example
|
32
|
+
#
|
33
|
+
# # random hexadecimal string.
|
34
|
+
# p SecureRandom.hex(10) #=> "52750b30ffbc7de3b362"
|
35
|
+
# p SecureRandom.hex(10) #=> "92b15d6c8dc4beb5f559"
|
36
|
+
# p SecureRandom.hex(11) #=> "6aca1b5c58e4863e6b81b8"
|
37
|
+
# p SecureRandom.hex(12) #=> "94b2fff3e7fd9b9c391a2306"
|
38
|
+
# p SecureRandom.hex(13) #=> "39b290146bea6ce975c37cfc23"
|
39
|
+
# ...
|
40
|
+
#
|
41
|
+
# # random base64 string.
|
42
|
+
# p SecureRandom.base64(10) #=> "EcmTPZwWRAozdA=="
|
43
|
+
# p SecureRandom.base64(10) #=> "9b0nsevdwNuM/w=="
|
44
|
+
# p SecureRandom.base64(10) #=> "KO1nIU+p9DKxGg=="
|
45
|
+
# p SecureRandom.base64(11) #=> "l7XEiFja+8EKEtY="
|
46
|
+
# p SecureRandom.base64(12) #=> "7kJSM/MzBJI+75j8"
|
47
|
+
# p SecureRandom.base64(13) #=> "vKLJ0tXBHqQOuIcSIg=="
|
48
|
+
# ...
|
49
|
+
#
|
50
|
+
# # random binary string.
|
51
|
+
# p SecureRandom.random_bytes(10) #=> "\016\t{\370g\310pbr\301"
|
52
|
+
# p SecureRandom.random_bytes(10) #=> "\323U\030TO\234\357\020\a\337"
|
53
|
+
# ...
|
54
|
+
module SecureRandom
|
55
|
+
# SecureRandom.random_bytes generates a random binary string.
|
56
|
+
#
|
57
|
+
# The argument n specifies the length of the result string.
|
58
|
+
#
|
59
|
+
# If n is not specified, 16 is assumed.
|
60
|
+
# It may be larger in future.
|
61
|
+
#
|
62
|
+
# If secure random number generator is not available,
|
63
|
+
# NotImplementedError is raised.
|
64
|
+
def self.random_bytes(n=nil)
|
65
|
+
n ||= 16
|
66
|
+
|
67
|
+
if defined? OpenSSL::Random
|
68
|
+
return OpenSSL::Random.random_bytes(n)
|
69
|
+
end
|
70
|
+
|
71
|
+
if !defined?(@has_urandom) || @has_urandom
|
72
|
+
flags = File::RDONLY
|
73
|
+
flags |= File::NONBLOCK if defined? File::NONBLOCK
|
74
|
+
flags |= File::NOCTTY if defined? File::NOCTTY
|
75
|
+
flags |= File::NOFOLLOW if defined? File::NOFOLLOW
|
76
|
+
begin
|
77
|
+
File.open("/dev/urandom", flags) {|f|
|
78
|
+
unless f.stat.chardev?
|
79
|
+
raise Errno::ENOENT
|
80
|
+
end
|
81
|
+
@has_urandom = true
|
82
|
+
ret = f.readpartial(n)
|
83
|
+
if ret.length != n
|
84
|
+
raise NotImplementedError, "Unexpected partial read from random device"
|
85
|
+
end
|
86
|
+
return ret
|
87
|
+
}
|
88
|
+
rescue Errno::ENOENT
|
89
|
+
@has_urandom = false
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
if !defined?(@has_win32)
|
94
|
+
begin
|
95
|
+
require 'Win32API'
|
96
|
+
|
97
|
+
crypt_acquire_context = Win32API.new("advapi32", "CryptAcquireContext", 'PPPII', 'L')
|
98
|
+
@crypt_gen_random = Win32API.new("advapi32", "CryptGenRandom", 'LIP', 'L')
|
99
|
+
|
100
|
+
hProvStr = " " * 4
|
101
|
+
prov_rsa_full = 1
|
102
|
+
crypt_verifycontext = 0xF0000000
|
103
|
+
|
104
|
+
if crypt_acquire_context.call(hProvStr, nil, nil, prov_rsa_full, crypt_verifycontext) == 0
|
105
|
+
raise SystemCallError, "CryptAcquireContext failed: #{lastWin32ErrorMessage}"
|
106
|
+
end
|
107
|
+
@hProv, = hProvStr.unpack('L')
|
108
|
+
|
109
|
+
@has_win32 = true
|
110
|
+
rescue LoadError
|
111
|
+
@has_win32 = false
|
112
|
+
end
|
113
|
+
end
|
114
|
+
if @has_win32
|
115
|
+
bytes = " " * n
|
116
|
+
if @crypt_gen_random.call(@hProv, bytes.size, bytes) == 0
|
117
|
+
raise SystemCallError, "CryptGenRandom failed: #{lastWin32ErrorMessage}"
|
118
|
+
end
|
119
|
+
return bytes
|
120
|
+
end
|
121
|
+
|
122
|
+
raise NotImplementedError, "No random device"
|
123
|
+
end
|
124
|
+
|
125
|
+
# SecureRandom.hex generates a random hex string.
|
126
|
+
#
|
127
|
+
# The argument n specifies the length of the random length.
|
128
|
+
# The length of the result string is twice of n.
|
129
|
+
#
|
130
|
+
# If n is not specified, 16 is assumed.
|
131
|
+
# It may be larger in future.
|
132
|
+
#
|
133
|
+
# If secure random number generator is not available,
|
134
|
+
# NotImplementedError is raised.
|
135
|
+
def self.hex(n=nil)
|
136
|
+
random_bytes(n).unpack("H*")[0]
|
137
|
+
end
|
138
|
+
|
139
|
+
# SecureRandom.base64 generates a random base64 string.
|
140
|
+
#
|
141
|
+
# The argument n specifies the length of the random length.
|
142
|
+
# The length of the result string is about 4/3 of n.
|
143
|
+
#
|
144
|
+
# If n is not specified, 16 is assumed.
|
145
|
+
# It may be larger in future.
|
146
|
+
#
|
147
|
+
# If secure random number generator is not available,
|
148
|
+
# NotImplementedError is raised.
|
149
|
+
def self.base64(n=nil)
|
150
|
+
[random_bytes(n)].pack("m*").delete("\n")
|
151
|
+
end
|
152
|
+
|
153
|
+
# SecureRandom.random_number generates a random number.
|
154
|
+
#
|
155
|
+
# If an positive integer is given as n,
|
156
|
+
# SecureRandom.random_number returns an integer:
|
157
|
+
# 0 <= SecureRandom.random_number(n) < n.
|
158
|
+
#
|
159
|
+
# If 0 is given or an argument is not given,
|
160
|
+
# SecureRandom.random_number returns an float:
|
161
|
+
# 0.0 <= SecureRandom.random_number() < 1.0.
|
162
|
+
def self.random_number(n=0)
|
163
|
+
if 0 < n
|
164
|
+
hex = n.to_s(16)
|
165
|
+
hex = '0' + hex if (hex.length & 1) == 1
|
166
|
+
bin = [hex].pack("H*")
|
167
|
+
mask = bin[0]
|
168
|
+
mask |= mask >> 1
|
169
|
+
mask |= mask >> 2
|
170
|
+
mask |= mask >> 4
|
171
|
+
begin
|
172
|
+
rnd = SecureRandom.random_bytes(bin.length)
|
173
|
+
rnd[0] = rnd[0] & mask
|
174
|
+
end until rnd < bin
|
175
|
+
rnd.unpack("H*")[0].hex
|
176
|
+
else
|
177
|
+
# assumption: Float::MANT_DIG <= 64
|
178
|
+
i64 = SecureRandom.random_bytes(8).unpack("Q")[0]
|
179
|
+
Math.ldexp(i64 >> (64-Float::MANT_DIG), -Float::MANT_DIG)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
# Following code is based on David Garamond's GUID library for Ruby.
|
184
|
+
def self.lastWin32ErrorMessage # :nodoc:
|
185
|
+
get_last_error = Win32API.new("kernel32", "GetLastError", '', 'L')
|
186
|
+
format_message = Win32API.new("kernel32", "FormatMessageA", 'LPLLPLPPPPPPPP', 'L')
|
187
|
+
format_message_ignore_inserts = 0x00000200
|
188
|
+
format_message_from_system = 0x00001000
|
189
|
+
|
190
|
+
code = get_last_error.call
|
191
|
+
msg = "\0" * 1024
|
192
|
+
len = format_message.call(format_message_ignore_inserts + format_message_from_system, 0, code, 0, msg, 1024, nil, nil, nil, nil, nil, nil, nil, nil)
|
193
|
+
msg[0, len].tr("\r", '').chomp
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
@@ -1,7 +1,17 @@
|
|
1
1
|
module ActiveSupport
|
2
|
+
# Wrapping a string in this class gives you a prettier way to test
|
3
|
+
# for equality. The value returned by <tt>Rails.env</tt> is wrapped
|
4
|
+
# in a StringInquirer object so instead of calling this:
|
5
|
+
#
|
6
|
+
# Rails.env == "production"
|
7
|
+
#
|
8
|
+
# you can call this:
|
9
|
+
#
|
10
|
+
# Rails.env.production?
|
11
|
+
#
|
2
12
|
class StringInquirer < String
|
3
13
|
def method_missing(method_name, *arguments)
|
4
|
-
if method_name.to_s
|
14
|
+
if method_name.to_s[-1,1] == "?"
|
5
15
|
self == method_name.to_s[0..-2]
|
6
16
|
else
|
7
17
|
super
|