activesupport 5.1.0.rc1 → 5.1.0.rc2
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 +29 -0
- data/lib/active_support/core_ext/enumerable.rb +45 -23
- data/lib/active_support/core_ext/module/delegation.rb +4 -1
- data/lib/active_support/deprecation.rb +1 -0
- data/lib/active_support/deprecation/constant_accessor.rb +50 -0
- data/lib/active_support/evented_file_update_checker.rb +5 -0
- data/lib/active_support/gem_version.rb +1 -1
- data/lib/active_support/notifications.rb +2 -0
- data/lib/active_support/testing/time_helpers.rb +1 -0
- data/lib/active_support/values/time_zone.rb +12 -5
- data/lib/active_support/xml_mini/libxml.rb +1 -3
- data/lib/active_support/xml_mini/libxmlsax.rb +1 -4
- data/lib/active_support/xml_mini/nokogiri.rb +1 -3
- data/lib/active_support/xml_mini/nokogirisax.rb +1 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e513c04158cd5eb4a0f3b2c1bc4883c9a418e50
|
4
|
+
data.tar.gz: abc66b41fb6d7303d844c5df29a8040c4b4aece0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8be1f941b6b37995a6ddccc7f89d8422a9c022e23dc92aa6396fd5413a39fc7b787bccbc4e5b8429ab72adda4109c3110d3151c6082d331c024b44a78e2e110f
|
7
|
+
data.tar.gz: 93e11dae71293b2c5e7e118ba17144f59eead8fcb99a8abe3938a99558e2bb784cd1d2356f56cbe6301fa1bc07573c9af0c7b6214a39f6c9417b64a8c6fa8768
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,32 @@
|
|
1
|
+
## Rails 5.1.0.rc2 (April 20, 2017) ##
|
2
|
+
|
3
|
+
* `ActiveSupport::EventedFileUpdateChecker` no longer listens to
|
4
|
+
directories outside of the application directory.
|
5
|
+
|
6
|
+
*radiospiel*
|
7
|
+
|
8
|
+
* Return unmapped timezones from `country_zones`
|
9
|
+
|
10
|
+
If a country doesn't exist in the MAPPINGS hash then create a new
|
11
|
+
`ActiveSupport::Timezone` instance using the supplied timezone id.
|
12
|
+
|
13
|
+
Fixes #28431.
|
14
|
+
|
15
|
+
*Andrew White*
|
16
|
+
|
17
|
+
* Add ActiveSupport::Deprecation::DeprecatedConstantAccessor
|
18
|
+
|
19
|
+
Provides transparent deprecation of constants, compatible with exceptions.
|
20
|
+
Example usage:
|
21
|
+
|
22
|
+
module Example
|
23
|
+
include ActiveSupport::Deprecation::DeprecatedConstantAccessor
|
24
|
+
deprecate_constant 'OldException', 'Elsewhere::NewException'
|
25
|
+
end
|
26
|
+
|
27
|
+
*Dominic Cleal*
|
28
|
+
|
29
|
+
|
1
30
|
## Rails 5.1.0.rc1 (March 20, 2017) ##
|
2
31
|
|
3
32
|
* Fixed bug in `DateAndTime::Compatibility#to_time` that caused it to
|
@@ -1,28 +1,50 @@
|
|
1
1
|
module Enumerable
|
2
|
-
#
|
2
|
+
# Enumerable#sum was added in Ruby 2.4 but it only works with Numeric elements
|
3
|
+
# when we omit an identity.
|
3
4
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
5
|
+
# We tried shimming it to attempt the fast native method, rescue TypeError,
|
6
|
+
# and fall back to the compatible implementation, but that's much slower than
|
7
|
+
# just calling the compat method in the first place.
|
8
|
+
if Enumerable.instance_methods(false).include?(:sum) && !((?a..?b).sum rescue false)
|
9
|
+
# We can't use Refinements here because Refinements with Module which will be prepended
|
10
|
+
# doesn't work well https://bugs.ruby-lang.org/issues/13446
|
11
|
+
alias :_original_sum_with_required_identity :sum
|
12
|
+
private :_original_sum_with_required_identity
|
13
|
+
# Calculates a sum from the elements.
|
14
|
+
#
|
15
|
+
# payments.sum { |p| p.price * p.tax_rate }
|
16
|
+
# payments.sum(&:price)
|
17
|
+
#
|
18
|
+
# The latter is a shortcut for:
|
19
|
+
#
|
20
|
+
# payments.inject(0) { |sum, p| sum + p.price }
|
21
|
+
#
|
22
|
+
# It can also calculate the sum without the use of a block.
|
23
|
+
#
|
24
|
+
# [5, 15, 10].sum # => 30
|
25
|
+
# ['foo', 'bar'].sum # => "foobar"
|
26
|
+
# [[1, 2], [3, 1, 5]].sum # => [1, 2, 3, 1, 5]
|
27
|
+
#
|
28
|
+
# The default sum of an empty list is zero. You can override this default:
|
29
|
+
#
|
30
|
+
# [].sum(Payment.new(0)) { |i| i.amount } # => Payment.new(0)
|
31
|
+
def sum(identity = nil, &block)
|
32
|
+
if identity
|
33
|
+
_original_sum_with_required_identity(identity, &block)
|
34
|
+
elsif block_given?
|
35
|
+
map(&block).sum(identity)
|
36
|
+
else
|
37
|
+
inject(:+) || 0
|
38
|
+
end
|
39
|
+
end
|
40
|
+
else
|
41
|
+
def sum(identity = nil, &block)
|
42
|
+
if block_given?
|
43
|
+
map(&block).sum(identity)
|
44
|
+
else
|
45
|
+
sum = identity ? inject(identity, :+) : inject(:+)
|
46
|
+
sum || identity || 0
|
47
|
+
end
|
26
48
|
end
|
27
49
|
end
|
28
50
|
|
@@ -267,7 +267,10 @@ class Module
|
|
267
267
|
|
268
268
|
module_eval <<-RUBY, __FILE__, __LINE__ + 1
|
269
269
|
def respond_to_missing?(name, include_private = false)
|
270
|
-
#
|
270
|
+
# It may look like an oversight, but we deliberately do not pass
|
271
|
+
# +include_private+, because they do not get delegated.
|
272
|
+
|
273
|
+
#{target}.respond_to?(name) || super
|
271
274
|
end
|
272
275
|
|
273
276
|
def method_missing(method, *args, &block)
|
@@ -15,6 +15,7 @@ module ActiveSupport
|
|
15
15
|
require "active_support/deprecation/instance_delegator"
|
16
16
|
require "active_support/deprecation/behaviors"
|
17
17
|
require "active_support/deprecation/reporting"
|
18
|
+
require "active_support/deprecation/constant_accessor"
|
18
19
|
require "active_support/deprecation/method_wrappers"
|
19
20
|
require "active_support/deprecation/proxy_wrappers"
|
20
21
|
require "active_support/core_ext/module/deprecation"
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "active_support/inflector/methods"
|
2
|
+
|
3
|
+
module ActiveSupport
|
4
|
+
class Deprecation
|
5
|
+
# DeprecatedConstantAccessor transforms a constant into a deprecated one by
|
6
|
+
# hooking +const_missing+.
|
7
|
+
#
|
8
|
+
# It takes the names of an old (deprecated) constant and of a new constant
|
9
|
+
# (both in string form) and optionally a deprecator. The deprecator defaults
|
10
|
+
# to +ActiveSupport::Deprecator+ if none is specified.
|
11
|
+
#
|
12
|
+
# The deprecated constant now returns the same object as the new one rather
|
13
|
+
# than a proxy object, so it can be used transparently in +rescue+ blocks
|
14
|
+
# etc.
|
15
|
+
#
|
16
|
+
# PLANETS = %w(mercury venus earth mars jupiter saturn uranus neptune pluto)
|
17
|
+
#
|
18
|
+
# (In a later update, the original implementation of `PLANETS` has been removed.)
|
19
|
+
#
|
20
|
+
# PLANETS_POST_2006 = %w(mercury venus earth mars jupiter saturn uranus neptune)
|
21
|
+
# include ActiveSupport::Deprecation::DeprecatedConstantAccessor
|
22
|
+
# deprecate_constant 'PLANETS', 'PLANETS_POST_2006'
|
23
|
+
#
|
24
|
+
# PLANETS.map { |planet| planet.capitalize }
|
25
|
+
# # => DEPRECATION WARNING: PLANETS is deprecated! Use PLANETS_POST_2006 instead.
|
26
|
+
# (Backtrace information…)
|
27
|
+
# ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"]
|
28
|
+
module DeprecatedConstantAccessor
|
29
|
+
def self.included(base)
|
30
|
+
extension = Module.new do
|
31
|
+
def const_missing(missing_const_name)
|
32
|
+
if class_variable_defined?(:@@_deprecated_constants)
|
33
|
+
if (replacement = class_variable_get(:@@_deprecated_constants)[missing_const_name.to_s])
|
34
|
+
replacement[:deprecator].warn(replacement[:message] || "#{name}::#{missing_const_name} is deprecated! Use #{replacement[:new]} instead.", caller_locations)
|
35
|
+
return ActiveSupport::Inflector.constantize(replacement[:new].to_s)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
super
|
39
|
+
end
|
40
|
+
|
41
|
+
def deprecate_constant(const_name, new_constant, message: nil, deprecator: ActiveSupport::Deprecation.instance)
|
42
|
+
class_variable_set(:@@_deprecated_constants, {}) unless class_variable_defined?(:@@_deprecated_constants)
|
43
|
+
class_variable_get(:@@_deprecated_constants)[const_name.to_s] = { new: new_constant, message: message, deprecator: deprecator }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
base.singleton_class.prepend extension
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -125,6 +125,11 @@ module ActiveSupport
|
|
125
125
|
dtw.compact!
|
126
126
|
dtw.uniq!
|
127
127
|
|
128
|
+
normalized_gem_paths = Gem.path.map { |path| File.join path, "" }
|
129
|
+
dtw = dtw.reject do |path|
|
130
|
+
normalized_gem_paths.any? { |gem_path| path.to_s.start_with?(gem_path) }
|
131
|
+
end
|
132
|
+
|
128
133
|
@ph.filter_out_descendants(dtw)
|
129
134
|
end
|
130
135
|
|
@@ -64,6 +64,8 @@ module ActiveSupport
|
|
64
64
|
# If an exception happens during that particular instrumentation the payload will
|
65
65
|
# have a key <tt>:exception</tt> with an array of two elements as value: a string with
|
66
66
|
# the name of the exception class, and the exception message.
|
67
|
+
# The <tt>:exception_object</tt> key of the payload will have the exception
|
68
|
+
# itself as the value.
|
67
69
|
#
|
68
70
|
# As the previous example depicts, the class <tt>ActiveSupport::Notifications::Event</tt>
|
69
71
|
# is able to take the arguments as they come and provide an object-oriented
|
@@ -250,14 +250,21 @@ module ActiveSupport
|
|
250
250
|
# for time zones in the country specified by its ISO 3166-1 Alpha2 code.
|
251
251
|
def country_zones(country_code)
|
252
252
|
code = country_code.to_s.upcase
|
253
|
-
@country_zones[code] ||=
|
254
|
-
TZInfo::Country.get(code).zone_identifiers.map do |tz_id|
|
255
|
-
name = MAPPING.key(tz_id)
|
256
|
-
name && self[name]
|
257
|
-
end.compact.sort!
|
253
|
+
@country_zones[code] ||= load_country_zones(code)
|
258
254
|
end
|
259
255
|
|
260
256
|
private
|
257
|
+
def load_country_zones(code)
|
258
|
+
country = TZInfo::Country.get(code)
|
259
|
+
country.zone_identifiers.map do |tz_id|
|
260
|
+
if MAPPING.value?(tz_id)
|
261
|
+
self[MAPPING.key(tz_id)]
|
262
|
+
else
|
263
|
+
create(tz_id, nil, TZInfo::Timezone.new(tz_id))
|
264
|
+
end
|
265
|
+
end.sort!
|
266
|
+
end
|
267
|
+
|
261
268
|
def zones_map
|
262
269
|
@zones_map ||= begin
|
263
270
|
MAPPING.each_key { |place| self[place] } # load all the zones
|
@@ -65,12 +65,9 @@ module ActiveSupport
|
|
65
65
|
data = StringIO.new(data || "")
|
66
66
|
end
|
67
67
|
|
68
|
-
|
69
|
-
if char.nil?
|
68
|
+
if data.eof?
|
70
69
|
{}
|
71
70
|
else
|
72
|
-
data.ungetc(char)
|
73
|
-
|
74
71
|
LibXML::XML::Error.set_handler(&LibXML::XML::Error::QUIET_HANDLER)
|
75
72
|
parser = LibXML::XML::SaxParser.io(data)
|
76
73
|
document = document_class.new
|
@@ -71,11 +71,9 @@ module ActiveSupport
|
|
71
71
|
data = StringIO.new(data || "")
|
72
72
|
end
|
73
73
|
|
74
|
-
|
75
|
-
if char.nil?
|
74
|
+
if data.eof?
|
76
75
|
{}
|
77
76
|
else
|
78
|
-
data.ungetc(char)
|
79
77
|
document = document_class.new
|
80
78
|
parser = Nokogiri::XML::SAX::Parser.new(document)
|
81
79
|
parser.parse(data)
|
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: 5.1.0.
|
4
|
+
version: 5.1.0.rc2
|
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: 2017-
|
11
|
+
date: 2017-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -220,6 +220,7 @@ files:
|
|
220
220
|
- lib/active_support/dependencies/interlock.rb
|
221
221
|
- lib/active_support/deprecation.rb
|
222
222
|
- lib/active_support/deprecation/behaviors.rb
|
223
|
+
- lib/active_support/deprecation/constant_accessor.rb
|
223
224
|
- lib/active_support/deprecation/instance_delegator.rb
|
224
225
|
- lib/active_support/deprecation/method_wrappers.rb
|
225
226
|
- lib/active_support/deprecation/proxy_wrappers.rb
|