activesupport 8.0.2.1 → 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.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +334 -129
  3. data/README.rdoc +1 -1
  4. data/lib/active_support/backtrace_cleaner.rb +71 -0
  5. data/lib/active_support/broadcast_logger.rb +46 -59
  6. data/lib/active_support/cache/mem_cache_store.rb +25 -27
  7. data/lib/active_support/cache/redis_cache_store.rb +36 -30
  8. data/lib/active_support/cache/strategy/local_cache.rb +16 -7
  9. data/lib/active_support/cache/strategy/local_cache_middleware.rb +7 -7
  10. data/lib/active_support/cache.rb +70 -6
  11. data/lib/active_support/callbacks.rb +20 -8
  12. data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +8 -62
  13. data/lib/active_support/concurrency/thread_monitor.rb +55 -0
  14. data/lib/active_support/configurable.rb +34 -0
  15. data/lib/active_support/continuous_integration.rb +145 -0
  16. data/lib/active_support/core_ext/array.rb +7 -7
  17. data/lib/active_support/core_ext/benchmark.rb +4 -11
  18. data/lib/active_support/core_ext/big_decimal.rb +1 -1
  19. data/lib/active_support/core_ext/class/attribute.rb +8 -6
  20. data/lib/active_support/core_ext/class.rb +2 -2
  21. data/lib/active_support/core_ext/date.rb +5 -5
  22. data/lib/active_support/core_ext/date_and_time/compatibility.rb +0 -35
  23. data/lib/active_support/core_ext/date_time/compatibility.rb +3 -5
  24. data/lib/active_support/core_ext/date_time/conversions.rb +4 -2
  25. data/lib/active_support/core_ext/date_time.rb +5 -5
  26. data/lib/active_support/core_ext/digest.rb +1 -1
  27. data/lib/active_support/core_ext/enumerable.rb +16 -4
  28. data/lib/active_support/core_ext/erb/util.rb +3 -3
  29. data/lib/active_support/core_ext/file.rb +1 -1
  30. data/lib/active_support/core_ext/hash.rb +8 -8
  31. data/lib/active_support/core_ext/integer.rb +3 -3
  32. data/lib/active_support/core_ext/kernel.rb +3 -3
  33. data/lib/active_support/core_ext/module.rb +11 -11
  34. data/lib/active_support/core_ext/numeric.rb +3 -3
  35. data/lib/active_support/core_ext/object/json.rb +8 -1
  36. data/lib/active_support/core_ext/object/to_query.rb +7 -1
  37. data/lib/active_support/core_ext/object/try.rb +2 -2
  38. data/lib/active_support/core_ext/object.rb +13 -13
  39. data/lib/active_support/core_ext/pathname.rb +2 -2
  40. data/lib/active_support/core_ext/range/overlap.rb +3 -3
  41. data/lib/active_support/core_ext/range/sole.rb +17 -0
  42. data/lib/active_support/core_ext/range.rb +4 -4
  43. data/lib/active_support/core_ext/string/filters.rb +3 -3
  44. data/lib/active_support/core_ext/string/multibyte.rb +12 -3
  45. data/lib/active_support/core_ext/string/output_safety.rb +19 -12
  46. data/lib/active_support/core_ext/string.rb +13 -13
  47. data/lib/active_support/core_ext/symbol.rb +1 -1
  48. data/lib/active_support/core_ext/time/calculations.rb +0 -7
  49. data/lib/active_support/core_ext/time/compatibility.rb +2 -27
  50. data/lib/active_support/core_ext/time.rb +5 -5
  51. data/lib/active_support/core_ext.rb +1 -1
  52. data/lib/active_support/current_attributes/test_helper.rb +2 -2
  53. data/lib/active_support/current_attributes.rb +26 -16
  54. data/lib/active_support/dependencies/interlock.rb +11 -5
  55. data/lib/active_support/dependencies.rb +6 -1
  56. data/lib/active_support/deprecation/reporting.rb +4 -2
  57. data/lib/active_support/deprecation.rb +1 -1
  58. data/lib/active_support/editor.rb +70 -0
  59. data/lib/active_support/error_reporter.rb +50 -6
  60. data/lib/active_support/event_reporter/test_helper.rb +32 -0
  61. data/lib/active_support/event_reporter.rb +592 -0
  62. data/lib/active_support/evented_file_update_checker.rb +5 -1
  63. data/lib/active_support/execution_context.rb +64 -7
  64. data/lib/active_support/file_update_checker.rb +8 -6
  65. data/lib/active_support/gem_version.rb +3 -3
  66. data/lib/active_support/gzip.rb +1 -0
  67. data/lib/active_support/hash_with_indifferent_access.rb +47 -24
  68. data/lib/active_support/i18n_railtie.rb +2 -2
  69. data/lib/active_support/inflector/inflections.rb +31 -15
  70. data/lib/active_support/inflector/transliterate.rb +6 -8
  71. data/lib/active_support/isolated_execution_state.rb +12 -15
  72. data/lib/active_support/json/decoding.rb +6 -4
  73. data/lib/active_support/json/encoding.rb +135 -17
  74. data/lib/active_support/lazy_load_hooks.rb +1 -1
  75. data/lib/active_support/log_subscriber.rb +2 -6
  76. data/lib/active_support/logger_thread_safe_level.rb +6 -3
  77. data/lib/active_support/message_encryptors.rb +52 -0
  78. data/lib/active_support/message_pack/extensions.rb +5 -0
  79. data/lib/active_support/message_verifiers.rb +52 -0
  80. data/lib/active_support/messages/rotation_coordinator.rb +9 -0
  81. data/lib/active_support/messages/rotator.rb +5 -0
  82. data/lib/active_support/multibyte/chars.rb +8 -1
  83. data/lib/active_support/multibyte.rb +4 -0
  84. data/lib/active_support/notifications/fanout.rb +64 -42
  85. data/lib/active_support/notifications/instrumenter.rb +1 -1
  86. data/lib/active_support/railtie.rb +32 -15
  87. data/lib/active_support/structured_event_subscriber.rb +99 -0
  88. data/lib/active_support/subscriber.rb +0 -5
  89. data/lib/active_support/syntax_error_proxy.rb +3 -0
  90. data/lib/active_support/test_case.rb +61 -6
  91. data/lib/active_support/testing/assertions.rb +34 -6
  92. data/lib/active_support/testing/error_reporter_assertions.rb +18 -1
  93. data/lib/active_support/testing/event_reporter_assertions.rb +227 -0
  94. data/lib/active_support/testing/notification_assertions.rb +92 -0
  95. data/lib/active_support/testing/parallelization/server.rb +15 -2
  96. data/lib/active_support/testing/parallelization/worker.rb +4 -2
  97. data/lib/active_support/testing/parallelization.rb +25 -1
  98. data/lib/active_support/testing/tests_without_assertions.rb +1 -1
  99. data/lib/active_support/testing/time_helpers.rb +7 -3
  100. data/lib/active_support/time_with_zone.rb +22 -22
  101. data/lib/active_support/values/time_zone.rb +8 -1
  102. data/lib/active_support/xml_mini.rb +3 -2
  103. data/lib/active_support.rb +20 -15
  104. metadata +25 -17
  105. data/lib/active_support/core_ext/range/each.rb +0 -24
@@ -5,41 +5,6 @@ require "active_support/core_ext/module/redefine_method"
5
5
 
6
6
  module DateAndTime
7
7
  module Compatibility
8
- # If true, +to_time+ preserves the timezone offset of receiver.
9
- #
10
- # NOTE: With Ruby 2.4+ the default for +to_time+ changed from
11
- # converting to the local system time, to preserving the offset
12
- # of the receiver. For backwards compatibility we're overriding
13
- # this behavior, but new apps will have an initializer that sets
14
- # this to true, because the new behavior is preferred.
15
- mattr_accessor :preserve_timezone, instance_accessor: false, default: nil
16
-
17
- singleton_class.silence_redefinition_of_method :preserve_timezone
18
-
19
- #--
20
- # This re-implements the behaviour of the mattr_reader, instead
21
- # of prepending on to it, to avoid overcomplicating a module that
22
- # is in turn included in several places. This will all go away in
23
- # Rails 8.0 anyway.
24
- def self.preserve_timezone # :nodoc:
25
- if @@preserve_timezone.nil?
26
- # Only warn once, the first time the value is used (which should
27
- # be the first time #to_time is called).
28
- ActiveSupport.deprecator.warn(
29
- "`to_time` will always preserve the receiver timezone rather than system local time in Rails 8.1." \
30
- "To opt in to the new behavior, set `config.active_support.to_time_preserves_timezone = :zone`."
31
- )
32
-
33
- @@preserve_timezone = false
34
- end
35
-
36
- @@preserve_timezone
37
- end
38
-
39
- def preserve_timezone # :nodoc:
40
- Compatibility.preserve_timezone
41
- end
42
-
43
8
  # Change the output of <tt>ActiveSupport::TimeZone.utc_to_local</tt>.
44
9
  #
45
10
  # When +true+, it returns local times with a UTC offset, with +false+ local
@@ -8,11 +8,9 @@ class DateTime
8
8
 
9
9
  silence_redefinition_of_method :to_time
10
10
 
11
- # Either return an instance of +Time+ with the same UTC offset
12
- # as +self+ or an instance of +Time+ representing the same time
13
- # in the local system timezone depending on the setting of
14
- # on the setting of +ActiveSupport.to_time_preserves_timezone+.
11
+ # Return an instance of +Time+ with the same UTC offset
12
+ # as +self+.
15
13
  def to_time
16
- preserve_timezone ? getlocal(utc_offset) : getlocal
14
+ getlocal(utc_offset)
17
15
  end
18
16
  end
@@ -11,7 +11,8 @@ class DateTime
11
11
  #
12
12
  # This method is aliased to <tt>to_formatted_s</tt>.
13
13
  #
14
- # === Examples
14
+ # ==== Examples
15
+ #
15
16
  # datetime = DateTime.civil(2007, 12, 4, 0, 0, 0, 0) # => Tue, 04 Dec 2007 00:00:00 +0000
16
17
  #
17
18
  # datetime.to_fs(:db) # => "2007-12-04 00:00:00"
@@ -23,7 +24,8 @@ class DateTime
23
24
  # datetime.to_fs(:rfc822) # => "Tue, 04 Dec 2007 00:00:00 +0000"
24
25
  # datetime.to_fs(:iso8601) # => "2007-12-04T00:00:00+00:00"
25
26
  #
26
- # == Adding your own datetime formats to to_fs
27
+ # ==== Adding your own datetime formats to +to_fs+
28
+ #
27
29
  # DateTime formats are shared with Time. You can add your own to the
28
30
  # Time::DATE_FORMATS hash. Use the format name as the hash key and
29
31
  # either a strftime string or Proc instance that takes a time or
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/core_ext/date_time/acts_like"
4
- require "active_support/core_ext/date_time/blank"
5
- require "active_support/core_ext/date_time/calculations"
6
- require "active_support/core_ext/date_time/compatibility"
7
- require "active_support/core_ext/date_time/conversions"
3
+ require_relative "date_time/acts_like"
4
+ require_relative "date_time/blank"
5
+ require_relative "date_time/calculations"
6
+ require_relative "date_time/compatibility"
7
+ require_relative "date_time/conversions"
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/core_ext/digest/uuid"
3
+ require_relative "digest/uuid"
@@ -209,10 +209,22 @@ module Enumerable
209
209
  # Set.new.sole # => Enumerable::SoleItemExpectedError: no item found
210
210
  # { a: 1, b: 2 }.sole # => Enumerable::SoleItemExpectedError: multiple items found
211
211
  def sole
212
- case count
213
- when 1 then return first # rubocop:disable Style/RedundantReturn
214
- when 0 then raise ActiveSupport::EnumerableCoreExt::SoleItemExpectedError, "no item found"
215
- when 2.. then raise ActiveSupport::EnumerableCoreExt::SoleItemExpectedError, "multiple items found"
212
+ result = nil
213
+ found = false
214
+
215
+ each do |*element|
216
+ if found
217
+ raise SoleItemExpectedError, "multiple items found"
218
+ end
219
+
220
+ result = element.size == 1 ? element[0] : element
221
+ found = true
222
+ end
223
+
224
+ if found
225
+ result
226
+ else
227
+ raise SoleItemExpectedError, "no item found"
216
228
  end
217
229
  end
218
230
  end
@@ -12,7 +12,7 @@ module ActiveSupport
12
12
  if s.html_safe?
13
13
  s
14
14
  else
15
- super(ActiveSupport::Multibyte::Unicode.tidy_bytes(s))
15
+ super(s)
16
16
  end
17
17
  end
18
18
  alias :unwrapped_html_escape :html_escape # :nodoc:
@@ -61,7 +61,7 @@ class ERB
61
61
  # html_escape_once('&lt;&lt; Accept & Checkout')
62
62
  # # => "&lt;&lt; Accept &amp; Checkout"
63
63
  def html_escape_once(s)
64
- ActiveSupport::Multibyte::Unicode.tidy_bytes(s.to_s).gsub(HTML_ESCAPE_ONCE_REGEXP, HTML_ESCAPE).html_safe
64
+ s.to_s.gsub(HTML_ESCAPE_ONCE_REGEXP, HTML_ESCAPE).html_safe
65
65
  end
66
66
 
67
67
  module_function :html_escape_once
@@ -169,7 +169,7 @@ class ERB
169
169
  while !source.eos?
170
170
  pos = source.pos
171
171
  source.scan_until(/(?:#{start_re}|#{finish_re})/)
172
- raise NotImplementedError if source.matched.nil?
172
+ return [[:PLAIN, source.string]] unless source.matched?
173
173
  len = source.pos - source.matched.bytesize - pos
174
174
 
175
175
  case source.matched
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/core_ext/file/atomic"
3
+ require_relative "file/atomic"
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/core_ext/hash/conversions"
4
- require "active_support/core_ext/hash/deep_merge"
5
- require "active_support/core_ext/hash/deep_transform_values"
6
- require "active_support/core_ext/hash/except"
7
- require "active_support/core_ext/hash/indifferent_access"
8
- require "active_support/core_ext/hash/keys"
9
- require "active_support/core_ext/hash/reverse_merge"
10
- require "active_support/core_ext/hash/slice"
3
+ require_relative "hash/conversions"
4
+ require_relative "hash/deep_merge"
5
+ require_relative "hash/deep_transform_values"
6
+ require_relative "hash/except"
7
+ require_relative "hash/indifferent_access"
8
+ require_relative "hash/keys"
9
+ require_relative "hash/reverse_merge"
10
+ require_relative "hash/slice"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/core_ext/integer/multiple"
4
- require "active_support/core_ext/integer/inflections"
5
- require "active_support/core_ext/integer/time"
3
+ require_relative "integer/multiple"
4
+ require_relative "integer/inflections"
5
+ require_relative "integer/time"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/core_ext/kernel/concern"
4
- require "active_support/core_ext/kernel/reporting"
5
- require "active_support/core_ext/kernel/singleton_class"
3
+ require_relative "kernel/concern"
4
+ require_relative "kernel/reporting"
5
+ require_relative "kernel/singleton_class"
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/core_ext/module/aliasing"
4
- require "active_support/core_ext/module/introspection"
5
- require "active_support/core_ext/module/anonymous"
6
- require "active_support/core_ext/module/attribute_accessors"
7
- require "active_support/core_ext/module/attribute_accessors_per_thread"
8
- require "active_support/core_ext/module/attr_internal"
9
- require "active_support/core_ext/module/concerning"
10
- require "active_support/core_ext/module/delegation"
11
- require "active_support/core_ext/module/deprecation"
12
- require "active_support/core_ext/module/redefine_method"
13
- require "active_support/core_ext/module/remove_method"
3
+ require_relative "module/aliasing"
4
+ require_relative "module/introspection"
5
+ require_relative "module/anonymous"
6
+ require_relative "module/attribute_accessors"
7
+ require_relative "module/attribute_accessors_per_thread"
8
+ require_relative "module/attr_internal"
9
+ require_relative "module/concerning"
10
+ require_relative "module/delegation"
11
+ require_relative "module/deprecation"
12
+ require_relative "module/redefine_method"
13
+ require_relative "module/remove_method"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/core_ext/numeric/bytes"
4
- require "active_support/core_ext/numeric/time"
5
- require "active_support/core_ext/numeric/conversions"
3
+ require_relative "numeric/bytes"
4
+ require_relative "numeric/time"
5
+ require_relative "numeric/conversions"
@@ -240,9 +240,16 @@ class Pathname # :nodoc:
240
240
  end
241
241
 
242
242
  unless IPAddr.method_defined?(:as_json, false)
243
+ # Use `IPAddr#as_json` from the IPAddr gem if the version is 1.2.7 or higher.
243
244
  class IPAddr # :nodoc:
244
245
  def as_json(options = nil)
245
- to_s
246
+ if ipv4? && prefix == 32
247
+ to_s
248
+ elsif ipv6? && prefix == 128
249
+ to_s
250
+ else
251
+ "#{self}/#{prefix}"
252
+ end
246
253
  end
247
254
  end
248
255
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "cgi"
3
+ require "cgi/escape"
4
+ require "cgi/util" if RUBY_VERSION < "3.5"
4
5
 
5
6
  class Object
6
7
  # Alias of <tt>to_s</tt>.
@@ -16,6 +17,11 @@ class Object
16
17
  end
17
18
 
18
19
  class NilClass
20
+ # Returns a CGI-escaped +key+.
21
+ def to_query(key)
22
+ CGI.escape(key.to_param)
23
+ end
24
+
19
25
  # Returns +self+.
20
26
  def to_param
21
27
  self
@@ -145,14 +145,14 @@ class NilClass
145
145
  #
146
146
  # With +try+
147
147
  # @person.try(:children).try(:first).try(:name)
148
- def try(*)
148
+ def try(*, &)
149
149
  nil
150
150
  end
151
151
 
152
152
  # Calling +try!+ on +nil+ always returns +nil+.
153
153
  #
154
154
  # nil.try!(:name) # => nil
155
- def try!(*)
155
+ def try!(*, &)
156
156
  nil
157
157
  end
158
158
  end
@@ -1,17 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/core_ext/object/acts_like"
4
- require "active_support/core_ext/object/blank"
5
- require "active_support/core_ext/object/duplicable"
6
- require "active_support/core_ext/object/deep_dup"
7
- require "active_support/core_ext/object/try"
8
- require "active_support/core_ext/object/inclusion"
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
- require "active_support/core_ext/object/conversions"
11
- require "active_support/core_ext/object/instance_variables"
10
+ require_relative "object/conversions"
11
+ require_relative "object/instance_variables"
12
12
 
13
- require "active_support/core_ext/object/json"
14
- require "active_support/core_ext/object/to_param"
15
- require "active_support/core_ext/object/to_query"
16
- require "active_support/core_ext/object/with"
17
- require "active_support/core_ext/object/with_options"
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,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/core_ext/pathname/blank"
4
- require "active_support/core_ext/pathname/existence"
3
+ require_relative "pathname/blank"
4
+ require_relative "pathname/existence"
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Range
4
- # Compare two ranges and see if they overlap each other
5
- # (1..5).overlap?(4..6) # => true
6
- # (1..5).overlap?(7..9) # => false
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
- require "active_support/core_ext/range/conversions"
4
- require "active_support/core_ext/range/compare_range"
5
- require "active_support/core_ext/range/overlap"
6
- require "active_support/core_ext/range/each"
3
+ require_relative "range/conversions"
4
+ require_relative "range/compare_range"
5
+ require_relative "range/overlap"
6
+ require_relative "range/sole"
@@ -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>.
@@ -12,12 +12,12 @@ 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
22
  # == \Method chaining
23
23
  #
@@ -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::Multibyte.proxy_class.new(self)
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,14 +67,13 @@ module ActiveSupport # :nodoc:
67
67
  original_concat(value)
68
68
  end
69
69
 
70
- def initialize(str = "")
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
- @html_safe = other.html_safe?
76
+ @html_unsafe = true unless other.html_safe?
78
77
  end
79
78
 
80
79
  def concat(value)
@@ -116,7 +115,9 @@ module ActiveSupport # :nodoc:
116
115
  def *(_)
117
116
  new_string = super
118
117
  new_safe_buffer = new_string.is_a?(SafeBuffer) ? new_string : SafeBuffer.new(new_string)
119
- new_safe_buffer.instance_variable_set(:@html_safe, @html_safe)
118
+ if @html_unsafe
119
+ new_safe_buffer.instance_variable_set(:@html_unsafe, true)
120
+ end
120
121
  new_safe_buffer
121
122
  end
122
123
 
@@ -131,14 +132,18 @@ module ActiveSupport # :nodoc:
131
132
  self.class.new(super(escaped_args))
132
133
  end
133
134
 
134
- attr_reader :html_safe
135
- alias_method :html_safe?, :html_safe
136
- remove_method :html_safe
135
+ def html_safe?
136
+ @html_unsafe.nil?
137
+ end
137
138
 
138
139
  def to_s
139
140
  self
140
141
  end
141
142
 
143
+ def as_json(*)
144
+ to_str
145
+ end
146
+
142
147
  def to_param
143
148
  to_str
144
149
  end
@@ -155,7 +160,7 @@ module ActiveSupport # :nodoc:
155
160
  end # end
156
161
 
157
162
  def #{unsafe_method}!(*args) # def capitalize!(*args)
158
- @html_safe = false # @html_safe = false
163
+ @html_unsafe = true # @html_unsafe = true
159
164
  super # super
160
165
  end # end
161
166
  EOT
@@ -176,7 +181,7 @@ module ActiveSupport # :nodoc:
176
181
  end # end
177
182
 
178
183
  def #{unsafe_method}!(*args, &block) # def gsub!(*args, &block)
179
- @html_safe = false # @html_safe = false
184
+ @html_unsafe = true # @html_unsafe = true
180
185
  if block # if block
181
186
  super(*args) { |*params| # super(*args) { |*params|
182
187
  set_block_back_references(block, $~) # set_block_back_references(block, $~)
@@ -191,14 +196,14 @@ module ActiveSupport # :nodoc:
191
196
 
192
197
  private
193
198
  def explicit_html_escape_interpolated_argument(arg)
194
- (!html_safe? || arg.html_safe?) ? arg : CGI.escapeHTML(arg.to_s)
199
+ (!html_safe? || arg.html_safe?) ? arg : ERB::Util.unwrapped_html_escape(arg)
195
200
  end
196
201
 
197
202
  def implicit_html_escape_interpolated_argument(arg)
198
203
  if !html_safe? || arg.html_safe?
199
204
  arg
200
205
  else
201
- CGI.escapeHTML(arg.to_str)
206
+ ERB::Util.unwrapped_html_escape(arg.to_str)
202
207
  end
203
208
  end
204
209
 
@@ -210,7 +215,9 @@ module ActiveSupport # :nodoc:
210
215
 
211
216
  def string_into_safe_buffer(new_string, is_html_safe)
212
217
  new_safe_buffer = new_string.is_a?(SafeBuffer) ? new_string : SafeBuffer.new(new_string)
213
- new_safe_buffer.instance_variable_set :@html_safe, is_html_safe
218
+ unless is_html_safe
219
+ new_safe_buffer.instance_variable_set :@html_unsafe, true
220
+ end
214
221
  new_safe_buffer
215
222
  end
216
223
  end
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/core_ext/string/conversions"
4
- require "active_support/core_ext/string/filters"
5
- require "active_support/core_ext/string/multibyte"
6
- require "active_support/core_ext/string/starts_ends_with"
7
- require "active_support/core_ext/string/inflections"
8
- require "active_support/core_ext/string/access"
9
- require "active_support/core_ext/string/behavior"
10
- require "active_support/core_ext/string/output_safety"
11
- require "active_support/core_ext/string/exclude"
12
- require "active_support/core_ext/string/strip"
13
- require "active_support/core_ext/string/inquiry"
14
- require "active_support/core_ext/string/indent"
15
- require "active_support/core_ext/string/zones"
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,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/core_ext/symbol/starts_ends_with"
3
+ require_relative "symbol/starts_ends_with"
@@ -224,13 +224,6 @@ class Time
224
224
  # Returns a new Time representing the time a number of seconds since the instance time
225
225
  def since(seconds)
226
226
  self + seconds
227
- rescue TypeError
228
- result = to_datetime.since(seconds)
229
- ActiveSupport.deprecator.warn(
230
- "Passing an instance of #{seconds.class} to #{self.class}#since is deprecated. This behavior will raise " \
231
- "a `TypeError` in Rails 8.1."
232
- )
233
- result
234
227
  end
235
228
  alias :in :since
236
229
 
@@ -8,33 +8,8 @@ class Time
8
8
 
9
9
  silence_redefinition_of_method :to_time
10
10
 
11
- # Either return +self+ or the time in the local system timezone depending
12
- # on the setting of +ActiveSupport.to_time_preserves_timezone+.
11
+ # Return +self+.
13
12
  def to_time
14
- preserve_timezone ? self : getlocal
13
+ self
15
14
  end
16
-
17
- def preserve_timezone # :nodoc:
18
- system_local_time? || super
19
- end
20
-
21
- private
22
- def system_local_time?
23
- if ::Time.equal?(self.class)
24
- zone = self.zone
25
- String === zone &&
26
- (zone != "UTC" || active_support_local_zone == "UTC")
27
- end
28
- end
29
-
30
- @@active_support_local_tz = nil
31
-
32
- def active_support_local_zone
33
- @@active_support_local_zone = nil if @@active_support_local_tz != ENV["TZ"]
34
- @@active_support_local_zone ||=
35
- begin
36
- @@active_support_local_tz = ENV["TZ"]
37
- Time.new.zone
38
- end
39
- end
40
15
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/core_ext/time/acts_like"
4
- require "active_support/core_ext/time/calculations"
5
- require "active_support/core_ext/time/compatibility"
6
- require "active_support/core_ext/time/conversions"
7
- require "active_support/core_ext/time/zones"
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,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Dir.glob(File.expand_path("core_ext/*.rb", __dir__)).sort.each do |path|
3
+ (Dir.glob(File.expand_path("core_ext/*.rb", __dir__)).sort - [File.expand_path("core_ext/benchmark.rb", __dir__)]).each do |path|
4
4
  require path
5
5
  end