activesupport 5.0.1 → 5.0.2.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 +17 -0
- data/lib/active_support/core_ext/hash/compact.rb +19 -15
- data/lib/active_support/core_ext/hash/transform_values.rb +2 -2
- data/lib/active_support/core_ext/marshal.rb +2 -2
- data/lib/active_support/core_ext/module/introspection.rb +4 -2
- data/lib/active_support/core_ext/numeric/conversions.rb +16 -17
- data/lib/active_support/core_ext/object/duplicable.rb +59 -33
- data/lib/active_support/gem_version.rb +2 -2
- data/lib/active_support/gzip.rb +1 -1
- data/lib/active_support/hash_with_indifferent_access.rb +9 -0
- data/lib/active_support/inflector/methods.rb +1 -1
- data/lib/active_support/json/encoding.rb +1 -1
- data/lib/active_support/message_encryptor.rb +4 -4
- data/lib/active_support/testing/autorun.rb +2 -2
- data/lib/active_support/testing/time_helpers.rb +5 -5
- data/lib/active_support/time_with_zone.rb +2 -1
- data/lib/active_support/xml_mini.rb +13 -3
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84ee84b518cd5d01572e17aa2459eb4b574e9f44
|
4
|
+
data.tar.gz: 93cdb19e7e5433f311a74976c252936fd8f9e424
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccdcffd35ec75b325c71108bba8f7d4bb5f2af68f6779387efdb8a0b6054e7cb4719d29646e0277c72f02e3b330798978fdd5cd34dfbf8d2ad951c4f761d0279
|
7
|
+
data.tar.gz: ac6fa11430bcb7eb7097a98ee048d18ce8ed1cd595cd199d28ec67ea01747cd9eba993a6c4c450db1138b8a864a359de504d87385388edd248936849d5627f08
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
## Rails 5.0.2.rc1 (February 24, 2017) ##
|
2
|
+
|
3
|
+
* In Core Extensions, make `MarshalWithAutoloading#load` pass through the second, optional
|
4
|
+
argument for `Marshal#load( source [, proc] )`. This way we don't have to do
|
5
|
+
`Marshal.method(:load).super_method.call(sourse, proc)` just to be able to pass a proc.
|
6
|
+
|
7
|
+
*Jeff Latz*
|
8
|
+
|
9
|
+
* `ActiveSupport::Gzip.decompress` now checks checksum and length in footer.
|
10
|
+
|
11
|
+
*Dylan Thacker-Smith*
|
12
|
+
|
13
|
+
* Cache `ActiveSupport::TimeWithZone#to_datetime` before freezing.
|
14
|
+
|
15
|
+
*Adam Rice*
|
16
|
+
|
17
|
+
|
1
18
|
## Rails 5.0.1 (December 21, 2016) ##
|
2
19
|
|
3
20
|
* No changes.
|
@@ -1,20 +1,24 @@
|
|
1
1
|
class Hash
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
2
|
+
unless Hash.instance_methods(false).include?(:compact)
|
3
|
+
# Returns a hash with non +nil+ values.
|
4
|
+
#
|
5
|
+
# hash = { a: true, b: false, c: nil}
|
6
|
+
# hash.compact # => { a: true, b: false}
|
7
|
+
# hash # => { a: true, b: false, c: nil}
|
8
|
+
# { c: nil }.compact # => {}
|
9
|
+
def compact
|
10
|
+
self.select { |_, value| !value.nil? }
|
11
|
+
end
|
10
12
|
end
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
unless Hash.instance_methods(false).include?(:compact!)
|
15
|
+
# Replaces current hash with non +nil+ values.
|
16
|
+
#
|
17
|
+
# hash = { a: true, b: false, c: nil}
|
18
|
+
# hash.compact! # => { a: true, b: false}
|
19
|
+
# hash # => { a: true, b: false}
|
20
|
+
def compact!
|
21
|
+
self.reject! { |_, value| value.nil? }
|
22
|
+
end
|
19
23
|
end
|
20
24
|
end
|
@@ -16,7 +16,7 @@ class Hash
|
|
16
16
|
result[key] = yield(value)
|
17
17
|
end
|
18
18
|
result
|
19
|
-
end
|
19
|
+
end unless method_defined? :transform_values
|
20
20
|
|
21
21
|
# Destructively converts all values using the +block+ operations.
|
22
22
|
# Same as +transform_values+ but modifies +self+.
|
@@ -25,5 +25,5 @@ class Hash
|
|
25
25
|
each do |key, value|
|
26
26
|
self[key] = yield(value)
|
27
27
|
end
|
28
|
-
end
|
28
|
+
end unless method_defined? :transform_values!
|
29
29
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module ActiveSupport
|
2
2
|
module MarshalWithAutoloading # :nodoc:
|
3
|
-
def load(source)
|
4
|
-
super(source)
|
3
|
+
def load(source, proc = nil)
|
4
|
+
super(source, proc)
|
5
5
|
rescue ArgumentError, NameError => exc
|
6
6
|
if exc.message.match(%r|undefined class/module (.+?)(?:::)?\z|)
|
7
7
|
# try loading the class/module
|
@@ -5,10 +5,12 @@ class Module
|
|
5
5
|
#
|
6
6
|
# M::N.parent_name # => "M"
|
7
7
|
def parent_name
|
8
|
-
if defined?
|
8
|
+
if defined?(@parent_name)
|
9
9
|
@parent_name
|
10
10
|
else
|
11
|
-
|
11
|
+
parent_name = name =~ /::[^:]+\Z/ ? $`.freeze : nil
|
12
|
+
@parent_name = parent_name unless frozen?
|
13
|
+
parent_name
|
12
14
|
end
|
13
15
|
end
|
14
16
|
|
@@ -100,31 +100,30 @@ module ActiveSupport::NumericWithFormat
|
|
100
100
|
# 1234567.to_s(:human, precision: 1,
|
101
101
|
# separator: ',',
|
102
102
|
# significant: false) # => "1,2 Million"
|
103
|
-
def to_s(
|
104
|
-
format, options = args
|
105
|
-
options ||= {}
|
106
|
-
|
103
|
+
def to_s(format = nil, options = nil)
|
107
104
|
case format
|
105
|
+
when nil
|
106
|
+
super()
|
107
|
+
when Integer, String
|
108
|
+
super(format)
|
108
109
|
when :phone
|
109
|
-
return ActiveSupport::NumberHelper.number_to_phone(self, options)
|
110
|
+
return ActiveSupport::NumberHelper.number_to_phone(self, options || {})
|
110
111
|
when :currency
|
111
|
-
return ActiveSupport::NumberHelper.number_to_currency(self, options)
|
112
|
+
return ActiveSupport::NumberHelper.number_to_currency(self, options || {})
|
112
113
|
when :percentage
|
113
|
-
return ActiveSupport::NumberHelper.number_to_percentage(self, options)
|
114
|
+
return ActiveSupport::NumberHelper.number_to_percentage(self, options || {})
|
114
115
|
when :delimited
|
115
|
-
return ActiveSupport::NumberHelper.number_to_delimited(self, options)
|
116
|
+
return ActiveSupport::NumberHelper.number_to_delimited(self, options || {})
|
116
117
|
when :rounded
|
117
|
-
return ActiveSupport::NumberHelper.number_to_rounded(self, options)
|
118
|
+
return ActiveSupport::NumberHelper.number_to_rounded(self, options || {})
|
118
119
|
when :human
|
119
|
-
return ActiveSupport::NumberHelper.number_to_human(self, options)
|
120
|
+
return ActiveSupport::NumberHelper.number_to_human(self, options || {})
|
120
121
|
when :human_size
|
121
|
-
return ActiveSupport::NumberHelper.number_to_human_size(self, options)
|
122
|
+
return ActiveSupport::NumberHelper.number_to_human_size(self, options || {})
|
123
|
+
when Symbol
|
124
|
+
super()
|
122
125
|
else
|
123
|
-
|
124
|
-
super()
|
125
|
-
else
|
126
|
-
super
|
127
|
-
end
|
126
|
+
super(format)
|
128
127
|
end
|
129
128
|
end
|
130
129
|
|
@@ -135,7 +134,7 @@ module ActiveSupport::NumericWithFormat
|
|
135
134
|
end
|
136
135
|
|
137
136
|
# Ruby 2.4+ unifies Fixnum & Bignum into Integer.
|
138
|
-
if
|
137
|
+
if 0.class == Integer
|
139
138
|
Integer.prepend ActiveSupport::NumericWithFormat
|
140
139
|
else
|
141
140
|
Fixnum.prepend ActiveSupport::NumericWithFormat
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#--
|
2
|
-
# Most objects are cloneable, but not all. For example you can't dup
|
2
|
+
# Most objects are cloneable, but not all. For example you can't dup methods:
|
3
3
|
#
|
4
|
-
#
|
4
|
+
# method(:puts).dup # => TypeError: allocator undefined for Method
|
5
5
|
#
|
6
6
|
# Classes may signal their instances are not duplicable removing +dup+/+clone+
|
7
7
|
# or raising exceptions from them. So, to dup an arbitrary object you normally
|
@@ -19,7 +19,7 @@
|
|
19
19
|
class Object
|
20
20
|
# Can you safely dup this object?
|
21
21
|
#
|
22
|
-
# False for
|
22
|
+
# False for method objects;
|
23
23
|
# true otherwise.
|
24
24
|
def duplicable?
|
25
25
|
true
|
@@ -27,52 +27,78 @@ class Object
|
|
27
27
|
end
|
28
28
|
|
29
29
|
class NilClass
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
30
|
+
begin
|
31
|
+
nil.dup
|
32
|
+
rescue TypeError
|
33
|
+
|
34
|
+
# +nil+ is not duplicable:
|
35
|
+
#
|
36
|
+
# nil.duplicable? # => false
|
37
|
+
# nil.dup # => TypeError: can't dup NilClass
|
38
|
+
def duplicable?
|
39
|
+
false
|
40
|
+
end
|
36
41
|
end
|
37
42
|
end
|
38
43
|
|
39
44
|
class FalseClass
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
45
|
+
begin
|
46
|
+
false.dup
|
47
|
+
rescue TypeError
|
48
|
+
|
49
|
+
# +false+ is not duplicable:
|
50
|
+
#
|
51
|
+
# false.duplicable? # => false
|
52
|
+
# false.dup # => TypeError: can't dup FalseClass
|
53
|
+
def duplicable?
|
54
|
+
false
|
55
|
+
end
|
46
56
|
end
|
47
57
|
end
|
48
58
|
|
49
59
|
class TrueClass
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
60
|
+
begin
|
61
|
+
true.dup
|
62
|
+
rescue TypeError
|
63
|
+
|
64
|
+
# +true+ is not duplicable:
|
65
|
+
#
|
66
|
+
# true.duplicable? # => false
|
67
|
+
# true.dup # => TypeError: can't dup TrueClass
|
68
|
+
def duplicable?
|
69
|
+
false
|
70
|
+
end
|
56
71
|
end
|
57
72
|
end
|
58
73
|
|
59
74
|
class Symbol
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
75
|
+
begin
|
76
|
+
:symbol.dup # Ruby 2.4.x.
|
77
|
+
'symbol_from_string'.to_sym.dup # Some symbols can't `dup` in Ruby 2.4.0.
|
78
|
+
rescue TypeError
|
79
|
+
|
80
|
+
# Symbols are not duplicable:
|
81
|
+
#
|
82
|
+
# :my_symbol.duplicable? # => false
|
83
|
+
# :my_symbol.dup # => TypeError: can't dup Symbol
|
84
|
+
def duplicable?
|
85
|
+
false
|
86
|
+
end
|
66
87
|
end
|
67
88
|
end
|
68
89
|
|
69
90
|
class Numeric
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
91
|
+
begin
|
92
|
+
1.dup
|
93
|
+
rescue TypeError
|
94
|
+
|
95
|
+
# Numbers are not duplicable:
|
96
|
+
#
|
97
|
+
# 3.duplicable? # => false
|
98
|
+
# 3.dup # => TypeError: can't dup Integer
|
99
|
+
def duplicable?
|
100
|
+
false
|
101
|
+
end
|
76
102
|
end
|
77
103
|
end
|
78
104
|
|
data/lib/active_support/gzip.rb
CHANGED
@@ -274,6 +274,15 @@ module ActiveSupport
|
|
274
274
|
dup.tap { |hash| hash.reject!(*args, &block) }
|
275
275
|
end
|
276
276
|
|
277
|
+
def transform_values(*args, &block)
|
278
|
+
return to_enum(:transform_values) unless block_given?
|
279
|
+
dup.tap { |hash| hash.transform_values!(*args, &block) }
|
280
|
+
end
|
281
|
+
|
282
|
+
def compact
|
283
|
+
dup.tap(&:compact!)
|
284
|
+
end
|
285
|
+
|
277
286
|
# Convert to a regular hash with string keys.
|
278
287
|
def to_hash
|
279
288
|
_new_hash = Hash.new
|
@@ -273,7 +273,7 @@ module ActiveSupport
|
|
273
273
|
|
274
274
|
# Go down the ancestors to check if it is owned directly. The check
|
275
275
|
# stops when we reach Object or the end of ancestors tree.
|
276
|
-
constant = constant.ancestors.inject do |const, ancestor|
|
276
|
+
constant = constant.ancestors.inject(constant) do |const, ancestor|
|
277
277
|
break const if ancestor == Object
|
278
278
|
break ancestor if ancestor.const_defined?(name, false)
|
279
279
|
const
|
@@ -13,10 +13,10 @@ module ActiveSupport
|
|
13
13
|
# where you don't want users to be able to determine the value of the payload.
|
14
14
|
#
|
15
15
|
# salt = SecureRandom.random_bytes(64)
|
16
|
-
# key = ActiveSupport::KeyGenerator.new('password').generate_key(salt) # => "\x89\xE0\x156\xAC..."
|
17
|
-
# crypt = ActiveSupport::MessageEncryptor.new(key)
|
18
|
-
# encrypted_data = crypt.encrypt_and_sign('my secret data')
|
19
|
-
# crypt.decrypt_and_verify(encrypted_data)
|
16
|
+
# key = ActiveSupport::KeyGenerator.new('password').generate_key(salt, 32) # => "\x89\xE0\x156\xAC..."
|
17
|
+
# crypt = ActiveSupport::MessageEncryptor.new(key) # => #<ActiveSupport::MessageEncryptor ...>
|
18
|
+
# encrypted_data = crypt.encrypt_and_sign('my secret data') # => "NlFBTTMwOUV5UlA1QlNEN2xkY2d6eThYWWh..."
|
19
|
+
# crypt.decrypt_and_verify(encrypted_data) # => "my secret data"
|
20
20
|
class MessageEncryptor
|
21
21
|
DEFAULT_CIPHER = "aes-256-cbc"
|
22
22
|
|
@@ -7,7 +7,7 @@ module ActiveSupport
|
|
7
7
|
@stubs = {}
|
8
8
|
end
|
9
9
|
|
10
|
-
def stub_object(object, method_name,
|
10
|
+
def stub_object(object, method_name, &block)
|
11
11
|
key = [object.object_id, method_name]
|
12
12
|
|
13
13
|
if stub = @stubs[key]
|
@@ -19,7 +19,7 @@ module ActiveSupport
|
|
19
19
|
@stubs[key] = Stub.new(object, method_name, new_name)
|
20
20
|
|
21
21
|
object.singleton_class.send :alias_method, new_name, method_name
|
22
|
-
object.define_singleton_method(method_name)
|
22
|
+
object.define_singleton_method(method_name, &block)
|
23
23
|
end
|
24
24
|
|
25
25
|
def unstub_all!
|
@@ -99,9 +99,9 @@ module ActiveSupport
|
|
99
99
|
now = date_or_time.to_time.change(usec: 0)
|
100
100
|
end
|
101
101
|
|
102
|
-
simple_stubs.stub_object(Time, :now
|
103
|
-
simple_stubs.stub_object(Date, :today
|
104
|
-
simple_stubs.stub_object(DateTime, :now, now.
|
102
|
+
simple_stubs.stub_object(Time, :now) { at(now.to_i) }
|
103
|
+
simple_stubs.stub_object(Date, :today) { jd(now.to_date.jd) }
|
104
|
+
simple_stubs.stub_object(DateTime, :now) { jd(now.to_date.jd, now.hour, now.min, now.sec, Rational(now.utc_offset, 86400)) }
|
105
105
|
|
106
106
|
if block_given?
|
107
107
|
begin
|
@@ -48,8 +48,8 @@ module ActiveSupport
|
|
48
48
|
}
|
49
49
|
|
50
50
|
# No need to map these on Ruby 2.4+
|
51
|
-
TYPE_NAMES["Fixnum"] = "integer" unless
|
52
|
-
TYPE_NAMES["Bignum"] = "integer" unless
|
51
|
+
TYPE_NAMES["Fixnum"] = "integer" unless 0.class == Integer
|
52
|
+
TYPE_NAMES["Bignum"] = "integer" unless 0.class == Integer
|
53
53
|
end
|
54
54
|
|
55
55
|
FORMATTING = {
|
@@ -68,7 +68,17 @@ module ActiveSupport
|
|
68
68
|
"datetime" => Proc.new { |time| Time.xmlschema(time).utc rescue ::DateTime.parse(time).utc },
|
69
69
|
"integer" => Proc.new { |integer| integer.to_i },
|
70
70
|
"float" => Proc.new { |float| float.to_f },
|
71
|
-
"decimal" => Proc.new
|
71
|
+
"decimal" => Proc.new do |number|
|
72
|
+
if String === number
|
73
|
+
begin
|
74
|
+
BigDecimal(number)
|
75
|
+
rescue ArgumentError
|
76
|
+
BigDecimal('0')
|
77
|
+
end
|
78
|
+
else
|
79
|
+
BigDecimal(number)
|
80
|
+
end
|
81
|
+
end,
|
72
82
|
"boolean" => Proc.new { |boolean| %w(1 true).include?(boolean.to_s.strip) },
|
73
83
|
"string" => Proc.new { |string| string.to_s },
|
74
84
|
"yaml" => Proc.new { |yaml| YAML::load(yaml) rescue yaml },
|
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.0.
|
4
|
+
version: 5.0.2.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:
|
11
|
+
date: 2017-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -331,15 +331,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
331
331
|
version: 2.2.2
|
332
332
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
333
333
|
requirements:
|
334
|
-
- - "
|
334
|
+
- - ">"
|
335
335
|
- !ruby/object:Gem::Version
|
336
|
-
version:
|
336
|
+
version: 1.3.1
|
337
337
|
requirements: []
|
338
338
|
rubyforge_project:
|
339
|
-
rubygems_version: 2.
|
339
|
+
rubygems_version: 2.6.10
|
340
340
|
signing_key:
|
341
341
|
specification_version: 4
|
342
342
|
summary: A toolkit of support libraries and Ruby core extensions extracted from the
|
343
343
|
Rails framework.
|
344
344
|
test_files: []
|
345
|
-
has_rdoc:
|