activesupport 4.0.3 → 4.0.4.rc1
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 +52 -0
- data/lib/active_support/cache/mem_cache_store.rb +2 -2
- data/lib/active_support/callbacks.rb +3 -3
- data/lib/active_support/core_ext/class/attribute.rb +5 -2
- data/lib/active_support/core_ext/date/conversions.rb +6 -4
- data/lib/active_support/core_ext/date_time/calculations.rb +5 -1
- data/lib/active_support/core_ext/file/atomic.rb +1 -1
- data/lib/active_support/core_ext/hash/slice.rb +2 -0
- data/lib/active_support/core_ext/integer/multiple.rb +3 -3
- data/lib/active_support/core_ext/kernel/reporting.rb +5 -0
- data/lib/active_support/core_ext/range/each.rb +1 -2
- data/lib/active_support/duration.rb +8 -0
- data/lib/active_support/file_update_checker.rb +1 -1
- data/lib/active_support/hash_with_indifferent_access.rb +8 -0
- data/lib/active_support/i18n_railtie.rb +11 -0
- data/lib/active_support/json/encoding.rb +1 -1
- data/lib/active_support/notifications/fanout.rb +4 -7
- data/lib/active_support/ordered_hash.rb +8 -0
- data/lib/active_support/tagged_logging.rb +1 -0
- data/lib/active_support/testing/deprecation.rb +10 -11
- data/lib/active_support/time_with_zone.rb +1 -1
- data/lib/active_support/values/time_zone.rb +1 -0
- data/lib/active_support/version.rb +1 -1
- data/lib/active_support/xml_mini.rb +4 -2
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7299f5dc3d23b612bf635e5e4b2da81dd9866299
|
4
|
+
data.tar.gz: 47fdf77c1b3235dcb8cfe201af9cf13def5582e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b66aabf063683175602e5cb2b78bb6b4818c848bc2047fd483518de2e08ded51e8bc8ad64028bf026f03f13eb9032fa5395d448db0581430fa9d78c9deb87ec
|
7
|
+
data.tar.gz: eff6c2f64f3c763159d3eb0da623c2a530f0308fe4d9bc8262f057380cf5a41f15b7ae48f0f8dbac1b2d5f3b4539aa7968e5303fdac6a67b2189b22302665619
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,55 @@
|
|
1
|
+
## Rails 4.0.4 ##
|
2
|
+
|
3
|
+
* Fix parsing bugs in `XmlMini`
|
4
|
+
|
5
|
+
Symbols or boolean parsing would raise an error for non string values (e.g.
|
6
|
+
integers). Decimal parsing would fail due to a missing requirement.
|
7
|
+
|
8
|
+
*Birkir A. Barkarson*
|
9
|
+
|
10
|
+
* Re-enable support for iterating over `DateTIme` ranges
|
11
|
+
|
12
|
+
Fixes #13667.
|
13
|
+
|
14
|
+
*Prathamesh Sonpatki*
|
15
|
+
|
16
|
+
* Use `remove_possible_method` instead of `remove_method` to avoid
|
17
|
+
a `NameError` to be thrown on FreeBSD with the `Date` object.
|
18
|
+
|
19
|
+
*Rafael Mendonça França*, *Robin Dupret*
|
20
|
+
|
21
|
+
* Default the new `I18n.enforce_available_locales` config to `true`, meaning
|
22
|
+
`I18n` will make sure that all locales passed to it must be declared in the
|
23
|
+
`available_locales` list.
|
24
|
+
|
25
|
+
To disable it add the following configuration to your application:
|
26
|
+
|
27
|
+
config.i18n.enforce_available_locales = false
|
28
|
+
|
29
|
+
This also ensures I18n configuration is properly initialized taking the new
|
30
|
+
option into account, to avoid their deprecations while booting up the app.
|
31
|
+
|
32
|
+
*Carlos Antonio da Silva*, *Yves Senn*
|
33
|
+
|
34
|
+
* Fix file descriptor being leaked on each call to `Kernel.silence_stream`.
|
35
|
+
|
36
|
+
*Mario Visic*
|
37
|
+
|
38
|
+
* Fix `slice!` deleting the default value of the hash.
|
39
|
+
|
40
|
+
*Antonio Santos*
|
41
|
+
|
42
|
+
|
43
|
+
## Rails 4.0.3 (February 18, 2014) ##
|
44
|
+
|
45
|
+
*No changes*
|
46
|
+
|
47
|
+
|
48
|
+
## Rails 4.0.2 (December 02, 2013) ##
|
49
|
+
|
50
|
+
*No changes*
|
51
|
+
|
52
|
+
|
1
53
|
## Rails 4.0.1 (November 01, 2013) ##
|
2
54
|
|
3
55
|
* Disable the ability to iterate over Range of AS::TimeWithZone
|
@@ -87,7 +87,7 @@ module ActiveSupport
|
|
87
87
|
instrument(:increment, name, :amount => amount) do
|
88
88
|
@data.incr(escape_key(namespaced_key(name, options)), amount)
|
89
89
|
end
|
90
|
-
rescue Dalli::DalliError
|
90
|
+
rescue Dalli::DalliError => e
|
91
91
|
logger.error("DalliError (#{e}): #{e.message}") if logger
|
92
92
|
nil
|
93
93
|
end
|
@@ -101,7 +101,7 @@ module ActiveSupport
|
|
101
101
|
instrument(:decrement, name, :amount => amount) do
|
102
102
|
@data.decr(escape_key(namespaced_key(name, options)), amount)
|
103
103
|
end
|
104
|
-
rescue Dalli::DalliError
|
104
|
+
rescue Dalli::DalliError => e
|
105
105
|
logger.error("DalliError (#{e}): #{e.message}") if logger
|
106
106
|
nil
|
107
107
|
end
|
@@ -6,14 +6,14 @@ require 'active_support/core_ext/kernel/reporting'
|
|
6
6
|
require 'active_support/core_ext/kernel/singleton_class'
|
7
7
|
|
8
8
|
module ActiveSupport
|
9
|
-
# Callbacks are code hooks that are run at key points in an object's
|
9
|
+
# Callbacks are code hooks that are run at key points in an object's life cycle.
|
10
10
|
# The typical use case is to have a base class define a set of callbacks
|
11
11
|
# relevant to the other functionality it supplies, so that subclasses can
|
12
12
|
# install callbacks that enhance or modify the base functionality without
|
13
13
|
# needing to override or redefine methods of the base class.
|
14
14
|
#
|
15
15
|
# Mixing in this module allows you to define the events in the object's
|
16
|
-
#
|
16
|
+
# life cycle that will support callbacks (via +ClassMethods.define_callbacks+),
|
17
17
|
# set the instance methods, procs, or callback objects to be called (via
|
18
18
|
# +ClassMethods.set_callback+), and run the installed callbacks at the
|
19
19
|
# appropriate times (via +run_callbacks+).
|
@@ -495,7 +495,7 @@ module ActiveSupport
|
|
495
495
|
__reset_runner(symbol)
|
496
496
|
end
|
497
497
|
|
498
|
-
# Define sets of events in the object
|
498
|
+
# Define sets of events in the object life cycle that support callbacks.
|
499
499
|
#
|
500
500
|
# define_callbacks :validate
|
501
501
|
# define_callbacks :initialize, :save, :destroy
|
@@ -19,8 +19,10 @@ class Date
|
|
19
19
|
# Ruby 1.9 has Date#to_time which converts to localtime only.
|
20
20
|
remove_method :to_time
|
21
21
|
|
22
|
-
# Ruby 1.9 has Date#xmlschema which converts to a string without the time
|
23
|
-
|
22
|
+
# Ruby 1.9 has Date#xmlschema which converts to a string without the time
|
23
|
+
# component. This removal may generate an issue on FreeBSD, that's why we
|
24
|
+
# need to use remove_possible_method here
|
25
|
+
remove_possible_method :xmlschema
|
24
26
|
|
25
27
|
# Convert to a formatted string. See DATE_FORMATS for predefined formats.
|
26
28
|
#
|
@@ -36,12 +38,12 @@ class Date
|
|
36
38
|
# date.to_formatted_s(:long_ordinal) # => "November 10th, 2007"
|
37
39
|
# date.to_formatted_s(:rfc822) # => "10 Nov 2007"
|
38
40
|
#
|
39
|
-
# == Adding your own
|
41
|
+
# == Adding your own date formats to to_formatted_s
|
40
42
|
# You can add your own formats to the Date::DATE_FORMATS hash.
|
41
43
|
# Use the format name as the hash key and either a strftime string
|
42
44
|
# or Proc instance that takes a date argument as the value.
|
43
45
|
#
|
44
|
-
# # config/initializers/
|
46
|
+
# # config/initializers/date_formats.rb
|
45
47
|
# Date::DATE_FORMATS[:month_and_year] = '%B %Y'
|
46
48
|
# Date::DATE_FORMATS[:short_ordinal] = ->(date) { date.strftime("%B #{date.day.ordinalize}") }
|
47
49
|
def to_formatted_s(format = :default)
|
@@ -158,7 +158,11 @@ class DateTime
|
|
158
158
|
# Layers additional behavior on DateTime#<=> so that Time and
|
159
159
|
# ActiveSupport::TimeWithZone instances can be compared with a DateTime.
|
160
160
|
def <=>(other)
|
161
|
-
|
161
|
+
if other.respond_to? :to_datetime
|
162
|
+
super other.to_datetime
|
163
|
+
else
|
164
|
+
nil
|
165
|
+
end
|
162
166
|
end
|
163
167
|
|
164
168
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
class Integer
|
2
2
|
# Check whether the integer is evenly divisible by the argument.
|
3
3
|
#
|
4
|
-
# 0.multiple_of?(0)
|
5
|
-
# 6.multiple_of?(5)
|
6
|
-
# 10.multiple_of?(2)
|
4
|
+
# 0.multiple_of?(0) # => true
|
5
|
+
# 6.multiple_of?(5) # => false
|
6
|
+
# 10.multiple_of?(2) # => true
|
7
7
|
def multiple_of?(number)
|
8
8
|
number != 0 ? self % number == 0 : zero?
|
9
9
|
end
|
@@ -41,6 +41,8 @@ module Kernel
|
|
41
41
|
# end
|
42
42
|
#
|
43
43
|
# puts 'But this will'
|
44
|
+
#
|
45
|
+
# This method is not thread-safe.
|
44
46
|
def silence_stream(stream)
|
45
47
|
old_stream = stream.dup
|
46
48
|
stream.reopen(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL:' : '/dev/null')
|
@@ -48,6 +50,7 @@ module Kernel
|
|
48
50
|
yield
|
49
51
|
ensure
|
50
52
|
stream.reopen(old_stream)
|
53
|
+
old_stream.close
|
51
54
|
end
|
52
55
|
|
53
56
|
# Blocks and ignores any exception passed as argument if raised within the block.
|
@@ -99,6 +102,8 @@ module Kernel
|
|
99
102
|
# Silences both STDOUT and STDERR, even for subprocesses.
|
100
103
|
#
|
101
104
|
# quietly { system 'bundle install' }
|
105
|
+
#
|
106
|
+
# This method is not thread-safe.
|
102
107
|
def quietly
|
103
108
|
silence_stream(STDOUT) do
|
104
109
|
silence_stream(STDERR) do
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'active_support/core_ext/module/aliasing'
|
2
|
-
require 'active_support/core_ext/object/acts_like'
|
3
2
|
|
4
3
|
class Range #:nodoc:
|
5
4
|
|
@@ -17,7 +16,7 @@ class Range #:nodoc:
|
|
17
16
|
|
18
17
|
private
|
19
18
|
def ensure_iteration_allowed
|
20
|
-
if first.
|
19
|
+
if first.is_a?(Time)
|
21
20
|
raise TypeError, "can't iterate from #{first.class}"
|
22
21
|
end
|
23
22
|
end
|
@@ -101,6 +101,14 @@ module ActiveSupport
|
|
101
101
|
|
102
102
|
private
|
103
103
|
|
104
|
+
# We define it as a workaround to Ruby 2.0.0-p353 bug.
|
105
|
+
# For more information, check rails/rails#13055.
|
106
|
+
# It should be dropped once a new Ruby patch-level
|
107
|
+
# release after 2.0.0-p353 happens.
|
108
|
+
def ===(other) #:nodoc:
|
109
|
+
value === other
|
110
|
+
end
|
111
|
+
|
104
112
|
def method_missing(method, *args, &block) #:nodoc:
|
105
113
|
value.send(method, *args, &block)
|
106
114
|
end
|
@@ -227,6 +227,14 @@ module ActiveSupport
|
|
227
227
|
def deep_symbolize_keys; to_hash.deep_symbolize_keys end
|
228
228
|
def to_options!; self end
|
229
229
|
|
230
|
+
def select(*args, &block)
|
231
|
+
dup.tap { |hash| hash.select!(*args, &block) }
|
232
|
+
end
|
233
|
+
|
234
|
+
def reject(*args, &block)
|
235
|
+
dup.tap { |hash| hash.reject!(*args, &block) }
|
236
|
+
end
|
237
|
+
|
230
238
|
# Convert to a regular hash with string keys.
|
231
239
|
def to_hash
|
232
240
|
_new_hash= {}
|
@@ -8,6 +8,8 @@ module I18n
|
|
8
8
|
config.i18n.railties_load_path = []
|
9
9
|
config.i18n.load_path = []
|
10
10
|
config.i18n.fallbacks = ActiveSupport::OrderedOptions.new
|
11
|
+
# Enforce I18n to check the available locales when setting a locale.
|
12
|
+
config.i18n.enforce_available_locales = true
|
11
13
|
|
12
14
|
# Set the i18n configuration after initialization since a lot of
|
13
15
|
# configuration is still usually done in application initializers.
|
@@ -31,6 +33,12 @@ module I18n
|
|
31
33
|
|
32
34
|
fallbacks = app.config.i18n.delete(:fallbacks)
|
33
35
|
|
36
|
+
# Avoid issues with setting the default_locale by disabling available locales
|
37
|
+
# check while configuring.
|
38
|
+
enforce_available_locales = app.config.i18n.delete(:enforce_available_locales)
|
39
|
+
enforce_available_locales = I18n.enforce_available_locales unless I18n.enforce_available_locales.nil?
|
40
|
+
I18n.enforce_available_locales = false
|
41
|
+
|
34
42
|
app.config.i18n.each do |setting, value|
|
35
43
|
case setting
|
36
44
|
when :railties_load_path
|
@@ -44,6 +52,9 @@ module I18n
|
|
44
52
|
|
45
53
|
init_fallbacks(fallbacks) if fallbacks && validate_fallbacks(fallbacks)
|
46
54
|
|
55
|
+
# Restore available locales check so it will take place from now on.
|
56
|
+
I18n.enforce_available_locales = enforce_available_locales
|
57
|
+
|
47
58
|
reloader = ActiveSupport::FileUpdateChecker.new(I18n.load_path.dup){ I18n.reload! }
|
48
59
|
app.reloaders << reloader
|
49
60
|
ActionDispatch::Reloader.to_prepare { reloader.execute_if_updated }
|
@@ -234,7 +234,7 @@ class BigDecimal
|
|
234
234
|
# BigDecimal, it still has the chance to post-process the string and get the
|
235
235
|
# real value.
|
236
236
|
#
|
237
|
-
# Use <tt>ActiveSupport.
|
237
|
+
# Use <tt>ActiveSupport.encode_big_decimal_as_string = true</tt> to
|
238
238
|
# override this behavior.
|
239
239
|
def as_json(options = nil) #:nodoc:
|
240
240
|
if finite?
|
@@ -107,21 +107,18 @@ module ActiveSupport
|
|
107
107
|
end
|
108
108
|
|
109
109
|
class Timed < Evented
|
110
|
-
def initialize(pattern, delegate)
|
111
|
-
@timestack = []
|
112
|
-
super
|
113
|
-
end
|
114
|
-
|
115
110
|
def publish(name, *args)
|
116
111
|
@delegate.call name, *args
|
117
112
|
end
|
118
113
|
|
119
114
|
def start(name, id, payload)
|
120
|
-
|
115
|
+
timestack = Thread.current[:_timestack] ||= []
|
116
|
+
timestack.push Time.now
|
121
117
|
end
|
122
118
|
|
123
119
|
def finish(name, id, payload)
|
124
|
-
|
120
|
+
timestack = Thread.current[:_timestack]
|
121
|
+
started = timestack.pop
|
125
122
|
@delegate.call(name, started, Time.now, id, payload)
|
126
123
|
end
|
127
124
|
end
|
@@ -28,6 +28,14 @@ module ActiveSupport
|
|
28
28
|
coder.represent_seq '!omap', map { |k,v| { k => v } }
|
29
29
|
end
|
30
30
|
|
31
|
+
def select(*args, &block)
|
32
|
+
dup.tap { |hash| hash.select!(*args, &block) }
|
33
|
+
end
|
34
|
+
|
35
|
+
def reject(*args, &block)
|
36
|
+
dup.tap { |hash| hash.reject!(*args, &block) }
|
37
|
+
end
|
38
|
+
|
31
39
|
def nested_under_indifferent_access
|
32
40
|
self
|
33
41
|
end
|
@@ -19,18 +19,17 @@ module ActiveSupport
|
|
19
19
|
result
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
deprecations << message
|
28
|
-
end
|
29
|
-
result = yield
|
30
|
-
[result, deprecations]
|
31
|
-
ensure
|
32
|
-
ActiveSupport::Deprecation.behavior = old_behavior
|
22
|
+
def collect_deprecations
|
23
|
+
old_behavior = ActiveSupport::Deprecation.behavior
|
24
|
+
deprecations = []
|
25
|
+
ActiveSupport::Deprecation.behavior = Proc.new do |message, callstack|
|
26
|
+
deprecations << message
|
33
27
|
end
|
28
|
+
result = yield
|
29
|
+
[result, deprecations]
|
30
|
+
ensure
|
31
|
+
ActiveSupport::Deprecation.behavior = old_behavior
|
32
|
+
end
|
34
33
|
end
|
35
34
|
end
|
36
35
|
end
|
@@ -147,7 +147,7 @@ module ActiveSupport
|
|
147
147
|
#
|
148
148
|
# # With ActiveSupport::JSON::Encoding.use_standard_json_time_format = true
|
149
149
|
# Time.utc(2005,2,1,15,15,10).in_time_zone.to_json
|
150
|
-
# # => "2005-02-01T15:15:
|
150
|
+
# # => "2005-02-01T15:15:10.000Z"
|
151
151
|
#
|
152
152
|
# # With ActiveSupport::JSON::Encoding.use_standard_json_time_format = false
|
153
153
|
# Time.utc(2005,2,1,15,15,10).in_time_zone.to_json
|
@@ -232,6 +232,7 @@ module ActiveSupport
|
|
232
232
|
# Compare this time zone to the parameter. The two are compared first on
|
233
233
|
# their offsets, and then by name.
|
234
234
|
def <=>(zone)
|
235
|
+
return unless zone.respond_to? :utc_offset
|
235
236
|
result = (utc_offset <=> zone.utc_offset)
|
236
237
|
result = (name <=> zone.name) if result == 0
|
237
238
|
result
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'time'
|
2
2
|
require 'base64'
|
3
|
+
require 'bigdecimal'
|
3
4
|
require 'active_support/core_ext/module/delegation'
|
4
5
|
require 'active_support/core_ext/string/inflections'
|
6
|
+
require 'active_support/core_ext/date_time/calculations'
|
5
7
|
|
6
8
|
module ActiveSupport
|
7
9
|
# = XmlMini
|
@@ -56,13 +58,13 @@ module ActiveSupport
|
|
56
58
|
# TODO use regexp instead of Date.parse
|
57
59
|
unless defined?(PARSING)
|
58
60
|
PARSING = {
|
59
|
-
"symbol" => Proc.new { |symbol| symbol.to_sym },
|
61
|
+
"symbol" => Proc.new { |symbol| symbol.to_s.to_sym },
|
60
62
|
"date" => Proc.new { |date| ::Date.parse(date) },
|
61
63
|
"datetime" => Proc.new { |time| Time.xmlschema(time).utc rescue ::DateTime.parse(time).utc },
|
62
64
|
"integer" => Proc.new { |integer| integer.to_i },
|
63
65
|
"float" => Proc.new { |float| float.to_f },
|
64
66
|
"decimal" => Proc.new { |number| BigDecimal(number) },
|
65
|
-
"boolean" => Proc.new { |boolean| %w(1 true).include?(boolean.strip) },
|
67
|
+
"boolean" => Proc.new { |boolean| %w(1 true).include?(boolean.to_s.strip) },
|
66
68
|
"string" => Proc.new { |string| string.to_s },
|
67
69
|
"yaml" => Proc.new { |yaml| YAML::load(yaml) rescue yaml },
|
68
70
|
"base64Binary" => Proc.new { |bin| ::Base64.decode64(bin) },
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activesupport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.4.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '0.6'
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.6.
|
22
|
+
version: 0.6.9
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '0.6'
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.6.
|
32
|
+
version: 0.6.9
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: multi_json
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -317,12 +317,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
317
317
|
version: 1.9.3
|
318
318
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
319
319
|
requirements:
|
320
|
-
- - "
|
320
|
+
- - ">"
|
321
321
|
- !ruby/object:Gem::Version
|
322
|
-
version:
|
322
|
+
version: 1.3.1
|
323
323
|
requirements: []
|
324
324
|
rubyforge_project:
|
325
|
-
rubygems_version: 2.2.
|
325
|
+
rubygems_version: 2.2.2
|
326
326
|
signing_key:
|
327
327
|
specification_version: 4
|
328
328
|
summary: A toolkit of support libraries and Ruby core extensions extracted from the
|