activesupport 8.0.2 → 8.0.5.2

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 (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +175 -1
  3. data/README.rdoc +1 -1
  4. data/lib/active_support/broadcast_logger.rb +46 -59
  5. data/lib/active_support/cache/mem_cache_store.rb +16 -15
  6. data/lib/active_support/cache/redis_cache_store.rb +1 -1
  7. data/lib/active_support/cache.rb +1 -0
  8. data/lib/active_support/core_ext/benchmark.rb +1 -0
  9. data/lib/active_support/core_ext/class/attribute.rb +8 -6
  10. data/lib/active_support/core_ext/date_time/conversions.rb +4 -2
  11. data/lib/active_support/core_ext/enumerable.rb +16 -4
  12. data/lib/active_support/core_ext/object/json.rb +1 -1
  13. data/lib/active_support/core_ext/object/to_query.rb +2 -1
  14. data/lib/active_support/core_ext/object/try.rb +2 -2
  15. data/lib/active_support/core_ext/range/overlap.rb +3 -3
  16. data/lib/active_support/core_ext/range/sole.rb +17 -0
  17. data/lib/active_support/core_ext/range.rb +1 -0
  18. data/lib/active_support/core_ext/string/filters.rb +3 -3
  19. data/lib/active_support/core_ext/string/inflections.rb +1 -1
  20. data/lib/active_support/core_ext/string/multibyte.rb +2 -2
  21. data/lib/active_support/core_ext/string/output_safety.rb +3 -1
  22. data/lib/active_support/current_attributes.rb +13 -6
  23. data/lib/active_support/delegation.rb +25 -42
  24. data/lib/active_support/file_update_checker.rb +1 -1
  25. data/lib/active_support/gem_version.rb +2 -2
  26. data/lib/active_support/hash_with_indifferent_access.rb +20 -17
  27. data/lib/active_support/inflector/inflections.rb +2 -1
  28. data/lib/active_support/inflector/methods.rb +5 -21
  29. data/lib/active_support/isolated_execution_state.rb +4 -2
  30. data/lib/active_support/json/decoding.rb +4 -2
  31. data/lib/active_support/lazy_load_hooks.rb +1 -1
  32. data/lib/active_support/logger_thread_safe_level.rb +6 -3
  33. data/lib/active_support/message_pack/extensions.rb +1 -1
  34. data/lib/active_support/notifications/instrumenter.rb +1 -1
  35. data/lib/active_support/number_helper/number_converter.rb +1 -1
  36. data/lib/active_support/number_helper/number_to_delimited_converter.rb +17 -2
  37. data/lib/active_support/test_case.rb +6 -0
  38. data/lib/active_support/testing/assertions.rb +8 -3
  39. data/lib/active_support/testing/autorun.rb +5 -0
  40. data/lib/active_support/testing/parallelization/server.rb +15 -2
  41. data/lib/active_support/testing/parallelization/worker.rb +7 -3
  42. data/lib/active_support/testing/parallelization.rb +12 -1
  43. data/lib/active_support/xml_mini.rb +2 -0
  44. metadata +7 -6
@@ -108,15 +108,18 @@ module ActiveSupport
108
108
  # ==== Options
109
109
  #
110
110
  # * <tt>:default</tt> - The default value for the attributes. If the value
111
- # is a proc or lambda, it will be called whenever an instance is
112
- # constructed. Otherwise, the value will be duplicated with +#dup+.
113
- # Default values are re-assigned when the attributes are reset.
111
+ # is a proc or lambda, it will be called whenever an instance is
112
+ # constructed. Otherwise, the value will be duplicated with +#dup+.
113
+ # Default values are re-assigned when the attributes are reset.
114
114
  def attribute(*names, default: NOT_SET)
115
115
  invalid_attribute_names = names.map(&:to_sym) & INVALID_ATTRIBUTE_NAMES
116
116
  if invalid_attribute_names.any?
117
117
  raise ArgumentError, "Restricted attribute names: #{invalid_attribute_names.join(", ")}"
118
118
  end
119
119
 
120
+ Delegation.generate(singleton_class, names, to: :instance, nilable: false, signature: "")
121
+ Delegation.generate(singleton_class, names.map { |n| "#{n}=" }, to: :instance, nilable: false, signature: "value")
122
+
120
123
  ActiveSupport::CodeGenerator.batch(generated_attribute_methods, __FILE__, __LINE__) do |owner|
121
124
  names.each do |name|
122
125
  owner.define_cached_method(name, namespace: :current_attributes) do |batch|
@@ -134,9 +137,6 @@ module ActiveSupport
134
137
  end
135
138
  end
136
139
 
137
- Delegation.generate(singleton_class, names, to: :instance, nilable: false, signature: "")
138
- Delegation.generate(singleton_class, names.map { |n| "#{n}=" }, to: :instance, nilable: false, signature: "value")
139
-
140
140
  self.defaults = defaults.merge(names.index_with { default })
141
141
  end
142
142
 
@@ -185,9 +185,16 @@ module ActiveSupport
185
185
 
186
186
  def method_added(name)
187
187
  super
188
+
189
+ # We try to generate instance delegators early to not rely on method_missing.
188
190
  return if name == :initialize
191
+
192
+ # If the added method isn't public, we don't delegate it.
189
193
  return unless public_method_defined?(name)
194
+
195
+ # If we already have a class method by that name, we don't override it.
190
196
  return if singleton_class.method_defined?(name) || singleton_class.private_method_defined?(name)
197
+
191
198
  Delegation.generate(singleton_class, [name], to: :instance, as: self, nilable: false)
192
199
  end
193
200
  end
@@ -134,11 +134,11 @@ module ActiveSupport
134
134
  "def #{method_name}(#{definition})" <<
135
135
  " _ = #{receiver}" <<
136
136
  " _.#{method}(#{definition})" <<
137
- "rescue NoMethodError => e" <<
137
+ "rescue ::NoMethodError => e" <<
138
138
  " if _.nil? && e.name == :#{method}" <<
139
- " raise ::ActiveSupport::DelegationError.nil_target(:#{method_name}, :'#{receiver}')" <<
139
+ " ::Kernel.raise ::ActiveSupport::DelegationError.nil_target(:#{method_name}, :'#{receiver}')" <<
140
140
  " else" <<
141
- " raise" <<
141
+ " ::Kernel.raise" <<
142
142
  " end" <<
143
143
  "end"
144
144
  end
@@ -151,49 +151,32 @@ module ActiveSupport
151
151
  target = target.to_s
152
152
  target = "self.#{target}" if RESERVED_METHOD_NAMES.include?(target) || target == "__target"
153
153
 
154
- if allow_nil
155
- owner.module_eval <<~RUBY, __FILE__, __LINE__ + 1
156
- def respond_to_missing?(name, include_private = false)
157
- # It may look like an oversight, but we deliberately do not pass
158
- # +include_private+, because they do not get delegated.
159
-
160
- return false if name == :marshal_dump || name == :_dump
161
- #{target}.respond_to?(name) || super
162
- end
163
-
164
- def method_missing(method, ...)
165
- __target = #{target}
166
- if __target.nil? && !nil.respond_to?(method)
167
- nil
168
- elsif __target.respond_to?(method)
169
- __target.public_send(method, ...)
170
- else
171
- super
172
- end
173
- end
174
- RUBY
154
+ nil_behavior = if allow_nil
155
+ "nil"
175
156
  else
176
- owner.module_eval <<~RUBY, __FILE__, __LINE__ + 1
177
- def respond_to_missing?(name, include_private = false)
178
- # It may look like an oversight, but we deliberately do not pass
179
- # +include_private+, because they do not get delegated.
157
+ "::Kernel.raise ::ActiveSupport::DelegationError.nil_target(method, :'#{target}')"
158
+ end
180
159
 
181
- return false if name == :marshal_dump || name == :_dump
182
- #{target}.respond_to?(name) || super
183
- end
160
+ owner.module_eval <<~RUBY, __FILE__, __LINE__ + 1
161
+ def respond_to_missing?(name, include_private = false)
162
+ # It may look like an oversight, but we deliberately do not pass
163
+ # +include_private+, because they do not get delegated.
184
164
 
185
- def method_missing(method, ...)
186
- __target = #{target}
187
- if __target.nil? && !nil.respond_to?(method)
188
- raise ::ActiveSupport::DelegationError.nil_target(method, :'#{target}')
189
- elsif __target.respond_to?(method)
190
- __target.public_send(method, ...)
191
- else
192
- super
193
- end
165
+ return false if name == :marshal_dump || name == :_dump
166
+ #{target}.respond_to?(name) || super
167
+ end
168
+
169
+ def method_missing(method, ...)
170
+ __target = #{target}
171
+ if __target.nil? && !nil.respond_to?(method)
172
+ #{nil_behavior}
173
+ elsif __target.respond_to?(method)
174
+ __target.public_send(method, ...)
175
+ else
176
+ super
194
177
  end
195
- RUBY
196
- end
178
+ end
179
+ RUBY
197
180
  end
198
181
  end
199
182
  end
@@ -120,7 +120,7 @@ module ActiveSupport
120
120
  # healthy to consider this edge case because with mtimes in the future
121
121
  # reloading is not triggered.
122
122
  def max_mtime(paths)
123
- time_now = Time.now
123
+ time_now = Time.at(0, Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond), :nanosecond)
124
124
  max_mtime = nil
125
125
 
126
126
  # Time comparisons are performed with #compare_without_coercion because
@@ -9,8 +9,8 @@ module ActiveSupport
9
9
  module VERSION
10
10
  MAJOR = 8
11
11
  MINOR = 0
12
- TINY = 2
13
- PRE = nil
12
+ TINY = 5
13
+ PRE = "2"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -262,9 +262,7 @@ module ActiveSupport
262
262
  # hash[:a][:c] # => "c"
263
263
  # dup[:a][:c] # => "c"
264
264
  def dup
265
- self.class.new(self).tap do |new_hash|
266
- set_defaults(new_hash)
267
- end
265
+ copy_defaults(self.class.new(self))
268
266
  end
269
267
 
270
268
  # This method has the same semantics of +update+, except it does not
@@ -338,21 +336,26 @@ module ActiveSupport
338
336
  NOT_GIVEN = Object.new # :nodoc:
339
337
 
340
338
  def transform_keys(hash = NOT_GIVEN, &block)
341
- return to_enum(:transform_keys) if NOT_GIVEN.equal?(hash) && !block_given?
342
- dup.tap { |h| h.transform_keys!(hash, &block) }
339
+ if NOT_GIVEN.equal?(hash)
340
+ if block_given?
341
+ self.class.new(super(&block))
342
+ else
343
+ to_enum(:transform_keys)
344
+ end
345
+ else
346
+ self.class.new(super)
347
+ end
343
348
  end
344
349
 
345
350
  def transform_keys!(hash = NOT_GIVEN, &block)
346
- return to_enum(:transform_keys!) if NOT_GIVEN.equal?(hash) && !block_given?
347
-
348
- if hash.nil?
349
- super
350
- elsif NOT_GIVEN.equal?(hash)
351
- keys.each { |key| self[yield(key)] = delete(key) }
352
- elsif block_given?
353
- keys.each { |key| self[hash[key] || yield(key)] = delete(key) }
351
+ if NOT_GIVEN.equal?(hash)
352
+ if block_given?
353
+ replace(copy_defaults(transform_keys(&block)))
354
+ else
355
+ return to_enum(:transform_keys!)
356
+ end
354
357
  else
355
- keys.each { |key| self[hash[key] || key] = delete(key) }
358
+ replace(copy_defaults(transform_keys(hash, &block)))
356
359
  end
357
360
 
358
361
  self
@@ -376,8 +379,7 @@ module ActiveSupport
376
379
  def to_hash
377
380
  copy = Hash[self]
378
381
  copy.transform_values! { |v| convert_value_to_hash(v) }
379
- set_defaults(copy)
380
- copy
382
+ copy_defaults(copy)
381
383
  end
382
384
 
383
385
  def to_proc
@@ -413,12 +415,13 @@ module ActiveSupport
413
415
  end
414
416
 
415
417
 
416
- def set_defaults(target)
418
+ def copy_defaults(target)
417
419
  if default_proc
418
420
  target.default_proc = default_proc.dup
419
421
  else
420
422
  target.default = default
421
423
  end
424
+ target
422
425
  end
423
426
 
424
427
  def update_with_single_argument(other_hash, block)
@@ -248,7 +248,8 @@ module ActiveSupport
248
248
 
249
249
  private
250
250
  def define_acronym_regex_patterns
251
- @acronym_regex = @acronyms.empty? ? /(?=a)b/ : /#{@acronyms.values.join("|")}/
251
+ sorted_acronyms = @acronyms.empty? ? [] : @acronyms.values.sort_by { |a| -a.length }
252
+ @acronym_regex = sorted_acronyms.empty? ? /(?=a)b/ : /#{sorted_acronyms.join("|")}/
252
253
  @acronyms_camelize_regex = /^(?:#{@acronym_regex}(?=\b|[A-Z_])|\w)/
253
254
  @acronyms_underscore_regex = /(?:(?<=([A-Za-z\d]))|\b)(#{@acronym_regex})(?=\b|[^a-z])/
254
255
  end
@@ -119,7 +119,7 @@ module ActiveSupport
119
119
  # The capitalization of the first word can be turned off by setting the
120
120
  # +:capitalize+ option to false (default is true).
121
121
  #
122
- # The trailing '_id' can be kept and capitalized by setting the
122
+ # The trailing '_id' can be kept by setting the
123
123
  # optional parameter +keep_id_suffix+ to true (default is false).
124
124
  #
125
125
  # humanize('employee_salary') # => "Employee salary"
@@ -143,13 +143,13 @@ module ActiveSupport
143
143
  result.delete_suffix!(" id")
144
144
  end
145
145
 
146
- result.gsub!(/([a-z\d]+)/i) do |match|
146
+ result.gsub!(/([[[:alpha:]]\d]+)/i) do |match|
147
147
  match.downcase!
148
148
  inflections.acronyms[match] || match
149
149
  end
150
150
 
151
151
  if capitalize
152
- result.sub!(/\A\w/) do |match|
152
+ result.sub!(/\A[[:alpha:]]/) do |match|
153
153
  match.upcase!
154
154
  match
155
155
  end
@@ -319,7 +319,8 @@ module ActiveSupport
319
319
  e.name.to_s == camel_cased_word.to_s)
320
320
  rescue LoadError => e
321
321
  message = e.respond_to?(:original_message) ? e.original_message : e.message
322
- raise unless /Unable to autoload constant #{const_regexp(camel_cased_word)}/.match?(message)
322
+ constant_name = camel_cased_word.split("::").find { |part| !part.empty? } || camel_cased_word
323
+ raise unless message.include?("Unable to autoload constant #{constant_name}")
323
324
  end
324
325
 
325
326
  # Returns the suffix that should be added to a number to denote the position
@@ -349,23 +350,6 @@ module ActiveSupport
349
350
  end
350
351
 
351
352
  private
352
- # Mounts a regular expression, returned as a string to ease interpolation,
353
- # that will match part by part the given constant.
354
- #
355
- # const_regexp("Foo::Bar::Baz") # => "Foo(::Bar(::Baz)?)?"
356
- # const_regexp("::") # => "::"
357
- def const_regexp(camel_cased_word)
358
- parts = camel_cased_word.split("::")
359
-
360
- return Regexp.escape(camel_cased_word) if parts.empty?
361
-
362
- last = parts.pop
363
-
364
- parts.reverse!.inject(last) do |acc, part|
365
- part.empty? ? acc : "#{part}(::#{acc})?"
366
- end
367
- end
368
-
369
353
  # Applies inflection rules for +singularize+ and +pluralize+.
370
354
  #
371
355
  # If passed an optional +locale+ parameter, the uncountables will be
@@ -56,11 +56,13 @@ module ActiveSupport
56
56
  scope.current
57
57
  end
58
58
 
59
- def share_with(other)
59
+ def share_with(other, except: [])
60
60
  # Action Controller streaming spawns a new thread and copy thread locals.
61
61
  # We do the same here for backward compatibility, but this is very much a hack
62
62
  # and streaming should be rethought.
63
- context.active_support_execution_state = other.active_support_execution_state.dup
63
+ state = other.active_support_execution_state.dup
64
+ Array(except).each { |key| state.delete(key) }
65
+ context.active_support_execution_state = state
64
66
  end
65
67
 
66
68
  private
@@ -14,11 +14,13 @@ module ActiveSupport
14
14
  DATETIME_REGEX = /\A(?:\d{4}-\d{2}-\d{2}|\d{4}-\d{1,2}-\d{1,2}[T \t]+\d{1,2}:\d{2}:\d{2}(\.[0-9]*)?(([ \t]*)Z|[-+]\d{2}?(:\d{2})?)?)\z/
15
15
 
16
16
  class << self
17
- # Parses a JSON string (JavaScript Object Notation) into a hash.
17
+ # Parses a JSON string (JavaScript Object Notation) into a Ruby object.
18
18
  # See http://www.json.org for more info.
19
19
  #
20
20
  # ActiveSupport::JSON.decode("{\"team\":\"rails\",\"players\":\"36\"}")
21
- # => {"team" => "rails", "players" => "36"}
21
+ # # => {"team" => "rails", "players" => "36"}
22
+ # ActiveSupport::JSON.decode("2.39")
23
+ # # => 2.39
22
24
  def decode(json)
23
25
  data = ::JSON.parse(json, quirks_mode: true)
24
26
 
@@ -53,7 +53,7 @@ module ActiveSupport
53
53
  # loaded. If the component has already loaded, the block is executed
54
54
  # immediately.
55
55
  #
56
- # Options:
56
+ # ==== Options
57
57
  #
58
58
  # * <tt>:yield</tt> - Yields the object that run_load_hooks to +block+.
59
59
  # * <tt>:run_once</tt> - Given +block+ will run only once.
@@ -7,6 +7,11 @@ module ActiveSupport
7
7
  module LoggerThreadSafeLevel # :nodoc:
8
8
  extend ActiveSupport::Concern
9
9
 
10
+ def initialize(...)
11
+ super
12
+ @local_level_key = :"logger_thread_safe_level_#{object_id}"
13
+ end
14
+
10
15
  def local_level
11
16
  IsolatedExecutionState[local_level_key]
12
17
  end
@@ -40,8 +45,6 @@ module ActiveSupport
40
45
  end
41
46
 
42
47
  private
43
- def local_level_key
44
- @local_level_key ||= :"logger_thread_safe_level_#{object_id}"
45
- end
48
+ attr_reader :local_level_key
46
49
  end
47
50
  end
@@ -4,7 +4,7 @@ require "bigdecimal"
4
4
  require "date"
5
5
  require "ipaddr"
6
6
  require "pathname"
7
- require "uri/generic"
7
+ require "uri"
8
8
  require "msgpack/bigint"
9
9
  require "active_support/hash_with_indifferent_access"
10
10
  require "active_support/time"
@@ -164,7 +164,7 @@ module ActiveSupport
164
164
  @cpu_time_finish - @cpu_time_start
165
165
  end
166
166
 
167
- # Returns the idle time time (in milliseconds) passed between the call to
167
+ # Returns the idle time (in milliseconds) passed between the call to
168
168
  # #start! and the call to #finish!.
169
169
  def idle_time
170
170
  diff = duration - cpu_time
@@ -180,7 +180,7 @@ module ActiveSupport
180
180
  when Float, Rational
181
181
  number.to_d(0)
182
182
  when String
183
- BigDecimal(number, exception: false)
183
+ BigDecimal(number, exception: false) unless number.to_s.match?(/[de]/i)
184
184
  else
185
185
  number.to_d rescue nil
186
186
  end
@@ -16,9 +16,24 @@ module ActiveSupport
16
16
  private
17
17
  def parts
18
18
  left, right = number.to_s.split(".")
19
- left.gsub!(delimiter_pattern) do |digit_to_delimit|
20
- "#{digit_to_delimit}#{options[:delimiter]}"
19
+ if delimiter_pattern
20
+ left.gsub!(delimiter_pattern) do |digit_to_delimit|
21
+ "#{digit_to_delimit}#{options[:delimiter]}"
22
+ end
23
+ else
24
+ left_parts = []
25
+ offset = left.size % 3
26
+ if offset > 0
27
+ left_parts << left[0, offset]
28
+ end
29
+
30
+ (left.size / 3).times do |i|
31
+ left_parts << left[offset + (i * 3), 3]
32
+ end
33
+
34
+ left = left_parts.join(options[:delimiter])
21
35
  end
36
+
22
37
  [left, right].compact
23
38
  end
24
39
 
@@ -45,6 +45,12 @@ module ActiveSupport
45
45
  ActiveSupport.test_order ||= :random
46
46
  end
47
47
 
48
+ if Minitest.respond_to? :run_order # MT6 API change
49
+ def run_order # :nodoc:
50
+ test_order
51
+ end
52
+ end
53
+
48
54
  # Parallelizes the test suite.
49
55
  #
50
56
  # Takes a +workers+ argument that controls how many times the process
@@ -120,7 +120,8 @@ module ActiveSupport
120
120
  actual = exp.call
121
121
  rich_message = -> do
122
122
  code_string = code.respond_to?(:call) ? _callable_to_source_string(code) : code
123
- error = "`#{code_string}` didn't change by #{diff}, but by #{actual - before_value}"
123
+ error = "`#{code_string}` didn't change by #{diff}, but by #{actual - before_value}."
124
+ error = "#{error}\n#{diff before_value + diff, actual}" if Minitest::VERSION > "6"
124
125
  error = "#{message}.\n#{error}" if message
125
126
  error
126
127
  end
@@ -212,7 +213,7 @@ module ActiveSupport
212
213
  rich_message = -> do
213
214
  code_string = expression.respond_to?(:call) ? _callable_to_source_string(expression) : expression
214
215
  error = "`#{code_string}` didn't change"
215
- error = "#{error}. It was already #{to.inspect}" if before == to
216
+ error = "#{error}. It was already #{to.inspect}." if before == to
216
217
  error = "#{message}.\n#{error}" if message
217
218
  error
218
219
  end
@@ -268,8 +269,9 @@ module ActiveSupport
268
269
 
269
270
  rich_message = -> do
270
271
  code_string = expression.respond_to?(:call) ? _callable_to_source_string(expression) : expression
271
- error = "`#{code_string}` changed"
272
+ error = "`#{code_string}` changed."
272
273
  error = "#{message}.\n#{error}" if message
274
+ error = "#{error}\n#{diff before, after}" if Minitest::VERSION > "6"
273
275
  error
274
276
  end
275
277
 
@@ -318,6 +320,9 @@ module ActiveSupport
318
320
  lines[0] = lines[0].byteslice(location[1]...)
319
321
  source = lines.join.strip
320
322
 
323
+ # Strip stabby lambda from Ruby 4.1+
324
+ source = source.sub(/^->\s*/, "")
325
+
321
326
  # We ignore procs defined with do/end as they are likely multi-line anyway.
322
327
  if source.start_with?("{")
323
328
  source.delete_suffix!("}")
@@ -2,4 +2,9 @@
2
2
 
3
3
  require "minitest"
4
4
 
5
+ # This respond_to check handles tests running sub-processes in an
6
+ # unbundled environment, which triggers MT5 usage. This conditional may
7
+ # be removable after the version bump, though it currently safeguards
8
+ # against issues in environments with multiple versions installed.
9
+ Minitest.load :rails if Minitest.respond_to? :load
5
10
  Minitest.autorun
@@ -14,6 +14,7 @@ module ActiveSupport
14
14
  def initialize
15
15
  @queue = Queue.new
16
16
  @active_workers = Concurrent::Map.new
17
+ @worker_pids = Concurrent::Map.new
17
18
  @in_flight = Concurrent::Map.new
18
19
  end
19
20
 
@@ -40,12 +41,24 @@ module ActiveSupport
40
41
  end
41
42
  end
42
43
 
43
- def start_worker(worker_id)
44
+ def start_worker(worker_id, worker_pid)
44
45
  @active_workers[worker_id] = true
46
+ @worker_pids[worker_id] = worker_pid
45
47
  end
46
48
 
47
- def stop_worker(worker_id)
49
+ def stop_worker(worker_id, worker_pid)
48
50
  @active_workers.delete(worker_id)
51
+ @worker_pids.delete(worker_id)
52
+ end
53
+
54
+ def remove_dead_workers(dead_pids)
55
+ dead_pids.each do |dead_pid|
56
+ worker_id = @worker_pids.key(dead_pid)
57
+ if worker_id
58
+ @active_workers.delete(worker_id)
59
+ @worker_pids.delete(worker_id)
60
+ end
61
+ end
49
62
  end
50
63
 
51
64
  def active_workers?
@@ -18,7 +18,7 @@ module ActiveSupport
18
18
  DRb.stop_service
19
19
 
20
20
  @queue = DRbObject.new_with_uri(@url)
21
- @queue.start_worker(@id)
21
+ @queue.start_worker(@id, Process.pid)
22
22
 
23
23
  begin
24
24
  after_fork
@@ -29,7 +29,7 @@ module ActiveSupport
29
29
  set_process_title("(stopping)")
30
30
 
31
31
  run_cleanup
32
- @queue.stop_worker(@id)
32
+ @queue.stop_worker(@id, Process.pid)
33
33
  end
34
34
  end
35
35
 
@@ -47,7 +47,11 @@ module ActiveSupport
47
47
  set_process_title("#{klass}##{method}")
48
48
 
49
49
  result = klass.with_info_handler reporter do
50
- Minitest.run_one_method(klass, method)
50
+ if Minitest.respond_to? :run_one_method
51
+ Minitest.run_one_method klass, method
52
+ else
53
+ klass.new(method).run
54
+ end
51
55
  end
52
56
 
53
57
  safe_record(reporter, result)
@@ -47,8 +47,19 @@ module ActiveSupport
47
47
  end
48
48
 
49
49
  def shutdown
50
+ dead_worker_pids = @worker_pool.filter_map do |pid|
51
+ Process.waitpid(pid, Process::WNOHANG)
52
+ rescue Errno::ECHILD
53
+ pid
54
+ end
55
+ @queue_server.remove_dead_workers(dead_worker_pids)
56
+
50
57
  @queue_server.shutdown
51
- @worker_pool.each { |pid| Process.waitpid pid }
58
+ @worker_pool.each do |pid|
59
+ Process.waitpid(pid)
60
+ rescue Errno::ECHILD
61
+ nil
62
+ end
52
63
  end
53
64
  end
54
65
  end
@@ -74,6 +74,8 @@ module ActiveSupport
74
74
  "decimal" => Proc.new do |number|
75
75
  if String === number
76
76
  number.to_d
77
+ elsif Float === number
78
+ BigDecimal(number, 0)
77
79
  else
78
80
  BigDecimal(number)
79
81
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activesupport
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.2
4
+ version: 8.0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-03-12 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: i18n
@@ -329,6 +329,7 @@ files:
329
329
  - lib/active_support/core_ext/range/conversions.rb
330
330
  - lib/active_support/core_ext/range/each.rb
331
331
  - lib/active_support/core_ext/range/overlap.rb
332
+ - lib/active_support/core_ext/range/sole.rb
332
333
  - lib/active_support/core_ext/regexp.rb
333
334
  - lib/active_support/core_ext/securerandom.rb
334
335
  - lib/active_support/core_ext/string.rb
@@ -493,10 +494,10 @@ licenses:
493
494
  - MIT
494
495
  metadata:
495
496
  bug_tracker_uri: https://github.com/rails/rails/issues
496
- changelog_uri: https://github.com/rails/rails/blob/v8.0.2/activesupport/CHANGELOG.md
497
- documentation_uri: https://api.rubyonrails.org/v8.0.2/
497
+ changelog_uri: https://github.com/rails/rails/blob/v8.0.5.2/activesupport/CHANGELOG.md
498
+ documentation_uri: https://api.rubyonrails.org/v8.0.5.2/
498
499
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
499
- source_code_uri: https://github.com/rails/rails/tree/v8.0.2/activesupport
500
+ source_code_uri: https://github.com/rails/rails/tree/v8.0.5.2/activesupport
500
501
  rubygems_mfa_required: 'true'
501
502
  rdoc_options:
502
503
  - "--encoding"
@@ -514,7 +515,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
514
515
  - !ruby/object:Gem::Version
515
516
  version: '0'
516
517
  requirements: []
517
- rubygems_version: 3.6.2
518
+ rubygems_version: 4.0.20
518
519
  specification_version: 4
519
520
  summary: A toolkit of support libraries and Ruby core extensions extracted from the
520
521
  Rails framework.