activesupport 6.0.2.2 → 6.0.3.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 +27 -0
- data/README.rdoc +1 -1
- data/lib/active_support/backtrace_cleaner.rb +0 -1
- data/lib/active_support/cache.rb +29 -28
- data/lib/active_support/cache/file_store.rb +7 -8
- data/lib/active_support/cache/mem_cache_store.rb +8 -8
- data/lib/active_support/cache/memory_store.rb +6 -7
- data/lib/active_support/cache/null_store.rb +3 -3
- data/lib/active_support/cache/redis_cache_store.rb +7 -7
- data/lib/active_support/cache/strategy/local_cache.rb +23 -23
- data/lib/active_support/callbacks.rb +0 -3
- data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +18 -0
- data/lib/active_support/concurrency/share_lock.rb +0 -1
- data/lib/active_support/core_ext/array/conversions.rb +5 -5
- data/lib/active_support/core_ext/date_and_time/zones.rb +0 -1
- data/lib/active_support/core_ext/date_time/conversions.rb +0 -1
- data/lib/active_support/core_ext/hash/conversions.rb +1 -1
- data/lib/active_support/core_ext/module/delegation.rb +8 -1
- data/lib/active_support/core_ext/module/introspection.rb +1 -0
- data/lib/active_support/core_ext/object/try.rb +2 -0
- data/lib/active_support/core_ext/range/each.rb +0 -1
- data/lib/active_support/core_ext/string/output_safety.rb +0 -1
- data/lib/active_support/dependencies.rb +0 -2
- data/lib/active_support/dependencies/zeitwerk_integration.rb +0 -1
- data/lib/active_support/deprecation/method_wrappers.rb +12 -6
- data/lib/active_support/deprecation/proxy_wrappers.rb +5 -1
- data/lib/active_support/descendants_tracker.rb +0 -1
- data/lib/active_support/duration.rb +13 -11
- data/lib/active_support/duration/iso8601_parser.rb +0 -1
- data/lib/active_support/duration/iso8601_serializer.rb +0 -1
- data/lib/active_support/encrypted_file.rb +1 -1
- data/lib/active_support/evented_file_update_checker.rb +0 -1
- data/lib/active_support/file_update_checker.rb +0 -1
- data/lib/active_support/gem_version.rb +2 -2
- data/lib/active_support/inflector/inflections.rb +0 -1
- data/lib/active_support/inflector/methods.rb +1 -2
- data/lib/active_support/json/decoding.rb +0 -1
- data/lib/active_support/lazy_load_hooks.rb +0 -1
- data/lib/active_support/locale/en.rb +4 -2
- data/lib/active_support/log_subscriber.rb +0 -1
- data/lib/active_support/logger.rb +1 -1
- data/lib/active_support/message_encryptor.rb +1 -1
- data/lib/active_support/message_verifier.rb +2 -2
- data/lib/active_support/messages/metadata.rb +3 -2
- data/lib/active_support/messages/rotator.rb +4 -4
- data/lib/active_support/multibyte/chars.rb +1 -2
- data/lib/active_support/multibyte/unicode.rb +0 -1
- data/lib/active_support/notifications/instrumenter.rb +0 -1
- data/lib/active_support/number_helper.rb +4 -0
- data/lib/active_support/number_helper/number_converter.rb +4 -5
- data/lib/active_support/number_helper/number_to_currency_converter.rb +7 -8
- data/lib/active_support/number_helper/number_to_delimited_converter.rb +0 -1
- data/lib/active_support/number_helper/number_to_human_converter.rb +0 -1
- data/lib/active_support/number_helper/number_to_human_size_converter.rb +0 -1
- data/lib/active_support/number_helper/number_to_phone_converter.rb +0 -1
- data/lib/active_support/number_helper/number_to_rounded_converter.rb +0 -1
- data/lib/active_support/option_merger.rb +21 -3
- data/lib/active_support/ordered_options.rb +4 -0
- data/lib/active_support/parameter_filter.rb +1 -2
- data/lib/active_support/string_inquirer.rb +0 -1
- data/lib/active_support/testing/parallelization.rb +8 -2
- data/lib/active_support/testing/stream.rb +0 -1
- data/lib/active_support/testing/time_helpers.rb +0 -2
- data/lib/active_support/xml_mini.rb +0 -1
- data/lib/active_support/xml_mini/jdom.rb +0 -1
- metadata +15 -9
@@ -50,27 +50,27 @@ module ActiveSupport
|
|
50
50
|
@data.clear
|
51
51
|
end
|
52
52
|
|
53
|
-
def read_entry(key, options)
|
53
|
+
def read_entry(key, **options)
|
54
54
|
@data[key]
|
55
55
|
end
|
56
56
|
|
57
|
-
def read_multi_entries(keys, options)
|
57
|
+
def read_multi_entries(keys, **options)
|
58
58
|
values = {}
|
59
59
|
|
60
60
|
keys.each do |name|
|
61
|
-
entry = read_entry(name, options)
|
61
|
+
entry = read_entry(name, **options)
|
62
62
|
values[name] = entry.value if entry
|
63
63
|
end
|
64
64
|
|
65
65
|
values
|
66
66
|
end
|
67
67
|
|
68
|
-
def write_entry(key, value, options)
|
68
|
+
def write_entry(key, value, **options)
|
69
69
|
@data[key] = value
|
70
70
|
true
|
71
71
|
end
|
72
72
|
|
73
|
-
def delete_entry(key, options)
|
73
|
+
def delete_entry(key, **options)
|
74
74
|
!!@data.delete(key)
|
75
75
|
end
|
76
76
|
|
@@ -92,34 +92,34 @@ module ActiveSupport
|
|
92
92
|
local_cache_key)
|
93
93
|
end
|
94
94
|
|
95
|
-
def clear(options
|
95
|
+
def clear(**options) # :nodoc:
|
96
96
|
return super unless cache = local_cache
|
97
97
|
cache.clear(options)
|
98
98
|
super
|
99
99
|
end
|
100
100
|
|
101
|
-
def cleanup(options
|
101
|
+
def cleanup(**options) # :nodoc:
|
102
102
|
return super unless cache = local_cache
|
103
103
|
cache.clear
|
104
104
|
super
|
105
105
|
end
|
106
106
|
|
107
|
-
def increment(name, amount = 1, options
|
107
|
+
def increment(name, amount = 1, **options) # :nodoc:
|
108
108
|
return super unless local_cache
|
109
109
|
value = bypass_local_cache { super }
|
110
|
-
write_cache_value(name, value, options)
|
110
|
+
write_cache_value(name, value, **options)
|
111
111
|
value
|
112
112
|
end
|
113
113
|
|
114
|
-
def decrement(name, amount = 1, options
|
114
|
+
def decrement(name, amount = 1, **options) # :nodoc:
|
115
115
|
return super unless local_cache
|
116
116
|
value = bypass_local_cache { super }
|
117
|
-
write_cache_value(name, value, options)
|
117
|
+
write_cache_value(name, value, **options)
|
118
118
|
value
|
119
119
|
end
|
120
120
|
|
121
121
|
private
|
122
|
-
def read_entry(key, options)
|
122
|
+
def read_entry(key, **options)
|
123
123
|
if cache = local_cache
|
124
124
|
cache.fetch_entry(key) { super }
|
125
125
|
else
|
@@ -127,42 +127,42 @@ module ActiveSupport
|
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
|
-
def read_multi_entries(keys, options)
|
130
|
+
def read_multi_entries(keys, **options)
|
131
131
|
return super unless local_cache
|
132
132
|
|
133
|
-
local_entries = local_cache.read_multi_entries(keys, options)
|
133
|
+
local_entries = local_cache.read_multi_entries(keys, **options)
|
134
134
|
missed_keys = keys - local_entries.keys
|
135
135
|
|
136
136
|
if missed_keys.any?
|
137
|
-
local_entries.merge!(super(missed_keys, options))
|
137
|
+
local_entries.merge!(super(missed_keys, **options))
|
138
138
|
else
|
139
139
|
local_entries
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
143
|
-
def write_entry(key, entry, options)
|
143
|
+
def write_entry(key, entry, **options)
|
144
144
|
if options[:unless_exist]
|
145
|
-
local_cache.delete_entry(key, options) if local_cache
|
145
|
+
local_cache.delete_entry(key, **options) if local_cache
|
146
146
|
else
|
147
|
-
local_cache.write_entry(key, entry, options) if local_cache
|
147
|
+
local_cache.write_entry(key, entry, **options) if local_cache
|
148
148
|
end
|
149
149
|
|
150
150
|
super
|
151
151
|
end
|
152
152
|
|
153
|
-
def delete_entry(key, options)
|
154
|
-
local_cache.delete_entry(key, options) if local_cache
|
153
|
+
def delete_entry(key, **options)
|
154
|
+
local_cache.delete_entry(key, **options) if local_cache
|
155
155
|
super
|
156
156
|
end
|
157
157
|
|
158
|
-
def write_cache_value(name, value, options)
|
158
|
+
def write_cache_value(name, value, **options)
|
159
159
|
name = normalize_key(name, options)
|
160
160
|
cache = local_cache
|
161
161
|
cache.mute do
|
162
162
|
if value
|
163
|
-
cache.write(name, value, options)
|
163
|
+
cache.write(name, value, **options)
|
164
164
|
else
|
165
|
-
cache.delete(name, options)
|
165
|
+
cache.delete(name, **options)
|
166
166
|
end
|
167
167
|
end
|
168
168
|
end
|
@@ -142,7 +142,6 @@ module ActiveSupport
|
|
142
142
|
end
|
143
143
|
|
144
144
|
private
|
145
|
-
|
146
145
|
# A hook invoked every time a before callback is halted.
|
147
146
|
# This can be overridden in ActiveSupport::Callbacks implementors in order
|
148
147
|
# to provide better debugging/logging.
|
@@ -582,7 +581,6 @@ module ActiveSupport
|
|
582
581
|
attr_reader :chain
|
583
582
|
|
584
583
|
private
|
585
|
-
|
586
584
|
def append_one(callback)
|
587
585
|
@callbacks = nil
|
588
586
|
remove_duplicates(callback)
|
@@ -843,7 +841,6 @@ module ActiveSupport
|
|
843
841
|
end
|
844
842
|
|
845
843
|
protected
|
846
|
-
|
847
844
|
def get_callbacks(name) # :nodoc:
|
848
845
|
__callbacks[name.to_sym]
|
849
846
|
end
|
@@ -7,11 +7,29 @@ module ActiveSupport
|
|
7
7
|
# A monitor that will permit dependency loading while blocked waiting for
|
8
8
|
# the lock.
|
9
9
|
class LoadInterlockAwareMonitor < Monitor
|
10
|
+
EXCEPTION_NEVER = { Exception => :never }.freeze
|
11
|
+
EXCEPTION_IMMEDIATE = { Exception => :immediate }.freeze
|
12
|
+
private_constant :EXCEPTION_NEVER, :EXCEPTION_IMMEDIATE
|
13
|
+
|
10
14
|
# Enters an exclusive section, but allows dependency loading while blocked
|
11
15
|
def mon_enter
|
12
16
|
mon_try_enter ||
|
13
17
|
ActiveSupport::Dependencies.interlock.permit_concurrent_loads { super }
|
14
18
|
end
|
19
|
+
|
20
|
+
def synchronize
|
21
|
+
Thread.handle_interrupt(EXCEPTION_NEVER) do
|
22
|
+
mon_enter
|
23
|
+
|
24
|
+
begin
|
25
|
+
Thread.handle_interrupt(EXCEPTION_IMMEDIATE) do
|
26
|
+
yield
|
27
|
+
end
|
28
|
+
ensure
|
29
|
+
mon_exit
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
15
33
|
end
|
16
34
|
end
|
17
35
|
end
|
@@ -74,13 +74,13 @@ class Array
|
|
74
74
|
|
75
75
|
case length
|
76
76
|
when 0
|
77
|
-
""
|
77
|
+
+""
|
78
78
|
when 1
|
79
|
-
"#{self[0]}"
|
79
|
+
+"#{self[0]}"
|
80
80
|
when 2
|
81
|
-
"#{self[0]}#{options[:two_words_connector]}#{self[1]}"
|
81
|
+
+"#{self[0]}#{options[:two_words_connector]}#{self[1]}"
|
82
82
|
else
|
83
|
-
"#{self[0...-1].join(options[:words_connector])}#{options[:last_word_connector]}#{self[-1]}"
|
83
|
+
+"#{self[0...-1].join(options[:words_connector])}#{options[:last_word_connector]}#{self[-1]}"
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
@@ -181,7 +181,7 @@ class Array
|
|
181
181
|
# </messages>
|
182
182
|
#
|
183
183
|
def to_xml(options = {})
|
184
|
-
require "active_support/builder" unless defined?(Builder)
|
184
|
+
require "active_support/builder" unless defined?(Builder::XmlMarkup)
|
185
185
|
|
186
186
|
options = options.dup
|
187
187
|
options[:indent] ||= 2
|
@@ -73,7 +73,7 @@ class Hash
|
|
73
73
|
# configure your own builder with the <tt>:builder</tt> option. The method also accepts
|
74
74
|
# options like <tt>:dasherize</tt> and friends, they are forwarded to the builder.
|
75
75
|
def to_xml(options = {})
|
76
|
-
require "active_support/builder" unless defined?(Builder)
|
76
|
+
require "active_support/builder" unless defined?(Builder::XmlMarkup)
|
77
77
|
|
78
78
|
options = options.dup
|
79
79
|
options[:indent] ||= 2
|
@@ -193,7 +193,13 @@ class Module
|
|
193
193
|
method_names = methods.map do |method|
|
194
194
|
# Attribute writer methods only accept one argument. Makes sure []=
|
195
195
|
# methods still accept two arguments.
|
196
|
-
definition = /[^\]]=$/.match?(method)
|
196
|
+
definition = if /[^\]]=$/.match?(method)
|
197
|
+
"arg"
|
198
|
+
elsif RUBY_VERSION >= "2.7"
|
199
|
+
"..."
|
200
|
+
else
|
201
|
+
"*args, &block"
|
202
|
+
end
|
197
203
|
|
198
204
|
# The following generated method calls the target exactly once, storing
|
199
205
|
# the returned value in a dummy variable.
|
@@ -308,6 +314,7 @@ class Module
|
|
308
314
|
end
|
309
315
|
end
|
310
316
|
end
|
317
|
+
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
|
311
318
|
RUBY
|
312
319
|
end
|
313
320
|
end
|
@@ -15,6 +15,7 @@ module ActiveSupport
|
|
15
15
|
public_send(method_name, *args, &b)
|
16
16
|
end
|
17
17
|
end
|
18
|
+
ruby2_keywords(:try) if respond_to?(:ruby2_keywords, true)
|
18
19
|
|
19
20
|
def try!(method_name = nil, *args, &b)
|
20
21
|
if method_name.nil? && block_given?
|
@@ -27,6 +28,7 @@ module ActiveSupport
|
|
27
28
|
public_send(method_name, *args, &b)
|
28
29
|
end
|
29
30
|
end
|
31
|
+
ruby2_keywords(:try!) if respond_to?(:ruby2_keywords, true)
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
@@ -313,7 +313,6 @@ module ActiveSupport #:nodoc:
|
|
313
313
|
end
|
314
314
|
|
315
315
|
private
|
316
|
-
|
317
316
|
def load(file, wrap = false)
|
318
317
|
result = false
|
319
318
|
load_dependency(file) { result = super }
|
@@ -794,7 +793,6 @@ module ActiveSupport #:nodoc:
|
|
794
793
|
end
|
795
794
|
|
796
795
|
private
|
797
|
-
|
798
796
|
# Returns the original name of a class or module even if `name` has been
|
799
797
|
# overridden.
|
800
798
|
def real_mod_name(mod)
|
@@ -58,15 +58,21 @@ module ActiveSupport
|
|
58
58
|
method_names.each do |method_name|
|
59
59
|
if target_module.method_defined?(method_name) || target_module.private_method_defined?(method_name)
|
60
60
|
method = target_module.instance_method(method_name)
|
61
|
-
target_module.
|
62
|
-
|
63
|
-
|
61
|
+
target_module.module_eval do
|
62
|
+
redefine_method(method_name) do |*args, &block|
|
63
|
+
deprecator.deprecation_warning(method_name, options[method_name])
|
64
|
+
method.bind(self).call(*args, &block)
|
65
|
+
end
|
66
|
+
ruby2_keywords(method_name) if respond_to?(:ruby2_keywords, true)
|
64
67
|
end
|
65
68
|
else
|
66
69
|
mod ||= Module.new
|
67
|
-
mod.
|
68
|
-
|
69
|
-
|
70
|
+
mod.module_eval do
|
71
|
+
define_method(method_name) do |*args, &block|
|
72
|
+
deprecator.deprecation_warning(method_name, options[method_name])
|
73
|
+
super(*args, &block)
|
74
|
+
end
|
75
|
+
ruby2_keywords(method_name) if respond_to?(:ruby2_keywords, true)
|
70
76
|
end
|
71
77
|
end
|
72
78
|
end
|
@@ -121,7 +121,7 @@ module ActiveSupport
|
|
121
121
|
# (Backtrace information…)
|
122
122
|
# ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"]
|
123
123
|
class DeprecatedConstantProxy < Module
|
124
|
-
def self.new(*args, &block)
|
124
|
+
def self.new(*args, **kwargs, &block)
|
125
125
|
object = args.first
|
126
126
|
|
127
127
|
return object unless object
|
@@ -145,6 +145,10 @@ module ActiveSupport
|
|
145
145
|
target.inspect
|
146
146
|
end
|
147
147
|
|
148
|
+
# Don't give a deprecation warning on methods that IRB may invoke
|
149
|
+
# during tab-completion.
|
150
|
+
delegate :hash, :instance_methods, :name, to: :target
|
151
|
+
|
148
152
|
# Returns the class of the new constant.
|
149
153
|
#
|
150
154
|
# PLANETS_POST_2006 = %w(mercury venus earth mars jupiter saturn uranus neptune)
|
@@ -182,15 +182,15 @@ module ActiveSupport
|
|
182
182
|
#
|
183
183
|
def build(value)
|
184
184
|
parts = {}
|
185
|
-
remainder = value.
|
185
|
+
remainder = value.round(9)
|
186
186
|
|
187
187
|
PARTS.each do |part|
|
188
188
|
unless part == :seconds
|
189
189
|
part_in_seconds = PARTS_IN_SECONDS[part]
|
190
190
|
parts[part] = remainder.div(part_in_seconds)
|
191
|
-
remainder
|
191
|
+
remainder %= part_in_seconds
|
192
192
|
end
|
193
|
-
end
|
193
|
+
end unless value == 0
|
194
194
|
|
195
195
|
parts[:seconds] = remainder
|
196
196
|
|
@@ -198,7 +198,6 @@ module ActiveSupport
|
|
198
198
|
end
|
199
199
|
|
200
200
|
private
|
201
|
-
|
202
201
|
def calculate_total_seconds(parts)
|
203
202
|
parts.inject(0) do |total, (part, value)|
|
204
203
|
total + value * PARTS_IN_SECONDS[part]
|
@@ -209,7 +208,7 @@ module ActiveSupport
|
|
209
208
|
def initialize(value, parts) #:nodoc:
|
210
209
|
@value, @parts = value, parts.to_h
|
211
210
|
@parts.default = 0
|
212
|
-
@parts.reject! { |k, v| v.zero? }
|
211
|
+
@parts.reject! { |k, v| v.zero? } unless value == 0
|
213
212
|
end
|
214
213
|
|
215
214
|
def coerce(other) #:nodoc:
|
@@ -372,7 +371,7 @@ module ActiveSupport
|
|
372
371
|
alias :before :ago
|
373
372
|
|
374
373
|
def inspect #:nodoc:
|
375
|
-
return "
|
374
|
+
return "#{value} seconds" if parts.empty?
|
376
375
|
|
377
376
|
parts.
|
378
377
|
sort_by { |unit, _ | PARTS.index(unit) }.
|
@@ -399,10 +398,15 @@ module ActiveSupport
|
|
399
398
|
end
|
400
399
|
|
401
400
|
private
|
402
|
-
|
403
401
|
def sum(sign, time = ::Time.current)
|
404
|
-
|
405
|
-
|
402
|
+
unless time.acts_like?(:time) || time.acts_like?(:date)
|
403
|
+
raise ::ArgumentError, "expected a time or date, got #{time.inspect}"
|
404
|
+
end
|
405
|
+
|
406
|
+
if parts.empty?
|
407
|
+
time.since(sign * value)
|
408
|
+
else
|
409
|
+
parts.inject(time) do |t, (type, number)|
|
406
410
|
if type == :seconds
|
407
411
|
t.since(sign * number)
|
408
412
|
elsif type == :minutes
|
@@ -412,8 +416,6 @@ module ActiveSupport
|
|
412
416
|
else
|
413
417
|
t.advance(type => sign * number)
|
414
418
|
end
|
415
|
-
else
|
416
|
-
raise ::ArgumentError, "expected a time or date, got #{time.inspect}"
|
417
419
|
end
|
418
420
|
end
|
419
421
|
end
|