activesupport 7.0.2.3 → 7.0.3
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 +14 -0
- data/lib/active_support/backtrace_cleaner.rb +2 -2
- data/lib/active_support/cache/mem_cache_store.rb +5 -5
- data/lib/active_support/cache/memory_store.rb +1 -1
- data/lib/active_support/cache/redis_cache_store.rb +5 -5
- data/lib/active_support/cache/strategy/local_cache.rb +3 -0
- data/lib/active_support/cache.rb +4 -1
- data/lib/active_support/callbacks.rb +5 -5
- data/lib/active_support/configurable.rb +2 -2
- data/lib/active_support/core_ext/array/conversions.rb +0 -1
- data/lib/active_support/core_ext/array/inquiry.rb +2 -2
- data/lib/active_support/core_ext/date/calculations.rb +5 -5
- data/lib/active_support/core_ext/date/conversions.rb +3 -3
- data/lib/active_support/core_ext/date_and_time/calculations.rb +4 -4
- data/lib/active_support/core_ext/date_and_time/compatibility.rb +1 -1
- data/lib/active_support/core_ext/enumerable.rb +26 -9
- data/lib/active_support/core_ext/hash/conversions.rb +0 -1
- data/lib/active_support/core_ext/hash/indifferent_access.rb +3 -3
- data/lib/active_support/core_ext/kernel/singleton_class.rb +1 -1
- data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +4 -4
- data/lib/active_support/core_ext/numeric/conversions.rb +1 -1
- data/lib/active_support/core_ext/object/json.rb +1 -1
- data/lib/active_support/core_ext/range/overlaps.rb +1 -1
- data/lib/active_support/core_ext/securerandom.rb +1 -1
- data/lib/active_support/core_ext/string/conversions.rb +2 -2
- data/lib/active_support/core_ext/string/inquiry.rb +1 -1
- data/lib/active_support/core_ext/string/output_safety.rb +30 -2
- data/lib/active_support/core_ext/time/calculations.rb +2 -2
- data/lib/active_support/core_ext/time/zones.rb +3 -3
- data/lib/active_support/deprecation/behaviors.rb +1 -1
- data/lib/active_support/deprecation/proxy_wrappers.rb +1 -1
- data/lib/active_support/deprecation.rb +1 -1
- data/lib/active_support/error_reporter.rb +2 -2
- data/lib/active_support/evented_file_update_checker.rb +2 -4
- data/lib/active_support/gem_version.rb +3 -3
- data/lib/active_support/inflector/transliterate.rb +1 -1
- data/lib/active_support/isolated_execution_state.rb +8 -0
- data/lib/active_support/key_generator.rb +4 -4
- data/lib/active_support/lazy_load_hooks.rb +14 -3
- data/lib/active_support/log_subscriber/test_helper.rb +2 -2
- data/lib/active_support/log_subscriber.rb +2 -2
- data/lib/active_support/logger.rb +4 -5
- data/lib/active_support/message_encryptor.rb +4 -3
- data/lib/active_support/notifications.rb +2 -2
- data/lib/active_support/ordered_options.rb +1 -1
- data/lib/active_support/railtie.rb +5 -5
- data/lib/active_support/rescuable.rb +2 -2
- data/lib/active_support/secure_compare_rotator.rb +1 -1
- data/lib/active_support/tagged_logging.rb +15 -0
- data/lib/active_support/testing/assertions.rb +1 -1
- data/lib/active_support/time_with_zone.rb +4 -4
- data/lib/active_support/values/time_zone.rb +5 -5
- data/lib/active_support/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d27252aaeb35881e33ca29221cd19156c808edbbaa87e39c426b29c0acbc53d6
|
4
|
+
data.tar.gz: 5b32e5b9ae6c1755f90b3fa7de2eaec2730342084103346cd8587d95c4a97f50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9167c7e108fd1ee981d8e577ff8b6ea7ad96a36abfc3c73230930036f46bbb4a40dab011bfbdb3290fe3d5f76a0b05907fe5b1ca1312d71383f4650273fbd120
|
7
|
+
data.tar.gz: 353971fe5ce79431e27d4060a71dcc347c90b48c39c738bc68ce16fe4b3e7e8fc294596dcdb586b3ebb05af8684d6ea9c3a20e193ebdce36a720d24930bf2fe0
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## Rails 7.0.3 (May 09, 2022) ##
|
2
|
+
|
3
|
+
* No changes.
|
4
|
+
|
5
|
+
|
6
|
+
## Rails 7.0.2.4 (April 26, 2022) ##
|
7
|
+
|
8
|
+
* Fix and add protections for XSS in `ActionView::Helpers` and `ERB::Util`.
|
9
|
+
|
10
|
+
Add the method `ERB::Util.xml_name_escape` to escape dangerous characters
|
11
|
+
in names of tags and names of attributes, following the specification of XML.
|
12
|
+
|
13
|
+
*Álvaro Martín Fraguas*
|
14
|
+
|
1
15
|
## Rails 7.0.2.3 (March 08, 2022) ##
|
2
16
|
|
3
17
|
* No changes.
|
@@ -21,10 +21,10 @@ module ActiveSupport
|
|
21
21
|
#
|
22
22
|
# To reconfigure an existing BacktraceCleaner (like the default one in Rails)
|
23
23
|
# and show as much data as possible, you can always call
|
24
|
-
#
|
24
|
+
# BacktraceCleaner#remove_silencers!, which will restore the
|
25
25
|
# backtrace to a pristine state. If you need to reconfigure an existing
|
26
26
|
# BacktraceCleaner so that it does not filter or modify the paths of any lines
|
27
|
-
# of the backtrace, you can call
|
27
|
+
# of the backtrace, you can call BacktraceCleaner#remove_filters!
|
28
28
|
# These two methods will give you a completely untouched backtrace.
|
29
29
|
#
|
30
30
|
# Inspired by the Quiet Backtrace gem by thoughtbot.
|
@@ -104,7 +104,7 @@ module ActiveSupport
|
|
104
104
|
#
|
105
105
|
# ActiveSupport::Cache::MemCacheStore.new("localhost", "server-downstairs.localnetwork:8229")
|
106
106
|
#
|
107
|
-
# If no addresses are provided, but ENV['MEMCACHE_SERVERS'] is defined, it will be used instead. Otherwise,
|
107
|
+
# If no addresses are provided, but <tt>ENV['MEMCACHE_SERVERS']</tt> is defined, it will be used instead. Otherwise,
|
108
108
|
# MemCacheStore will connect to localhost:11211 (the default memcached port).
|
109
109
|
def initialize(*addresses)
|
110
110
|
addresses = addresses.flatten
|
@@ -129,8 +129,8 @@ module ActiveSupport
|
|
129
129
|
end
|
130
130
|
|
131
131
|
# Increment a cached value. This method uses the memcached incr atomic
|
132
|
-
# operator and can only be used on values written with the
|
133
|
-
# Calling it on a value not stored with
|
132
|
+
# operator and can only be used on values written with the +:raw+ option.
|
133
|
+
# Calling it on a value not stored with +:raw+ will initialize that value
|
134
134
|
# to zero.
|
135
135
|
def increment(name, amount = 1, options = nil)
|
136
136
|
options = merged_options(options)
|
@@ -142,8 +142,8 @@ module ActiveSupport
|
|
142
142
|
end
|
143
143
|
|
144
144
|
# Decrement a cached value. This method uses the memcached decr atomic
|
145
|
-
# operator and can only be used on values written with the
|
146
|
-
# Calling it on a value not stored with
|
145
|
+
# operator and can only be used on values written with the +:raw+ option.
|
146
|
+
# Calling it on a value not stored with +:raw+ will initialize that value
|
147
147
|
# to zero.
|
148
148
|
def decrement(name, amount = 1, options = nil)
|
149
149
|
options = merged_options(options)
|
@@ -11,7 +11,7 @@ module ActiveSupport
|
|
11
11
|
# to share cache data with each other and this may not be the most
|
12
12
|
# appropriate cache in that scenario.
|
13
13
|
#
|
14
|
-
# This cache has a bounded size specified by the
|
14
|
+
# This cache has a bounded size specified by the +:size+ options to the
|
15
15
|
# initializer (default is 32Mb). When the cache exceeds the allotted size,
|
16
16
|
# a cleanup will occur which tries to prune the cache down to three quarters
|
17
17
|
# of the maximum size by removing the least recently used entries.
|
@@ -139,7 +139,7 @@ module ActiveSupport
|
|
139
139
|
#
|
140
140
|
# Race condition TTL is not set by default. This can be used to avoid
|
141
141
|
# "thundering herd" cache writes when hot cache entries are expired.
|
142
|
-
# See
|
142
|
+
# See ActiveSupport::Cache::Store#fetch for more.
|
143
143
|
def initialize(namespace: nil, compress: true, compress_threshold: 1.kilobyte, coder: default_coder, expires_in: nil, race_condition_ttl: nil, error_handler: DEFAULT_ERROR_HANDLER, **redis_options)
|
144
144
|
@redis_options = redis_options
|
145
145
|
|
@@ -225,8 +225,8 @@ module ActiveSupport
|
|
225
225
|
# Cache Store API implementation.
|
226
226
|
#
|
227
227
|
# Increment a cached value. This method uses the Redis incr atomic
|
228
|
-
# operator and can only be used on values written with the
|
229
|
-
# Calling it on a value not stored with
|
228
|
+
# operator and can only be used on values written with the +:raw+ option.
|
229
|
+
# Calling it on a value not stored with +:raw+ will initialize that value
|
230
230
|
# to zero.
|
231
231
|
#
|
232
232
|
# Failsafe: Raises errors.
|
@@ -248,8 +248,8 @@ module ActiveSupport
|
|
248
248
|
# Cache Store API implementation.
|
249
249
|
#
|
250
250
|
# Decrement a cached value. This method uses the Redis decr atomic
|
251
|
-
# operator and can only be used on values written with the
|
252
|
-
# Calling it on a value not stored with
|
251
|
+
# operator and can only be used on values written with the +:raw+ option.
|
252
|
+
# Calling it on a value not stored with +:raw+ will initialize that value
|
253
253
|
# to zero.
|
254
254
|
#
|
255
255
|
# Failsafe: Raises errors.
|
@@ -123,6 +123,9 @@ module ActiveSupport
|
|
123
123
|
return super unless local_cache
|
124
124
|
|
125
125
|
local_entries = local_cache.read_multi_entries(keys)
|
126
|
+
local_entries.transform_values! do |payload|
|
127
|
+
deserialize_entry(payload).value
|
128
|
+
end
|
126
129
|
missed_keys = keys - local_entries.keys
|
127
130
|
|
128
131
|
if missed_keys.any?
|
data/lib/active_support/cache.rb
CHANGED
@@ -141,7 +141,8 @@ module ActiveSupport
|
|
141
141
|
# Some implementations may not support all methods beyond the basic cache
|
142
142
|
# methods of +fetch+, +write+, +read+, +exist?+, and +delete+.
|
143
143
|
#
|
144
|
-
# ActiveSupport::Cache::Store can store any
|
144
|
+
# ActiveSupport::Cache::Store can store any Ruby object that is supported by
|
145
|
+
# its +coder+'s +dump+ and +load+ methods.
|
145
146
|
#
|
146
147
|
# cache = ActiveSupport::Cache::MemoryStore.new
|
147
148
|
#
|
@@ -149,6 +150,8 @@ module ActiveSupport
|
|
149
150
|
# cache.write('city', "Duckburgh")
|
150
151
|
# cache.read('city') # => "Duckburgh"
|
151
152
|
#
|
153
|
+
# cache.write('not serializable', Proc.new {}) # => TypeError
|
154
|
+
#
|
152
155
|
# Keys are always translated into Strings and are case sensitive. When an
|
153
156
|
# object is specified as a key and has a +cache_key+ method defined, this
|
154
157
|
# method will be called to define the key. Otherwise, the +to_param+
|
@@ -16,19 +16,19 @@ module ActiveSupport
|
|
16
16
|
# needing to override or redefine methods of the base class.
|
17
17
|
#
|
18
18
|
# Mixing in this module allows you to define the events in the object's
|
19
|
-
# life cycle that will support callbacks (via
|
19
|
+
# life cycle that will support callbacks (via ClassMethods#define_callbacks),
|
20
20
|
# set the instance methods, procs, or callback objects to be called (via
|
21
|
-
#
|
21
|
+
# ClassMethods#set_callback), and run the installed callbacks at the
|
22
22
|
# appropriate times (via +run_callbacks+).
|
23
23
|
#
|
24
24
|
# By default callbacks are halted by throwing +:abort+.
|
25
|
-
# See
|
25
|
+
# See ClassMethods#define_callbacks for details.
|
26
26
|
#
|
27
27
|
# Three kinds of callbacks are supported: before callbacks, run before a
|
28
28
|
# certain event; after callbacks, run after the event; and around callbacks,
|
29
29
|
# blocks that surround the event, triggering it when they yield. Callback code
|
30
30
|
# can be contained in instance methods, procs or lambdas, or callback objects
|
31
|
-
# that respond to certain predetermined methods. See
|
31
|
+
# that respond to certain predetermined methods. See ClassMethods#set_callback
|
32
32
|
# for details.
|
33
33
|
#
|
34
34
|
# class Record
|
@@ -600,7 +600,7 @@ module ActiveSupport
|
|
600
600
|
end
|
601
601
|
end
|
602
602
|
|
603
|
-
class CallbackChain # :nodoc
|
603
|
+
class CallbackChain # :nodoc:
|
604
604
|
include Enumerable
|
605
605
|
|
606
606
|
attr_reader :name, :config
|
@@ -5,7 +5,7 @@ require "active_support/ordered_options"
|
|
5
5
|
|
6
6
|
module ActiveSupport
|
7
7
|
# Configurable provides a <tt>config</tt> method to store and retrieve
|
8
|
-
# configuration options as an
|
8
|
+
# configuration options as an OrderedOptions.
|
9
9
|
module Configurable
|
10
10
|
extend ActiveSupport::Concern
|
11
11
|
|
@@ -127,7 +127,7 @@ module ActiveSupport
|
|
127
127
|
private :config_accessor
|
128
128
|
end
|
129
129
|
|
130
|
-
# Reads and writes attributes from a configuration
|
130
|
+
# Reads and writes attributes from a configuration OrderedOptions.
|
131
131
|
#
|
132
132
|
# require "active_support/configurable"
|
133
133
|
#
|
@@ -3,8 +3,8 @@
|
|
3
3
|
require "active_support/array_inquirer"
|
4
4
|
|
5
5
|
class Array
|
6
|
-
# Wraps the array in an
|
7
|
-
# to check its string-like contents.
|
6
|
+
# Wraps the array in an ActiveSupport::ArrayInquirer object, which gives a
|
7
|
+
# friendlier way to check its string-like contents.
|
8
8
|
#
|
9
9
|
# pets = [:cat, :dog].inquiry
|
10
10
|
#
|
@@ -13,22 +13,22 @@ class Date
|
|
13
13
|
class << self
|
14
14
|
attr_accessor :beginning_of_week_default
|
15
15
|
|
16
|
-
# Returns the week start (e.g.
|
16
|
+
# Returns the week start (e.g. +:monday+) for the current request, if this has been set (via Date.beginning_of_week=).
|
17
17
|
# If <tt>Date.beginning_of_week</tt> has not been set for the current request, returns the week start specified in <tt>config.beginning_of_week</tt>.
|
18
|
-
# If no config.beginning_of_week was specified, returns
|
18
|
+
# If no +config.beginning_of_week+ was specified, returns +:monday+.
|
19
19
|
def beginning_of_week
|
20
20
|
::ActiveSupport::IsolatedExecutionState[:beginning_of_week] || beginning_of_week_default || :monday
|
21
21
|
end
|
22
22
|
|
23
|
-
# Sets <tt>Date.beginning_of_week</tt> to a week start (e.g.
|
23
|
+
# Sets <tt>Date.beginning_of_week</tt> to a week start (e.g. +:monday+) for current request/thread.
|
24
24
|
#
|
25
25
|
# This method accepts any of the following day symbols:
|
26
|
-
#
|
26
|
+
# +:monday+, +:tuesday+, +:wednesday+, +:thursday+, +:friday+, +:saturday+, +:sunday+
|
27
27
|
def beginning_of_week=(week_start)
|
28
28
|
::ActiveSupport::IsolatedExecutionState[:beginning_of_week] = find_beginning_of_week!(week_start)
|
29
29
|
end
|
30
30
|
|
31
|
-
# Returns week start day symbol (e.g.
|
31
|
+
# Returns week start day symbol (e.g. +:monday+), or raises an +ArgumentError+ for invalid day symbol.
|
32
32
|
def find_beginning_of_week!(week_start)
|
33
33
|
raise ArgumentError, "Invalid beginning of week: #{week_start}" unless ::Date::DAYS_INTO_WEEK.key?(week_start)
|
34
34
|
week_start
|
@@ -68,7 +68,7 @@ class Date
|
|
68
68
|
silence_redefinition_of_method :to_time
|
69
69
|
|
70
70
|
# Converts a Date instance to a Time, where the time is set to the beginning of the day.
|
71
|
-
# The timezone can be either
|
71
|
+
# The timezone can be either +:local+ or +:utc+ (default +:local+).
|
72
72
|
#
|
73
73
|
# date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007
|
74
74
|
#
|
@@ -77,8 +77,8 @@ class Date
|
|
77
77
|
#
|
78
78
|
# date.to_time(:utc) # => 2007-11-10 00:00:00 UTC
|
79
79
|
#
|
80
|
-
# NOTE: The
|
81
|
-
#
|
80
|
+
# NOTE: The +:local+ timezone is Ruby's *process* timezone, i.e. <tt>ENV['TZ']</tt>.
|
81
|
+
# If the <b>application's</b> timezone is needed, then use +in_time_zone+ instead.
|
82
82
|
def to_time(form = :local)
|
83
83
|
raise ArgumentError, "Expected :local or :utc, got #{form.inspect}." unless [:local, :utc].include?(form)
|
84
84
|
::Time.public_send(form, year, month, day)
|
@@ -201,7 +201,7 @@ module DateAndTime
|
|
201
201
|
end
|
202
202
|
end
|
203
203
|
|
204
|
-
# Short-hand for months_since(3)
|
204
|
+
# Short-hand for <tt>months_since(3)</tt>.
|
205
205
|
def next_quarter
|
206
206
|
months_since(3)
|
207
207
|
end
|
@@ -226,18 +226,18 @@ module DateAndTime
|
|
226
226
|
end
|
227
227
|
alias_method :last_weekday, :prev_weekday
|
228
228
|
|
229
|
-
# Short-hand for months_ago(1)
|
229
|
+
# Short-hand for <tt>months_ago(1)</tt>.
|
230
230
|
def last_month
|
231
231
|
months_ago(1)
|
232
232
|
end
|
233
233
|
|
234
|
-
# Short-hand for months_ago(3)
|
234
|
+
# Short-hand for <tt>months_ago(3)</tt>.
|
235
235
|
def prev_quarter
|
236
236
|
months_ago(3)
|
237
237
|
end
|
238
238
|
alias_method :last_quarter, :prev_quarter
|
239
239
|
|
240
|
-
# Short-hand for years_ago(1)
|
240
|
+
# Short-hand for <tt>years_ago(1)</tt>.
|
241
241
|
def last_year
|
242
242
|
years_ago(1)
|
243
243
|
end
|
@@ -15,7 +15,7 @@ module DateAndTime
|
|
15
15
|
|
16
16
|
# Change the output of <tt>ActiveSupport::TimeZone.utc_to_local</tt>.
|
17
17
|
#
|
18
|
-
# When
|
18
|
+
# When +true+, it returns local times with a UTC offset, with +false+ local
|
19
19
|
# times are returned as UTC.
|
20
20
|
#
|
21
21
|
# # Given this zone:
|
@@ -1,13 +1,30 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
4
|
-
|
5
|
-
|
3
|
+
module ActiveSupport
|
4
|
+
module EnumerableCoreExt # :nodoc:
|
5
|
+
module Constants
|
6
|
+
private
|
7
|
+
def const_missing(name)
|
8
|
+
if name == :SoleItemExpectedError
|
9
|
+
::ActiveSupport::EnumerableCoreExt::SoleItemExpectedError
|
10
|
+
else
|
11
|
+
super
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
6
17
|
|
18
|
+
module Enumerable
|
7
19
|
# Error generated by +sole+ when called on an enumerable that doesn't have
|
8
20
|
# exactly one item.
|
9
21
|
class SoleItemExpectedError < StandardError; end
|
10
22
|
|
23
|
+
# HACK: For performance reasons, Enumerable shouldn't have any constants of its own.
|
24
|
+
# So we move SoleItemExpectedError into ActiveSupport::EnumerableCoreExt.
|
25
|
+
ActiveSupport::EnumerableCoreExt::SoleItemExpectedError = remove_const(:SoleItemExpectedError)
|
26
|
+
singleton_class.prepend(ActiveSupport::EnumerableCoreExt::Constants)
|
27
|
+
|
11
28
|
# Enumerable#sum was added in Ruby 2.4, but it only works with Numeric elements
|
12
29
|
# when we omit an identity.
|
13
30
|
|
@@ -106,17 +123,17 @@ module Enumerable
|
|
106
123
|
#
|
107
124
|
# %i( created_at updated_at ).index_with(Time.now)
|
108
125
|
# # => { created_at: 2020-03-09 22:31:47, updated_at: 2020-03-09 22:31:47 }
|
109
|
-
def index_with(default =
|
126
|
+
def index_with(default = (no_default = true))
|
110
127
|
if block_given?
|
111
128
|
result = {}
|
112
129
|
each { |elem| result[elem] = yield(elem) }
|
113
130
|
result
|
114
|
-
elsif
|
131
|
+
elsif no_default
|
132
|
+
to_enum(:index_with) { size if respond_to?(:size) }
|
133
|
+
else
|
115
134
|
result = {}
|
116
135
|
each { |elem| result[elem] = default }
|
117
136
|
result
|
118
|
-
else
|
119
|
-
to_enum(:index_with) { size if respond_to?(:size) }
|
120
137
|
end
|
121
138
|
end
|
122
139
|
|
@@ -240,8 +257,8 @@ module Enumerable
|
|
240
257
|
def sole
|
241
258
|
case count
|
242
259
|
when 1 then return first # rubocop:disable Style/RedundantReturn
|
243
|
-
when 0 then raise SoleItemExpectedError, "no item found"
|
244
|
-
when 2.. then raise SoleItemExpectedError, "multiple items found"
|
260
|
+
when 0 then raise ActiveSupport::EnumerableCoreExt::SoleItemExpectedError, "no item found"
|
261
|
+
when 2.. then raise ActiveSupport::EnumerableCoreExt::SoleItemExpectedError, "multiple items found"
|
245
262
|
end
|
246
263
|
end
|
247
264
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require "active_support/hash_with_indifferent_access"
|
4
4
|
|
5
5
|
class Hash
|
6
|
-
# Returns an
|
6
|
+
# Returns an ActiveSupport::HashWithIndifferentAccess out of its receiver:
|
7
7
|
#
|
8
8
|
# { a: 1 }.with_indifferent_access['a'] # => 1
|
9
9
|
def with_indifferent_access
|
@@ -13,8 +13,8 @@ class Hash
|
|
13
13
|
# Called when object is nested under an object that receives
|
14
14
|
# #with_indifferent_access. This method will be called on the current object
|
15
15
|
# by the enclosing object and is aliased to #with_indifferent_access by
|
16
|
-
# default. Subclasses of Hash may
|
17
|
-
# converting to an
|
16
|
+
# default. Subclasses of Hash may override this method to return +self+ if
|
17
|
+
# converting to an ActiveSupport::HashWithIndifferentAccess would not be
|
18
18
|
# desirable.
|
19
19
|
#
|
20
20
|
# b = { b: 1 }
|
@@ -9,8 +9,8 @@
|
|
9
9
|
# So the values are scoped within the Thread.current space under the class name
|
10
10
|
# of the module.
|
11
11
|
#
|
12
|
-
# Note that it can also be scoped per-fiber if Rails.application.config.active_support.isolation_level
|
13
|
-
# is set to
|
12
|
+
# Note that it can also be scoped per-fiber if +Rails.application.config.active_support.isolation_level+
|
13
|
+
# is set to +:fiber+.
|
14
14
|
class Module
|
15
15
|
# Defines a per-thread class attribute and creates class and instance reader methods.
|
16
16
|
# The underlying per-thread class variable is set to +nil+, if it is not previously defined.
|
@@ -21,7 +21,7 @@ class Module
|
|
21
21
|
#
|
22
22
|
# Current.user = "DHH"
|
23
23
|
# Current.user # => "DHH"
|
24
|
-
# Thread.new { Current.user }.
|
24
|
+
# Thread.new { Current.user }.value # => nil
|
25
25
|
#
|
26
26
|
# The attribute name must be a valid method name in Ruby.
|
27
27
|
#
|
@@ -118,7 +118,7 @@ class Module
|
|
118
118
|
# Account.user # => "DHH"
|
119
119
|
# Account.new.user # => "DHH"
|
120
120
|
#
|
121
|
-
# Unlike
|
121
|
+
# Unlike +mattr_accessor+, values are *not* shared with subclasses or parent classes.
|
122
122
|
# If a subclass changes the value, the parent class' value is not changed.
|
123
123
|
# If the parent class changes the value, the value of subclasses is not changed.
|
124
124
|
#
|
@@ -7,7 +7,7 @@ module ActiveSupport
|
|
7
7
|
module NumericWithFormat
|
8
8
|
# Provides options for converting numbers into formatted strings.
|
9
9
|
# Options are provided for phone numbers, currency, percentage,
|
10
|
-
# precision, positional notation, file size and pretty printing.
|
10
|
+
# precision, positional notation, file size, and pretty printing.
|
11
11
|
#
|
12
12
|
# This method is aliased to <tt>to_formatted_s</tt>.
|
13
13
|
#
|
@@ -12,7 +12,7 @@ module SecureRandom
|
|
12
12
|
#
|
13
13
|
# If _n_ is not specified or is +nil+, 16 is assumed. It may be larger in the future.
|
14
14
|
#
|
15
|
-
# The result may contain alphanumeric characters except 0, O, I and l.
|
15
|
+
# The result may contain alphanumeric characters except 0, O, I, and l.
|
16
16
|
#
|
17
17
|
# p SecureRandom.base58 # => "4kUgL2pdQMSCQtjE"
|
18
18
|
# p SecureRandom.base58(24) # => "77TMHrHJFvFDwodq8w7Ev2m7"
|
@@ -5,10 +5,10 @@ require "active_support/core_ext/time/calculations"
|
|
5
5
|
|
6
6
|
class String
|
7
7
|
# Converts a string to a Time value.
|
8
|
-
# The +form+ can be either
|
8
|
+
# The +form+ can be either +:utc+ or +:local+ (default +:local+).
|
9
9
|
#
|
10
10
|
# The time is parsed using Time.parse method.
|
11
|
-
# If +form+ is
|
11
|
+
# If +form+ is +:local+, then the time is in the system timezone.
|
12
12
|
# If the date part is missing then the current date is used and if
|
13
13
|
# the time part is missing then it is assumed to be 00:00:00.
|
14
14
|
#
|
@@ -4,7 +4,7 @@ require "active_support/string_inquirer"
|
|
4
4
|
require "active_support/environment_inquirer"
|
5
5
|
|
6
6
|
class String
|
7
|
-
# Wraps the current string in the
|
7
|
+
# Wraps the current string in the ActiveSupport::StringInquirer class,
|
8
8
|
# which gives you a prettier way to test for equality.
|
9
9
|
#
|
10
10
|
# env = 'production'.inquiry
|
@@ -11,6 +11,14 @@ class ERB
|
|
11
11
|
HTML_ESCAPE_ONCE_REGEXP = /["><']|&(?!([a-zA-Z]+|(#\d+)|(#[xX][\dA-Fa-f]+));)/
|
12
12
|
JSON_ESCAPE_REGEXP = /[\u2028\u2029&><]/u
|
13
13
|
|
14
|
+
# Following XML requirements: https://www.w3.org/TR/REC-xml/#NT-Name
|
15
|
+
TAG_NAME_START_REGEXP_SET = "@:A-Z_a-z\u{C0}-\u{D6}\u{D8}-\u{F6}\u{F8}-\u{2FF}\u{370}-\u{37D}\u{37F}-\u{1FFF}" \
|
16
|
+
"\u{200C}-\u{200D}\u{2070}-\u{218F}\u{2C00}-\u{2FEF}\u{3001}-\u{D7FF}\u{F900}-\u{FDCF}" \
|
17
|
+
"\u{FDF0}-\u{FFFD}\u{10000}-\u{EFFFF}"
|
18
|
+
TAG_NAME_START_REGEXP = /[^#{TAG_NAME_START_REGEXP_SET}]/
|
19
|
+
TAG_NAME_FOLLOWING_REGEXP = /[^#{TAG_NAME_START_REGEXP_SET}\-.0-9\u{B7}\u{0300}-\u{036F}\u{203F}-\u{2040}]/
|
20
|
+
TAG_NAME_REPLACEMENT_CHAR = "_"
|
21
|
+
|
14
22
|
# A utility method for escaping HTML tag characters.
|
15
23
|
# This method is also aliased as <tt>h</tt>.
|
16
24
|
#
|
@@ -97,7 +105,7 @@ class ERB
|
|
97
105
|
# WARNING: this helper only works with valid JSON. Using this on non-JSON values
|
98
106
|
# will open up serious XSS vulnerabilities. For example, if you replace the
|
99
107
|
# +current_user.to_json+ in the example above with user input instead, the browser
|
100
|
-
# will happily eval() that string as JavaScript.
|
108
|
+
# will happily <tt>eval()</tt> that string as JavaScript.
|
101
109
|
#
|
102
110
|
# The escaping performed in this method is identical to those performed in the
|
103
111
|
# Active Support JSON encoder when +ActiveSupport.escape_html_entities_in_json+ is
|
@@ -115,6 +123,26 @@ class ERB
|
|
115
123
|
end
|
116
124
|
|
117
125
|
module_function :json_escape
|
126
|
+
|
127
|
+
# A utility method for escaping XML names of tags and names of attributes.
|
128
|
+
#
|
129
|
+
# xml_name_escape('1 < 2 & 3')
|
130
|
+
# # => "1___2___3"
|
131
|
+
#
|
132
|
+
# It follows the requirements of the specification: https://www.w3.org/TR/REC-xml/#NT-Name
|
133
|
+
def xml_name_escape(name)
|
134
|
+
name = name.to_s
|
135
|
+
return "" if name.blank?
|
136
|
+
|
137
|
+
starting_char = name[0].gsub(TAG_NAME_START_REGEXP, TAG_NAME_REPLACEMENT_CHAR)
|
138
|
+
|
139
|
+
return starting_char if name.size == 1
|
140
|
+
|
141
|
+
following_chars = name[1..-1].gsub(TAG_NAME_FOLLOWING_REGEXP, TAG_NAME_REPLACEMENT_CHAR)
|
142
|
+
|
143
|
+
starting_char + following_chars
|
144
|
+
end
|
145
|
+
module_function :xml_name_escape
|
118
146
|
end
|
119
147
|
end
|
120
148
|
|
@@ -143,7 +171,7 @@ module ActiveSupport # :nodoc:
|
|
143
171
|
alias_method :original_concat, :concat
|
144
172
|
private :original_concat
|
145
173
|
|
146
|
-
# Raised when
|
174
|
+
# Raised when ActiveSupport::SafeBuffer#safe_concat is called on unsafe buffers.
|
147
175
|
class SafeConcatError < StandardError
|
148
176
|
def initialize
|
149
177
|
super "Could not concatenate to the buffer because it is not html safe."
|
@@ -126,8 +126,8 @@ class Time
|
|
126
126
|
# Returns a new Time where one or more of the elements have been changed according
|
127
127
|
# to the +options+ parameter. The time options (<tt>:hour</tt>, <tt>:min</tt>,
|
128
128
|
# <tt>:sec</tt>, <tt>:usec</tt>, <tt>:nsec</tt>) reset cascadingly, so if only
|
129
|
-
# the hour is passed, then minute, sec, usec and nsec is set to 0. If the hour
|
130
|
-
# and minute is passed, then sec, usec and nsec is set to 0. The +options+ parameter
|
129
|
+
# the hour is passed, then minute, sec, usec, and nsec is set to 0. If the hour
|
130
|
+
# and minute is passed, then sec, usec, and nsec is set to 0. The +options+ parameter
|
131
131
|
# takes a hash with any of these keys: <tt>:year</tt>, <tt>:month</tt>, <tt>:day</tt>,
|
132
132
|
# <tt>:hour</tt>, <tt>:min</tt>, <tt>:sec</tt>, <tt>:usec</tt>, <tt>:nsec</tt>,
|
133
133
|
# <tt>:offset</tt>. Pass either <tt>:usec</tt> or <tt>:nsec</tt>, not both.
|
@@ -21,8 +21,8 @@ class Time
|
|
21
21
|
#
|
22
22
|
# * A Rails TimeZone object.
|
23
23
|
# * An identifier for a Rails TimeZone object (e.g., "Eastern Time (US & Canada)", <tt>-5.hours</tt>).
|
24
|
-
# * A TZInfo::Timezone object.
|
25
|
-
# * An identifier for a TZInfo::Timezone object (e.g., "America/New_York").
|
24
|
+
# * A <tt>TZInfo::Timezone</tt> object.
|
25
|
+
# * An identifier for a <tt>TZInfo::Timezone</tt> object (e.g., "America/New_York").
|
26
26
|
#
|
27
27
|
# Here's an example of how you might set <tt>Time.zone</tt> on a per request basis and reset it when the request is done.
|
28
28
|
# <tt>current_user.time_zone</tt> just needs to return a string identifying the user's preferred time zone:
|
@@ -55,7 +55,7 @@ class Time
|
|
55
55
|
# end
|
56
56
|
# end
|
57
57
|
#
|
58
|
-
# NOTE: This won't affect any
|
58
|
+
# NOTE: This won't affect any ActiveSupport::TimeWithZone
|
59
59
|
# objects that have already been created, e.g. any model timestamp
|
60
60
|
# attributes that have been read before the block will remain in
|
61
61
|
# the application's default timezone.
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require "active_support/notifications"
|
4
4
|
|
5
5
|
module ActiveSupport
|
6
|
-
# Raised when
|
6
|
+
# Raised when ActiveSupport::Deprecation::Behavior#behavior is set with <tt>:raise</tt>.
|
7
7
|
# You would set <tt>:raise</tt>, as a behavior to raise errors and proactively report exceptions from deprecations.
|
8
8
|
class DeprecationException < StandardError
|
9
9
|
end
|
@@ -26,7 +26,7 @@ module ActiveSupport
|
|
26
26
|
end
|
27
27
|
|
28
28
|
# DeprecatedObjectProxy transforms an object into a deprecated one. It
|
29
|
-
# takes an object, a deprecation message and optionally a deprecator. The
|
29
|
+
# takes an object, a deprecation message, and optionally a deprecator. The
|
30
30
|
# deprecator defaults to +ActiveSupport::Deprecator+ if none is specified.
|
31
31
|
#
|
32
32
|
# deprecated_object = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(Object.new, "This object is now deprecated")
|
@@ -4,7 +4,7 @@ require "singleton"
|
|
4
4
|
|
5
5
|
module ActiveSupport
|
6
6
|
# \Deprecation specifies the API used by Rails to deprecate methods, instance
|
7
|
-
# variables, objects and constants.
|
7
|
+
# variables, objects, and constants.
|
8
8
|
class Deprecation
|
9
9
|
# active_support.rb sets an autoload for ActiveSupport::Deprecation.
|
10
10
|
#
|
@@ -28,8 +28,8 @@ module ActiveSupport
|
|
28
28
|
# end
|
29
29
|
#
|
30
30
|
# Additionally a +severity+ can be passed along to communicate how important the error report is.
|
31
|
-
# +severity+ can be one of +:error+, +:warning
|
32
|
-
# severity, and unhandled ones to
|
31
|
+
# +severity+ can be one of +:error+, +:warning+, or +:info+. Handled errors default to the +:warning+
|
32
|
+
# severity, and unhandled ones to +:error+.
|
33
33
|
#
|
34
34
|
# Both +handle+ and +record+ pass through the return value from the block. In the case of +handle+
|
35
35
|
# rescuing an error, a fallback can be provided. The fallback must be a callable whose result will
|
@@ -8,8 +8,8 @@ require "active_support/fork_tracker"
|
|
8
8
|
|
9
9
|
module ActiveSupport
|
10
10
|
# Allows you to "listen" to changes in a file system.
|
11
|
-
# The evented file updater does not hit disk when checking for updates
|
12
|
-
#
|
11
|
+
# The evented file updater does not hit disk when checking for updates.
|
12
|
+
# Instead, it uses platform-specific file system events to trigger a change
|
13
13
|
# in state.
|
14
14
|
#
|
15
15
|
# The file checker takes an array of files to watch or a hash specifying directories
|
@@ -17,8 +17,6 @@ module ActiveSupport
|
|
17
17
|
# EventedFileUpdateChecker#execute is run or when EventedFileUpdateChecker#execute_if_updated
|
18
18
|
# is run and there have been changes to the file system.
|
19
19
|
#
|
20
|
-
# Note: Forking will cause the first call to `updated?` to return `true`.
|
21
|
-
#
|
22
20
|
# Example:
|
23
21
|
#
|
24
22
|
# checker = ActiveSupport::EventedFileUpdateChecker.new(["/tmp/foo"]) { puts "changed" }
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ActiveSupport
|
4
|
-
# Returns the version of
|
4
|
+
# Returns the currently loaded version of Active Support as a <tt>Gem::Version</tt>.
|
5
5
|
def self.gem_version
|
6
6
|
Gem::Version.new VERSION::STRING
|
7
7
|
end
|
@@ -9,8 +9,8 @@ module ActiveSupport
|
|
9
9
|
module VERSION
|
10
10
|
MAJOR = 7
|
11
11
|
MINOR = 0
|
12
|
-
TINY =
|
13
|
-
PRE =
|
12
|
+
TINY = 3
|
13
|
+
PRE = nil
|
14
14
|
|
15
15
|
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
|
16
16
|
end
|
@@ -59,7 +59,7 @@ module ActiveSupport
|
|
59
59
|
# transliterate('Jürgen', locale: :de)
|
60
60
|
# # => "Juergen"
|
61
61
|
#
|
62
|
-
# Transliteration is restricted to UTF-8, US-ASCII and GB18030 strings
|
62
|
+
# Transliteration is restricted to UTF-8, US-ASCII, and GB18030 strings.
|
63
63
|
# Other encodings will raise an ArgumentError.
|
64
64
|
def transliterate(string, replacement = "?", locale: nil)
|
65
65
|
string = string.dup if string.frozen?
|
@@ -49,6 +49,14 @@ module ActiveSupport
|
|
49
49
|
current.clear
|
50
50
|
end
|
51
51
|
|
52
|
+
def share_with(other)
|
53
|
+
# Action Controller streaming spawns a new thread and copy thread locals.
|
54
|
+
# We do the same here for backward compatibility, but this is very much a hack
|
55
|
+
# and streaming should be rethought.
|
56
|
+
context = @isolation_level == :thread ? Thread.current : Fiber.current
|
57
|
+
context.active_support_execution_state = other.active_support_execution_state.dup
|
58
|
+
end
|
59
|
+
|
52
60
|
private
|
53
61
|
def current_thread
|
54
62
|
Thread.current.active_support_execution_state ||= {}
|
@@ -33,17 +33,17 @@ module ActiveSupport
|
|
33
33
|
@hash_digest_class = options[:hash_digest_class] || self.class.hash_digest_class
|
34
34
|
end
|
35
35
|
|
36
|
-
# Returns a derived key suitable for use. The default key_size is chosen
|
36
|
+
# Returns a derived key suitable for use. The default +key_size+ is chosen
|
37
37
|
# to be compatible with the default settings of ActiveSupport::MessageVerifier.
|
38
|
-
# i.e. OpenSSL::Digest::SHA1#block_length
|
38
|
+
# i.e. <tt>OpenSSL::Digest::SHA1#block_length</tt>
|
39
39
|
def generate_key(salt, key_size = 64)
|
40
40
|
OpenSSL::PKCS5.pbkdf2_hmac(@secret, salt, @iterations, key_size, @hash_digest_class.new)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
# CachingKeyGenerator is a wrapper around KeyGenerator which allows users to avoid
|
45
|
-
# re-executing the key generation process when it's called using the same salt and
|
46
|
-
# key_size
|
45
|
+
# re-executing the key generation process when it's called using the same +salt+ and
|
46
|
+
# +key_size+.
|
47
47
|
class CachingKeyGenerator
|
48
48
|
def initialize(key_generator)
|
49
49
|
@key_generator = key_generator
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ActiveSupport
|
4
|
-
#
|
4
|
+
# LazyLoadHooks allows Rails to lazily load a lot of components and thus
|
5
5
|
# making the app boot faster. Because of this feature now there is no need to
|
6
6
|
# require <tt>ActiveRecord::Base</tt> at boot time purely to apply
|
7
7
|
# configuration. Instead a hook is registered that applies configuration once
|
8
8
|
# <tt>ActiveRecord::Base</tt> is loaded. Here <tt>ActiveRecord::Base</tt> is
|
9
9
|
# used as example but this feature can be applied elsewhere too.
|
10
10
|
#
|
11
|
-
# Here is an example where
|
11
|
+
# Here is an example where on_load method is called to register a hook.
|
12
12
|
#
|
13
13
|
# initializer 'active_record.initialize_timezone' do
|
14
14
|
# ActiveSupport.on_load(:active_record) do
|
@@ -18,10 +18,14 @@ module ActiveSupport
|
|
18
18
|
# end
|
19
19
|
#
|
20
20
|
# When the entirety of +ActiveRecord::Base+ has been
|
21
|
-
# evaluated then
|
21
|
+
# evaluated then run_load_hooks is invoked. The very last line of
|
22
22
|
# +ActiveRecord::Base+ is:
|
23
23
|
#
|
24
24
|
# ActiveSupport.run_load_hooks(:active_record, ActiveRecord::Base)
|
25
|
+
#
|
26
|
+
# run_load_hooks will then execute all the hooks that were registered
|
27
|
+
# with the on_load method. In the case of the above example, it will
|
28
|
+
# execute the block of code that is in the +initializer+.
|
25
29
|
module LazyLoadHooks
|
26
30
|
def self.extended(base) # :nodoc:
|
27
31
|
base.class_eval do
|
@@ -46,6 +50,13 @@ module ActiveSupport
|
|
46
50
|
@load_hooks[name] << [block, options]
|
47
51
|
end
|
48
52
|
|
53
|
+
# Executes all blocks registered to +name+ via on_load, using +base+ as the
|
54
|
+
# evaluation context.
|
55
|
+
#
|
56
|
+
# ActiveSupport.run_load_hooks(:active_record, ActiveRecord::Base)
|
57
|
+
#
|
58
|
+
# In the case of the above example, it will execute all hooks registered
|
59
|
+
# for +:active_record+ within the class +ActiveRecord::Base+.
|
49
60
|
def run_load_hooks(name, base = Object)
|
50
61
|
@loaded[name] << base
|
51
62
|
@load_hooks[name].each do |hook, options|
|
@@ -27,13 +27,13 @@ module ActiveSupport
|
|
27
27
|
#
|
28
28
|
# All you need to do is to ensure that your log subscriber is added to
|
29
29
|
# Rails::Subscriber, as in the second line of the code above. The test
|
30
|
-
# helpers are responsible for setting up the queue
|
30
|
+
# helpers are responsible for setting up the queue and subscriptions, and
|
31
31
|
# turning colors in logs off.
|
32
32
|
#
|
33
33
|
# The messages are available in the @logger instance, which is a logger with
|
34
34
|
# limited powers (it actually does not send anything to your output), and
|
35
35
|
# you can collect them doing @logger.logged(level), where level is the level
|
36
|
-
# used in logging, like info, debug, warn and so on.
|
36
|
+
# used in logging, like info, debug, warn, and so on.
|
37
37
|
module TestHelper
|
38
38
|
def setup # :nodoc:
|
39
39
|
@logger = MockLogger.new
|
@@ -6,7 +6,7 @@ require "active_support/subscriber"
|
|
6
6
|
|
7
7
|
module ActiveSupport
|
8
8
|
# <tt>ActiveSupport::LogSubscriber</tt> is an object set to consume
|
9
|
-
#
|
9
|
+
# ActiveSupport::Notifications with the sole purpose of logging them.
|
10
10
|
# The log subscriber dispatches notifications to a registered object based
|
11
11
|
# on its given namespace.
|
12
12
|
#
|
@@ -36,7 +36,7 @@ module ActiveSupport
|
|
36
36
|
# it will properly dispatch the event
|
37
37
|
# (<tt>ActiveSupport::Notifications::Event</tt>) to the sql method.
|
38
38
|
#
|
39
|
-
# Being an
|
39
|
+
# Being an ActiveSupport::Notifications consumer,
|
40
40
|
# <tt>ActiveSupport::LogSubscriber</tt> exposes a simple interface to check if
|
41
41
|
# instrumented code raises an exception. It is common to log a different
|
42
42
|
# message in case of an error, and this can be achieved by extending
|
@@ -22,6 +22,10 @@ module ActiveSupport
|
|
22
22
|
# Broadcasts logs to multiple loggers.
|
23
23
|
def self.broadcast(logger) # :nodoc:
|
24
24
|
Module.new do
|
25
|
+
define_singleton_method(:extended) do |base|
|
26
|
+
base.public_send(:broadcast_to, logger) if base.respond_to?(:broadcast_to)
|
27
|
+
end
|
28
|
+
|
25
29
|
define_method(:add) do |*args, &block|
|
26
30
|
logger.add(*args, &block)
|
27
31
|
super(*args, &block)
|
@@ -42,11 +46,6 @@ module ActiveSupport
|
|
42
46
|
super(name)
|
43
47
|
end
|
44
48
|
|
45
|
-
define_method(:formatter=) do |formatter|
|
46
|
-
logger.formatter = formatter
|
47
|
-
super(formatter)
|
48
|
-
end
|
49
|
-
|
50
49
|
define_method(:level=) do |level|
|
51
50
|
logger.level = level
|
52
51
|
super(level)
|
@@ -13,7 +13,7 @@ module ActiveSupport
|
|
13
13
|
# The cipher text and initialization vector are base64 encoded and returned
|
14
14
|
# to you.
|
15
15
|
#
|
16
|
-
# This can be used in situations similar to the
|
16
|
+
# This can be used in situations similar to the MessageVerifier, but
|
17
17
|
# where you don't want users to be able to determine the value of the payload.
|
18
18
|
#
|
19
19
|
# len = ActiveSupport::MessageEncryptor.key_len
|
@@ -22,6 +22,7 @@ module ActiveSupport
|
|
22
22
|
# crypt = ActiveSupport::MessageEncryptor.new(key) # => #<ActiveSupport::MessageEncryptor ...>
|
23
23
|
# encrypted_data = crypt.encrypt_and_sign('my secret data') # => "NlFBTTMwOUV5UlA1QlNEN2xkY2d6eThYWWh..."
|
24
24
|
# crypt.decrypt_and_verify(encrypted_data) # => "my secret data"
|
25
|
+
#
|
25
26
|
# The +decrypt_and_verify+ method will raise an
|
26
27
|
# <tt>ActiveSupport::MessageEncryptor::InvalidMessage</tt> exception if the data
|
27
28
|
# provided cannot be decrypted or verified.
|
@@ -124,10 +125,10 @@ module ActiveSupport
|
|
124
125
|
# Initialize a new MessageEncryptor. +secret+ must be at least as long as
|
125
126
|
# the cipher key size. For the default 'aes-256-gcm' cipher, this is 256
|
126
127
|
# bits. If you are using a user-entered secret, you can generate a suitable
|
127
|
-
# key by using
|
128
|
+
# key by using ActiveSupport::KeyGenerator or a similar key
|
128
129
|
# derivation function.
|
129
130
|
#
|
130
|
-
# First additional parameter is used as the signature key for
|
131
|
+
# First additional parameter is used as the signature key for MessageVerifier.
|
131
132
|
# This allows you to specify keys to encrypt and sign data.
|
132
133
|
#
|
133
134
|
# ActiveSupport::MessageEncryptor.new('secret', 'signature_secret')
|
@@ -4,7 +4,7 @@ require "active_support/notifications/instrumenter"
|
|
4
4
|
require "active_support/notifications/fanout"
|
5
5
|
|
6
6
|
module ActiveSupport
|
7
|
-
# = Notifications
|
7
|
+
# = \Notifications
|
8
8
|
#
|
9
9
|
# <tt>ActiveSupport::Notifications</tt> provides an instrumentation API for
|
10
10
|
# Ruby.
|
@@ -84,7 +84,7 @@ module ActiveSupport
|
|
84
84
|
# event.payload[:exception] # => ["ArgumentError", "Invalid value"]
|
85
85
|
# event.payload[:exception_object] # => #<ArgumentError: Invalid value>
|
86
86
|
#
|
87
|
-
# As the earlier example depicts, the class
|
87
|
+
# As the earlier example depicts, the class ActiveSupport::Notifications::Event
|
88
88
|
# is able to take the arguments as they come and provide an object-oriented
|
89
89
|
# interface to that data.
|
90
90
|
#
|
@@ -68,7 +68,7 @@ module ActiveSupport
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
# +InheritableOptions+ provides a constructor to build an
|
71
|
+
# +InheritableOptions+ provides a constructor to build an OrderedOptions
|
72
72
|
# hash inherited from another hash.
|
73
73
|
#
|
74
74
|
# Use this if you already have some hash and you want to create a new one based on it.
|
@@ -11,8 +11,10 @@ module ActiveSupport
|
|
11
11
|
config.eager_load_namespaces << ActiveSupport
|
12
12
|
|
13
13
|
initializer "active_support.isolation_level" do |app|
|
14
|
-
|
15
|
-
|
14
|
+
config.after_initialize do
|
15
|
+
if level = app.config.active_support.delete(:isolation_level)
|
16
|
+
ActiveSupport::IsolatedExecutionState.isolation_level = level
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
@@ -41,14 +43,12 @@ module ActiveSupport
|
|
41
43
|
end
|
42
44
|
|
43
45
|
initializer "active_support.reset_all_current_attributes_instances" do |app|
|
44
|
-
executor_around_test_case = app.config.active_support.executor_around_test_case
|
45
|
-
|
46
46
|
app.reloader.before_class_unload { ActiveSupport::CurrentAttributes.clear_all }
|
47
47
|
app.executor.to_run { ActiveSupport::CurrentAttributes.reset_all }
|
48
48
|
app.executor.to_complete { ActiveSupport::CurrentAttributes.reset_all }
|
49
49
|
|
50
50
|
ActiveSupport.on_load(:active_support_test_case) do
|
51
|
-
if executor_around_test_case
|
51
|
+
if app.config.active_support.executor_around_test_case
|
52
52
|
require "active_support/executor/test_helper"
|
53
53
|
include ActiveSupport::Executor::TestHelper
|
54
54
|
else
|
@@ -74,7 +74,7 @@ module ActiveSupport
|
|
74
74
|
# Matches an exception to a handler based on the exception class.
|
75
75
|
#
|
76
76
|
# If no handler matches the exception, check for a handler matching the
|
77
|
-
# (optional) exception.cause
|
77
|
+
# (optional) +exception.cause+. If no handler matches the exception or its
|
78
78
|
# cause, this returns +nil+, so you can deal with unhandled exceptions.
|
79
79
|
# Be sure to re-raise unhandled exceptions if this is what you expect.
|
80
80
|
#
|
@@ -160,7 +160,7 @@ module ActiveSupport
|
|
160
160
|
end
|
161
161
|
|
162
162
|
# Delegates to the class method, but uses the instance as the subject for
|
163
|
-
# rescue_from handlers (method calls, instance_exec blocks).
|
163
|
+
# rescue_from handlers (method calls, +instance_exec+ blocks).
|
164
164
|
def rescue_with_handler(exception)
|
165
165
|
self.class.rescue_with_handler exception, object: self
|
166
166
|
end
|
@@ -4,7 +4,7 @@ require "active_support/security_utils"
|
|
4
4
|
require "active_support/messages/rotator"
|
5
5
|
|
6
6
|
module ActiveSupport
|
7
|
-
# The ActiveSupport::SecureCompareRotator is a wrapper around
|
7
|
+
# The ActiveSupport::SecureCompareRotator is a wrapper around ActiveSupport::SecurityUtils.secure_compare
|
8
8
|
# and allows you to rotate a previously defined value to a new one.
|
9
9
|
#
|
10
10
|
# It can be used as follow:
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "active_support/core_ext/module/delegation"
|
4
|
+
require "active_support/core_ext/module/redefine_method"
|
4
5
|
require "active_support/core_ext/object/blank"
|
5
6
|
require "logger"
|
6
7
|
require "active_support/logger"
|
@@ -94,6 +95,20 @@ module ActiveSupport
|
|
94
95
|
|
95
96
|
delegate :push_tags, :pop_tags, :clear_tags!, to: :formatter
|
96
97
|
|
98
|
+
def broadcast_to(other_logger) # :nodoc:
|
99
|
+
define_singleton_method(:formatter=) do |formatter|
|
100
|
+
other_logger.formatter ||= formatter
|
101
|
+
|
102
|
+
other_logger.formatter.singleton_class.redefine_method(:current_tags) do
|
103
|
+
formatter.current_tags
|
104
|
+
end
|
105
|
+
|
106
|
+
super(formatter)
|
107
|
+
end
|
108
|
+
|
109
|
+
self.formatter = self.formatter.clone
|
110
|
+
end
|
111
|
+
|
97
112
|
def tagged(*tags)
|
98
113
|
if block_given?
|
99
114
|
formatter.tagged(*tags) { yield self }
|
@@ -159,7 +159,7 @@ module ActiveSupport
|
|
159
159
|
# @object = 42
|
160
160
|
# end
|
161
161
|
#
|
162
|
-
# The keyword arguments
|
162
|
+
# The keyword arguments +:from+ and +:to+ can be given to specify the
|
163
163
|
# expected initial value and the expected value after the block was
|
164
164
|
# executed.
|
165
165
|
#
|
@@ -13,7 +13,7 @@ module ActiveSupport
|
|
13
13
|
# system's <tt>ENV['TZ']</tt> zone.
|
14
14
|
#
|
15
15
|
# You shouldn't ever need to create a TimeWithZone instance directly via +new+.
|
16
|
-
# Instead use methods +local+, +parse+, +at
|
16
|
+
# Instead use methods +local+, +parse+, +at+, and +now+ on TimeZone instances,
|
17
17
|
# and +in_time_zone+ on Time and DateTime instances.
|
18
18
|
#
|
19
19
|
# Time.zone = 'Eastern Time (US & Canada)' # => 'Eastern Time (US & Canada)'
|
@@ -78,7 +78,7 @@ module ActiveSupport
|
|
78
78
|
alias_method :getutc, :utc
|
79
79
|
alias_method :gmtime, :utc
|
80
80
|
|
81
|
-
# Returns the underlying TZInfo::TimezonePeriod
|
81
|
+
# Returns the underlying <tt>TZInfo::TimezonePeriod</tt>.
|
82
82
|
def period
|
83
83
|
@period ||= time_zone.period_for_utc(@utc)
|
84
84
|
end
|
@@ -395,8 +395,8 @@ module ActiveSupport
|
|
395
395
|
# Returns a new +ActiveSupport::TimeWithZone+ where one or more of the elements have
|
396
396
|
# been changed according to the +options+ parameter. The time options (<tt>:hour</tt>,
|
397
397
|
# <tt>:min</tt>, <tt>:sec</tt>, <tt>:usec</tt>, <tt>:nsec</tt>) reset cascadingly,
|
398
|
-
# so if only the hour is passed, then minute, sec, usec and nsec is set to 0. If the
|
399
|
-
# hour and minute is passed, then sec, usec and nsec is set to 0. The +options+
|
398
|
+
# so if only the hour is passed, then minute, sec, usec, and nsec is set to 0. If the
|
399
|
+
# hour and minute is passed, then sec, usec, and nsec is set to 0. The +options+
|
400
400
|
# parameter takes a hash with any of these keys: <tt>:year</tt>, <tt>:month</tt>,
|
401
401
|
# <tt>:day</tt>, <tt>:hour</tt>, <tt>:min</tt>, <tt>:sec</tt>, <tt>:usec</tt>,
|
402
402
|
# <tt>:nsec</tt>, <tt>:offset</tt>, <tt>:zone</tt>. Pass either <tt>:usec</tt>
|
@@ -4,16 +4,16 @@ require "tzinfo"
|
|
4
4
|
require "concurrent/map"
|
5
5
|
|
6
6
|
module ActiveSupport
|
7
|
-
# The TimeZone class serves as a wrapper around TZInfo::Timezone instances.
|
7
|
+
# The TimeZone class serves as a wrapper around <tt>TZInfo::Timezone</tt> instances.
|
8
8
|
# It allows us to do the following:
|
9
9
|
#
|
10
10
|
# * Limit the set of zones provided by TZInfo to a meaningful subset of 134
|
11
11
|
# zones.
|
12
12
|
# * Retrieve and display zones with a friendlier name
|
13
13
|
# (e.g., "Eastern Time (US & Canada)" instead of "America/New_York").
|
14
|
-
# * Lazily load TZInfo::Timezone instances only when they're needed.
|
14
|
+
# * Lazily load <tt>TZInfo::Timezone</tt> instances only when they're needed.
|
15
15
|
# * Create ActiveSupport::TimeWithZone instances via TimeZone's +local+,
|
16
|
-
# +parse+, +at
|
16
|
+
# +parse+, +at+, and +now+ methods.
|
17
17
|
#
|
18
18
|
# If you set <tt>config.time_zone</tt> in the Rails Application, you can
|
19
19
|
# access this TimeZone object via <tt>Time.zone</tt>:
|
@@ -543,13 +543,13 @@ module ActiveSupport
|
|
543
543
|
tzinfo.local_to_utc(time, dst)
|
544
544
|
end
|
545
545
|
|
546
|
-
# Available so that TimeZone instances respond like TZInfo::Timezone
|
546
|
+
# Available so that TimeZone instances respond like <tt>TZInfo::Timezone</tt>
|
547
547
|
# instances.
|
548
548
|
def period_for_utc(time)
|
549
549
|
tzinfo.period_for_utc(time)
|
550
550
|
end
|
551
551
|
|
552
|
-
# Available so that TimeZone instances respond like TZInfo::Timezone
|
552
|
+
# Available so that TimeZone instances respond like <tt>TZInfo::Timezone</tt>
|
553
553
|
# instances.
|
554
554
|
def period_for_local(time, dst = true)
|
555
555
|
tzinfo.period_for_local(time, dst) { |periods| periods.last }
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "gem_version"
|
4
4
|
|
5
5
|
module ActiveSupport
|
6
|
-
# Returns the version of
|
6
|
+
# Returns the currently loaded version of Active Support as a <tt>Gem::Version</tt>.
|
7
7
|
def self.version
|
8
8
|
gem_version
|
9
9
|
end
|
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: 7.0.
|
4
|
+
version: 7.0.3
|
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: 2022-
|
11
|
+
date: 2022-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -359,10 +359,10 @@ licenses:
|
|
359
359
|
- MIT
|
360
360
|
metadata:
|
361
361
|
bug_tracker_uri: https://github.com/rails/rails/issues
|
362
|
-
changelog_uri: https://github.com/rails/rails/blob/v7.0.
|
363
|
-
documentation_uri: https://api.rubyonrails.org/v7.0.
|
362
|
+
changelog_uri: https://github.com/rails/rails/blob/v7.0.3/activesupport/CHANGELOG.md
|
363
|
+
documentation_uri: https://api.rubyonrails.org/v7.0.3/
|
364
364
|
mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
|
365
|
-
source_code_uri: https://github.com/rails/rails/tree/v7.0.
|
365
|
+
source_code_uri: https://github.com/rails/rails/tree/v7.0.3/activesupport
|
366
366
|
rubygems_mfa_required: 'true'
|
367
367
|
post_install_message:
|
368
368
|
rdoc_options:
|
@@ -381,7 +381,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
381
381
|
- !ruby/object:Gem::Version
|
382
382
|
version: '0'
|
383
383
|
requirements: []
|
384
|
-
rubygems_version: 3.
|
384
|
+
rubygems_version: 3.3.7
|
385
385
|
signing_key:
|
386
386
|
specification_version: 4
|
387
387
|
summary: A toolkit of support libraries and Ruby core extensions extracted from the
|