activesupport 8.0.5.2 → 8.1.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +220 -278
- data/lib/active_support/backtrace_cleaner.rb +71 -0
- data/lib/active_support/cache/mem_cache_store.rb +14 -17
- data/lib/active_support/cache/redis_cache_store.rb +37 -31
- data/lib/active_support/cache/strategy/local_cache.rb +16 -7
- data/lib/active_support/cache/strategy/local_cache_middleware.rb +7 -7
- data/lib/active_support/cache.rb +69 -6
- data/lib/active_support/configurable.rb +28 -0
- data/lib/active_support/continuous_integration.rb +145 -0
- data/lib/active_support/core_ext/benchmark.rb +0 -1
- data/lib/active_support/core_ext/class/attribute.rb +6 -8
- data/lib/active_support/core_ext/date_and_time/compatibility.rb +1 -1
- data/lib/active_support/core_ext/enumerable.rb +2 -2
- data/lib/active_support/core_ext/erb/util.rb +3 -3
- data/lib/active_support/core_ext/object/json.rb +9 -2
- data/lib/active_support/core_ext/object/to_query.rb +5 -0
- data/lib/active_support/core_ext/range.rb +0 -1
- data/lib/active_support/core_ext/string/inflections.rb +1 -1
- data/lib/active_support/core_ext/string/multibyte.rb +10 -1
- data/lib/active_support/core_ext/string/output_safety.rb +20 -15
- data/lib/active_support/current_attributes/test_helper.rb +2 -2
- data/lib/active_support/current_attributes.rb +13 -10
- data/lib/active_support/delegation.rb +42 -25
- data/lib/active_support/deprecation/reporting.rb +4 -2
- data/lib/active_support/deprecation.rb +1 -1
- data/lib/active_support/editor.rb +70 -0
- data/lib/active_support/error_reporter.rb +50 -6
- data/lib/active_support/event_reporter/test_helper.rb +32 -0
- data/lib/active_support/event_reporter.rb +570 -0
- data/lib/active_support/evented_file_update_checker.rb +5 -1
- data/lib/active_support/execution_context.rb +64 -7
- data/lib/active_support/file_update_checker.rb +8 -6
- data/lib/active_support/gem_version.rb +3 -3
- data/lib/active_support/gzip.rb +1 -0
- data/lib/active_support/hash_with_indifferent_access.rb +27 -7
- data/lib/active_support/i18n_railtie.rb +1 -2
- data/lib/active_support/inflector/inflections.rb +32 -17
- data/lib/active_support/inflector/methods.rb +21 -5
- data/lib/active_support/inflector/transliterate.rb +6 -8
- data/lib/active_support/isolated_execution_state.rb +9 -17
- data/lib/active_support/json/decoding.rb +2 -2
- data/lib/active_support/json/encoding.rb +103 -14
- data/lib/active_support/log_subscriber.rb +2 -0
- data/lib/active_support/message_encryptors.rb +52 -0
- data/lib/active_support/message_pack/extensions.rb +6 -1
- data/lib/active_support/message_verifiers.rb +52 -0
- data/lib/active_support/messages/rotation_coordinator.rb +9 -0
- data/lib/active_support/messages/rotator.rb +5 -0
- data/lib/active_support/multibyte/chars.rb +8 -1
- data/lib/active_support/multibyte.rb +4 -0
- data/lib/active_support/notifications/instrumenter.rb +1 -1
- data/lib/active_support/number_helper/number_converter.rb +1 -1
- data/lib/active_support/number_helper/number_to_delimited_converter.rb +2 -17
- data/lib/active_support/railtie.rb +26 -12
- data/lib/active_support/syntax_error_proxy.rb +3 -0
- data/lib/active_support/test_case.rb +61 -12
- data/lib/active_support/testing/assertions.rb +37 -14
- data/lib/active_support/testing/autorun.rb +0 -5
- data/lib/active_support/testing/error_reporter_assertions.rb +18 -1
- data/lib/active_support/testing/event_reporter_assertions.rb +217 -0
- data/lib/active_support/testing/notification_assertions.rb +92 -0
- data/lib/active_support/testing/parallelization/server.rb +2 -15
- data/lib/active_support/testing/parallelization/worker.rb +5 -7
- data/lib/active_support/testing/parallelization.rb +14 -12
- data/lib/active_support/testing/tests_without_assertions.rb +1 -1
- data/lib/active_support/testing/time_helpers.rb +7 -3
- data/lib/active_support/time_with_zone.rb +19 -5
- data/lib/active_support/values/time_zone.rb +8 -1
- data/lib/active_support/xml_mini.rb +1 -4
- data/lib/active_support.rb +11 -0
- metadata +11 -6
- data/lib/active_support/core_ext/range/each.rb +0 -24
|
@@ -20,8 +20,8 @@ module ActiveSupport
|
|
|
20
20
|
# ActiveSupport::JSON.encode({ team: 'rails', players: '36' })
|
|
21
21
|
# # => "{\"team\":\"rails\",\"players\":\"36\"}"
|
|
22
22
|
#
|
|
23
|
-
#
|
|
24
|
-
# U+2028 (Line Separator) and U+2029 (Paragraph Separator):
|
|
23
|
+
# By default, it generates JSON that is safe to include in JavaScript, as
|
|
24
|
+
# it escapes U+2028 (Line Separator) and U+2029 (Paragraph Separator):
|
|
25
25
|
#
|
|
26
26
|
# ActiveSupport::JSON.encode({ key: "\u2028" })
|
|
27
27
|
# # => "{\"key\":\"\\u2028\"}"
|
|
@@ -32,18 +32,42 @@ module ActiveSupport
|
|
|
32
32
|
# ActiveSupport::JSON.encode({ key: "<>&" })
|
|
33
33
|
# # => "{\"key\":\"\\u003c\\u003e\\u0026\"}"
|
|
34
34
|
#
|
|
35
|
-
# This can be changed with the +escape_html_entities+ option, or the
|
|
35
|
+
# This behavior can be changed with the +escape_html_entities+ option, or the
|
|
36
36
|
# global escape_html_entities_in_json configuration option.
|
|
37
37
|
#
|
|
38
38
|
# ActiveSupport::JSON.encode({ key: "<>&" }, escape_html_entities: false)
|
|
39
39
|
# # => "{\"key\":\"<>&\"}"
|
|
40
|
+
#
|
|
41
|
+
# For performance reasons, you can set the +escape+ option to false,
|
|
42
|
+
# which will skip all escaping:
|
|
43
|
+
#
|
|
44
|
+
# ActiveSupport::JSON.encode({ key: "\u2028<>&" }, escape: false)
|
|
45
|
+
# # => "{\"key\":\"\u2028<>&\"}"
|
|
40
46
|
def encode(value, options = nil)
|
|
41
|
-
|
|
47
|
+
if options.nil? || options.empty?
|
|
48
|
+
Encoding.encode_without_options(value)
|
|
49
|
+
else
|
|
50
|
+
Encoding.json_encoder.new(options).encode(value)
|
|
51
|
+
end
|
|
42
52
|
end
|
|
43
53
|
alias_method :dump, :encode
|
|
44
54
|
end
|
|
45
55
|
|
|
46
56
|
module Encoding # :nodoc:
|
|
57
|
+
U2028 = -"\u2028".b
|
|
58
|
+
U2029 = -"\u2029".b
|
|
59
|
+
|
|
60
|
+
ESCAPED_CHARS = {
|
|
61
|
+
U2028 => '\u2028'.b,
|
|
62
|
+
U2029 => '\u2029'.b,
|
|
63
|
+
">".b => '\u003e'.b,
|
|
64
|
+
"<".b => '\u003c'.b,
|
|
65
|
+
"&".b => '\u0026'.b,
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
ESCAPE_REGEX_WITH_HTML_ENTITIES = Regexp.union(*ESCAPED_CHARS.keys)
|
|
69
|
+
ESCAPE_REGEX_WITHOUT_HTML_ENTITIES = Regexp.union(U2028, U2029)
|
|
70
|
+
|
|
47
71
|
class JSONGemEncoder # :nodoc:
|
|
48
72
|
attr_reader :options
|
|
49
73
|
|
|
@@ -58,17 +82,18 @@ module ActiveSupport
|
|
|
58
82
|
end
|
|
59
83
|
json = stringify(jsonify(value))
|
|
60
84
|
|
|
85
|
+
return json unless @options.fetch(:escape, true)
|
|
86
|
+
|
|
61
87
|
# Rails does more escaping than the JSON gem natively does (we
|
|
62
88
|
# escape \u2028 and \u2029 and optionally >, <, & to work around
|
|
63
89
|
# certain browser problems).
|
|
90
|
+
json.force_encoding(::Encoding::BINARY)
|
|
64
91
|
if @options.fetch(:escape_html_entities, Encoding.escape_html_entities_in_json)
|
|
65
|
-
json.gsub!(
|
|
66
|
-
|
|
67
|
-
json.gsub!(
|
|
92
|
+
json.gsub!(ESCAPE_REGEX_WITH_HTML_ENTITIES, ESCAPED_CHARS)
|
|
93
|
+
else
|
|
94
|
+
json.gsub!(ESCAPE_REGEX_WITHOUT_HTML_ENTITIES, ESCAPED_CHARS)
|
|
68
95
|
end
|
|
69
|
-
json.
|
|
70
|
-
json.gsub!("\u2029", '\u2029')
|
|
71
|
-
json
|
|
96
|
+
json.force_encoding(::Encoding::UTF_8)
|
|
72
97
|
end
|
|
73
98
|
|
|
74
99
|
private
|
|
@@ -101,16 +126,66 @@ module ActiveSupport
|
|
|
101
126
|
when Array
|
|
102
127
|
value.map { |v| jsonify(v) }
|
|
103
128
|
else
|
|
104
|
-
|
|
129
|
+
if defined?(::JSON::Fragment) && ::JSON::Fragment === value
|
|
130
|
+
value
|
|
131
|
+
else
|
|
132
|
+
jsonify value.as_json
|
|
133
|
+
end
|
|
105
134
|
end
|
|
106
135
|
end
|
|
107
136
|
|
|
108
137
|
# Encode a "jsonified" Ruby data structure using the JSON gem
|
|
109
138
|
def stringify(jsonified)
|
|
110
|
-
::JSON.generate(jsonified
|
|
139
|
+
::JSON.generate(jsonified)
|
|
111
140
|
end
|
|
112
141
|
end
|
|
113
142
|
|
|
143
|
+
if defined?(::JSON::Coder)
|
|
144
|
+
class JSONGemCoderEncoder # :nodoc:
|
|
145
|
+
JSON_NATIVE_TYPES = [Hash, Array, Float, String, Symbol, Integer, NilClass, TrueClass, FalseClass, ::JSON::Fragment].freeze
|
|
146
|
+
CODER = ::JSON::Coder.new do |value|
|
|
147
|
+
json_value = value.as_json
|
|
148
|
+
# Handle objects returning self from as_json
|
|
149
|
+
if json_value.equal?(value)
|
|
150
|
+
next ::JSON::Fragment.new(::JSON.generate(json_value))
|
|
151
|
+
end
|
|
152
|
+
# Handle objects not returning JSON-native types from as_json
|
|
153
|
+
count = 5
|
|
154
|
+
until JSON_NATIVE_TYPES.include?(json_value.class)
|
|
155
|
+
raise SystemStackError if count == 0
|
|
156
|
+
json_value = json_value.as_json
|
|
157
|
+
count -= 1
|
|
158
|
+
end
|
|
159
|
+
json_value
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def initialize(options = nil)
|
|
164
|
+
@options = options ? options.dup.freeze : {}.freeze
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# Encode the given object into a JSON string
|
|
168
|
+
def encode(value)
|
|
169
|
+
value = value.as_json(@options) unless @options.empty?
|
|
170
|
+
|
|
171
|
+
json = CODER.dump(value)
|
|
172
|
+
|
|
173
|
+
return json unless @options.fetch(:escape, true)
|
|
174
|
+
|
|
175
|
+
# Rails does more escaping than the JSON gem natively does (we
|
|
176
|
+
# escape \u2028 and \u2029 and optionally >, <, & to work around
|
|
177
|
+
# certain browser problems).
|
|
178
|
+
json.force_encoding(::Encoding::BINARY)
|
|
179
|
+
if @options.fetch(:escape_html_entities, Encoding.escape_html_entities_in_json)
|
|
180
|
+
json.gsub!(ESCAPE_REGEX_WITH_HTML_ENTITIES, ESCAPED_CHARS)
|
|
181
|
+
else
|
|
182
|
+
json.gsub!(ESCAPE_REGEX_WITHOUT_HTML_ENTITIES, ESCAPED_CHARS)
|
|
183
|
+
end
|
|
184
|
+
json.force_encoding(::Encoding::UTF_8)
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
114
189
|
class << self
|
|
115
190
|
# If true, use ISO 8601 format for dates and times. Otherwise, fall back
|
|
116
191
|
# to the Active Support legacy format.
|
|
@@ -126,12 +201,26 @@ module ActiveSupport
|
|
|
126
201
|
|
|
127
202
|
# Sets the encoder used by \Rails to encode Ruby objects into JSON strings
|
|
128
203
|
# in +Object#to_json+ and +ActiveSupport::JSON.encode+.
|
|
129
|
-
|
|
204
|
+
attr_reader :json_encoder
|
|
205
|
+
|
|
206
|
+
def json_encoder=(encoder)
|
|
207
|
+
@json_encoder = encoder
|
|
208
|
+
@encoder_without_options = encoder.new
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
def encode_without_options(value) # :nodoc:
|
|
212
|
+
@encoder_without_options.encode(value)
|
|
213
|
+
end
|
|
130
214
|
end
|
|
131
215
|
|
|
132
216
|
self.use_standard_json_time_format = true
|
|
133
217
|
self.escape_html_entities_in_json = true
|
|
134
|
-
self.json_encoder =
|
|
218
|
+
self.json_encoder =
|
|
219
|
+
if defined?(::JSON::Coder)
|
|
220
|
+
JSONGemCoderEncoder
|
|
221
|
+
else
|
|
222
|
+
JSONGemEncoder
|
|
223
|
+
end
|
|
135
224
|
self.time_precision = 3
|
|
136
225
|
end
|
|
137
226
|
end
|
|
@@ -26,6 +26,9 @@ module ActiveSupport
|
|
|
26
26
|
# as the first rotation and <tt>transitional = true</tt>. Then, after all
|
|
27
27
|
# servers have been updated, perform a second rolling deploy with
|
|
28
28
|
# <tt>transitional = false</tt>.
|
|
29
|
+
#
|
|
30
|
+
#--
|
|
31
|
+
# Implemented by ActiveSupport::Messages::RotationCoordinator#transitional
|
|
29
32
|
|
|
30
33
|
##
|
|
31
34
|
# :singleton-method: new
|
|
@@ -43,6 +46,9 @@ module ActiveSupport
|
|
|
43
46
|
# end
|
|
44
47
|
#
|
|
45
48
|
# encryptors.rotate(base: "...")
|
|
49
|
+
#
|
|
50
|
+
#--
|
|
51
|
+
# Implemented by ActiveSupport::Messages::RotationCoordinator#initialize
|
|
46
52
|
|
|
47
53
|
##
|
|
48
54
|
# :method: []
|
|
@@ -51,12 +57,18 @@ module ActiveSupport
|
|
|
51
57
|
# Returns a MessageEncryptor configured with a secret derived from the
|
|
52
58
|
# given +salt+, and options from #rotate. MessageEncryptor instances will
|
|
53
59
|
# be memoized, so the same +salt+ will return the same instance.
|
|
60
|
+
#
|
|
61
|
+
#--
|
|
62
|
+
# Implemented by ActiveSupport::Messages::RotationCoordinator#[]
|
|
54
63
|
|
|
55
64
|
##
|
|
56
65
|
# :method: []=
|
|
57
66
|
# :call-seq: []=(salt, encryptor)
|
|
58
67
|
#
|
|
59
68
|
# Overrides a MessageEncryptor instance associated with a given +salt+.
|
|
69
|
+
#
|
|
70
|
+
#--
|
|
71
|
+
# Implemented by ActiveSupport::Messages::RotationCoordinator#[]=
|
|
60
72
|
|
|
61
73
|
##
|
|
62
74
|
# :method: rotate
|
|
@@ -106,18 +118,55 @@ module ActiveSupport
|
|
|
106
118
|
#
|
|
107
119
|
# # Uses `serializer: Marshal, url_safe: false`.
|
|
108
120
|
# encryptors[:baz]
|
|
121
|
+
#
|
|
122
|
+
#--
|
|
123
|
+
# Implemented by ActiveSupport::Messages::RotationCoordinator#rotate
|
|
124
|
+
|
|
125
|
+
##
|
|
126
|
+
# :method: prepend
|
|
127
|
+
# :call-seq:
|
|
128
|
+
# prepend(**options)
|
|
129
|
+
# prepend(&block)
|
|
130
|
+
#
|
|
131
|
+
# Just like #rotate, but prepends the given options or block to the list of
|
|
132
|
+
# option sets.
|
|
133
|
+
#
|
|
134
|
+
# This can be useful when you have an already-configured +MessageEncryptors+
|
|
135
|
+
# instance, but you want to override the way messages are encrypted.
|
|
136
|
+
#
|
|
137
|
+
# module ThirdParty
|
|
138
|
+
# ENCRYPTORS = ActiveSupport::MessageEncryptors.new { ... }.
|
|
139
|
+
# rotate(serializer: Marshal, url_safe: true).
|
|
140
|
+
# rotate(serializer: Marshal, url_safe: false)
|
|
141
|
+
# end
|
|
142
|
+
#
|
|
143
|
+
# ThirdParty.ENCRYPTORS.prepend(serializer: JSON, url_safe: true)
|
|
144
|
+
#
|
|
145
|
+
# # Uses `serializer: JSON, url_safe: true`.
|
|
146
|
+
# # Falls back to `serializer: Marshal, url_safe: true` or
|
|
147
|
+
# # `serializer: Marshal, url_safe: false`.
|
|
148
|
+
# ThirdParty.ENCRYPTORS[:foo]
|
|
149
|
+
#
|
|
150
|
+
#--
|
|
151
|
+
# Implemented by ActiveSupport::Messages::RotationCoordinator#prepend
|
|
109
152
|
|
|
110
153
|
##
|
|
111
154
|
# :method: rotate_defaults
|
|
112
155
|
# :call-seq: rotate_defaults
|
|
113
156
|
#
|
|
114
157
|
# Invokes #rotate with the default options.
|
|
158
|
+
#
|
|
159
|
+
#--
|
|
160
|
+
# Implemented by ActiveSupport::Messages::RotationCoordinator#rotate_defaults
|
|
115
161
|
|
|
116
162
|
##
|
|
117
163
|
# :method: clear_rotations
|
|
118
164
|
# :call-seq: clear_rotations
|
|
119
165
|
#
|
|
120
166
|
# Clears the list of option sets.
|
|
167
|
+
#
|
|
168
|
+
#--
|
|
169
|
+
# Implemented by ActiveSupport::Messages::RotationCoordinator#clear_rotations
|
|
121
170
|
|
|
122
171
|
##
|
|
123
172
|
# :method: on_rotation
|
|
@@ -129,6 +178,9 @@ module ActiveSupport
|
|
|
129
178
|
# For example, this callback could log each time it is called, and thus
|
|
130
179
|
# indicate whether old option sets are still in use or can be removed from
|
|
131
180
|
# rotation.
|
|
181
|
+
#
|
|
182
|
+
#--
|
|
183
|
+
# Implemented by ActiveSupport::Messages::RotationCoordinator#on_rotation
|
|
132
184
|
|
|
133
185
|
##
|
|
134
186
|
private
|
|
@@ -4,9 +4,10 @@ require "bigdecimal"
|
|
|
4
4
|
require "date"
|
|
5
5
|
require "ipaddr"
|
|
6
6
|
require "pathname"
|
|
7
|
-
require "uri"
|
|
7
|
+
require "uri/generic"
|
|
8
8
|
require "msgpack/bigint"
|
|
9
9
|
require "active_support/hash_with_indifferent_access"
|
|
10
|
+
require "active_support/core_ext/string/output_safety"
|
|
10
11
|
require "active_support/time"
|
|
11
12
|
|
|
12
13
|
module ActiveSupport
|
|
@@ -102,6 +103,10 @@ module ActiveSupport
|
|
|
102
103
|
packer: method(:write_hash_with_indifferent_access),
|
|
103
104
|
unpacker: method(:read_hash_with_indifferent_access),
|
|
104
105
|
recursive: true
|
|
106
|
+
|
|
107
|
+
registry.register_type 18, ActiveSupport::SafeBuffer,
|
|
108
|
+
packer: :to_s,
|
|
109
|
+
unpacker: :new
|
|
105
110
|
end
|
|
106
111
|
|
|
107
112
|
def install_unregistered_type_error(registry)
|
|
@@ -26,6 +26,9 @@ module ActiveSupport
|
|
|
26
26
|
# as the first rotation and <tt>transitional = true</tt>. Then, after all
|
|
27
27
|
# servers have been updated, perform a second rolling deploy with
|
|
28
28
|
# <tt>transitional = false</tt>.
|
|
29
|
+
#
|
|
30
|
+
#--
|
|
31
|
+
# Implemented by ActiveSupport::Messages::RotationCoordinator#transitional
|
|
29
32
|
|
|
30
33
|
##
|
|
31
34
|
# :singleton-method: new
|
|
@@ -42,6 +45,9 @@ module ActiveSupport
|
|
|
42
45
|
# end
|
|
43
46
|
#
|
|
44
47
|
# verifiers.rotate(base: "...")
|
|
48
|
+
#
|
|
49
|
+
#--
|
|
50
|
+
# Implemented by ActiveSupport::Messages::RotationCoordinator#initialize
|
|
45
51
|
|
|
46
52
|
##
|
|
47
53
|
# :method: []
|
|
@@ -50,12 +56,18 @@ module ActiveSupport
|
|
|
50
56
|
# Returns a MessageVerifier configured with a secret derived from the
|
|
51
57
|
# given +salt+, and options from #rotate. MessageVerifier instances will
|
|
52
58
|
# be memoized, so the same +salt+ will return the same instance.
|
|
59
|
+
#
|
|
60
|
+
#--
|
|
61
|
+
# Implemented by ActiveSupport::Messages::RotationCoordinator#[]
|
|
53
62
|
|
|
54
63
|
##
|
|
55
64
|
# :method: []=
|
|
56
65
|
# :call-seq: []=(salt, verifier)
|
|
57
66
|
#
|
|
58
67
|
# Overrides a MessageVerifier instance associated with a given +salt+.
|
|
68
|
+
#
|
|
69
|
+
#--
|
|
70
|
+
# Implemented by ActiveSupport::Messages::RotationCoordinator#[]=
|
|
59
71
|
|
|
60
72
|
##
|
|
61
73
|
# :method: rotate
|
|
@@ -104,18 +116,55 @@ module ActiveSupport
|
|
|
104
116
|
#
|
|
105
117
|
# # Uses `serializer: Marshal, url_safe: false`.
|
|
106
118
|
# verifiers[:baz]
|
|
119
|
+
#
|
|
120
|
+
#--
|
|
121
|
+
# Implemented by ActiveSupport::Messages::RotationCoordinator#rotate
|
|
122
|
+
|
|
123
|
+
##
|
|
124
|
+
# :method: prepend
|
|
125
|
+
# :call-seq:
|
|
126
|
+
# prepend(**options)
|
|
127
|
+
# prepend(&block)
|
|
128
|
+
#
|
|
129
|
+
# Just like #rotate, but prepends the given options or block to the list of
|
|
130
|
+
# option sets.
|
|
131
|
+
#
|
|
132
|
+
# This can be useful when you have an already-configured +MessageVerifiers+
|
|
133
|
+
# instance, but you want to override the way messages are signed.
|
|
134
|
+
#
|
|
135
|
+
# module ThirdParty
|
|
136
|
+
# VERIFIERS = ActiveSupport::MessageVerifiers.new { ... }.
|
|
137
|
+
# rotate(serializer: Marshal, url_safe: true).
|
|
138
|
+
# rotate(serializer: Marshal, url_safe: false)
|
|
139
|
+
# end
|
|
140
|
+
#
|
|
141
|
+
# ThirdParty.VERIFIERS.prepend(serializer: JSON, url_safe: true)
|
|
142
|
+
#
|
|
143
|
+
# # Uses `serializer: JSON, url_safe: true`.
|
|
144
|
+
# # Falls back to `serializer: Marshal, url_safe: true` or
|
|
145
|
+
# # `serializer: Marshal, url_safe: false`.
|
|
146
|
+
# ThirdParty.VERIFIERS[:foo]
|
|
147
|
+
#
|
|
148
|
+
#--
|
|
149
|
+
# Implemented by ActiveSupport::Messages::RotationCoordinator#prepend
|
|
107
150
|
|
|
108
151
|
##
|
|
109
152
|
# :method: rotate_defaults
|
|
110
153
|
# :call-seq: rotate_defaults
|
|
111
154
|
#
|
|
112
155
|
# Invokes #rotate with the default options.
|
|
156
|
+
#
|
|
157
|
+
#--
|
|
158
|
+
# Implemented by ActiveSupport::Messages::RotationCoordinator#rotate_defaults
|
|
113
159
|
|
|
114
160
|
##
|
|
115
161
|
# :method: clear_rotations
|
|
116
162
|
# :call-seq: clear_rotations
|
|
117
163
|
#
|
|
118
164
|
# Clears the list of option sets.
|
|
165
|
+
#
|
|
166
|
+
#--
|
|
167
|
+
# Implemented by ActiveSupport::Messages::RotationCoordinator#clear_rotations
|
|
119
168
|
|
|
120
169
|
##
|
|
121
170
|
# :method: on_rotation
|
|
@@ -127,6 +176,9 @@ module ActiveSupport
|
|
|
127
176
|
# For example, this callback could log each time it is called, and thus
|
|
128
177
|
# indicate whether old option sets are still in use or can be removed from
|
|
129
178
|
# rotation.
|
|
179
|
+
#
|
|
180
|
+
#--
|
|
181
|
+
# Implemented by ActiveSupport::Messages::RotationCoordinator#on_rotation
|
|
130
182
|
|
|
131
183
|
##
|
|
132
184
|
private
|
|
@@ -32,6 +32,15 @@ module ActiveSupport
|
|
|
32
32
|
self
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
+
def prepend(**options, &block)
|
|
36
|
+
raise ArgumentError, "Options cannot be specified when using a block" if block && !options.empty?
|
|
37
|
+
changing_configuration!
|
|
38
|
+
|
|
39
|
+
@rotate_options.unshift(block || options)
|
|
40
|
+
|
|
41
|
+
self
|
|
42
|
+
end
|
|
43
|
+
|
|
35
44
|
def rotate_defaults
|
|
36
45
|
rotate()
|
|
37
46
|
end
|
|
@@ -53,7 +53,14 @@ module ActiveSupport # :nodoc:
|
|
|
53
53
|
delegate :<=>, :=~, :match?, :acts_like_string?, to: :wrapped_string
|
|
54
54
|
|
|
55
55
|
# Creates a new Chars instance by wrapping _string_.
|
|
56
|
-
def initialize(string)
|
|
56
|
+
def initialize(string, deprecation: true)
|
|
57
|
+
if deprecation
|
|
58
|
+
ActiveSupport.deprecator.warn(
|
|
59
|
+
"ActiveSupport::Multibyte::Chars is deprecated and will be removed in Rails 8.2. " \
|
|
60
|
+
"Use normal string methods instead."
|
|
61
|
+
)
|
|
62
|
+
end
|
|
63
|
+
|
|
57
64
|
@wrapped_string = string
|
|
58
65
|
if string.encoding != Encoding::UTF_8
|
|
59
66
|
@wrapped_string = @wrapped_string.dup
|
|
@@ -12,6 +12,10 @@ module ActiveSupport # :nodoc:
|
|
|
12
12
|
#
|
|
13
13
|
# ActiveSupport::Multibyte.proxy_class = CharsForUTF32
|
|
14
14
|
def self.proxy_class=(klass)
|
|
15
|
+
ActiveSupport.deprecator.warn(
|
|
16
|
+
"ActiveSupport::Multibyte.proxy_class= is deprecated and will be removed in Rails 8.2. " \
|
|
17
|
+
"Use normal string methods instead."
|
|
18
|
+
)
|
|
15
19
|
@proxy_class = klass
|
|
16
20
|
end
|
|
17
21
|
|
|
@@ -164,7 +164,7 @@ module ActiveSupport
|
|
|
164
164
|
@cpu_time_finish - @cpu_time_start
|
|
165
165
|
end
|
|
166
166
|
|
|
167
|
-
# Returns the idle time (in milliseconds) passed between the call to
|
|
167
|
+
# Returns the idle time time (in milliseconds) passed between the call to
|
|
168
168
|
# #start! and the call to #finish!.
|
|
169
169
|
def idle_time
|
|
170
170
|
diff = duration - cpu_time
|
|
@@ -16,24 +16,9 @@ module ActiveSupport
|
|
|
16
16
|
private
|
|
17
17
|
def parts
|
|
18
18
|
left, right = number.to_s.split(".")
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"#{digit_to_delimit}#{options[:delimiter]}"
|
|
22
|
-
end
|
|
23
|
-
else
|
|
24
|
-
left_parts = []
|
|
25
|
-
offset = left.size % 3
|
|
26
|
-
if offset > 0
|
|
27
|
-
left_parts << left[0, offset]
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
(left.size / 3).times do |i|
|
|
31
|
-
left_parts << left[offset + (i * 3), 3]
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
left = left_parts.join(options[:delimiter])
|
|
19
|
+
left.gsub!(delimiter_pattern) do |digit_to_delimit|
|
|
20
|
+
"#{digit_to_delimit}#{options[:delimiter]}"
|
|
35
21
|
end
|
|
36
|
-
|
|
37
22
|
[left, right].compact
|
|
38
23
|
end
|
|
39
24
|
|
|
@@ -15,7 +15,7 @@ module ActiveSupport
|
|
|
15
15
|
|
|
16
16
|
initializer "active_support.isolation_level" do |app|
|
|
17
17
|
config.after_initialize do
|
|
18
|
-
if level = app.config.active_support.
|
|
18
|
+
if level = app.config.active_support.isolation_level
|
|
19
19
|
ActiveSupport::IsolatedExecutionState.isolation_level = level
|
|
20
20
|
end
|
|
21
21
|
end
|
|
@@ -38,19 +38,35 @@ module ActiveSupport
|
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
initializer "active_support.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
initializer "active_support.set_event_reporter_context_store" do |app|
|
|
42
|
+
config.after_initialize do
|
|
43
|
+
if klass = app.config.active_support.event_reporter_context_store
|
|
44
|
+
ActiveSupport::EventReporter.context_store = klass
|
|
45
|
+
end
|
|
46
|
+
end
|
|
45
47
|
end
|
|
46
48
|
|
|
47
|
-
initializer "active_support.
|
|
48
|
-
app.reloader.before_class_unload
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
initializer "active_support.reset_execution_context" do |app|
|
|
50
|
+
app.reloader.before_class_unload do
|
|
51
|
+
ActiveSupport::CurrentAttributes.clear_all
|
|
52
|
+
ActiveSupport::ExecutionContext.clear
|
|
53
|
+
ActiveSupport.event_reporter.clear_context
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
app.executor.to_run do
|
|
57
|
+
ActiveSupport::ExecutionContext.push
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
app.executor.to_complete do
|
|
61
|
+
ActiveSupport::CurrentAttributes.clear_all
|
|
62
|
+
ActiveSupport::ExecutionContext.pop
|
|
63
|
+
ActiveSupport.event_reporter.clear_context
|
|
64
|
+
end
|
|
51
65
|
|
|
52
66
|
ActiveSupport.on_load(:active_support_test_case) do
|
|
53
67
|
if app.config.active_support.executor_around_test_case
|
|
68
|
+
ActiveSupport::ExecutionContext.nestable = true
|
|
69
|
+
|
|
54
70
|
require "active_support/executor/test_helper"
|
|
55
71
|
include ActiveSupport::Executor::TestHelper
|
|
56
72
|
else
|
|
@@ -97,9 +113,7 @@ module ActiveSupport
|
|
|
97
113
|
end
|
|
98
114
|
|
|
99
115
|
initializer "active_support.to_time_preserves_timezone" do |app|
|
|
100
|
-
config.
|
|
101
|
-
ActiveSupport.to_time_preserves_timezone = app.config.active_support.to_time_preserves_timezone
|
|
102
|
-
end
|
|
116
|
+
ActiveSupport.to_time_preserves_timezone = app.config.active_support.to_time_preserves_timezone
|
|
103
117
|
end
|
|
104
118
|
|
|
105
119
|
# Sets the default week start
|