activesupport 1.2.4 → 8.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +505 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +40 -0
- data/lib/active_support/actionable_error.rb +50 -0
- data/lib/active_support/all.rb +5 -0
- data/lib/active_support/array_inquirer.rb +50 -0
- data/lib/active_support/backtrace_cleaner.rb +234 -0
- data/lib/active_support/benchmark.rb +21 -0
- data/lib/active_support/benchmarkable.rb +53 -0
- data/lib/active_support/broadcast_logger.rb +238 -0
- data/lib/active_support/builder.rb +8 -0
- data/lib/active_support/cache/coder.rb +153 -0
- data/lib/active_support/cache/entry.rb +134 -0
- data/lib/active_support/cache/file_store.rb +244 -0
- data/lib/active_support/cache/mem_cache_store.rb +288 -0
- data/lib/active_support/cache/memory_store.rb +264 -0
- data/lib/active_support/cache/null_store.rb +62 -0
- data/lib/active_support/cache/redis_cache_store.rb +498 -0
- data/lib/active_support/cache/serializer_with_fallback.rb +152 -0
- data/lib/active_support/cache/strategy/local_cache.rb +246 -0
- data/lib/active_support/cache/strategy/local_cache_middleware.rb +45 -0
- data/lib/active_support/cache.rb +1170 -0
- data/lib/active_support/callbacks.rb +960 -0
- data/lib/active_support/class_attribute.rb +33 -0
- data/lib/active_support/code_generator.rb +79 -0
- data/lib/active_support/concern.rb +217 -0
- data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +18 -0
- data/lib/active_support/concurrency/null_lock.rb +13 -0
- data/lib/active_support/concurrency/share_lock.rb +225 -0
- data/lib/active_support/concurrency/thread_monitor.rb +55 -0
- data/lib/active_support/configurable.rb +193 -0
- data/lib/active_support/configuration_file.rb +60 -0
- data/lib/active_support/continuous_integration.rb +145 -0
- data/lib/active_support/core_ext/array/access.rb +100 -0
- data/lib/active_support/core_ext/array/conversions.rb +209 -26
- data/lib/active_support/core_ext/array/extract.rb +21 -0
- data/lib/active_support/core_ext/array/extract_options.rb +31 -0
- data/lib/active_support/core_ext/array/grouping.rb +109 -0
- data/lib/active_support/core_ext/array/inquiry.rb +19 -0
- data/lib/active_support/core_ext/array/wrap.rb +48 -0
- data/lib/active_support/core_ext/array.rb +8 -4
- data/lib/active_support/core_ext/benchmark.rb +6 -0
- data/lib/active_support/core_ext/big_decimal/conversions.rb +14 -0
- data/lib/active_support/core_ext/big_decimal.rb +3 -0
- data/lib/active_support/core_ext/class/attribute.rb +137 -0
- data/lib/active_support/core_ext/class/attribute_accessors.rb +6 -0
- data/lib/active_support/core_ext/class/subclasses.rb +24 -0
- data/lib/active_support/core_ext/class.rb +4 -0
- data/lib/active_support/core_ext/date/acts_like.rb +10 -0
- data/lib/active_support/core_ext/date/blank.rb +18 -0
- data/lib/active_support/core_ext/date/calculations.rb +161 -0
- data/lib/active_support/core_ext/date/conversions.rb +95 -28
- data/lib/active_support/core_ext/date/zones.rb +8 -0
- data/lib/active_support/core_ext/date.rb +6 -5
- data/lib/active_support/core_ext/date_and_time/calculations.rb +374 -0
- data/lib/active_support/core_ext/date_and_time/compatibility.rb +23 -0
- data/lib/active_support/core_ext/date_and_time/zones.rb +40 -0
- data/lib/active_support/core_ext/date_time/acts_like.rb +16 -0
- data/lib/active_support/core_ext/date_time/blank.rb +18 -0
- data/lib/active_support/core_ext/date_time/calculations.rb +215 -0
- data/lib/active_support/core_ext/date_time/compatibility.rb +16 -0
- data/lib/active_support/core_ext/date_time/conversions.rb +108 -0
- data/lib/active_support/core_ext/date_time.rb +7 -0
- data/lib/active_support/core_ext/digest/uuid.rb +76 -0
- data/lib/active_support/core_ext/digest.rb +3 -0
- data/lib/active_support/core_ext/enumerable.rb +277 -7
- data/lib/active_support/core_ext/erb/util.rb +201 -0
- data/lib/active_support/core_ext/file/atomic.rb +72 -0
- data/lib/active_support/core_ext/file.rb +3 -0
- data/lib/active_support/core_ext/hash/conversions.rb +262 -0
- data/lib/active_support/core_ext/hash/deep_merge.rb +43 -0
- data/lib/active_support/core_ext/hash/deep_transform_values.rb +46 -0
- data/lib/active_support/core_ext/hash/except.rb +12 -0
- data/lib/active_support/core_ext/hash/indifferent_access.rb +19 -55
- data/lib/active_support/core_ext/hash/keys.rb +134 -44
- data/lib/active_support/core_ext/hash/reverse_merge.rb +22 -22
- data/lib/active_support/core_ext/hash/slice.rb +27 -0
- data/lib/active_support/core_ext/hash.rb +9 -8
- data/lib/active_support/core_ext/integer/inflections.rb +29 -13
- data/lib/active_support/core_ext/integer/multiple.rb +12 -0
- data/lib/active_support/core_ext/integer/time.rb +22 -0
- data/lib/active_support/core_ext/integer.rb +4 -6
- data/lib/active_support/core_ext/kernel/concern.rb +14 -0
- data/lib/active_support/core_ext/kernel/reporting.rb +45 -0
- data/lib/active_support/core_ext/kernel/singleton_class.rb +8 -0
- data/lib/active_support/core_ext/kernel.rb +4 -78
- data/lib/active_support/core_ext/load_error.rb +6 -35
- data/lib/active_support/core_ext/module/aliasing.rb +31 -0
- data/lib/active_support/core_ext/module/anonymous.rb +30 -0
- data/lib/active_support/core_ext/module/attr_internal.rb +48 -0
- data/lib/active_support/core_ext/module/attribute_accessors.rb +214 -0
- data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +175 -0
- data/lib/active_support/core_ext/module/concerning.rb +140 -0
- data/lib/active_support/core_ext/module/delegation.rb +225 -0
- data/lib/active_support/core_ext/module/deprecation.rb +25 -0
- data/lib/active_support/core_ext/module/introspection.rb +65 -0
- data/lib/active_support/core_ext/module/redefine_method.rb +40 -0
- data/lib/active_support/core_ext/module/remove_method.rb +17 -0
- data/lib/active_support/core_ext/module.rb +13 -0
- data/lib/active_support/core_ext/name_error.rb +59 -0
- data/lib/active_support/core_ext/numeric/bytes.rb +73 -42
- data/lib/active_support/core_ext/numeric/conversions.rb +145 -0
- data/lib/active_support/core_ext/numeric/time.rb +64 -57
- data/lib/active_support/core_ext/numeric.rb +4 -6
- data/lib/active_support/core_ext/object/acts_like.rb +45 -0
- data/lib/active_support/core_ext/object/blank.rb +199 -0
- data/lib/active_support/core_ext/object/conversions.rb +6 -0
- data/lib/active_support/core_ext/object/deep_dup.rb +71 -0
- data/lib/active_support/core_ext/object/duplicable.rb +69 -0
- data/lib/active_support/core_ext/object/inclusion.rb +37 -0
- data/lib/active_support/core_ext/object/instance_variables.rb +32 -0
- data/lib/active_support/core_ext/object/json.rb +267 -0
- data/lib/active_support/core_ext/object/to_param.rb +3 -0
- data/lib/active_support/core_ext/object/to_query.rb +93 -0
- data/lib/active_support/core_ext/object/try.rb +158 -0
- data/lib/active_support/core_ext/object/with.rb +46 -0
- data/lib/active_support/core_ext/object/with_options.rb +101 -0
- data/lib/active_support/core_ext/object.rb +17 -0
- data/lib/active_support/core_ext/pathname/blank.rb +20 -0
- data/lib/active_support/core_ext/pathname/existence.rb +23 -0
- data/lib/active_support/core_ext/pathname.rb +4 -0
- data/lib/active_support/core_ext/range/compare_range.rb +57 -0
- data/lib/active_support/core_ext/range/conversions.rb +58 -17
- data/lib/active_support/core_ext/range/overlap.rb +40 -0
- data/lib/active_support/core_ext/range/sole.rb +17 -0
- data/lib/active_support/core_ext/range.rb +5 -4
- data/lib/active_support/core_ext/regexp.rb +14 -0
- data/lib/active_support/core_ext/securerandom.rb +57 -0
- data/lib/active_support/core_ext/string/access.rb +93 -56
- data/lib/active_support/core_ext/string/behavior.rb +8 -0
- data/lib/active_support/core_ext/string/conversions.rb +57 -16
- data/lib/active_support/core_ext/string/exclude.rb +13 -0
- data/lib/active_support/core_ext/string/filters.rb +151 -0
- data/lib/active_support/core_ext/string/indent.rb +45 -0
- data/lib/active_support/core_ext/string/inflections.rb +297 -54
- data/lib/active_support/core_ext/string/inquiry.rb +16 -0
- data/lib/active_support/core_ext/string/multibyte.rb +67 -0
- data/lib/active_support/core_ext/string/output_safety.rb +235 -0
- data/lib/active_support/core_ext/string/starts_ends_with.rb +4 -18
- data/lib/active_support/core_ext/string/strip.rb +27 -0
- data/lib/active_support/core_ext/string/zones.rb +16 -0
- data/lib/active_support/core_ext/string.rb +14 -10
- data/lib/active_support/core_ext/symbol/starts_ends_with.rb +6 -0
- data/lib/active_support/core_ext/symbol.rb +3 -0
- data/lib/active_support/core_ext/thread/backtrace/location.rb +7 -0
- data/lib/active_support/core_ext/time/acts_like.rb +10 -0
- data/lib/active_support/core_ext/time/calculations.rb +358 -153
- data/lib/active_support/core_ext/time/compatibility.rb +15 -0
- data/lib/active_support/core_ext/time/conversions.rb +69 -30
- data/lib/active_support/core_ext/time/zones.rb +97 -0
- data/lib/active_support/core_ext/time.rb +6 -6
- data/lib/active_support/core_ext.rb +5 -1
- data/lib/active_support/current_attributes/test_helper.rb +13 -0
- data/lib/active_support/current_attributes.rb +243 -0
- data/lib/active_support/deep_mergeable.rb +53 -0
- data/lib/active_support/delegation.rb +183 -0
- data/lib/active_support/dependencies/autoload.rb +72 -0
- data/lib/active_support/dependencies/interlock.rb +55 -0
- data/lib/active_support/dependencies/require_dependency.rb +28 -0
- data/lib/active_support/dependencies.rb +84 -222
- data/lib/active_support/deprecation/behaviors.rb +148 -0
- data/lib/active_support/deprecation/constant_accessor.rb +74 -0
- data/lib/active_support/deprecation/deprecators.rb +104 -0
- data/lib/active_support/deprecation/disallowed.rb +54 -0
- data/lib/active_support/deprecation/method_wrappers.rb +68 -0
- data/lib/active_support/deprecation/proxy_wrappers.rb +189 -0
- data/lib/active_support/deprecation/reporting.rb +162 -0
- data/lib/active_support/deprecation.rb +81 -0
- data/lib/active_support/deprecator.rb +7 -0
- data/lib/active_support/descendants_tracker.rb +112 -0
- data/lib/active_support/digest.rb +22 -0
- data/lib/active_support/duration/iso8601_parser.rb +123 -0
- data/lib/active_support/duration/iso8601_serializer.rb +64 -0
- data/lib/active_support/duration.rb +524 -0
- data/lib/active_support/editor.rb +70 -0
- data/lib/active_support/encrypted_configuration.rb +126 -0
- data/lib/active_support/encrypted_file.rb +133 -0
- data/lib/active_support/environment_inquirer.rb +40 -0
- data/lib/active_support/error_reporter/test_helper.rb +15 -0
- data/lib/active_support/error_reporter.rb +318 -0
- data/lib/active_support/event_reporter/test_helper.rb +32 -0
- data/lib/active_support/event_reporter.rb +592 -0
- data/lib/active_support/evented_file_update_checker.rb +185 -0
- data/lib/active_support/execution_context/test_helper.rb +13 -0
- data/lib/active_support/execution_context.rb +110 -0
- data/lib/active_support/execution_wrapper.rb +150 -0
- data/lib/active_support/executor/test_helper.rb +7 -0
- data/lib/active_support/executor.rb +8 -0
- data/lib/active_support/file_update_checker.rb +166 -0
- data/lib/active_support/fork_tracker.rb +43 -0
- data/lib/active_support/gem_version.rb +17 -0
- data/lib/active_support/gzip.rb +41 -0
- data/lib/active_support/hash_with_indifferent_access.rb +464 -0
- data/lib/active_support/html_safe_translation.rb +56 -0
- data/lib/active_support/i18n.rb +17 -0
- data/lib/active_support/i18n_railtie.rb +140 -0
- data/lib/active_support/inflections.rb +68 -49
- data/lib/active_support/inflector/inflections.rb +290 -0
- data/lib/active_support/inflector/methods.rb +387 -0
- data/lib/active_support/inflector/transliterate.rb +147 -0
- data/lib/active_support/inflector.rb +7 -164
- data/lib/active_support/isolated_execution_state.rb +76 -0
- data/lib/active_support/json/decoding.rb +78 -0
- data/lib/active_support/json/encoding.rb +256 -0
- data/lib/active_support/json.rb +4 -0
- data/lib/active_support/key_generator.rb +66 -0
- data/lib/active_support/lazy_load_hooks.rb +107 -0
- data/lib/active_support/locale/en.rb +33 -0
- data/lib/active_support/locale/en.yml +141 -0
- data/lib/active_support/log_subscriber/test_helper.rb +106 -0
- data/lib/active_support/log_subscriber.rb +188 -0
- data/lib/active_support/logger.rb +55 -0
- data/lib/active_support/logger_silence.rb +21 -0
- data/lib/active_support/logger_thread_safe_level.rb +50 -0
- data/lib/active_support/message_encryptor.rb +374 -0
- data/lib/active_support/message_encryptors.rb +193 -0
- data/lib/active_support/message_pack/cache_serializer.rb +23 -0
- data/lib/active_support/message_pack/extensions.rb +310 -0
- data/lib/active_support/message_pack/serializer.rb +63 -0
- data/lib/active_support/message_pack.rb +50 -0
- data/lib/active_support/message_verifier.rb +377 -0
- data/lib/active_support/message_verifiers.rb +189 -0
- data/lib/active_support/messages/codec.rb +65 -0
- data/lib/active_support/messages/metadata.rb +146 -0
- data/lib/active_support/messages/rotation_configuration.rb +23 -0
- data/lib/active_support/messages/rotation_coordinator.rb +102 -0
- data/lib/active_support/messages/rotator.rb +69 -0
- data/lib/active_support/messages/serializer_with_fallback.rb +158 -0
- data/lib/active_support/multibyte/chars.rb +188 -0
- data/lib/active_support/multibyte/unicode.rb +42 -0
- data/lib/active_support/multibyte.rb +27 -0
- data/lib/active_support/notifications/fanout.rb +467 -0
- data/lib/active_support/notifications/instrumenter.rb +240 -0
- data/lib/active_support/notifications.rb +281 -0
- data/lib/active_support/number_helper/number_converter.rb +190 -0
- data/lib/active_support/number_helper/number_to_currency_converter.rb +46 -0
- data/lib/active_support/number_helper/number_to_delimited_converter.rb +30 -0
- data/lib/active_support/number_helper/number_to_human_converter.rb +69 -0
- data/lib/active_support/number_helper/number_to_human_size_converter.rb +60 -0
- data/lib/active_support/number_helper/number_to_percentage_converter.rb +16 -0
- data/lib/active_support/number_helper/number_to_phone_converter.rb +60 -0
- data/lib/active_support/number_helper/number_to_rounded_converter.rb +59 -0
- data/lib/active_support/number_helper/rounding_helper.rb +46 -0
- data/lib/active_support/number_helper.rb +479 -0
- data/lib/active_support/option_merger.rb +38 -0
- data/lib/active_support/ordered_hash.rb +50 -0
- data/lib/active_support/ordered_options.rb +141 -25
- data/lib/active_support/parameter_filter.rb +157 -0
- data/lib/active_support/rails.rb +26 -0
- data/lib/active_support/railtie.rb +180 -0
- data/lib/active_support/reloader.rb +138 -0
- data/lib/active_support/rescuable.rb +176 -0
- data/lib/active_support/secure_compare_rotator.rb +58 -0
- data/lib/active_support/security_utils.rb +38 -0
- data/lib/active_support/string_inquirer.rb +35 -0
- data/lib/active_support/structured_event_subscriber.rb +99 -0
- data/lib/active_support/subscriber.rb +141 -0
- data/lib/active_support/syntax_error_proxy.rb +67 -0
- data/lib/active_support/tagged_logging.rb +157 -0
- data/lib/active_support/test_case.rb +365 -0
- data/lib/active_support/testing/assertions.rb +369 -0
- data/lib/active_support/testing/autorun.rb +10 -0
- data/lib/active_support/testing/constant_lookup.rb +51 -0
- data/lib/active_support/testing/constant_stubbing.rb +54 -0
- data/lib/active_support/testing/declarative.rb +28 -0
- data/lib/active_support/testing/deprecation.rb +82 -0
- data/lib/active_support/testing/error_reporter_assertions.rb +124 -0
- data/lib/active_support/testing/event_reporter_assertions.rb +227 -0
- data/lib/active_support/testing/file_fixtures.rb +38 -0
- data/lib/active_support/testing/isolation.rb +121 -0
- data/lib/active_support/testing/method_call_assertions.rb +69 -0
- data/lib/active_support/testing/notification_assertions.rb +92 -0
- data/lib/active_support/testing/parallelization/server.rb +98 -0
- data/lib/active_support/testing/parallelization/worker.rb +107 -0
- data/lib/active_support/testing/parallelization.rb +79 -0
- data/lib/active_support/testing/parallelize_executor.rb +81 -0
- data/lib/active_support/testing/setup_and_teardown.rb +57 -0
- data/lib/active_support/testing/stream.rb +41 -0
- data/lib/active_support/testing/tagged_logging.rb +27 -0
- data/lib/active_support/testing/tests_without_assertions.rb +19 -0
- data/lib/active_support/testing/time_helpers.rb +273 -0
- data/lib/active_support/time.rb +20 -0
- data/lib/active_support/time_with_zone.rb +613 -0
- data/lib/active_support/values/time_zone.rb +599 -158
- data/lib/active_support/version.rb +7 -6
- data/lib/active_support/xml_mini/jdom.rb +175 -0
- data/lib/active_support/xml_mini/libxml.rb +80 -0
- data/lib/active_support/xml_mini/libxmlsax.rb +83 -0
- data/lib/active_support/xml_mini/nokogiri.rb +83 -0
- data/lib/active_support/xml_mini/nokogirisax.rb +86 -0
- data/lib/active_support/xml_mini/rexml.rb +137 -0
- data/lib/active_support/xml_mini.rb +212 -0
- data/lib/active_support.rb +122 -10
- metadata +524 -93
- data/CHANGELOG +0 -283
- data/lib/active_support/binding_of_caller.rb +0 -84
- data/lib/active_support/breakpoint.rb +0 -523
- data/lib/active_support/class_attribute_accessors.rb +0 -57
- data/lib/active_support/class_inheritable_attributes.rb +0 -117
- data/lib/active_support/clean_logger.rb +0 -36
- data/lib/active_support/core_ext/blank.rb +0 -38
- data/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +0 -14
- data/lib/active_support/core_ext/cgi.rb +0 -5
- data/lib/active_support/core_ext/exception.rb +0 -29
- data/lib/active_support/core_ext/integer/even_odd.rb +0 -24
- data/lib/active_support/core_ext/object_and_class.rb +0 -44
- data/lib/active_support/module_attribute_accessors.rb +0 -57
- data/lib/active_support/whiny_nil.rb +0 -38
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
require 'logger'
|
|
2
|
-
require File.dirname(__FILE__) + '/class_attribute_accessors'
|
|
3
|
-
|
|
4
|
-
class Logger #:nodoc:
|
|
5
|
-
cattr_accessor :silencer
|
|
6
|
-
self.silencer = true
|
|
7
|
-
|
|
8
|
-
# Silences the logger for the duration of the block.
|
|
9
|
-
def silence(temporary_level = Logger::ERROR)
|
|
10
|
-
if silencer
|
|
11
|
-
begin
|
|
12
|
-
old_logger_level, self.level = level, temporary_level
|
|
13
|
-
yield self
|
|
14
|
-
ensure
|
|
15
|
-
self.level = old_logger_level
|
|
16
|
-
end
|
|
17
|
-
else
|
|
18
|
-
yield self
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
private
|
|
23
|
-
# Ruby 1.8.3 transposed the msg and progname arguments to format_message.
|
|
24
|
-
# We can't test RUBY_VERSION because some distributions don't keep Ruby
|
|
25
|
-
# and its standard library in sync, leading to installations of Ruby 1.8.2
|
|
26
|
-
# with Logger from 1.8.3 and vice versa.
|
|
27
|
-
if method_defined?(:formatter=)
|
|
28
|
-
def format_message(severity, timestamp, progname, msg)
|
|
29
|
-
"#{msg}\n"
|
|
30
|
-
end
|
|
31
|
-
else
|
|
32
|
-
def format_message(severity, timestamp, msg, progname)
|
|
33
|
-
"#{msg}\n"
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# The methods here are provided to speed up function blank? in class Object
|
|
2
|
-
class NilClass #:nodoc:
|
|
3
|
-
def blank?
|
|
4
|
-
true
|
|
5
|
-
end
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
class FalseClass #:nodoc:
|
|
9
|
-
def blank?
|
|
10
|
-
true
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
class TrueClass #:nodoc:
|
|
15
|
-
def blank?
|
|
16
|
-
false
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
class Array #:nodoc:
|
|
21
|
-
alias_method :blank?, :empty?
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
class Hash #:nodoc:
|
|
25
|
-
alias_method :blank?, :empty?
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
class String #:nodoc:
|
|
29
|
-
def blank?
|
|
30
|
-
empty? || strip.empty?
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
class Numeric #:nodoc:
|
|
35
|
-
def blank?
|
|
36
|
-
false
|
|
37
|
-
end
|
|
38
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
module ActiveSupport #:nodoc:
|
|
2
|
-
module CoreExtensions #:nodoc:
|
|
3
|
-
module CGI #:nodoc:
|
|
4
|
-
module EscapeSkippingSlashes #:nodoc:
|
|
5
|
-
def escape_skipping_slashes(str)
|
|
6
|
-
str = str.join('/') if str.respond_to? :join
|
|
7
|
-
str.gsub(/([^ \/a-zA-Z0-9_.-])/n) do
|
|
8
|
-
"%#{$1.unpack('H2').first.upcase}"
|
|
9
|
-
end.tr(' ', '+')
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
class Exception
|
|
2
|
-
|
|
3
|
-
alias :clean_message :message
|
|
4
|
-
|
|
5
|
-
TraceSubstitutions = []
|
|
6
|
-
FrameworkRegexp = /generated_code|vendor|dispatch|ruby|script\/\w+/
|
|
7
|
-
|
|
8
|
-
def clean_backtrace
|
|
9
|
-
backtrace.collect do |line|
|
|
10
|
-
TraceSubstitutions.inject(line) do |line, (regexp, sub)|
|
|
11
|
-
line.gsub regexp, sub
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def application_backtrace
|
|
17
|
-
before_application_frame = true
|
|
18
|
-
|
|
19
|
-
clean_backtrace.reject do |line|
|
|
20
|
-
non_app_frame = !! (line =~ FrameworkRegexp)
|
|
21
|
-
before_application_frame = false unless non_app_frame
|
|
22
|
-
non_app_frame && ! before_application_frame
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def framework_backtrace
|
|
27
|
-
clean_backtrace.select {|line| line =~ FrameworkRegexp}
|
|
28
|
-
end
|
|
29
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
module ActiveSupport #:nodoc:
|
|
2
|
-
module CoreExtensions #:nodoc:
|
|
3
|
-
module Integer #:nodoc:
|
|
4
|
-
# For checking if a fixnum is even or odd.
|
|
5
|
-
# * 1.even? # => false
|
|
6
|
-
# * 1.odd? # => true
|
|
7
|
-
# * 2.even? # => true
|
|
8
|
-
# * 2.odd? # => false
|
|
9
|
-
module EvenOdd
|
|
10
|
-
def multiple_of?(number)
|
|
11
|
-
self % number == 0
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def even?
|
|
15
|
-
multiple_of? 2
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def odd?
|
|
19
|
-
!even?
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
class Object #:nodoc:
|
|
2
|
-
def remove_subclasses_of(*superclasses)
|
|
3
|
-
subclasses_of(*superclasses).each do |subclass|
|
|
4
|
-
Object.send(:remove_const, subclass.to_s) rescue nil
|
|
5
|
-
end
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def subclasses_of(*superclasses)
|
|
9
|
-
subclasses = []
|
|
10
|
-
ObjectSpace.each_object(Class) do |k|
|
|
11
|
-
next if (k.ancestors & superclasses).empty? || superclasses.include?(k) || k.to_s.include?("::") || subclasses.include?(k)
|
|
12
|
-
subclasses << k
|
|
13
|
-
end
|
|
14
|
-
subclasses
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# "", " ", nil, [], and {} are blank
|
|
18
|
-
def blank?
|
|
19
|
-
if respond_to?(:empty?) && respond_to?(:strip)
|
|
20
|
-
empty? or strip.empty?
|
|
21
|
-
elsif respond_to?(:empty?)
|
|
22
|
-
empty?
|
|
23
|
-
else
|
|
24
|
-
!self
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def suppress(*exception_classes)
|
|
29
|
-
begin yield
|
|
30
|
-
rescue Exception => e
|
|
31
|
-
raise unless exception_classes.any? {|cls| e.kind_of? cls}
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
class Class #:nodoc:
|
|
37
|
-
def remove_subclasses
|
|
38
|
-
Object.remove_subclasses_of(self)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def subclasses
|
|
42
|
-
Object.subclasses_of(self).map { |o| o.to_s }
|
|
43
|
-
end
|
|
44
|
-
end
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# Extends the module object with module and instance accessors for class attributes,
|
|
2
|
-
# just like the native attr* accessors for instance attributes.
|
|
3
|
-
class Module # :nodoc:
|
|
4
|
-
def mattr_reader(*syms)
|
|
5
|
-
syms.each do |sym|
|
|
6
|
-
class_eval <<-EOS
|
|
7
|
-
if ! defined? @@#{sym.id2name}
|
|
8
|
-
@@#{sym.id2name} = nil
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def self.#{sym.id2name}
|
|
12
|
-
@@#{sym}
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def #{sym.id2name}
|
|
16
|
-
@@#{sym}
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def call_#{sym.id2name}
|
|
20
|
-
case @@#{sym.id2name}
|
|
21
|
-
when Symbol then send(@@#{sym})
|
|
22
|
-
when Proc then @@#{sym}.call(self)
|
|
23
|
-
when String then @@#{sym}
|
|
24
|
-
else nil
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
EOS
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def mattr_writer(*syms)
|
|
32
|
-
syms.each do |sym|
|
|
33
|
-
class_eval <<-EOS
|
|
34
|
-
if ! defined? @@#{sym.id2name}
|
|
35
|
-
@@#{sym.id2name} = nil
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def self.#{sym.id2name}=(obj)
|
|
39
|
-
@@#{sym.id2name} = obj
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def self.set_#{sym.id2name}(obj)
|
|
43
|
-
@@#{sym.id2name} = obj
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def #{sym.id2name}=(obj)
|
|
47
|
-
@@#{sym} = obj
|
|
48
|
-
end
|
|
49
|
-
EOS
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def mattr_accessor(*syms)
|
|
54
|
-
mattr_reader(*syms)
|
|
55
|
-
mattr_writer(*syms)
|
|
56
|
-
end
|
|
57
|
-
end
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# Extensions to nil which allow for more helpful error messages for
|
|
2
|
-
# people who are new to rails.
|
|
3
|
-
#
|
|
4
|
-
# The aim is to ensure that when users pass nil to methods where that isn't
|
|
5
|
-
# appropriate, instead of NoMethodError and the name of some method used
|
|
6
|
-
# by the framework users will see a message explaining what type of object
|
|
7
|
-
# was expected.
|
|
8
|
-
|
|
9
|
-
class NilClass
|
|
10
|
-
WHINERS = [ ::ActiveRecord::Base, ::Array ]
|
|
11
|
-
|
|
12
|
-
@@method_class_map = Hash.new
|
|
13
|
-
|
|
14
|
-
WHINERS.each do |klass|
|
|
15
|
-
methods = klass.public_instance_methods - public_instance_methods
|
|
16
|
-
methods.each do |method|
|
|
17
|
-
@@method_class_map[method.to_sym] = klass
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def id
|
|
22
|
-
raise RuntimeError, "Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id", caller
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
private
|
|
26
|
-
def method_missing(method, *args, &block)
|
|
27
|
-
raise_nil_warning_for @@method_class_map[method], method, caller
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def raise_nil_warning_for(klass = nil, selector = nil, with_caller = nil)
|
|
31
|
-
message = "You have a nil object when you didn't expect it!"
|
|
32
|
-
message << "\nYou might have expected an instance of #{klass}." if klass
|
|
33
|
-
message << "\nThe error occured while evaluating nil.#{selector}" if selector
|
|
34
|
-
|
|
35
|
-
raise NoMethodError, message, with_caller || caller
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|