activesupport 4.0.13 → 5.2.5
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.
- checksums.yaml +5 -5
- data/CHANGELOG.md +412 -444
- data/MIT-LICENSE +2 -2
- data/README.rdoc +8 -4
- data/lib/active_support/all.rb +5 -3
- data/lib/active_support/array_inquirer.rb +48 -0
- data/lib/active_support/backtrace_cleaner.rb +14 -12
- data/lib/active_support/benchmarkable.rb +6 -14
- data/lib/active_support/builder.rb +3 -1
- data/lib/active_support/cache/file_store.rb +67 -51
- data/lib/active_support/cache/mem_cache_store.rb +95 -97
- data/lib/active_support/cache/memory_store.rb +28 -30
- data/lib/active_support/cache/null_store.rb +7 -8
- data/lib/active_support/cache/redis_cache_store.rb +466 -0
- data/lib/active_support/cache/strategy/local_cache.rb +70 -56
- data/lib/active_support/cache/strategy/local_cache_middleware.rb +45 -0
- data/lib/active_support/cache.rb +331 -206
- data/lib/active_support/callbacks.rb +697 -426
- data/lib/active_support/concern.rb +32 -10
- data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +17 -0
- data/lib/active_support/concurrency/share_lock.rb +227 -0
- data/lib/active_support/configurable.rb +8 -5
- data/lib/active_support/core_ext/array/access.rb +39 -1
- data/lib/active_support/core_ext/array/conversions.rb +24 -35
- data/lib/active_support/core_ext/array/extract_options.rb +2 -0
- data/lib/active_support/core_ext/array/grouping.rb +23 -13
- data/lib/active_support/core_ext/array/inquiry.rb +19 -0
- data/lib/active_support/core_ext/array/prepend_and_append.rb +7 -5
- data/lib/active_support/core_ext/array/wrap.rb +7 -4
- data/lib/active_support/core_ext/array.rb +9 -7
- data/lib/active_support/core_ext/benchmark.rb +3 -1
- data/lib/active_support/core_ext/big_decimal/conversions.rb +9 -26
- data/lib/active_support/core_ext/big_decimal.rb +3 -1
- data/lib/active_support/core_ext/class/attribute.rb +41 -23
- data/lib/active_support/core_ext/class/attribute_accessors.rb +5 -169
- data/lib/active_support/core_ext/class/subclasses.rb +20 -8
- data/lib/active_support/core_ext/class.rb +4 -4
- data/lib/active_support/core_ext/date/acts_like.rb +3 -1
- data/lib/active_support/core_ext/date/blank.rb +14 -0
- data/lib/active_support/core_ext/date/calculations.rb +21 -9
- data/lib/active_support/core_ext/date/conversions.rb +32 -22
- data/lib/active_support/core_ext/date/zones.rb +5 -34
- data/lib/active_support/core_ext/date.rb +6 -4
- data/lib/active_support/core_ext/date_and_time/calculations.rb +199 -57
- data/lib/active_support/core_ext/date_and_time/compatibility.rb +16 -0
- data/lib/active_support/core_ext/date_and_time/zones.rb +41 -0
- data/lib/active_support/core_ext/date_time/acts_like.rb +4 -2
- data/lib/active_support/core_ext/date_time/blank.rb +14 -0
- data/lib/active_support/core_ext/date_time/calculations.rb +78 -37
- data/lib/active_support/core_ext/date_time/compatibility.rb +18 -0
- data/lib/active_support/core_ext/date_time/conversions.rb +19 -13
- data/lib/active_support/core_ext/date_time.rb +7 -4
- data/lib/active_support/core_ext/digest/uuid.rb +53 -0
- data/lib/active_support/core_ext/digest.rb +3 -0
- data/lib/active_support/core_ext/enumerable.rb +113 -29
- data/lib/active_support/core_ext/file/atomic.rb +38 -31
- data/lib/active_support/core_ext/file.rb +3 -1
- data/lib/active_support/core_ext/hash/compact.rb +29 -0
- data/lib/active_support/core_ext/hash/conversions.rb +71 -49
- data/lib/active_support/core_ext/hash/deep_merge.rb +9 -13
- data/lib/active_support/core_ext/hash/except.rb +12 -3
- data/lib/active_support/core_ext/hash/indifferent_access.rb +5 -3
- data/lib/active_support/core_ext/hash/keys.rb +50 -38
- data/lib/active_support/core_ext/hash/reverse_merge.rb +5 -2
- data/lib/active_support/core_ext/hash/slice.rb +12 -6
- data/lib/active_support/core_ext/hash/transform_values.rb +32 -0
- data/lib/active_support/core_ext/hash.rb +11 -8
- data/lib/active_support/core_ext/integer/inflections.rb +3 -1
- data/lib/active_support/core_ext/integer/multiple.rb +2 -0
- data/lib/active_support/core_ext/integer/time.rb +11 -33
- data/lib/active_support/core_ext/integer.rb +5 -3
- data/lib/active_support/core_ext/kernel/agnostics.rb +2 -0
- data/lib/active_support/core_ext/kernel/concern.rb +14 -0
- data/lib/active_support/core_ext/kernel/reporting.rb +5 -74
- data/lib/active_support/core_ext/kernel/singleton_class.rb +2 -0
- data/lib/active_support/core_ext/kernel.rb +6 -4
- data/lib/active_support/core_ext/load_error.rb +5 -21
- data/lib/active_support/core_ext/marshal.rb +13 -10
- data/lib/active_support/core_ext/module/aliasing.rb +6 -44
- data/lib/active_support/core_ext/module/anonymous.rb +12 -1
- data/lib/active_support/core_ext/module/attr_internal.rb +8 -8
- data/lib/active_support/core_ext/module/attribute_accessors.rb +170 -21
- data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +150 -0
- data/lib/active_support/core_ext/module/concerning.rb +134 -0
- data/lib/active_support/core_ext/module/delegation.rb +135 -45
- data/lib/active_support/core_ext/module/deprecation.rb +3 -3
- data/lib/active_support/core_ext/module/introspection.rb +9 -25
- data/lib/active_support/core_ext/module/reachable.rb +5 -2
- data/lib/active_support/core_ext/module/redefine_method.rb +49 -0
- data/lib/active_support/core_ext/module/remove_method.rb +8 -3
- data/lib/active_support/core_ext/module.rb +14 -10
- data/lib/active_support/core_ext/name_error.rb +22 -2
- data/lib/active_support/core_ext/numeric/bytes.rb +22 -0
- data/lib/active_support/core_ext/numeric/conversions.rb +79 -74
- data/lib/active_support/core_ext/numeric/inquiry.rb +28 -0
- data/lib/active_support/core_ext/numeric/time.rb +37 -50
- data/lib/active_support/core_ext/numeric.rb +6 -3
- data/lib/active_support/core_ext/object/acts_like.rb +12 -1
- data/lib/active_support/core_ext/object/blank.rb +70 -19
- data/lib/active_support/core_ext/object/conversions.rb +6 -4
- data/lib/active_support/core_ext/object/deep_dup.rb +19 -10
- data/lib/active_support/core_ext/object/duplicable.rb +100 -34
- data/lib/active_support/core_ext/object/inclusion.rb +18 -15
- data/lib/active_support/core_ext/object/instance_variables.rb +3 -1
- data/lib/active_support/core_ext/object/json.rb +227 -0
- data/lib/active_support/core_ext/object/to_param.rb +3 -1
- data/lib/active_support/core_ext/object/to_query.rb +21 -8
- data/lib/active_support/core_ext/object/try.rb +94 -24
- data/lib/active_support/core_ext/object/with_options.rb +45 -5
- data/lib/active_support/core_ext/object.rb +14 -12
- data/lib/active_support/core_ext/range/compare_range.rb +61 -0
- data/lib/active_support/core_ext/range/conversions.rb +27 -7
- data/lib/active_support/core_ext/range/each.rb +19 -17
- data/lib/active_support/core_ext/range/include_range.rb +2 -22
- data/lib/active_support/core_ext/range/include_time_with_zone.rb +23 -0
- data/lib/active_support/core_ext/range/overlaps.rb +2 -0
- data/lib/active_support/core_ext/range.rb +7 -4
- data/lib/active_support/core_ext/regexp.rb +6 -0
- data/lib/active_support/core_ext/securerandom.rb +25 -0
- data/lib/active_support/core_ext/string/access.rb +41 -39
- data/lib/active_support/core_ext/string/behavior.rb +3 -1
- data/lib/active_support/core_ext/string/conversions.rb +17 -13
- data/lib/active_support/core_ext/string/exclude.rb +5 -3
- data/lib/active_support/core_ext/string/filters.rb +55 -6
- data/lib/active_support/core_ext/string/indent.rb +6 -4
- data/lib/active_support/core_ext/string/inflections.rb +66 -24
- data/lib/active_support/core_ext/string/inquiry.rb +3 -1
- data/lib/active_support/core_ext/string/multibyte.rb +15 -7
- data/lib/active_support/core_ext/string/output_safety.rb +114 -54
- data/lib/active_support/core_ext/string/starts_ends_with.rb +2 -0
- data/lib/active_support/core_ext/string/strip.rb +4 -5
- data/lib/active_support/core_ext/string/zones.rb +4 -1
- data/lib/active_support/core_ext/string.rb +15 -13
- data/lib/active_support/core_ext/time/acts_like.rb +3 -1
- data/lib/active_support/core_ext/time/calculations.rb +123 -110
- data/lib/active_support/core_ext/time/compatibility.rb +16 -0
- data/lib/active_support/core_ext/time/conversions.rb +23 -14
- data/lib/active_support/core_ext/time/zones.rb +42 -26
- data/lib/active_support/core_ext/time.rb +7 -5
- data/lib/active_support/core_ext/uri.rb +6 -8
- data/lib/active_support/core_ext.rb +3 -2
- data/lib/active_support/current_attributes.rb +195 -0
- data/lib/active_support/dependencies/autoload.rb +3 -1
- data/lib/active_support/dependencies/interlock.rb +57 -0
- data/lib/active_support/dependencies.rb +196 -166
- data/lib/active_support/deprecation/behaviors.rb +48 -15
- data/lib/active_support/deprecation/constant_accessor.rb +52 -0
- data/lib/active_support/deprecation/instance_delegator.rb +17 -2
- data/lib/active_support/deprecation/method_wrappers.rb +66 -20
- data/lib/active_support/deprecation/proxy_wrappers.rb +56 -28
- data/lib/active_support/deprecation/reporting.rb +32 -12
- data/lib/active_support/deprecation.rb +14 -11
- data/lib/active_support/descendants_tracker.rb +2 -0
- data/lib/active_support/digest.rb +20 -0
- data/lib/active_support/duration/iso8601_parser.rb +125 -0
- data/lib/active_support/duration/iso8601_serializer.rb +55 -0
- data/lib/active_support/duration.rb +354 -34
- data/lib/active_support/encrypted_configuration.rb +49 -0
- data/lib/active_support/encrypted_file.rb +99 -0
- data/lib/active_support/evented_file_update_checker.rb +205 -0
- data/lib/active_support/execution_wrapper.rb +128 -0
- data/lib/active_support/executor.rb +8 -0
- data/lib/active_support/file_update_checker.rb +63 -37
- data/lib/active_support/gem_version.rb +17 -0
- data/lib/active_support/gzip.rb +7 -5
- data/lib/active_support/hash_with_indifferent_access.rb +158 -35
- data/lib/active_support/i18n.rb +8 -6
- data/lib/active_support/i18n_railtie.rb +38 -20
- data/lib/active_support/inflections.rb +19 -12
- data/lib/active_support/inflector/inflections.rb +79 -30
- data/lib/active_support/inflector/methods.rb +197 -129
- data/lib/active_support/inflector/transliterate.rb +48 -27
- data/lib/active_support/inflector.rb +7 -5
- data/lib/active_support/json/decoding.rb +21 -25
- data/lib/active_support/json/encoding.rb +84 -292
- data/lib/active_support/json.rb +4 -2
- data/lib/active_support/key_generator.rb +26 -28
- data/lib/active_support/lazy_load_hooks.rb +51 -21
- data/lib/active_support/locale/en.yml +2 -0
- data/lib/active_support/log_subscriber/test_helper.rb +14 -12
- data/lib/active_support/log_subscriber.rb +13 -10
- data/lib/active_support/logger.rb +54 -3
- data/lib/active_support/logger_silence.rb +12 -7
- data/lib/active_support/logger_thread_safe_level.rb +34 -0
- data/lib/active_support/message_encryptor.rb +173 -50
- data/lib/active_support/message_verifier.rb +159 -22
- data/lib/active_support/messages/metadata.rb +71 -0
- data/lib/active_support/messages/rotation_configuration.rb +22 -0
- data/lib/active_support/messages/rotator.rb +56 -0
- data/lib/active_support/multibyte/chars.rb +38 -26
- data/lib/active_support/multibyte/unicode.rb +138 -146
- data/lib/active_support/multibyte.rb +4 -2
- data/lib/active_support/notifications/fanout.rb +23 -16
- data/lib/active_support/notifications/instrumenter.rb +29 -8
- data/lib/active_support/notifications.rb +22 -13
- data/lib/active_support/number_helper/number_converter.rb +184 -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 +29 -0
- data/lib/active_support/number_helper/number_to_human_converter.rb +68 -0
- data/lib/active_support/number_helper/number_to_human_size_converter.rb +59 -0
- data/lib/active_support/number_helper/number_to_percentage_converter.rb +14 -0
- data/lib/active_support/number_helper/number_to_phone_converter.rb +58 -0
- data/lib/active_support/number_helper/number_to_rounded_converter.rb +54 -0
- data/lib/active_support/number_helper/rounding_helper.rb +66 -0
- data/lib/active_support/number_helper.rb +125 -391
- data/lib/active_support/option_merger.rb +3 -1
- data/lib/active_support/ordered_hash.rb +6 -4
- data/lib/active_support/ordered_options.rb +31 -5
- data/lib/active_support/per_thread_registry.rb +19 -11
- data/lib/active_support/proxy_object.rb +2 -0
- data/lib/active_support/rails.rb +16 -8
- data/lib/active_support/railtie.rb +43 -9
- data/lib/active_support/reloader.rb +131 -0
- data/lib/active_support/rescuable.rb +108 -53
- data/lib/active_support/security_utils.rb +31 -0
- data/lib/active_support/string_inquirer.rb +11 -3
- data/lib/active_support/subscriber.rb +54 -17
- data/lib/active_support/tagged_logging.rb +14 -11
- data/lib/active_support/test_case.rb +42 -37
- data/lib/active_support/testing/assertions.rb +126 -39
- data/lib/active_support/testing/autorun.rb +5 -3
- data/lib/active_support/testing/constant_lookup.rb +3 -6
- data/lib/active_support/testing/declarative.rb +10 -22
- data/lib/active_support/testing/deprecation.rb +14 -10
- data/lib/active_support/testing/file_fixtures.rb +36 -0
- data/lib/active_support/testing/isolation.rb +55 -86
- data/lib/active_support/testing/method_call_assertions.rb +43 -0
- data/lib/active_support/testing/setup_and_teardown.rb +30 -10
- data/lib/active_support/testing/stream.rb +44 -0
- data/lib/active_support/testing/tagged_logging.rb +5 -3
- data/lib/active_support/testing/time_helpers.rb +200 -0
- data/lib/active_support/time.rb +13 -13
- data/lib/active_support/time_with_zone.rb +223 -73
- data/lib/active_support/values/time_zone.rb +261 -126
- data/lib/active_support/values/unicode_tables.dat +0 -0
- data/lib/active_support/version.rb +6 -7
- data/lib/active_support/xml_mini/jdom.rb +116 -113
- data/lib/active_support/xml_mini/libxml.rb +17 -16
- data/lib/active_support/xml_mini/libxmlsax.rb +16 -18
- data/lib/active_support/xml_mini/nokogiri.rb +15 -15
- data/lib/active_support/xml_mini/nokogirisax.rb +15 -16
- data/lib/active_support/xml_mini/rexml.rb +17 -16
- data/lib/active_support/xml_mini.rb +69 -51
- data/lib/active_support.rb +29 -3
- metadata +84 -54
- data/lib/active_support/basic_object.rb +0 -11
- data/lib/active_support/buffered_logger.rb +0 -21
- data/lib/active_support/concurrency/latch.rb +0 -27
- data/lib/active_support/core_ext/array/uniq_by.rb +0 -19
- data/lib/active_support/core_ext/class/delegating_attributes.rb +0 -40
- data/lib/active_support/core_ext/date_time/zones.rb +0 -24
- data/lib/active_support/core_ext/hash/diff.rb +0 -14
- data/lib/active_support/core_ext/kernel/debugger.rb +0 -10
- data/lib/active_support/core_ext/logger.rb +0 -67
- data/lib/active_support/core_ext/module/qualified_const.rb +0 -52
- data/lib/active_support/core_ext/object/to_json.rb +0 -27
- data/lib/active_support/core_ext/proc.rb +0 -17
- data/lib/active_support/core_ext/string/encoding.rb +0 -8
- data/lib/active_support/core_ext/struct.rb +0 -6
- data/lib/active_support/core_ext/thread.rb +0 -79
- data/lib/active_support/core_ext/time/marshal.rb +0 -30
- data/lib/active_support/file_watcher.rb +0 -36
- data/lib/active_support/json/variable.rb +0 -18
- data/lib/active_support/testing/pending.rb +0 -14
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'active_support/deprecation'
|
2
|
-
require 'active_support/logger'
|
3
|
-
|
4
|
-
module ActiveSupport
|
5
|
-
class BufferedLogger < Logger
|
6
|
-
|
7
|
-
def initialize(*args)
|
8
|
-
self.class._deprecation_warning
|
9
|
-
super
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.inherited(*)
|
13
|
-
_deprecation_warning
|
14
|
-
super
|
15
|
-
end
|
16
|
-
|
17
|
-
def self._deprecation_warning
|
18
|
-
::ActiveSupport::Deprecation.warn 'ActiveSupport::BufferedLogger is deprecated! Use ActiveSupport::Logger instead.'
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'thread'
|
2
|
-
require 'monitor'
|
3
|
-
|
4
|
-
module ActiveSupport
|
5
|
-
module Concurrency
|
6
|
-
class Latch
|
7
|
-
def initialize(count = 1)
|
8
|
-
@count = count
|
9
|
-
@lock = Monitor.new
|
10
|
-
@cv = @lock.new_cond
|
11
|
-
end
|
12
|
-
|
13
|
-
def release
|
14
|
-
@lock.synchronize do
|
15
|
-
@count -= 1 if @count > 0
|
16
|
-
@cv.broadcast if @count.zero?
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def await
|
21
|
-
@lock.synchronize do
|
22
|
-
@cv.wait_while { @count > 0 }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
class Array
|
2
|
-
# *DEPRECATED*: Use <tt>Array#uniq</tt> instead.
|
3
|
-
#
|
4
|
-
# Returns a unique array based on the criteria in the block.
|
5
|
-
#
|
6
|
-
# [1, 2, 3, 4].uniq_by { |i| i.odd? } # => [1, 2]
|
7
|
-
def uniq_by(&block)
|
8
|
-
ActiveSupport::Deprecation.warn 'uniq_by is deprecated. Use Array#uniq instead'
|
9
|
-
uniq(&block)
|
10
|
-
end
|
11
|
-
|
12
|
-
# *DEPRECATED*: Use <tt>Array#uniq!</tt> instead.
|
13
|
-
#
|
14
|
-
# Same as +uniq_by+, but modifies +self+.
|
15
|
-
def uniq_by!(&block)
|
16
|
-
ActiveSupport::Deprecation.warn 'uniq_by! is deprecated. Use Array#uniq! instead'
|
17
|
-
uniq!(&block)
|
18
|
-
end
|
19
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/kernel/singleton_class'
|
2
|
-
require 'active_support/core_ext/module/remove_method'
|
3
|
-
|
4
|
-
class Class
|
5
|
-
def superclass_delegating_accessor(name, options = {})
|
6
|
-
# Create private _name and _name= methods that can still be used if the public
|
7
|
-
# methods are overridden. This allows
|
8
|
-
_superclass_delegating_accessor("_#{name}")
|
9
|
-
|
10
|
-
# Generate the public methods name, name=, and name?
|
11
|
-
# These methods dispatch to the private _name, and _name= methods, making them
|
12
|
-
# overridable
|
13
|
-
singleton_class.send(:define_method, name) { send("_#{name}") }
|
14
|
-
singleton_class.send(:define_method, "#{name}?") { !!send("_#{name}") }
|
15
|
-
singleton_class.send(:define_method, "#{name}=") { |value| send("_#{name}=", value) }
|
16
|
-
|
17
|
-
# If an instance_reader is needed, generate methods for name and name= on the
|
18
|
-
# class itself, so instances will be able to see them
|
19
|
-
define_method(name) { send("_#{name}") } if options[:instance_reader] != false
|
20
|
-
define_method("#{name}?") { !!send("#{name}") } if options[:instance_reader] != false
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
# Take the object being set and store it in a method. This gives us automatic
|
25
|
-
# inheritance behavior, without having to store the object in an instance
|
26
|
-
# variable and look up the superclass chain manually.
|
27
|
-
def _stash_object_in_method(object, method, instance_reader = true)
|
28
|
-
singleton_class.remove_possible_method(method)
|
29
|
-
singleton_class.send(:define_method, method) { object }
|
30
|
-
remove_possible_method(method)
|
31
|
-
define_method(method) { object } if instance_reader
|
32
|
-
end
|
33
|
-
|
34
|
-
def _superclass_delegating_accessor(name, options = {})
|
35
|
-
singleton_class.send(:define_method, "#{name}=") do |value|
|
36
|
-
_stash_object_in_method(value, name, options[:instance_reader] != false)
|
37
|
-
end
|
38
|
-
send("#{name}=", nil)
|
39
|
-
end
|
40
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/time/zones'
|
2
|
-
|
3
|
-
class DateTime
|
4
|
-
# Returns the simultaneous time in <tt>Time.zone</tt>.
|
5
|
-
#
|
6
|
-
# Time.zone = 'Hawaii' # => 'Hawaii'
|
7
|
-
# DateTime.new(2000).in_time_zone # => Fri, 31 Dec 1999 14:00:00 HST -10:00
|
8
|
-
#
|
9
|
-
# This method is similar to Time#localtime, except that it uses <tt>Time.zone</tt>
|
10
|
-
# as the local zone instead of the operating system's time zone.
|
11
|
-
#
|
12
|
-
# You can also pass in a TimeZone instance or string that identifies a TimeZone
|
13
|
-
# as an argument, and the conversion will be based on that zone instead of
|
14
|
-
# <tt>Time.zone</tt>.
|
15
|
-
#
|
16
|
-
# DateTime.new(2000).in_time_zone('Alaska') # => Fri, 31 Dec 1999 15:00:00 AKST -09:00
|
17
|
-
def in_time_zone(zone = ::Time.zone)
|
18
|
-
if zone
|
19
|
-
ActiveSupport::TimeWithZone.new(utc? ? self : getutc, ::Time.find_zone!(zone))
|
20
|
-
else
|
21
|
-
self
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class Hash
|
2
|
-
# Returns a hash that represents the difference between two hashes.
|
3
|
-
#
|
4
|
-
# {1 => 2}.diff(1 => 2) # => {}
|
5
|
-
# {1 => 2}.diff(1 => 3) # => {1 => 2}
|
6
|
-
# {}.diff(1 => 2) # => {1 => 2}
|
7
|
-
# {1 => 2, 3 => 4}.diff(1 => 2) # => {3 => 4}
|
8
|
-
def diff(other)
|
9
|
-
ActiveSupport::Deprecation.warn "Hash#diff is no longer used inside of Rails, and is being deprecated with no replacement. If you're using it to compare hashes for the purpose of testing, please use MiniTest's assert_equal instead."
|
10
|
-
dup.
|
11
|
-
delete_if { |k, v| other[k] == v }.
|
12
|
-
merge!(other.dup.delete_if { |k, v| has_key?(k) })
|
13
|
-
end
|
14
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
module Kernel
|
2
|
-
unless respond_to?(:debugger)
|
3
|
-
# Starts a debugging session if the +debugger+ gem has been loaded (call rails server --debugger to do load it).
|
4
|
-
def debugger
|
5
|
-
message = "\n***** Debugger requested, but was not available (ensure the debugger gem is listed in Gemfile/installed as gem): Start server with --debugger to enable *****\n"
|
6
|
-
defined?(Rails) ? Rails.logger.info(message) : $stderr.puts(message)
|
7
|
-
end
|
8
|
-
alias breakpoint debugger unless respond_to?(:breakpoint)
|
9
|
-
end
|
10
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/class/attribute_accessors'
|
2
|
-
require 'active_support/deprecation'
|
3
|
-
require 'active_support/logger_silence'
|
4
|
-
|
5
|
-
ActiveSupport::Deprecation.warn 'this file is deprecated and will be removed'
|
6
|
-
|
7
|
-
# Adds the 'around_level' method to Logger.
|
8
|
-
class Logger #:nodoc:
|
9
|
-
def self.define_around_helper(level)
|
10
|
-
module_eval <<-end_eval, __FILE__, __LINE__ + 1
|
11
|
-
def around_#{level}(before_message, after_message) # def around_debug(before_message, after_message, &block)
|
12
|
-
self.#{level}(before_message) # self.debug(before_message)
|
13
|
-
return_value = yield(self) # return_value = yield(self)
|
14
|
-
self.#{level}(after_message) # self.debug(after_message)
|
15
|
-
return_value # return_value
|
16
|
-
end # end
|
17
|
-
end_eval
|
18
|
-
end
|
19
|
-
[:debug, :info, :error, :fatal].each {|level| define_around_helper(level) }
|
20
|
-
end
|
21
|
-
|
22
|
-
require 'logger'
|
23
|
-
|
24
|
-
# Extensions to the built-in Ruby logger.
|
25
|
-
#
|
26
|
-
# If you want to use the default log formatter as defined in the Ruby core, then you
|
27
|
-
# will need to set the formatter for the logger as in:
|
28
|
-
#
|
29
|
-
# logger.formatter = Formatter.new
|
30
|
-
#
|
31
|
-
# You can then specify the datetime format, for example:
|
32
|
-
#
|
33
|
-
# logger.datetime_format = "%Y-%m-%d"
|
34
|
-
#
|
35
|
-
# Note: This logger is deprecated in favor of ActiveSupport::Logger
|
36
|
-
class Logger
|
37
|
-
include LoggerSilence
|
38
|
-
|
39
|
-
alias :old_datetime_format= :datetime_format=
|
40
|
-
# Logging date-time format (string passed to +strftime+). Ignored if the formatter
|
41
|
-
# does not respond to datetime_format=.
|
42
|
-
def datetime_format=(format)
|
43
|
-
formatter.datetime_format = format if formatter.respond_to?(:datetime_format=)
|
44
|
-
end
|
45
|
-
|
46
|
-
alias :old_datetime_format :datetime_format
|
47
|
-
# Get the logging datetime format. Returns nil if the formatter does not support
|
48
|
-
# datetime formatting.
|
49
|
-
def datetime_format
|
50
|
-
formatter.datetime_format if formatter.respond_to?(:datetime_format)
|
51
|
-
end
|
52
|
-
|
53
|
-
alias :old_initialize :initialize
|
54
|
-
# Overwrite initialize to set a default formatter.
|
55
|
-
def initialize(*args)
|
56
|
-
old_initialize(*args)
|
57
|
-
self.formatter = SimpleFormatter.new
|
58
|
-
end
|
59
|
-
|
60
|
-
# Simple formatter which only displays the message.
|
61
|
-
class SimpleFormatter < Logger::Formatter
|
62
|
-
# This method is invoked when a log event occurs
|
63
|
-
def call(severity, timestamp, progname, msg)
|
64
|
-
"#{String === msg ? msg : msg.inspect}\n"
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/string/inflections'
|
2
|
-
|
3
|
-
#--
|
4
|
-
# Allows code reuse in the methods below without polluting Module.
|
5
|
-
#++
|
6
|
-
module QualifiedConstUtils
|
7
|
-
def self.raise_if_absolute(path)
|
8
|
-
raise NameError.new("wrong constant name #$&") if path =~ /\A::[^:]+/
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.names(path)
|
12
|
-
path.split('::')
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
##
|
17
|
-
# Extends the API for constants to be able to deal with qualified names. Arguments
|
18
|
-
# are assumed to be relative to the receiver.
|
19
|
-
#
|
20
|
-
#--
|
21
|
-
# Qualified names are required to be relative because we are extending existing
|
22
|
-
# methods that expect constant names, ie, relative paths of length 1. For example,
|
23
|
-
# Object.const_get('::String') raises NameError and so does qualified_const_get.
|
24
|
-
#++
|
25
|
-
class Module
|
26
|
-
def qualified_const_defined?(path, search_parents=true)
|
27
|
-
QualifiedConstUtils.raise_if_absolute(path)
|
28
|
-
|
29
|
-
QualifiedConstUtils.names(path).inject(self) do |mod, name|
|
30
|
-
return unless mod.const_defined?(name, search_parents)
|
31
|
-
mod.const_get(name)
|
32
|
-
end
|
33
|
-
return true
|
34
|
-
end
|
35
|
-
|
36
|
-
def qualified_const_get(path)
|
37
|
-
QualifiedConstUtils.raise_if_absolute(path)
|
38
|
-
|
39
|
-
QualifiedConstUtils.names(path).inject(self) do |mod, name|
|
40
|
-
mod.const_get(name)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def qualified_const_set(path, value)
|
45
|
-
QualifiedConstUtils.raise_if_absolute(path)
|
46
|
-
|
47
|
-
const_name = path.demodulize
|
48
|
-
mod_name = path.deconstantize
|
49
|
-
mod = mod_name.empty? ? self : qualified_const_get(mod_name)
|
50
|
-
mod.const_set(const_name, value)
|
51
|
-
end
|
52
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# Hack to load json gem first so we can overwrite its to_json.
|
2
|
-
begin
|
3
|
-
require 'json'
|
4
|
-
rescue LoadError
|
5
|
-
end
|
6
|
-
|
7
|
-
# The JSON gem adds a few modules to Ruby core classes containing :to_json definition, overwriting
|
8
|
-
# their default behavior. That said, we need to define the basic to_json method in all of them,
|
9
|
-
# otherwise they will always use to_json gem implementation, which is backwards incompatible in
|
10
|
-
# several cases (for instance, the JSON implementation for Hash does not work) with inheritance
|
11
|
-
# and consequently classes as ActiveSupport::OrderedHash cannot be serialized to json.
|
12
|
-
[Object, Array, FalseClass, Float, Hash, Integer, NilClass, String, TrueClass].each do |klass|
|
13
|
-
klass.class_eval do
|
14
|
-
# Dumps object in JSON (JavaScript Object Notation). See www.json.org for more info.
|
15
|
-
def to_json(options = nil)
|
16
|
-
ActiveSupport::JSON.encode(self, options)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
module Process
|
22
|
-
class Status
|
23
|
-
def as_json(options = nil)
|
24
|
-
{ :exitstatus => exitstatus, :pid => pid }
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require "active_support/core_ext/kernel/singleton_class"
|
2
|
-
require "active_support/deprecation"
|
3
|
-
|
4
|
-
class Proc #:nodoc:
|
5
|
-
def bind(object)
|
6
|
-
ActiveSupport::Deprecation.warn 'Proc#bind is deprecated and will be removed in future versions'
|
7
|
-
|
8
|
-
block, time = self, Time.now
|
9
|
-
object.class_eval do
|
10
|
-
method_name = "__bind_#{time.to_i}_#{time.usec}"
|
11
|
-
define_method(method_name, &block)
|
12
|
-
method = instance_method(method_name)
|
13
|
-
remove_method(method_name)
|
14
|
-
method
|
15
|
-
end.bind(object)
|
16
|
-
end
|
17
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
class Thread
|
2
|
-
LOCK = Mutex.new # :nodoc:
|
3
|
-
|
4
|
-
# Returns the value of a thread local variable that has been set. Note that
|
5
|
-
# these are different than fiber local values.
|
6
|
-
#
|
7
|
-
# Thread local values are carried along with threads, and do not respect
|
8
|
-
# fibers. For example:
|
9
|
-
#
|
10
|
-
# Thread.new {
|
11
|
-
# Thread.current.thread_variable_set("foo", "bar") # set a thread local
|
12
|
-
# Thread.current["foo"] = "bar" # set a fiber local
|
13
|
-
#
|
14
|
-
# Fiber.new {
|
15
|
-
# Fiber.yield [
|
16
|
-
# Thread.current.thread_variable_get("foo"), # get the thread local
|
17
|
-
# Thread.current["foo"], # get the fiber local
|
18
|
-
# ]
|
19
|
-
# }.resume
|
20
|
-
# }.join.value # => ['bar', nil]
|
21
|
-
#
|
22
|
-
# The value <tt>"bar"</tt> is returned for the thread local, where +nil+ is returned
|
23
|
-
# for the fiber local. The fiber is executed in the same thread, so the
|
24
|
-
# thread local values are available.
|
25
|
-
def thread_variable_get(key)
|
26
|
-
_locals[key.to_sym]
|
27
|
-
end
|
28
|
-
|
29
|
-
# Sets a thread local with +key+ to +value+. Note that these are local to
|
30
|
-
# threads, and not to fibers. Please see Thread#thread_variable_get for
|
31
|
-
# more information.
|
32
|
-
def thread_variable_set(key, value)
|
33
|
-
_locals[key.to_sym] = value
|
34
|
-
end
|
35
|
-
|
36
|
-
# Returns an an array of the names of the thread-local variables (as Symbols).
|
37
|
-
#
|
38
|
-
# thr = Thread.new do
|
39
|
-
# Thread.current.thread_variable_set(:cat, 'meow')
|
40
|
-
# Thread.current.thread_variable_set("dog", 'woof')
|
41
|
-
# end
|
42
|
-
# thr.join #=> #<Thread:0x401b3f10 dead>
|
43
|
-
# thr.thread_variables #=> [:dog, :cat]
|
44
|
-
#
|
45
|
-
# Note that these are not fiber local variables. Please see Thread#thread_variable_get
|
46
|
-
# for more details.
|
47
|
-
def thread_variables
|
48
|
-
_locals.keys
|
49
|
-
end
|
50
|
-
|
51
|
-
# Returns <tt>true</tt> if the given string (or symbol) exists as a
|
52
|
-
# thread-local variable.
|
53
|
-
#
|
54
|
-
# me = Thread.current
|
55
|
-
# me.thread_variable_set(:oliver, "a")
|
56
|
-
# me.thread_variable?(:oliver) #=> true
|
57
|
-
# me.thread_variable?(:stanley) #=> false
|
58
|
-
#
|
59
|
-
# Note that these are not fiber local variables. Please see Thread#thread_variable_get
|
60
|
-
# for more details.
|
61
|
-
def thread_variable?(key)
|
62
|
-
_locals.has_key?(key.to_sym)
|
63
|
-
end
|
64
|
-
|
65
|
-
def freeze
|
66
|
-
_locals.freeze
|
67
|
-
super
|
68
|
-
end
|
69
|
-
|
70
|
-
private
|
71
|
-
|
72
|
-
def _locals
|
73
|
-
if defined?(@_locals)
|
74
|
-
@_locals
|
75
|
-
else
|
76
|
-
LOCK.synchronize { @_locals ||= {} }
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end unless Thread.instance_methods.include?(:thread_variable_set)
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# Ruby 1.9.2 adds utc_offset and zone to Time, but marshaling only
|
2
|
-
# preserves utc_offset. Preserve zone also, even though it may not
|
3
|
-
# work in some edge cases.
|
4
|
-
if Time.local(2010).zone != Marshal.load(Marshal.dump(Time.local(2010))).zone
|
5
|
-
class Time
|
6
|
-
class << self
|
7
|
-
alias_method :_load_without_zone, :_load
|
8
|
-
def _load(marshaled_time)
|
9
|
-
time = _load_without_zone(marshaled_time)
|
10
|
-
time.instance_eval do
|
11
|
-
if zone = defined?(@_zone) && remove_instance_variable('@_zone')
|
12
|
-
ary = to_a
|
13
|
-
ary[0] += subsec if ary[0] == sec
|
14
|
-
ary[-1] = zone
|
15
|
-
utc? ? Time.utc(*ary) : Time.local(*ary)
|
16
|
-
else
|
17
|
-
self
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
alias_method :_dump_without_zone, :_dump
|
24
|
-
def _dump(*args)
|
25
|
-
obj = dup
|
26
|
-
obj.instance_variable_set('@_zone', zone)
|
27
|
-
obj.send :_dump_without_zone, *args
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
module ActiveSupport
|
2
|
-
class FileWatcher
|
3
|
-
class Backend
|
4
|
-
def initialize(path, watcher)
|
5
|
-
@watcher = watcher
|
6
|
-
@path = path
|
7
|
-
end
|
8
|
-
|
9
|
-
def trigger(files)
|
10
|
-
@watcher.trigger(files)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def initialize
|
15
|
-
@regex_matchers = {}
|
16
|
-
end
|
17
|
-
|
18
|
-
def watch(pattern, &block)
|
19
|
-
@regex_matchers[pattern] = block
|
20
|
-
end
|
21
|
-
|
22
|
-
def trigger(files)
|
23
|
-
trigger_files = Hash.new { |h,k| h[k] = Hash.new { |h2,k2| h2[k2] = [] } }
|
24
|
-
|
25
|
-
files.each do |file, state|
|
26
|
-
@regex_matchers.each do |pattern, block|
|
27
|
-
trigger_files[block][state] << file if pattern === file
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
trigger_files.each do |block, payload|
|
32
|
-
block.call payload
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'active_support/deprecation'
|
2
|
-
|
3
|
-
module ActiveSupport
|
4
|
-
module JSON
|
5
|
-
# Deprecated: A string that returns itself as its JSON-encoded form.
|
6
|
-
class Variable < String
|
7
|
-
def initialize(*args)
|
8
|
-
message = 'ActiveSupport::JSON::Variable is deprecated and will be removed in Rails 4.1. ' \
|
9
|
-
'For your own custom JSON literals, define #as_json and #encode_json yourself.'
|
10
|
-
ActiveSupport::Deprecation.warn message
|
11
|
-
super
|
12
|
-
end
|
13
|
-
|
14
|
-
def as_json(options = nil) self end #:nodoc:
|
15
|
-
def encode_json(encoder) self end #:nodoc:
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'active_support/deprecation'
|
2
|
-
|
3
|
-
module ActiveSupport
|
4
|
-
module Testing
|
5
|
-
module Pending # :nodoc:
|
6
|
-
unless defined?(Spec)
|
7
|
-
def pending(description = "", &block)
|
8
|
-
ActiveSupport::Deprecation.warn("#pending is deprecated and will be removed in Rails 4.1, please use #skip instead.")
|
9
|
-
skip(description.blank? ? nil : description)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|