activesupport 5.2.0.rc1 → 5.2.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 +37 -13
- data/README.rdoc +1 -1
- data/lib/active_support/cache.rb +16 -15
- data/lib/active_support/cache/redis_cache_store.rb +49 -48
- data/lib/active_support/cache/strategy/local_cache.rb +17 -0
- data/lib/active_support/callbacks.rb +2 -2
- data/lib/active_support/deprecation/behaviors.rb +1 -1
- data/lib/active_support/duration.rb +8 -0
- data/lib/active_support/gem_version.rb +1 -1
- data/lib/active_support/hash_with_indifferent_access.rb +8 -0
- data/lib/active_support/values/time_zone.rb +5 -2
- data/lib/active_support/xml_mini.rb +1 -1
- metadata +13 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1812312a643d64b718b7d411199d13a71949348238c9b5b31b6bf537cdffd472
|
4
|
+
data.tar.gz: c3caffc29248cb9137d707e6db92083d1669897a2d323c41735420f259fce54d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eec80019150e86c22e14aa189f2976394e650d20a6ab60186aff930ec07453ea17301065e459781169bd1681dc29e337186c39af2fb0aea4eb70c966c8efd56b
|
7
|
+
data.tar.gz: 5601cb1a255c5021276817cf534279ff90ca971c25065105c070b226742d12fc64b4bd119ee9ccc198c68aa9abe9e1e9df7c33bad7ff4dc647809796514097c7
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,27 @@
|
|
1
|
+
## Rails 5.2.0.rc2 (March 20, 2018) ##
|
2
|
+
|
3
|
+
* Caching: MemCache and Redis `read_multi` and `fetch_multi` speedup.
|
4
|
+
Read from the local in-memory cache before consulting the backend.
|
5
|
+
|
6
|
+
*Gabriel Sobrinho*
|
7
|
+
|
8
|
+
* Return all mappings for a timezone identifier in `country_zones`.
|
9
|
+
|
10
|
+
Some timezones like `Europe/London` have multiple mappings in
|
11
|
+
`ActiveSupport::TimeZone::MAPPING` so return all of them instead
|
12
|
+
of the first one found by using `Hash#value`. e.g:
|
13
|
+
|
14
|
+
# Before
|
15
|
+
ActiveSupport::TimeZone.country_zones("GB") # => ["Edinburgh"]
|
16
|
+
|
17
|
+
# After
|
18
|
+
ActiveSupport::TimeZone.country_zones("GB") # => ["Edinburgh", "London"]
|
19
|
+
|
20
|
+
Fixes #31668.
|
21
|
+
|
22
|
+
*Andrew White*
|
23
|
+
|
24
|
+
|
1
25
|
## Rails 5.2.0.rc1 (January 30, 2018) ##
|
2
26
|
|
3
27
|
* Add support for connection pooling on RedisCacheStore.
|
@@ -63,7 +87,7 @@
|
|
63
87
|
|
64
88
|
*Takumasa Ochi*
|
65
89
|
|
66
|
-
* Handle `TZInfo::AmbiguousTime` errors
|
90
|
+
* Handle `TZInfo::AmbiguousTime` errors.
|
67
91
|
|
68
92
|
Make `ActiveSupport::TimeWithZone` match Ruby's handling of ambiguous
|
69
93
|
times by choosing the later period, e.g.
|
@@ -142,7 +166,7 @@
|
|
142
166
|
|
143
167
|
*Jeremy Daer*
|
144
168
|
|
145
|
-
* Allow `Range#include?` on TWZ ranges
|
169
|
+
* Allow `Range#include?` on TWZ ranges.
|
146
170
|
|
147
171
|
In #11474 we prevented TWZ ranges being iterated over which matched
|
148
172
|
Ruby's handling of Time ranges and as a consequence `include?`
|
@@ -155,7 +179,7 @@
|
|
155
179
|
|
156
180
|
*Andrew White*
|
157
181
|
|
158
|
-
* Fix acronym support in `humanize
|
182
|
+
* Fix acronym support in `humanize`.
|
159
183
|
|
160
184
|
Acronym inflections are stored with lowercase keys in the hash but
|
161
185
|
the match wasn't being lowercased before being looked up in the hash.
|
@@ -283,7 +307,7 @@
|
|
283
307
|
|
284
308
|
*Yuji Yaginuma*
|
285
309
|
|
286
|
-
* Add key rotation support to `MessageEncryptor` and `MessageVerifier
|
310
|
+
* Add key rotation support to `MessageEncryptor` and `MessageVerifier`.
|
287
311
|
|
288
312
|
This change introduces a `rotate` method to both the `MessageEncryptor` and
|
289
313
|
`MessageVerifier` classes. This method accepts the same arguments and
|
@@ -322,7 +346,7 @@
|
|
322
346
|
|
323
347
|
*Anton Khamets*
|
324
348
|
|
325
|
-
* Update `String#camelize` to provide feedback when wrong option is passed
|
349
|
+
* Update `String#camelize` to provide feedback when wrong option is passed.
|
326
350
|
|
327
351
|
`String#camelize` was returning nil without any feedback when an
|
328
352
|
invalid option was passed as a parameter.
|
@@ -339,7 +363,7 @@
|
|
339
363
|
|
340
364
|
*Ricardo Díaz*
|
341
365
|
|
342
|
-
* Fix modulo operations involving durations
|
366
|
+
* Fix modulo operations involving durations.
|
343
367
|
|
344
368
|
Rails 5.1 introduced `ActiveSupport::Duration::Scalar` as a wrapper
|
345
369
|
around numeric values as a way of ensuring a duration was the outcome of
|
@@ -361,7 +385,7 @@
|
|
361
385
|
|
362
386
|
*Sayan Chakraborty*, *Andrew White*
|
363
387
|
|
364
|
-
* Fix division where a duration is the denominator
|
388
|
+
* Fix division where a duration is the denominator.
|
365
389
|
|
366
390
|
PR #29163 introduced a change in behavior when a duration was the denominator
|
367
391
|
in a calculation - this was incorrect as dividing by a duration should always
|
@@ -371,7 +395,7 @@
|
|
371
395
|
|
372
396
|
*Andrew White*
|
373
397
|
|
374
|
-
* Add purpose and expiry support to `ActiveSupport::MessageVerifier`
|
398
|
+
* Add purpose and expiry support to `ActiveSupport::MessageVerifier` and
|
375
399
|
`ActiveSupport::MessageEncryptor`.
|
376
400
|
|
377
401
|
For instance, to ensure a message is only usable for one intended purpose:
|
@@ -408,7 +432,7 @@
|
|
408
432
|
|
409
433
|
*Assain Jaleel*
|
410
434
|
|
411
|
-
* Cache: `write_multi
|
435
|
+
* Cache: `write_multi`.
|
412
436
|
|
413
437
|
Rails.cache.write_multi foo: 'bar', baz: 'qux'
|
414
438
|
|
@@ -457,7 +481,7 @@
|
|
457
481
|
|
458
482
|
*DHH*
|
459
483
|
|
460
|
-
* Fix implicit coercion calculations with scalars and durations
|
484
|
+
* Fix implicit coercion calculations with scalars and durations.
|
461
485
|
|
462
486
|
Previously, calculations where the scalar is first would be converted to a duration
|
463
487
|
of seconds, but this causes issues with dates being converted to times, e.g:
|
@@ -489,17 +513,17 @@
|
|
489
513
|
|
490
514
|
*Willem van Bergen*
|
491
515
|
|
492
|
-
* Add support for `:offset` and `:zone` to `ActiveSupport::TimeWithZone#change
|
516
|
+
* Add support for `:offset` and `:zone` to `ActiveSupport::TimeWithZone#change`.
|
493
517
|
|
494
518
|
*Andrew White*
|
495
519
|
|
496
|
-
* Add support for `:offset` to `Time#change
|
520
|
+
* Add support for `:offset` to `Time#change`.
|
497
521
|
|
498
522
|
Fixes #28723.
|
499
523
|
|
500
524
|
*Andrew White*
|
501
525
|
|
502
|
-
* Add `fetch_values` for `HashWithIndifferentAccess
|
526
|
+
* Add `fetch_values` for `HashWithIndifferentAccess`.
|
503
527
|
|
504
528
|
The method was originally added to `Hash` in Ruby 2.3.0.
|
505
529
|
|
data/README.rdoc
CHANGED
@@ -14,7 +14,7 @@ The latest version of Active Support can be installed with RubyGems:
|
|
14
14
|
|
15
15
|
Source code can be downloaded as part of the Rails project on GitHub:
|
16
16
|
|
17
|
-
* https://github.com/rails/rails/tree/
|
17
|
+
* https://github.com/rails/rails/tree/5-2-stable/activesupport
|
18
18
|
|
19
19
|
|
20
20
|
== License
|
data/lib/active_support/cache.rb
CHANGED
@@ -164,8 +164,8 @@ module ActiveSupport
|
|
164
164
|
private
|
165
165
|
def retrieve_pool_options(options)
|
166
166
|
{}.tap do |pool_options|
|
167
|
-
pool_options[:size] = options
|
168
|
-
pool_options[:timeout] = options
|
167
|
+
pool_options[:size] = options.delete(:pool_size) if options[:pool_size]
|
168
|
+
pool_options[:timeout] = options.delete(:pool_timeout) if options[:pool_timeout]
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
@@ -714,11 +714,9 @@ module ActiveSupport
|
|
714
714
|
# Creates a new cache entry for the specified value. Options supported are
|
715
715
|
# +:compress+, +:compress_threshold+, and +:expires_in+.
|
716
716
|
def initialize(value, options = {})
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
else
|
721
|
-
@value = value
|
717
|
+
@value = value
|
718
|
+
if should_compress?(options)
|
719
|
+
compress!
|
722
720
|
end
|
723
721
|
|
724
722
|
@version = options[:version]
|
@@ -783,28 +781,31 @@ module ActiveSupport
|
|
783
781
|
end
|
784
782
|
|
785
783
|
private
|
786
|
-
def should_compress?(
|
787
|
-
if value && options.fetch(:compress, true)
|
784
|
+
def should_compress?(options)
|
785
|
+
if @value && options.fetch(:compress, true)
|
788
786
|
compress_threshold = options.fetch(:compress_threshold, DEFAULT_COMPRESS_LIMIT)
|
789
|
-
serialized_value_size = (value.is_a?(String) ? value :
|
787
|
+
serialized_value_size = (@value.is_a?(String) ? @value : marshaled_value).bytesize
|
790
788
|
|
791
|
-
|
789
|
+
serialized_value_size >= compress_threshold
|
792
790
|
end
|
793
|
-
|
794
|
-
false
|
795
791
|
end
|
796
792
|
|
797
793
|
def compressed?
|
798
794
|
defined?(@compressed) ? @compressed : false
|
799
795
|
end
|
800
796
|
|
801
|
-
def compress
|
802
|
-
Zlib::Deflate.deflate(
|
797
|
+
def compress!
|
798
|
+
@value = Zlib::Deflate.deflate(marshaled_value)
|
799
|
+
@compressed = true
|
803
800
|
end
|
804
801
|
|
805
802
|
def uncompress(value)
|
806
803
|
Marshal.load(Zlib::Inflate.inflate(value))
|
807
804
|
end
|
805
|
+
|
806
|
+
def marshaled_value
|
807
|
+
@marshaled_value ||= Marshal.dump(@value)
|
808
|
+
end
|
808
809
|
end
|
809
810
|
end
|
810
811
|
end
|
@@ -17,6 +17,7 @@ end
|
|
17
17
|
|
18
18
|
require "digest/sha2"
|
19
19
|
require "active_support/core_ext/marshal"
|
20
|
+
require "active_support/core_ext/hash/transform_values"
|
20
21
|
|
21
22
|
module ActiveSupport
|
22
23
|
module Cache
|
@@ -27,23 +28,7 @@ module ActiveSupport
|
|
27
28
|
end
|
28
29
|
|
29
30
|
::Redis.include(ConnectionPoolLike)
|
30
|
-
|
31
|
-
class RedisDistributedWithConnectionPool < ::Redis::Distributed
|
32
|
-
def add_node(options)
|
33
|
-
pool_options = {}
|
34
|
-
pool_options[:size] = options[:pool_size] if options[:pool_size]
|
35
|
-
pool_options[:timeout] = options[:pool_timeout] if options[:pool_timeout]
|
36
|
-
|
37
|
-
if pool_options.empty?
|
38
|
-
super
|
39
|
-
else
|
40
|
-
options = { url: options } if options.is_a?(String)
|
41
|
-
options = @default_options.merge(options)
|
42
|
-
pool = ConnectionPool.new(pool_options) { ::Redis.new(options) }
|
43
|
-
@ring.add_node(pool)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
31
|
+
::Redis::Distributed.include(ConnectionPoolLike)
|
47
32
|
|
48
33
|
# Redis cache store.
|
49
34
|
#
|
@@ -94,7 +79,7 @@ module ActiveSupport
|
|
94
79
|
|
95
80
|
def write_entry(key, entry, options)
|
96
81
|
if options[:raw] && local_cache
|
97
|
-
raw_entry = Entry.new(entry
|
82
|
+
raw_entry = Entry.new(serialize_entry(entry, raw: true))
|
98
83
|
raw_entry.expires_at = entry.expires_at
|
99
84
|
super(key, raw_entry, options)
|
100
85
|
else
|
@@ -105,7 +90,7 @@ module ActiveSupport
|
|
105
90
|
def write_multi_entries(entries, options)
|
106
91
|
if options[:raw] && local_cache
|
107
92
|
raw_entries = entries.map do |key, entry|
|
108
|
-
raw_entry = Entry.new(entry
|
93
|
+
raw_entry = Entry.new(serialize_entry(entry, raw: true))
|
109
94
|
raw_entry.expires_at = entry.expires_at
|
110
95
|
end.to_h
|
111
96
|
|
@@ -134,7 +119,7 @@ module ActiveSupport
|
|
134
119
|
def build_redis(redis: nil, url: nil, **redis_options) #:nodoc:
|
135
120
|
urls = Array(url)
|
136
121
|
|
137
|
-
if redis.
|
122
|
+
if redis.is_a?(Proc)
|
138
123
|
redis.call
|
139
124
|
elsif redis
|
140
125
|
redis
|
@@ -147,7 +132,7 @@ module ActiveSupport
|
|
147
132
|
|
148
133
|
private
|
149
134
|
def build_redis_distributed_client(urls:, **redis_options)
|
150
|
-
|
135
|
+
::Redis::Distributed.new([], DEFAULT_REDIS_OPTIONS.merge(redis_options)).tap do |dist|
|
151
136
|
urls.each { |u| dist.add_node url: u }
|
152
137
|
end
|
153
138
|
end
|
@@ -174,7 +159,7 @@ module ActiveSupport
|
|
174
159
|
#
|
175
160
|
# Compression is enabled by default with a 1kB threshold, so cached
|
176
161
|
# values larger than 1kB are automatically compressed. Disable by
|
177
|
-
# passing <tt>
|
162
|
+
# passing <tt>compress: false</tt> or change the threshold by passing
|
178
163
|
# <tt>compress_threshold: 4.kilobytes</tt>.
|
179
164
|
#
|
180
165
|
# No expiry is set on cache entries by default. Redis is expected to
|
@@ -197,7 +182,16 @@ module ActiveSupport
|
|
197
182
|
end
|
198
183
|
|
199
184
|
def redis
|
200
|
-
@redis ||=
|
185
|
+
@redis ||= begin
|
186
|
+
pool_options = self.class.send(:retrieve_pool_options, redis_options)
|
187
|
+
|
188
|
+
if pool_options.any?
|
189
|
+
self.class.send(:ensure_connection_pool_added!)
|
190
|
+
::ConnectionPool.new(pool_options) { self.class.build_redis(**redis_options) }
|
191
|
+
else
|
192
|
+
self.class.build_redis(**redis_options)
|
193
|
+
end
|
194
|
+
end
|
201
195
|
end
|
202
196
|
|
203
197
|
def inspect
|
@@ -211,7 +205,11 @@ module ActiveSupport
|
|
211
205
|
# fetched values.
|
212
206
|
def read_multi(*names)
|
213
207
|
if mget_capable?
|
214
|
-
|
208
|
+
instrument(:read_multi, names, options) do |payload|
|
209
|
+
read_multi_mget(*names).tap do |results|
|
210
|
+
payload[:hits] = results.keys
|
211
|
+
end
|
212
|
+
end
|
215
213
|
else
|
216
214
|
super
|
217
215
|
end
|
@@ -308,21 +306,6 @@ module ActiveSupport
|
|
308
306
|
end
|
309
307
|
|
310
308
|
private
|
311
|
-
def wrap_in_connection_pool(redis_connection)
|
312
|
-
if redis_connection.is_a?(::Redis)
|
313
|
-
pool_options = self.class.send(:retrieve_pool_options, redis_options)
|
314
|
-
|
315
|
-
if pool_options.empty?
|
316
|
-
redis_connection
|
317
|
-
else
|
318
|
-
self.class.send(:ensure_connection_pool_added!)
|
319
|
-
ConnectionPool.new(pool_options) { redis_connection }
|
320
|
-
end
|
321
|
-
else
|
322
|
-
redis_connection
|
323
|
-
end
|
324
|
-
end
|
325
|
-
|
326
309
|
def set_redis_capabilities
|
327
310
|
case redis
|
328
311
|
when Redis::Distributed
|
@@ -342,6 +325,14 @@ module ActiveSupport
|
|
342
325
|
end
|
343
326
|
end
|
344
327
|
|
328
|
+
def read_multi_entries(names, _options)
|
329
|
+
if mget_capable?
|
330
|
+
read_multi_mget(*names)
|
331
|
+
else
|
332
|
+
super
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
345
336
|
def read_multi_mget(*names)
|
346
337
|
options = names.extract_options!
|
347
338
|
options = merged_options(options)
|
@@ -366,7 +357,7 @@ module ActiveSupport
|
|
366
357
|
#
|
367
358
|
# Requires Redis 2.6.12+ for extended SET options.
|
368
359
|
def write_entry(key, entry, unless_exist: false, raw: false, expires_in: nil, race_condition_ttl: nil, **options)
|
369
|
-
|
360
|
+
serialized_entry = serialize_entry(entry, raw: raw)
|
370
361
|
|
371
362
|
# If race condition TTL is in use, ensure that cache entries
|
372
363
|
# stick around a bit longer after they would have expired
|
@@ -381,9 +372,9 @@ module ActiveSupport
|
|
381
372
|
modifiers[:nx] = unless_exist
|
382
373
|
modifiers[:px] = (1000 * expires_in.to_f).ceil if expires_in
|
383
374
|
|
384
|
-
redis.with { |c| c.set key,
|
375
|
+
redis.with { |c| c.set key, serialized_entry, modifiers }
|
385
376
|
else
|
386
|
-
redis.with { |c| c.set key,
|
377
|
+
redis.with { |c| c.set key, serialized_entry }
|
387
378
|
end
|
388
379
|
end
|
389
380
|
end
|
@@ -400,7 +391,7 @@ module ActiveSupport
|
|
400
391
|
if entries.any?
|
401
392
|
if mset_capable? && expires_in.nil?
|
402
393
|
failsafe :write_multi_entries do
|
403
|
-
redis.with { |c| c.mapped_mset(entries) }
|
394
|
+
redis.with { |c| c.mapped_mset(serialize_entries(entries, raw: options[:raw])) }
|
404
395
|
end
|
405
396
|
else
|
406
397
|
super
|
@@ -423,15 +414,25 @@ module ActiveSupport
|
|
423
414
|
end
|
424
415
|
end
|
425
416
|
|
426
|
-
def deserialize_entry(
|
427
|
-
if
|
428
|
-
entry = Marshal.load(
|
417
|
+
def deserialize_entry(serialized_entry)
|
418
|
+
if serialized_entry
|
419
|
+
entry = Marshal.load(serialized_entry) rescue serialized_entry
|
429
420
|
entry.is_a?(Entry) ? entry : Entry.new(entry)
|
430
421
|
end
|
431
422
|
end
|
432
423
|
|
433
|
-
def serialize_entry(entry)
|
434
|
-
|
424
|
+
def serialize_entry(entry, raw: false)
|
425
|
+
if raw
|
426
|
+
entry.value.to_s
|
427
|
+
else
|
428
|
+
Marshal.dump(entry)
|
429
|
+
end
|
430
|
+
end
|
431
|
+
|
432
|
+
def serialize_entries(entries, raw: false)
|
433
|
+
entries.transform_values do |entry|
|
434
|
+
serialize_entry entry, raw: raw
|
435
|
+
end
|
435
436
|
end
|
436
437
|
|
437
438
|
def failsafe(method, returning: nil)
|
@@ -54,6 +54,10 @@ module ActiveSupport
|
|
54
54
|
@data[key]
|
55
55
|
end
|
56
56
|
|
57
|
+
def read_multi_entries(keys, options)
|
58
|
+
Hash[keys.map { |name| [name, read_entry(name, options)] }.keep_if { |_name, value| value }]
|
59
|
+
end
|
60
|
+
|
57
61
|
def write_entry(key, value, options)
|
58
62
|
@data[key] = value
|
59
63
|
true
|
@@ -116,6 +120,19 @@ module ActiveSupport
|
|
116
120
|
end
|
117
121
|
end
|
118
122
|
|
123
|
+
def read_multi_entries(keys, options)
|
124
|
+
return super unless local_cache
|
125
|
+
|
126
|
+
local_entries = local_cache.read_multi_entries(keys, options)
|
127
|
+
missed_keys = keys - local_entries.keys
|
128
|
+
|
129
|
+
if missed_keys.any?
|
130
|
+
local_entries.merge!(super(missed_keys, options))
|
131
|
+
else
|
132
|
+
local_entries
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
119
136
|
def write_entry(key, entry, options)
|
120
137
|
if options[:unless_exist]
|
121
138
|
local_cache.delete_entry(key, options) if local_cache
|
@@ -749,8 +749,8 @@ module ActiveSupport
|
|
749
749
|
# * <tt>:skip_after_callbacks_if_terminated</tt> - Determines if after
|
750
750
|
# callbacks should be terminated by the <tt>:terminator</tt> option. By
|
751
751
|
# default after callbacks are executed no matter if callback chain was
|
752
|
-
# terminated or not. This option
|
753
|
-
# option is
|
752
|
+
# terminated or not. This option has no effect if <tt>:terminator</tt>
|
753
|
+
# option is set to +nil+.
|
754
754
|
#
|
755
755
|
# * <tt>:scope</tt> - Indicates which methods should be executed when an
|
756
756
|
# object is used as a callback.
|
@@ -85,7 +85,7 @@ module ActiveSupport
|
|
85
85
|
# ActiveSupport::Deprecation.behavior = :stderr
|
86
86
|
# ActiveSupport::Deprecation.behavior = [:stderr, :log]
|
87
87
|
# ActiveSupport::Deprecation.behavior = MyCustomHandler
|
88
|
-
# ActiveSupport::Deprecation.behavior = ->(message, callstack) {
|
88
|
+
# ActiveSupport::Deprecation.behavior = ->(message, callstack, deprecation_horizon, gem_name) {
|
89
89
|
# # custom stuff
|
90
90
|
# }
|
91
91
|
def behavior=(behavior)
|
@@ -383,6 +383,14 @@ module ActiveSupport
|
|
383
383
|
to_i
|
384
384
|
end
|
385
385
|
|
386
|
+
def init_with(coder) #:nodoc:
|
387
|
+
initialize(coder["value"], coder["parts"])
|
388
|
+
end
|
389
|
+
|
390
|
+
def encode_with(coder) #:nodoc:
|
391
|
+
coder.map = { "value" => @value, "parts" => @parts }
|
392
|
+
end
|
393
|
+
|
386
394
|
# Build ISO 8601 Duration string for this duration.
|
387
395
|
# The +precision+ parameter can be used to limit seconds' precision of duration.
|
388
396
|
def iso8601(precision: nil)
|
@@ -311,6 +311,14 @@ module ActiveSupport
|
|
311
311
|
dup.tap { |hash| hash.transform_keys!(*args, &block) }
|
312
312
|
end
|
313
313
|
|
314
|
+
def transform_keys!
|
315
|
+
return enum_for(:transform_keys!) { size } unless block_given?
|
316
|
+
keys.each do |key|
|
317
|
+
self[yield(key)] = delete(key)
|
318
|
+
end
|
319
|
+
self
|
320
|
+
end
|
321
|
+
|
314
322
|
def slice(*keys)
|
315
323
|
keys.map! { |key| convert_key(key) }
|
316
324
|
self.class.new(super)
|
@@ -268,11 +268,14 @@ module ActiveSupport
|
|
268
268
|
country = TZInfo::Country.get(code)
|
269
269
|
country.zone_identifiers.map do |tz_id|
|
270
270
|
if MAPPING.value?(tz_id)
|
271
|
-
|
271
|
+
MAPPING.inject([]) do |memo, (key, value)|
|
272
|
+
memo << self[key] if value == tz_id
|
273
|
+
memo
|
274
|
+
end
|
272
275
|
else
|
273
276
|
create(tz_id, nil, TZInfo::Timezone.new(tz_id))
|
274
277
|
end
|
275
|
-
end.sort!
|
278
|
+
end.flatten(1).sort!
|
276
279
|
end
|
277
280
|
|
278
281
|
def zones_map
|
@@ -83,7 +83,7 @@ module ActiveSupport
|
|
83
83
|
end,
|
84
84
|
"boolean" => Proc.new { |boolean| %w(1 true).include?(boolean.to_s.strip) },
|
85
85
|
"string" => Proc.new { |string| string.to_s },
|
86
|
-
"yaml" => Proc.new { |yaml| YAML
|
86
|
+
"yaml" => Proc.new { |yaml| YAML.load(yaml) rescue yaml },
|
87
87
|
"base64Binary" => Proc.new { |bin| ::Base64.decode64(bin) },
|
88
88
|
"binary" => Proc.new { |bin, entity| _parse_binary(bin, entity) },
|
89
89
|
"file" => Proc.new { |file, entity| _parse_file(file, entity) }
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activesupport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.2.0.
|
4
|
+
version: 5.2.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: 2018-
|
11
|
+
date: 2018-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.7'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '0.7'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: tzinfo
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -325,8 +331,8 @@ homepage: http://rubyonrails.org
|
|
325
331
|
licenses:
|
326
332
|
- MIT
|
327
333
|
metadata:
|
328
|
-
source_code_uri: https://github.com/rails/rails/tree/v5.2.0.
|
329
|
-
changelog_uri: https://github.com/rails/rails/blob/v5.2.0.
|
334
|
+
source_code_uri: https://github.com/rails/rails/tree/v5.2.0.rc2/activesupport
|
335
|
+
changelog_uri: https://github.com/rails/rails/blob/v5.2.0.rc2/activesupport/CHANGELOG.md
|
330
336
|
post_install_message:
|
331
337
|
rdoc_options:
|
332
338
|
- "--encoding"
|
@@ -345,7 +351,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
345
351
|
version: 1.3.1
|
346
352
|
requirements: []
|
347
353
|
rubyforge_project:
|
348
|
-
rubygems_version: 2.7.
|
354
|
+
rubygems_version: 2.7.6
|
349
355
|
signing_key:
|
350
356
|
specification_version: 4
|
351
357
|
summary: A toolkit of support libraries and Ruby core extensions extracted from the
|