activesupport 4.0.13 → 4.1.0.beta1
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 +4 -4
- data/CHANGELOG.md +283 -508
- data/README.rdoc +1 -1
- data/lib/active_support.rb +7 -1
- data/lib/active_support/backtrace_cleaner.rb +5 -5
- data/lib/active_support/benchmarkable.rb +0 -10
- data/lib/active_support/cache.rb +62 -26
- data/lib/active_support/cache/file_store.rb +27 -22
- data/lib/active_support/cache/mem_cache_store.rb +2 -2
- data/lib/active_support/cache/memory_store.rb +1 -0
- data/lib/active_support/cache/strategy/local_cache.rb +3 -0
- data/lib/active_support/callbacks.rb +416 -245
- data/lib/active_support/concern.rb +13 -5
- data/lib/active_support/core_ext.rb +0 -1
- data/lib/active_support/core_ext/array.rb +0 -1
- data/lib/active_support/core_ext/array/access.rb +2 -0
- data/lib/active_support/core_ext/array/conversions.rb +2 -17
- data/lib/active_support/core_ext/array/grouping.rb +24 -12
- data/lib/active_support/core_ext/array/prepend_and_append.rb +2 -2
- data/lib/active_support/core_ext/class.rb +0 -1
- data/lib/active_support/core_ext/class/attribute.rb +1 -2
- data/lib/active_support/core_ext/class/attribute_accessors.rb +5 -169
- data/lib/active_support/core_ext/date/calculations.rb +10 -0
- data/lib/active_support/core_ext/date/conversions.rb +5 -6
- data/lib/active_support/core_ext/date/zones.rb +2 -33
- data/lib/active_support/core_ext/date_and_time/calculations.rb +30 -11
- data/lib/active_support/core_ext/date_and_time/zones.rb +41 -0
- data/lib/active_support/core_ext/date_time/calculations.rb +12 -25
- data/lib/active_support/core_ext/date_time/conversions.rb +2 -0
- data/lib/active_support/core_ext/date_time/zones.rb +3 -21
- data/lib/active_support/core_ext/hash.rb +0 -1
- data/lib/active_support/core_ext/hash/conversions.rb +6 -3
- data/lib/active_support/core_ext/hash/deep_merge.rb +11 -22
- data/lib/active_support/core_ext/hash/indifferent_access.rb +1 -0
- data/lib/active_support/core_ext/hash/keys.rb +27 -47
- data/lib/active_support/core_ext/kernel/reporting.rb +2 -6
- data/lib/active_support/core_ext/module.rb +1 -0
- data/lib/active_support/core_ext/module/attribute_accessors.rb +160 -14
- data/lib/active_support/core_ext/module/concerning.rb +135 -0
- data/lib/active_support/core_ext/module/delegation.rb +14 -4
- data/lib/active_support/core_ext/module/deprecation.rb +0 -2
- data/lib/active_support/core_ext/module/introspection.rb +0 -16
- data/lib/active_support/core_ext/module/method_transplanting.rb +11 -0
- data/lib/active_support/core_ext/numeric/time.rb +8 -0
- data/lib/active_support/core_ext/object.rb +1 -1
- data/lib/active_support/core_ext/object/blank.rb +1 -1
- data/lib/active_support/core_ext/object/deep_dup.rb +6 -6
- data/lib/active_support/core_ext/object/inclusion.rb +4 -15
- data/lib/active_support/core_ext/object/json.rb +197 -0
- data/lib/active_support/core_ext/object/to_json.rb +4 -26
- data/lib/active_support/core_ext/object/to_param.rb +58 -1
- data/lib/active_support/core_ext/object/to_query.rb +7 -56
- data/lib/active_support/core_ext/object/try.rb +1 -1
- data/lib/active_support/core_ext/range/each.rb +2 -1
- data/lib/active_support/core_ext/string/access.rb +31 -31
- data/lib/active_support/core_ext/string/conversions.rb +9 -8
- data/lib/active_support/core_ext/string/exclude.rb +3 -3
- data/lib/active_support/core_ext/string/filters.rb +14 -4
- data/lib/active_support/core_ext/string/inflections.rb +11 -9
- data/lib/active_support/core_ext/string/output_safety.rb +65 -24
- data/lib/active_support/core_ext/string/zones.rb +1 -0
- data/lib/active_support/core_ext/thread.rb +4 -4
- data/lib/active_support/core_ext/time/calculations.rb +10 -57
- data/lib/active_support/core_ext/time/conversions.rb +3 -1
- data/lib/active_support/core_ext/time/zones.rb +2 -21
- data/lib/active_support/dependencies.rb +29 -13
- data/lib/active_support/deprecation.rb +4 -4
- data/lib/active_support/deprecation/behaviors.rb +3 -3
- data/lib/active_support/duration.rb +5 -7
- data/lib/active_support/file_update_checker.rb +1 -1
- data/lib/active_support/hash_with_indifferent_access.rb +4 -9
- data/lib/active_support/i18n.rb +4 -4
- data/lib/active_support/i18n_railtie.rb +2 -6
- data/lib/active_support/inflections.rb +0 -1
- data/lib/active_support/inflector/inflections.rb +17 -17
- data/lib/active_support/inflector/methods.rb +34 -17
- data/lib/active_support/json/decoding.rb +14 -21
- data/lib/active_support/json/encoding.rb +113 -285
- data/lib/active_support/key_generator.rb +1 -1
- data/lib/active_support/lazy_load_hooks.rb +1 -1
- data/lib/active_support/log_subscriber/test_helper.rb +1 -1
- data/lib/active_support/logger.rb +1 -1
- data/lib/active_support/message_encryptor.rb +3 -3
- data/lib/active_support/message_verifier.rb +6 -1
- data/lib/active_support/multibyte/chars.rb +1 -2
- data/lib/active_support/multibyte/unicode.rb +27 -39
- data/lib/active_support/notifications.rb +3 -3
- data/lib/active_support/notifications/instrumenter.rb +2 -1
- data/lib/active_support/number_helper.rb +20 -311
- data/lib/active_support/number_helper/number_converter.rb +182 -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 +21 -0
- data/lib/active_support/number_helper/number_to_human_converter.rb +66 -0
- data/lib/active_support/number_helper/number_to_human_size_converter.rb +58 -0
- data/lib/active_support/number_helper/number_to_percentage_converter.rb +12 -0
- data/lib/active_support/number_helper/number_to_phone_converter.rb +49 -0
- data/lib/active_support/number_helper/number_to_rounded_converter.rb +62 -0
- data/lib/active_support/option_merger.rb +1 -1
- data/lib/active_support/ordered_hash.rb +0 -8
- data/lib/active_support/ordered_options.rb +8 -0
- data/lib/active_support/per_thread_registry.rb +9 -8
- data/lib/active_support/subscriber.rb +26 -3
- data/lib/active_support/test_case.rb +9 -10
- data/lib/active_support/testing/assertions.rb +0 -30
- data/lib/active_support/testing/autorun.rb +2 -2
- data/lib/active_support/testing/declarative.rb +18 -8
- data/lib/active_support/testing/isolation.rb +13 -65
- data/lib/active_support/testing/setup_and_teardown.rb +17 -2
- data/lib/active_support/testing/tagged_logging.rb +1 -1
- data/lib/active_support/testing/time_helpers.rb +55 -0
- data/lib/active_support/time_with_zone.rb +4 -4
- data/lib/active_support/values/time_zone.rb +18 -15
- data/lib/active_support/version.rb +1 -1
- data/lib/active_support/xml_mini.rb +2 -4
- metadata +71 -61
- data/lib/active_support/basic_object.rb +0 -11
- data/lib/active_support/buffered_logger.rb +0 -21
- data/lib/active_support/core_ext/array/uniq_by.rb +0 -19
- data/lib/active_support/core_ext/hash/diff.rb +0 -14
- data/lib/active_support/core_ext/logger.rb +0 -67
- 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/json/variable.rb +0 -18
- data/lib/active_support/testing/pending.rb +0 -14
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'active_support/deprecation'
|
2
|
-
require 'active_support/proxy_object'
|
3
|
-
|
4
|
-
module ActiveSupport
|
5
|
-
class BasicObject < ProxyObject # :nodoc:
|
6
|
-
def self.inherited(*)
|
7
|
-
::ActiveSupport::Deprecation.warn 'ActiveSupport::BasicObject is deprecated! Use ActiveSupport::ProxyObject instead.'
|
8
|
-
super
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -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,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,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,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,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,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
|