activesupport 7.1.6 → 8.1.1
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 +256 -1133
- data/README.rdoc +1 -1
- data/lib/active_support/array_inquirer.rb +1 -1
- data/lib/active_support/backtrace_cleaner.rb +81 -3
- data/lib/active_support/benchmark.rb +21 -0
- data/lib/active_support/benchmarkable.rb +3 -2
- data/lib/active_support/broadcast_logger.rb +65 -78
- data/lib/active_support/cache/file_store.rb +29 -14
- data/lib/active_support/cache/mem_cache_store.rb +42 -102
- data/lib/active_support/cache/memory_store.rb +11 -6
- data/lib/active_support/cache/null_store.rb +2 -2
- data/lib/active_support/cache/redis_cache_store.rb +58 -46
- data/lib/active_support/cache/serializer_with_fallback.rb +0 -23
- data/lib/active_support/cache/strategy/local_cache.rb +72 -27
- data/lib/active_support/cache/strategy/local_cache_middleware.rb +7 -7
- data/lib/active_support/cache.rb +146 -86
- data/lib/active_support/callbacks.rb +102 -126
- data/lib/active_support/class_attribute.rb +33 -0
- data/lib/active_support/code_generator.rb +9 -0
- data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +8 -62
- data/lib/active_support/concurrency/share_lock.rb +0 -1
- data/lib/active_support/concurrency/thread_monitor.rb +55 -0
- data/lib/active_support/configurable.rb +34 -0
- data/lib/active_support/configuration_file.rb +15 -6
- data/lib/active_support/continuous_integration.rb +145 -0
- data/lib/active_support/core_ext/array/conversions.rb +3 -5
- data/lib/active_support/core_ext/array.rb +7 -7
- data/lib/active_support/core_ext/benchmark.rb +4 -14
- data/lib/active_support/core_ext/big_decimal.rb +1 -1
- data/lib/active_support/core_ext/class/attribute.rb +26 -19
- data/lib/active_support/core_ext/class/subclasses.rb +15 -35
- data/lib/active_support/core_ext/class.rb +2 -2
- data/lib/active_support/core_ext/date/blank.rb +4 -0
- data/lib/active_support/core_ext/date/conversions.rb +2 -2
- data/lib/active_support/core_ext/date.rb +5 -5
- data/lib/active_support/core_ext/date_and_time/compatibility.rb +1 -9
- data/lib/active_support/core_ext/date_time/blank.rb +4 -0
- data/lib/active_support/core_ext/date_time/compatibility.rb +3 -5
- data/lib/active_support/core_ext/date_time/conversions.rb +4 -6
- data/lib/active_support/core_ext/date_time.rb +5 -5
- data/lib/active_support/core_ext/digest/uuid.rb +6 -0
- data/lib/active_support/core_ext/digest.rb +1 -1
- data/lib/active_support/core_ext/enumerable.rb +25 -8
- data/lib/active_support/core_ext/erb/util.rb +10 -5
- data/lib/active_support/core_ext/file.rb +1 -1
- data/lib/active_support/core_ext/hash/deep_merge.rb +1 -0
- data/lib/active_support/core_ext/hash/except.rb +0 -12
- data/lib/active_support/core_ext/hash/keys.rb +4 -4
- data/lib/active_support/core_ext/hash.rb +8 -8
- data/lib/active_support/core_ext/integer.rb +3 -3
- data/lib/active_support/core_ext/kernel.rb +3 -3
- data/lib/active_support/core_ext/module/attr_internal.rb +16 -6
- data/lib/active_support/core_ext/module/delegation.rb +20 -163
- data/lib/active_support/core_ext/module/deprecation.rb +1 -4
- data/lib/active_support/core_ext/module/introspection.rb +3 -0
- data/lib/active_support/core_ext/module.rb +11 -11
- data/lib/active_support/core_ext/numeric/conversions.rb +3 -3
- data/lib/active_support/core_ext/numeric.rb +3 -3
- data/lib/active_support/core_ext/object/blank.rb +45 -1
- data/lib/active_support/core_ext/object/instance_variables.rb +11 -19
- data/lib/active_support/core_ext/object/json.rb +24 -11
- data/lib/active_support/core_ext/object/to_query.rb +7 -1
- data/lib/active_support/core_ext/object/try.rb +2 -2
- data/lib/active_support/core_ext/object/with.rb +5 -3
- data/lib/active_support/core_ext/object.rb +13 -13
- data/lib/active_support/core_ext/pathname/blank.rb +4 -0
- data/lib/active_support/core_ext/pathname.rb +2 -2
- data/lib/active_support/core_ext/range/overlap.rb +4 -4
- data/lib/active_support/core_ext/range/sole.rb +17 -0
- data/lib/active_support/core_ext/range.rb +4 -4
- data/lib/active_support/core_ext/securerandom.rb +4 -4
- data/lib/active_support/core_ext/string/conversions.rb +1 -1
- data/lib/active_support/core_ext/string/filters.rb +4 -4
- data/lib/active_support/core_ext/string/multibyte.rb +13 -4
- data/lib/active_support/core_ext/string/output_safety.rb +19 -19
- data/lib/active_support/core_ext/string.rb +13 -13
- data/lib/active_support/core_ext/symbol.rb +1 -1
- data/lib/active_support/core_ext/thread/backtrace/location.rb +2 -7
- data/lib/active_support/core_ext/time/calculations.rb +25 -30
- data/lib/active_support/core_ext/time/compatibility.rb +2 -3
- data/lib/active_support/core_ext/time/conversions.rb +2 -2
- data/lib/active_support/core_ext/time/zones.rb +1 -1
- data/lib/active_support/core_ext/time.rb +5 -5
- data/lib/active_support/core_ext.rb +1 -2
- data/lib/active_support/current_attributes/test_helper.rb +2 -2
- data/lib/active_support/current_attributes.rb +58 -50
- data/lib/active_support/delegation.rb +200 -0
- data/lib/active_support/dependencies/autoload.rb +0 -12
- data/lib/active_support/dependencies/interlock.rb +11 -5
- data/lib/active_support/dependencies.rb +6 -2
- data/lib/active_support/deprecation/constant_accessor.rb +47 -26
- data/lib/active_support/deprecation/proxy_wrappers.rb +9 -12
- data/lib/active_support/deprecation/reporting.rb +5 -17
- data/lib/active_support/deprecation.rb +8 -5
- data/lib/active_support/descendants_tracker.rb +9 -87
- data/lib/active_support/duration/iso8601_parser.rb +2 -2
- data/lib/active_support/duration/iso8601_serializer.rb +1 -2
- data/lib/active_support/duration.rb +25 -16
- data/lib/active_support/editor.rb +70 -0
- data/lib/active_support/encrypted_configuration.rb +20 -2
- data/lib/active_support/encrypted_file.rb +1 -1
- data/lib/active_support/error_reporter.rb +121 -6
- data/lib/active_support/event_reporter/test_helper.rb +32 -0
- data/lib/active_support/event_reporter.rb +592 -0
- data/lib/active_support/evented_file_update_checker.rb +5 -3
- data/lib/active_support/execution_context.rb +64 -7
- data/lib/active_support/execution_wrapper.rb +1 -2
- data/lib/active_support/file_update_checker.rb +9 -7
- data/lib/active_support/fork_tracker.rb +2 -38
- data/lib/active_support/gem_version.rb +2 -2
- data/lib/active_support/gzip.rb +1 -0
- data/lib/active_support/hash_with_indifferent_access.rb +66 -45
- data/lib/active_support/html_safe_translation.rb +3 -0
- data/lib/active_support/i18n_railtie.rb +19 -11
- data/lib/active_support/inflector/inflections.rb +31 -15
- data/lib/active_support/inflector/transliterate.rb +6 -8
- data/lib/active_support/isolated_execution_state.rb +12 -17
- data/lib/active_support/json/decoding.rb +6 -4
- data/lib/active_support/json/encoding.rb +157 -21
- data/lib/active_support/lazy_load_hooks.rb +1 -1
- data/lib/active_support/log_subscriber.rb +2 -18
- data/lib/active_support/logger.rb +15 -2
- data/lib/active_support/logger_thread_safe_level.rb +4 -9
- data/lib/active_support/message_encryptors.rb +54 -2
- data/lib/active_support/message_pack/extensions.rb +20 -2
- data/lib/active_support/message_verifier.rb +21 -0
- data/lib/active_support/message_verifiers.rb +57 -3
- data/lib/active_support/messages/rotation_coordinator.rb +9 -0
- data/lib/active_support/messages/rotator.rb +10 -0
- data/lib/active_support/multibyte/chars.rb +14 -4
- data/lib/active_support/multibyte.rb +4 -0
- data/lib/active_support/notifications/fanout.rb +68 -50
- data/lib/active_support/notifications/instrumenter.rb +22 -19
- data/lib/active_support/notifications.rb +28 -27
- data/lib/active_support/number_helper/number_converter.rb +2 -2
- data/lib/active_support/number_helper.rb +22 -0
- data/lib/active_support/option_merger.rb +2 -2
- data/lib/active_support/ordered_options.rb +53 -15
- data/lib/active_support/railtie.rb +36 -20
- data/lib/active_support/string_inquirer.rb +1 -1
- data/lib/active_support/structured_event_subscriber.rb +99 -0
- data/lib/active_support/subscriber.rb +1 -5
- data/lib/active_support/syntax_error_proxy.rb +3 -0
- data/lib/active_support/tagged_logging.rb +5 -1
- data/lib/active_support/test_case.rb +63 -6
- data/lib/active_support/testing/assertions.rb +113 -27
- data/lib/active_support/testing/constant_stubbing.rb +30 -8
- data/lib/active_support/testing/deprecation.rb +5 -12
- data/lib/active_support/testing/error_reporter_assertions.rb +18 -1
- data/lib/active_support/testing/event_reporter_assertions.rb +227 -0
- data/lib/active_support/testing/isolation.rb +19 -9
- data/lib/active_support/testing/method_call_assertions.rb +2 -16
- data/lib/active_support/testing/notification_assertions.rb +92 -0
- data/lib/active_support/testing/parallelization/server.rb +18 -2
- data/lib/active_support/testing/parallelization/worker.rb +4 -2
- data/lib/active_support/testing/parallelization.rb +25 -1
- data/lib/active_support/testing/tests_without_assertions.rb +19 -0
- data/lib/active_support/testing/time_helpers.rb +11 -6
- data/lib/active_support/time_with_zone.rb +39 -26
- data/lib/active_support/values/time_zone.rb +26 -17
- data/lib/active_support/xml_mini.rb +14 -4
- data/lib/active_support.rb +22 -9
- metadata +31 -17
- data/lib/active_support/core_ext/range/each.rb +0 -24
- data/lib/active_support/deprecation/instance_delegator.rb +0 -65
- data/lib/active_support/proxy_object.rb +0 -17
- data/lib/active_support/ruby_features.rb +0 -7
- data/lib/active_support/testing/strict_warnings.rb +0 -39
|
@@ -4,11 +4,13 @@ class Object
|
|
|
4
4
|
# Set and restore public attributes around a block.
|
|
5
5
|
#
|
|
6
6
|
# client.timeout # => 5
|
|
7
|
-
# client.with(timeout: 1) do
|
|
8
|
-
#
|
|
7
|
+
# client.with(timeout: 1) do |c|
|
|
8
|
+
# c.timeout # => 1
|
|
9
9
|
# end
|
|
10
10
|
# client.timeout # => 5
|
|
11
11
|
#
|
|
12
|
+
# The receiver is yielded to the provided block.
|
|
13
|
+
#
|
|
12
14
|
# This method is a shorthand for the common begin/ensure pattern:
|
|
13
15
|
#
|
|
14
16
|
# old_value = object.attribute
|
|
@@ -28,7 +30,7 @@ class Object
|
|
|
28
30
|
old_values[key] = public_send(key)
|
|
29
31
|
public_send("#{key}=", value)
|
|
30
32
|
end
|
|
31
|
-
yield
|
|
33
|
+
yield self
|
|
32
34
|
ensure
|
|
33
35
|
old_values.each do |key, old_value|
|
|
34
36
|
public_send("#{key}=", old_value)
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
require_relative "object/acts_like"
|
|
4
|
+
require_relative "object/blank"
|
|
5
|
+
require_relative "object/duplicable"
|
|
6
|
+
require_relative "object/deep_dup"
|
|
7
|
+
require_relative "object/try"
|
|
8
|
+
require_relative "object/inclusion"
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
require_relative "object/conversions"
|
|
11
|
+
require_relative "object/instance_variables"
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
require_relative "object/json"
|
|
14
|
+
require_relative "object/to_param"
|
|
15
|
+
require_relative "object/to_query"
|
|
16
|
+
require_relative "object/with"
|
|
17
|
+
require_relative "object/with_options"
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
class Range
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
unless Range.method_defined?(:overlap?) # Ruby 3.3+
|
|
5
|
+
# Compare two ranges and see if they overlap each other
|
|
6
|
+
# (1..5).overlap?(4..6) # => true
|
|
7
|
+
# (1..5).overlap?(7..9) # => false
|
|
8
8
|
def overlap?(other)
|
|
9
9
|
raise TypeError unless other.is_a? Range
|
|
10
10
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Range
|
|
4
|
+
# Returns the sole item in the range. If there are no items, or more
|
|
5
|
+
# than one item, raises Enumerable::SoleItemExpectedError.
|
|
6
|
+
#
|
|
7
|
+
# (1..1).sole # => 1
|
|
8
|
+
# (2..1).sole # => Enumerable::SoleItemExpectedError: no item found
|
|
9
|
+
# (..1).sole # => Enumerable::SoleItemExpectedError: infinite range cannot represent a sole item
|
|
10
|
+
def sole
|
|
11
|
+
if self.begin.nil? || self.end.nil?
|
|
12
|
+
raise ActiveSupport::EnumerableCoreExt::SoleItemExpectedError, "infinite range '#{inspect}' cannot represent a sole item"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
super
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
require_relative "range/conversions"
|
|
4
|
+
require_relative "range/compare_range"
|
|
5
|
+
require_relative "range/overlap"
|
|
6
|
+
require_relative "range/sole"
|
|
@@ -16,9 +16,9 @@ module SecureRandom
|
|
|
16
16
|
#
|
|
17
17
|
# p SecureRandom.base58 # => "4kUgL2pdQMSCQtjE"
|
|
18
18
|
# p SecureRandom.base58(24) # => "77TMHrHJFvFDwodq8w7Ev2m7"
|
|
19
|
-
if
|
|
19
|
+
if SecureRandom.method(:alphanumeric).parameters.size == 2 # Remove check when Ruby 3.3 is the minimum supported version
|
|
20
20
|
def self.base58(n = 16)
|
|
21
|
-
|
|
21
|
+
alphanumeric(n, chars: BASE58_ALPHABET)
|
|
22
22
|
end
|
|
23
23
|
else
|
|
24
24
|
def self.base58(n = 16)
|
|
@@ -41,9 +41,9 @@ module SecureRandom
|
|
|
41
41
|
#
|
|
42
42
|
# p SecureRandom.base36 # => "4kugl2pdqmscqtje"
|
|
43
43
|
# p SecureRandom.base36(24) # => "77tmhrhjfvfdwodq8w7ev2m7"
|
|
44
|
-
if
|
|
44
|
+
if SecureRandom.method(:alphanumeric).parameters.size == 2 # Remove check when Ruby 3.3 is the minimum supported version
|
|
45
45
|
def self.base36(n = 16)
|
|
46
|
-
|
|
46
|
+
alphanumeric(n, chars: BASE36_ALPHABET)
|
|
47
47
|
end
|
|
48
48
|
else
|
|
49
49
|
def self.base36(n = 16)
|
|
@@ -22,7 +22,7 @@ class String
|
|
|
22
22
|
def to_time(form = :local)
|
|
23
23
|
parts = Date._parse(self, false)
|
|
24
24
|
used_keys = %i(year mon mday hour min sec sec_fraction offset)
|
|
25
|
-
return if
|
|
25
|
+
return if !parts.keys.intersect?(used_keys)
|
|
26
26
|
|
|
27
27
|
now = Time.now
|
|
28
28
|
time = Time.new(
|
|
@@ -88,11 +88,11 @@ class String
|
|
|
88
88
|
# characters.
|
|
89
89
|
#
|
|
90
90
|
# >> "🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪".size
|
|
91
|
-
# => 20
|
|
91
|
+
# # => 20
|
|
92
92
|
# >> "🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪".bytesize
|
|
93
|
-
# => 80
|
|
93
|
+
# # => 80
|
|
94
94
|
# >> "🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪🔪".truncate_bytes(20)
|
|
95
|
-
# => "🔪🔪🔪🔪…"
|
|
95
|
+
# # => "🔪🔪🔪🔪…"
|
|
96
96
|
#
|
|
97
97
|
# The truncated text ends with the <tt>:omission</tt> string, defaulting
|
|
98
98
|
# to "…", for a total length not exceeding <tt>truncate_to</tt>.
|
|
@@ -109,7 +109,7 @@ class String
|
|
|
109
109
|
when omission.bytesize == truncate_to
|
|
110
110
|
omission.dup
|
|
111
111
|
else
|
|
112
|
-
self.class.new.tap do |cut|
|
|
112
|
+
self.class.new.force_encoding(encoding).tap do |cut|
|
|
113
113
|
cut_at = truncate_to - omission.bytesize
|
|
114
114
|
|
|
115
115
|
each_grapheme_cluster do |grapheme|
|
|
@@ -12,14 +12,14 @@ class String
|
|
|
12
12
|
# class. If the proxy class doesn't respond to a certain method, it's forwarded to the encapsulated string.
|
|
13
13
|
#
|
|
14
14
|
# >> "lj".mb_chars.upcase.to_s
|
|
15
|
-
# => "LJ"
|
|
15
|
+
# # => "LJ"
|
|
16
16
|
#
|
|
17
17
|
# NOTE: Ruby 2.4 and later support native Unicode case mappings:
|
|
18
18
|
#
|
|
19
19
|
# >> "lj".upcase
|
|
20
|
-
# => "LJ"
|
|
20
|
+
# # => "LJ"
|
|
21
21
|
#
|
|
22
|
-
# == Method chaining
|
|
22
|
+
# == \Method chaining
|
|
23
23
|
#
|
|
24
24
|
# All the methods on the Chars proxy which normally return a string will return a Chars object. This allows
|
|
25
25
|
# method chaining on the result of any of these methods.
|
|
@@ -35,7 +35,16 @@ class String
|
|
|
35
35
|
# For more information about the methods defined on the Chars proxy see ActiveSupport::Multibyte::Chars. For
|
|
36
36
|
# information about how to change the default Multibyte behavior see ActiveSupport::Multibyte.
|
|
37
37
|
def mb_chars
|
|
38
|
-
ActiveSupport
|
|
38
|
+
ActiveSupport.deprecator.warn(
|
|
39
|
+
"String#mb_chars is deprecated and will be removed in Rails 8.2. " \
|
|
40
|
+
"Use normal string methods instead."
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
if ActiveSupport::Multibyte.proxy_class == ActiveSupport::Multibyte::Chars
|
|
44
|
+
ActiveSupport::Multibyte::Chars.new(self, deprecation: false)
|
|
45
|
+
else
|
|
46
|
+
ActiveSupport::Multibyte.proxy_class.new(self)
|
|
47
|
+
end
|
|
39
48
|
end
|
|
40
49
|
|
|
41
50
|
# Returns +true+ if string has utf_8 encoding.
|
|
@@ -67,21 +67,13 @@ module ActiveSupport # :nodoc:
|
|
|
67
67
|
original_concat(value)
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
-
def initialize(
|
|
71
|
-
@html_safe = true
|
|
70
|
+
def initialize(_str = "")
|
|
72
71
|
super
|
|
73
72
|
end
|
|
74
73
|
|
|
75
74
|
def initialize_copy(other)
|
|
76
75
|
super
|
|
77
|
-
@
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def clone_empty # :nodoc:
|
|
81
|
-
ActiveSupport.deprecator.warn <<~EOM
|
|
82
|
-
ActiveSupport::SafeBuffer#clone_empty is deprecated and will be removed in Rails 7.2.
|
|
83
|
-
EOM
|
|
84
|
-
self[0, 0]
|
|
76
|
+
@html_unsafe = true unless other.html_safe?
|
|
85
77
|
end
|
|
86
78
|
|
|
87
79
|
def concat(value)
|
|
@@ -123,7 +115,9 @@ module ActiveSupport # :nodoc:
|
|
|
123
115
|
def *(_)
|
|
124
116
|
new_string = super
|
|
125
117
|
new_safe_buffer = new_string.is_a?(SafeBuffer) ? new_string : SafeBuffer.new(new_string)
|
|
126
|
-
|
|
118
|
+
if @html_unsafe
|
|
119
|
+
new_safe_buffer.instance_variable_set(:@html_unsafe, true)
|
|
120
|
+
end
|
|
127
121
|
new_safe_buffer
|
|
128
122
|
end
|
|
129
123
|
|
|
@@ -138,14 +132,18 @@ module ActiveSupport # :nodoc:
|
|
|
138
132
|
self.class.new(super(escaped_args))
|
|
139
133
|
end
|
|
140
134
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
135
|
+
def html_safe?
|
|
136
|
+
@html_unsafe.nil?
|
|
137
|
+
end
|
|
144
138
|
|
|
145
139
|
def to_s
|
|
146
140
|
self
|
|
147
141
|
end
|
|
148
142
|
|
|
143
|
+
def as_json(*)
|
|
144
|
+
to_str
|
|
145
|
+
end
|
|
146
|
+
|
|
149
147
|
def to_param
|
|
150
148
|
to_str
|
|
151
149
|
end
|
|
@@ -162,7 +160,7 @@ module ActiveSupport # :nodoc:
|
|
|
162
160
|
end # end
|
|
163
161
|
|
|
164
162
|
def #{unsafe_method}!(*args) # def capitalize!(*args)
|
|
165
|
-
@
|
|
163
|
+
@html_unsafe = true # @html_unsafe = true
|
|
166
164
|
super # super
|
|
167
165
|
end # end
|
|
168
166
|
EOT
|
|
@@ -183,7 +181,7 @@ module ActiveSupport # :nodoc:
|
|
|
183
181
|
end # end
|
|
184
182
|
|
|
185
183
|
def #{unsafe_method}!(*args, &block) # def gsub!(*args, &block)
|
|
186
|
-
@
|
|
184
|
+
@html_unsafe = true # @html_unsafe = true
|
|
187
185
|
if block # if block
|
|
188
186
|
super(*args) { |*params| # super(*args) { |*params|
|
|
189
187
|
set_block_back_references(block, $~) # set_block_back_references(block, $~)
|
|
@@ -198,14 +196,14 @@ module ActiveSupport # :nodoc:
|
|
|
198
196
|
|
|
199
197
|
private
|
|
200
198
|
def explicit_html_escape_interpolated_argument(arg)
|
|
201
|
-
(!html_safe? || arg.html_safe?) ? arg :
|
|
199
|
+
(!html_safe? || arg.html_safe?) ? arg : ERB::Util.unwrapped_html_escape(arg)
|
|
202
200
|
end
|
|
203
201
|
|
|
204
202
|
def implicit_html_escape_interpolated_argument(arg)
|
|
205
203
|
if !html_safe? || arg.html_safe?
|
|
206
204
|
arg
|
|
207
205
|
else
|
|
208
|
-
|
|
206
|
+
ERB::Util.unwrapped_html_escape(arg.to_str)
|
|
209
207
|
end
|
|
210
208
|
end
|
|
211
209
|
|
|
@@ -217,7 +215,9 @@ module ActiveSupport # :nodoc:
|
|
|
217
215
|
|
|
218
216
|
def string_into_safe_buffer(new_string, is_html_safe)
|
|
219
217
|
new_safe_buffer = new_string.is_a?(SafeBuffer) ? new_string : SafeBuffer.new(new_string)
|
|
220
|
-
|
|
218
|
+
unless is_html_safe
|
|
219
|
+
new_safe_buffer.instance_variable_set :@html_unsafe, true
|
|
220
|
+
end
|
|
221
221
|
new_safe_buffer
|
|
222
222
|
end
|
|
223
223
|
end
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
require_relative "string/conversions"
|
|
4
|
+
require_relative "string/filters"
|
|
5
|
+
require_relative "string/multibyte"
|
|
6
|
+
require_relative "string/starts_ends_with"
|
|
7
|
+
require_relative "string/inflections"
|
|
8
|
+
require_relative "string/access"
|
|
9
|
+
require_relative "string/behavior"
|
|
10
|
+
require_relative "string/output_safety"
|
|
11
|
+
require_relative "string/exclude"
|
|
12
|
+
require_relative "string/strip"
|
|
13
|
+
require_relative "string/inquiry"
|
|
14
|
+
require_relative "string/indent"
|
|
15
|
+
require_relative "string/zones"
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
class Thread::Backtrace::Location # :nodoc:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
ErrorHighlight.spot(ex, backtrace_location: self)
|
|
7
|
-
end
|
|
8
|
-
else
|
|
9
|
-
def spot(ex)
|
|
10
|
-
end
|
|
4
|
+
def spot(ex)
|
|
5
|
+
ErrorHighlight.spot(ex, backtrace_location: self)
|
|
11
6
|
end
|
|
12
7
|
end
|
|
@@ -42,20 +42,20 @@ class Time
|
|
|
42
42
|
|
|
43
43
|
# Layers additional behavior on Time.at so that ActiveSupport::TimeWithZone and DateTime
|
|
44
44
|
# instances can be used when called with a single argument
|
|
45
|
-
def at_with_coercion(*args
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
at_without_coercion(time_or_number.to_f).getlocal
|
|
45
|
+
def at_with_coercion(time_or_number, *args)
|
|
46
|
+
if args.empty?
|
|
47
|
+
if time_or_number.is_a?(ActiveSupport::TimeWithZone)
|
|
48
|
+
at_without_coercion(time_or_number.to_r).getlocal
|
|
49
|
+
elsif time_or_number.is_a?(DateTime)
|
|
50
|
+
at_without_coercion(time_or_number.to_f).getlocal
|
|
51
|
+
else
|
|
52
|
+
at_without_coercion(time_or_number)
|
|
53
|
+
end
|
|
55
54
|
else
|
|
56
|
-
at_without_coercion(time_or_number)
|
|
55
|
+
at_without_coercion(time_or_number, *args)
|
|
57
56
|
end
|
|
58
57
|
end
|
|
58
|
+
ruby2_keywords :at_with_coercion
|
|
59
59
|
alias_method :at_without_coercion, :at
|
|
60
60
|
alias_method :at, :at_with_coercion
|
|
61
61
|
|
|
@@ -108,21 +108,6 @@ class Time
|
|
|
108
108
|
subsec
|
|
109
109
|
end
|
|
110
110
|
|
|
111
|
-
unless Time.method_defined?(:floor)
|
|
112
|
-
def floor(precision = 0)
|
|
113
|
-
change(nsec: 0) + subsec.floor(precision)
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
# Restricted Ruby version due to a bug in `Time#ceil`
|
|
118
|
-
# See https://bugs.ruby-lang.org/issues/17025 for more details
|
|
119
|
-
if RUBY_VERSION <= "2.8"
|
|
120
|
-
remove_possible_method :ceil
|
|
121
|
-
def ceil(precision = 0)
|
|
122
|
-
change(nsec: 0) + subsec.ceil(precision)
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
|
|
126
111
|
# Returns a new Time where one or more of the elements have been changed according
|
|
127
112
|
# to the +options+ parameter. The time options (<tt>:hour</tt>, <tt>:min</tt>,
|
|
128
113
|
# <tt>:sec</tt>, <tt>:usec</tt>, <tt>:nsec</tt>) reset cascadingly, so if only
|
|
@@ -159,9 +144,16 @@ class Time
|
|
|
159
144
|
::Time.new(new_year, new_month, new_day, new_hour, new_min, new_sec, new_offset)
|
|
160
145
|
elsif utc?
|
|
161
146
|
::Time.utc(new_year, new_month, new_day, new_hour, new_min, new_sec)
|
|
162
|
-
elsif zone
|
|
147
|
+
elsif zone.respond_to?(:utc_to_local)
|
|
163
148
|
new_time = ::Time.new(new_year, new_month, new_day, new_hour, new_min, new_sec, zone)
|
|
164
149
|
|
|
150
|
+
# Some versions of Ruby have a bug where Time.new with a zone object and
|
|
151
|
+
# fractional seconds will end up with a broken utc_offset.
|
|
152
|
+
# This is fixed in Ruby 3.3.1 and 3.2.4
|
|
153
|
+
unless new_time.utc_offset.integer?
|
|
154
|
+
new_time += 0
|
|
155
|
+
end
|
|
156
|
+
|
|
165
157
|
# When there are two occurrences of a nominal time due to DST ending,
|
|
166
158
|
# `Time.new` chooses the first chronological occurrence (the one with a
|
|
167
159
|
# larger UTC offset). However, for `change`, we want to choose the
|
|
@@ -232,8 +224,6 @@ class Time
|
|
|
232
224
|
# Returns a new Time representing the time a number of seconds since the instance time
|
|
233
225
|
def since(seconds)
|
|
234
226
|
self + seconds
|
|
235
|
-
rescue
|
|
236
|
-
to_datetime.since(seconds)
|
|
237
227
|
end
|
|
238
228
|
alias :in :since
|
|
239
229
|
|
|
@@ -334,7 +324,12 @@ class Time
|
|
|
334
324
|
if other.class == Time
|
|
335
325
|
compare_without_coercion(other)
|
|
336
326
|
elsif other.is_a?(Time)
|
|
337
|
-
|
|
327
|
+
# also avoid ActiveSupport::TimeWithZone#to_time before Rails 8.0
|
|
328
|
+
if other.respond_to?(:comparable_time)
|
|
329
|
+
compare_without_coercion(other.comparable_time)
|
|
330
|
+
else
|
|
331
|
+
compare_without_coercion(other.to_time)
|
|
332
|
+
end
|
|
338
333
|
else
|
|
339
334
|
to_datetime <=> other
|
|
340
335
|
end
|
|
@@ -8,9 +8,8 @@ class Time
|
|
|
8
8
|
|
|
9
9
|
silence_redefinition_of_method :to_time
|
|
10
10
|
|
|
11
|
-
#
|
|
12
|
-
# on the setting of +ActiveSupport.to_time_preserves_timezone+.
|
|
11
|
+
# Return +self+.
|
|
13
12
|
def to_time
|
|
14
|
-
|
|
13
|
+
self
|
|
15
14
|
end
|
|
16
15
|
end
|
|
@@ -22,6 +22,7 @@ class Time
|
|
|
22
22
|
offset_format = time.formatted_offset(false)
|
|
23
23
|
time.strftime("%a, %d %b %Y %H:%M:%S #{offset_format}")
|
|
24
24
|
},
|
|
25
|
+
rfc2822: lambda { |time| time.rfc2822 },
|
|
25
26
|
iso8601: lambda { |time| time.iso8601 }
|
|
26
27
|
}
|
|
27
28
|
|
|
@@ -40,6 +41,7 @@ class Time
|
|
|
40
41
|
# time.to_fs(:long) # => "January 18, 2007 06:10"
|
|
41
42
|
# time.to_fs(:long_ordinal) # => "January 18th, 2007 06:10"
|
|
42
43
|
# time.to_fs(:rfc822) # => "Thu, 18 Jan 2007 06:10:17 -0600"
|
|
44
|
+
# time.to_fs(:rfc2822) # => "Thu, 18 Jan 2007 06:10:17 -0600"
|
|
43
45
|
# time.to_fs(:iso8601) # => "2007-01-18T06:10:17-06:00"
|
|
44
46
|
#
|
|
45
47
|
# == Adding your own time formats to +to_fs+
|
|
@@ -58,8 +60,6 @@ class Time
|
|
|
58
60
|
end
|
|
59
61
|
end
|
|
60
62
|
alias_method :to_formatted_s, :to_fs
|
|
61
|
-
alias_method :to_default_s, :to_s
|
|
62
|
-
deprecate to_default_s: :to_s, deprecator: ActiveSupport.deprecator
|
|
63
63
|
|
|
64
64
|
# Returns a formatted string of the offset from UTC, or an alternative
|
|
65
65
|
# string if the time zone is already UTC.
|
|
@@ -20,7 +20,7 @@ class Time
|
|
|
20
20
|
# This method accepts any of the following:
|
|
21
21
|
#
|
|
22
22
|
# * A \Rails TimeZone object.
|
|
23
|
-
# * An identifier for a \Rails TimeZone object (e.g., "Eastern Time (US & Canada)", <tt>-5.hours</tt>).
|
|
23
|
+
# * An identifier for a \Rails TimeZone object (e.g., "Eastern \Time (US & Canada)", <tt>-5.hours</tt>).
|
|
24
24
|
# * A +TZInfo::Timezone+ object.
|
|
25
25
|
# * An identifier for a +TZInfo::Timezone+ object (e.g., "America/New_York").
|
|
26
26
|
#
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
require_relative "time/acts_like"
|
|
4
|
+
require_relative "time/calculations"
|
|
5
|
+
require_relative "time/compatibility"
|
|
6
|
+
require_relative "time/conversions"
|
|
7
|
+
require_relative "time/zones"
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
Dir.glob(File.expand_path("core_ext/*.rb", __dir__)).sort.each do |path|
|
|
4
|
-
next if path.end_with?("core_ext/uri.rb")
|
|
3
|
+
(Dir.glob(File.expand_path("core_ext/*.rb", __dir__)).sort - [File.expand_path("core_ext/benchmark.rb", __dir__)]).each do |path|
|
|
5
4
|
require path
|
|
6
5
|
end
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
module ActiveSupport::CurrentAttributes::TestHelper # :nodoc:
|
|
4
4
|
def before_setup
|
|
5
|
-
ActiveSupport::CurrentAttributes.
|
|
5
|
+
ActiveSupport::CurrentAttributes.clear_all
|
|
6
6
|
super
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def after_teardown
|
|
10
10
|
super
|
|
11
|
-
ActiveSupport::CurrentAttributes.
|
|
11
|
+
ActiveSupport::CurrentAttributes.clear_all
|
|
12
12
|
end
|
|
13
13
|
end
|