activesupport 8.0.3 → 8.1.0.rc1

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 (96) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +312 -159
  3. data/lib/active_support/backtrace_cleaner.rb +71 -0
  4. data/lib/active_support/cache/mem_cache_store.rb +13 -13
  5. data/lib/active_support/cache/redis_cache_store.rb +36 -30
  6. data/lib/active_support/cache/strategy/local_cache.rb +16 -7
  7. data/lib/active_support/cache/strategy/local_cache_middleware.rb +7 -7
  8. data/lib/active_support/cache.rb +69 -6
  9. data/lib/active_support/callbacks.rb +20 -8
  10. data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +8 -62
  11. data/lib/active_support/concurrency/thread_monitor.rb +55 -0
  12. data/lib/active_support/configurable.rb +28 -0
  13. data/lib/active_support/continuous_integration.rb +145 -0
  14. data/lib/active_support/core_ext/array.rb +7 -7
  15. data/lib/active_support/core_ext/benchmark.rb +4 -12
  16. data/lib/active_support/core_ext/big_decimal.rb +1 -1
  17. data/lib/active_support/core_ext/class/attribute.rb +8 -6
  18. data/lib/active_support/core_ext/class.rb +2 -2
  19. data/lib/active_support/core_ext/date.rb +5 -5
  20. data/lib/active_support/core_ext/date_and_time/compatibility.rb +0 -35
  21. data/lib/active_support/core_ext/date_time/compatibility.rb +3 -5
  22. data/lib/active_support/core_ext/date_time.rb +5 -5
  23. data/lib/active_support/core_ext/digest.rb +1 -1
  24. data/lib/active_support/core_ext/enumerable.rb +2 -2
  25. data/lib/active_support/core_ext/erb/util.rb +3 -3
  26. data/lib/active_support/core_ext/file.rb +1 -1
  27. data/lib/active_support/core_ext/hash.rb +8 -8
  28. data/lib/active_support/core_ext/integer.rb +3 -3
  29. data/lib/active_support/core_ext/kernel.rb +3 -3
  30. data/lib/active_support/core_ext/module.rb +11 -11
  31. data/lib/active_support/core_ext/numeric.rb +3 -3
  32. data/lib/active_support/core_ext/object/json.rb +8 -1
  33. data/lib/active_support/core_ext/object/to_query.rb +5 -0
  34. data/lib/active_support/core_ext/object.rb +13 -13
  35. data/lib/active_support/core_ext/pathname.rb +2 -2
  36. data/lib/active_support/core_ext/range.rb +4 -5
  37. data/lib/active_support/core_ext/string/multibyte.rb +10 -1
  38. data/lib/active_support/core_ext/string/output_safety.rb +19 -12
  39. data/lib/active_support/core_ext/string.rb +13 -13
  40. data/lib/active_support/core_ext/symbol.rb +1 -1
  41. data/lib/active_support/core_ext/time/calculations.rb +0 -7
  42. data/lib/active_support/core_ext/time/compatibility.rb +2 -27
  43. data/lib/active_support/core_ext/time.rb +5 -5
  44. data/lib/active_support/core_ext.rb +1 -1
  45. data/lib/active_support/current_attributes/test_helper.rb +2 -2
  46. data/lib/active_support/current_attributes.rb +13 -10
  47. data/lib/active_support/dependencies/interlock.rb +11 -5
  48. data/lib/active_support/dependencies.rb +6 -1
  49. data/lib/active_support/deprecation/reporting.rb +4 -2
  50. data/lib/active_support/deprecation.rb +1 -1
  51. data/lib/active_support/editor.rb +70 -0
  52. data/lib/active_support/error_reporter.rb +50 -6
  53. data/lib/active_support/event_reporter/test_helper.rb +32 -0
  54. data/lib/active_support/event_reporter.rb +592 -0
  55. data/lib/active_support/evented_file_update_checker.rb +5 -1
  56. data/lib/active_support/execution_context.rb +64 -7
  57. data/lib/active_support/file_update_checker.rb +7 -5
  58. data/lib/active_support/gem_version.rb +3 -3
  59. data/lib/active_support/gzip.rb +1 -0
  60. data/lib/active_support/hash_with_indifferent_access.rb +27 -7
  61. data/lib/active_support/i18n_railtie.rb +1 -2
  62. data/lib/active_support/inflector/inflections.rb +31 -15
  63. data/lib/active_support/inflector/transliterate.rb +6 -8
  64. data/lib/active_support/isolated_execution_state.rb +12 -15
  65. data/lib/active_support/json/decoding.rb +2 -2
  66. data/lib/active_support/json/encoding.rb +135 -17
  67. data/lib/active_support/log_subscriber.rb +2 -6
  68. data/lib/active_support/message_encryptors.rb +52 -0
  69. data/lib/active_support/message_pack/extensions.rb +5 -0
  70. data/lib/active_support/message_verifiers.rb +52 -0
  71. data/lib/active_support/messages/rotation_coordinator.rb +9 -0
  72. data/lib/active_support/messages/rotator.rb +5 -0
  73. data/lib/active_support/multibyte/chars.rb +8 -1
  74. data/lib/active_support/multibyte.rb +4 -0
  75. data/lib/active_support/notifications/fanout.rb +64 -42
  76. data/lib/active_support/notifications/instrumenter.rb +1 -1
  77. data/lib/active_support/railtie.rb +32 -15
  78. data/lib/active_support/structured_event_subscriber.rb +99 -0
  79. data/lib/active_support/subscriber.rb +0 -5
  80. data/lib/active_support/syntax_error_proxy.rb +3 -0
  81. data/lib/active_support/test_case.rb +61 -6
  82. data/lib/active_support/testing/assertions.rb +34 -6
  83. data/lib/active_support/testing/error_reporter_assertions.rb +18 -1
  84. data/lib/active_support/testing/event_reporter_assertions.rb +227 -0
  85. data/lib/active_support/testing/notification_assertions.rb +92 -0
  86. data/lib/active_support/testing/parallelization/server.rb +15 -2
  87. data/lib/active_support/testing/parallelization/worker.rb +4 -2
  88. data/lib/active_support/testing/parallelization.rb +25 -1
  89. data/lib/active_support/testing/tests_without_assertions.rb +1 -1
  90. data/lib/active_support/testing/time_helpers.rb +7 -3
  91. data/lib/active_support/time_with_zone.rb +22 -22
  92. data/lib/active_support/values/time_zone.rb +8 -1
  93. data/lib/active_support/xml_mini.rb +3 -2
  94. data/lib/active_support.rb +23 -14
  95. metadata +24 -17
  96. data/lib/active_support/core_ext/range/each.rb +0 -24
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveSupport
4
+ module Concurrency
5
+ class ThreadMonitor # :nodoc:
6
+ EXCEPTION_NEVER = { Exception => :never }.freeze
7
+ EXCEPTION_IMMEDIATE = { Exception => :immediate }.freeze
8
+ private_constant :EXCEPTION_NEVER, :EXCEPTION_IMMEDIATE
9
+
10
+ def initialize
11
+ @owner = nil
12
+ @count = 0
13
+ @mutex = Mutex.new
14
+ end
15
+
16
+ def synchronize(&block)
17
+ Thread.handle_interrupt(EXCEPTION_NEVER) do
18
+ mon_enter
19
+
20
+ begin
21
+ Thread.handle_interrupt(EXCEPTION_IMMEDIATE, &block)
22
+ ensure
23
+ mon_exit
24
+ end
25
+ end
26
+ end
27
+
28
+ private
29
+ def mon_try_enter
30
+ if @owner != Thread.current
31
+ return false unless @mutex.try_lock
32
+ @owner = Thread.current
33
+ end
34
+ @count += 1
35
+ end
36
+
37
+ def mon_enter
38
+ @mutex.lock if @owner != Thread.current
39
+ @owner = Thread.current
40
+ @count += 1
41
+ end
42
+
43
+ def mon_exit
44
+ unless @owner == Thread.current
45
+ raise ThreadError, "current thread not owner"
46
+ end
47
+
48
+ @count -= 1
49
+ return unless @count == 0
50
+ @owner = nil
51
+ @mutex.unlock
52
+ end
53
+ end
54
+ end
55
+ end
@@ -27,6 +27,19 @@ module ActiveSupport
27
27
  end
28
28
 
29
29
  module ClassMethods
30
+ # Reads and writes attributes from a configuration OrderedOptions.
31
+ #
32
+ # require "active_support/configurable"
33
+ #
34
+ # class User
35
+ # include ActiveSupport::Configurable
36
+ # end
37
+ #
38
+ # User.config.allowed_access = true
39
+ # User.config.level = 1
40
+ #
41
+ # User.config.allowed_access # => true
42
+ # User.config.level # => 1
30
43
  def config
31
44
  @_config ||= if respond_to?(:superclass) && superclass.respond_to?(:config)
32
45
  superclass.config.inheritable_copy
@@ -36,6 +49,21 @@ module ActiveSupport
36
49
  end
37
50
  end
38
51
 
52
+ # Configure values from within the passed block.
53
+ #
54
+ # require "active_support/configurable"
55
+ #
56
+ # class User
57
+ # include ActiveSupport::Configurable
58
+ # end
59
+ #
60
+ # User.allowed_access # => nil
61
+ #
62
+ # User.configure do |config|
63
+ # config.allowed_access = true
64
+ # end
65
+ #
66
+ # User.allowed_access # => true
39
67
  def configure
40
68
  yield config
41
69
  end
@@ -0,0 +1,145 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveSupport
4
+ # Provides a DSL for declaring a continuous integration workflow that can be run either locally or in the cloud.
5
+ # Each step is timed, reports success/error, and is aggregated into a collective report that reports total runtime,
6
+ # as well as whether the entire run was successful or not.
7
+ #
8
+ # Example:
9
+ #
10
+ # ActiveSupport::ContinuousIntegration.run do
11
+ # step "Setup", "bin/setup --skip-server"
12
+ # step "Style: Ruby", "bin/rubocop"
13
+ # step "Security: Gem audit", "bin/bundler-audit"
14
+ # step "Tests: Rails", "bin/rails test test:system"
15
+ #
16
+ # if success?
17
+ # step "Signoff: Ready for merge and deploy", "gh signoff"
18
+ # else
19
+ # failure "Skipping signoff; CI failed.", "Fix the issues and try again."
20
+ # end
21
+ # end
22
+ #
23
+ # Starting with Rails 8.1, a default `bin/ci` and `config/ci.rb` file are created to provide out-of-the-box CI.
24
+ class ContinuousIntegration
25
+ COLORS = {
26
+ banner: "\033[1;32m", # Green
27
+ title: "\033[1;35m", # Purple
28
+ subtitle: "\033[1;90m", # Medium Gray
29
+ error: "\033[1;31m", # Red
30
+ success: "\033[1;32m" # Green
31
+ }
32
+
33
+ attr_reader :results
34
+
35
+ # Perform a CI run. Execute each step, show their results and runtime, and exit with a non-zero status if there are any failures.
36
+ #
37
+ # Pass an optional title, subtitle, and a block that declares the steps to be executed.
38
+ #
39
+ # Sets the CI environment variable to "true" to allow for conditional behavior in the app, like enabling eager loading and disabling logging.
40
+ #
41
+ # Example:
42
+ #
43
+ # ActiveSupport::ContinuousIntegration.run do
44
+ # step "Setup", "bin/setup --skip-server"
45
+ # step "Style: Ruby", "bin/rubocop"
46
+ # step "Security: Gem audit", "bin/bundler-audit"
47
+ # step "Tests: Rails", "bin/rails test test:system"
48
+ #
49
+ # if success?
50
+ # step "Signoff: Ready for merge and deploy", "gh signoff"
51
+ # else
52
+ # failure "Skipping signoff; CI failed.", "Fix the issues and try again."
53
+ # end
54
+ # end
55
+ def self.run(title = "Continuous Integration", subtitle = "Running tests, style checks, and security audits", &block)
56
+ new.tap do |ci|
57
+ ENV["CI"] = "true"
58
+ ci.heading title, subtitle, padding: false
59
+ ci.report(title, &block)
60
+ abort unless ci.success?
61
+ end
62
+ end
63
+
64
+ def initialize
65
+ @results = []
66
+ end
67
+
68
+ # Declare a step with a title and a command. The command can either be given as a single string or as multiple
69
+ # strings that will be passed to `system` as individual arguments (and therefore correctly escaped for paths etc).
70
+ #
71
+ # Examples:
72
+ #
73
+ # step "Setup", "bin/setup"
74
+ # step "Single test", "bin/rails", "test", "--name", "test_that_is_one"
75
+ def step(title, *command)
76
+ heading title, command.join(" "), type: :title
77
+ report(title) { results << system(*command) }
78
+ end
79
+
80
+ # Returns true if all steps were successful.
81
+ def success?
82
+ results.all?
83
+ end
84
+
85
+ # Display an error heading with the title and optional subtitle to reflect that the run failed.
86
+ def failure(title, subtitle = nil)
87
+ heading title, subtitle, type: :error
88
+ end
89
+
90
+ # Display a colorized heading followed by an optional subtitle.
91
+ #
92
+ # Examples:
93
+ #
94
+ # heading "Smoke Testing", "End-to-end tests verifying key functionality", padding: false
95
+ # heading "Skipping video encoding tests", "Install FFmpeg to run these tests", type: :error
96
+ #
97
+ # See ActiveSupport::ContinuousIntegration::COLORS for a complete list of options.
98
+ def heading(heading, subtitle = nil, type: :banner, padding: true)
99
+ echo "#{padding ? "\n\n" : ""}#{heading}", type: type
100
+ echo "#{subtitle}#{padding ? "\n" : ""}", type: :subtitle if subtitle
101
+ end
102
+
103
+ # Echo text to the terminal in the color corresponding to the type of the text.
104
+ #
105
+ # Examples:
106
+ #
107
+ # echo "This is going to be green!", type: :success
108
+ # echo "This is going to be red!", type: :error
109
+ #
110
+ # See ActiveSupport::ContinuousIntegration::COLORS for a complete list of options.
111
+ def echo(text, type:)
112
+ puts colorize(text, type)
113
+ end
114
+
115
+ # :nodoc:
116
+ def report(title, &block)
117
+ Signal.trap("INT") { abort colorize(:error, "\n❌ #{title} interrupted") }
118
+
119
+ ci = self.class.new
120
+ elapsed = timing { ci.instance_eval(&block) }
121
+
122
+ if ci.success?
123
+ echo "\n✅ #{title} passed in #{elapsed}", type: :success
124
+ else
125
+ echo "\n❌ #{title} failed in #{elapsed}", type: :error
126
+ end
127
+
128
+ results.concat ci.results
129
+ ensure
130
+ Signal.trap("INT", "-")
131
+ end
132
+
133
+ private
134
+ def timing
135
+ started_at = Time.now.to_f
136
+ yield
137
+ min, sec = (Time.now.to_f - started_at).divmod(60)
138
+ "#{"#{min}m" if min > 0}%.2fs" % sec
139
+ end
140
+
141
+ def colorize(text, type)
142
+ "#{COLORS.fetch(type)}#{text}\033[0m"
143
+ end
144
+ end
145
+ end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/core_ext/array/wrap"
4
- require "active_support/core_ext/array/access"
5
- require "active_support/core_ext/array/conversions"
6
- require "active_support/core_ext/array/extract"
7
- require "active_support/core_ext/array/extract_options"
8
- require "active_support/core_ext/array/grouping"
9
- require "active_support/core_ext/array/inquiry"
3
+ require_relative "array/wrap"
4
+ require_relative "array/access"
5
+ require_relative "array/conversions"
6
+ require_relative "array/extract"
7
+ require_relative "array/extract_options"
8
+ require_relative "array/grouping"
9
+ require_relative "array/inquiry"
@@ -1,14 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "benchmark"
4
- return if Benchmark.respond_to?(:ms)
5
-
6
- class << Benchmark
7
- def ms(&block) # :nodoc
8
- # NOTE: Please also remove the Active Support `benchmark` dependency when removing this
9
- ActiveSupport.deprecator.warn <<~TEXT
10
- `Benchmark.ms` is deprecated and will be removed in Rails 8.1 without replacement.
11
- TEXT
12
- ActiveSupport::Benchmark.realtime(:float_millisecond, &block)
13
- end
14
- end
3
+ # Remove this file from activesupport/lib/active_support/core_ext.rb when deleting the deprecation.
4
+ ActiveSupport.deprecator.warn <<~TEXT
5
+ active_support/core_ext/benchmark.rb is deprecated and will be removed in Rails 8.2 without replacement.
6
+ TEXT
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/core_ext/big_decimal/conversions"
3
+ require_relative "big_decimal/conversions"
@@ -96,14 +96,16 @@ class Class
96
96
  namespaced_name = :"__class_attr_#{name}"
97
97
  ::ActiveSupport::ClassAttribute.redefine(self, name, namespaced_name, default)
98
98
 
99
- delegators = [
100
- "def #{name}; #{namespaced_name}; end",
101
- "def #{name}=(value); self.#{namespaced_name} = value; end",
102
- ]
99
+ class_methods << "def #{name}; #{namespaced_name}; end"
100
+ class_methods << "def #{name}=(value); self.#{namespaced_name} = value; end"
103
101
 
104
- class_methods.concat(delegators)
105
102
  if singleton_class?
106
- methods.concat(delegators)
103
+ methods << <<~RUBY if instance_reader
104
+ silence_redefinition_of_method(:#{name})
105
+ def #{name}
106
+ self.singleton_class.#{name}
107
+ end
108
+ RUBY
107
109
  else
108
110
  methods << <<~RUBY if instance_reader
109
111
  silence_redefinition_of_method def #{name}
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/core_ext/class/attribute"
4
- require "active_support/core_ext/class/subclasses"
3
+ require_relative "class/attribute"
4
+ require_relative "class/subclasses"
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/core_ext/date/acts_like"
4
- require "active_support/core_ext/date/blank"
5
- require "active_support/core_ext/date/calculations"
6
- require "active_support/core_ext/date/conversions"
7
- require "active_support/core_ext/date/zones"
3
+ require_relative "date/acts_like"
4
+ require_relative "date/blank"
5
+ require_relative "date/calculations"
6
+ require_relative "date/conversions"
7
+ require_relative "date/zones"
@@ -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
@@ -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"
@@ -212,12 +212,12 @@ module Enumerable
212
212
  result = nil
213
213
  found = false
214
214
 
215
- each do |element|
215
+ each do |*element|
216
216
  if found
217
217
  raise SoleItemExpectedError, "multiple items found"
218
218
  end
219
219
 
220
- result = element
220
+ result = element.size == 1 ? element[0] : element
221
221
  found = true
222
222
  end
223
223
 
@@ -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
@@ -17,6 +17,11 @@ class Object
17
17
  end
18
18
 
19
19
  class NilClass
20
+ # Returns a CGI-escaped +key+.
21
+ def to_query(key)
22
+ CGI.escape(key.to_param)
23
+ end
24
+
20
25
  # Returns +self+.
21
26
  def to_param
22
27
  self
@@ -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,7 +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"
7
- require "active_support/core_ext/range/sole"
3
+ require_relative "range/conversions"
4
+ require_relative "range/compare_range"
5
+ require_relative "range/overlap"
6
+ require_relative "range/sole"
@@ -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.