activesupport 7.1.3.1 → 7.1.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0caeb01dd45687820a3b9376d7b57a90f881651a02ee49f36ed88377621c8fdd
4
- data.tar.gz: 52d9f59bfea168914f2350656069e28ce6b6d7d741378bb05faaabf8ec86e06b
3
+ metadata.gz: 8afd025f9789b16a78502f9d672ae2acccbd9d77c71073423af187bf828f6185
4
+ data.tar.gz: 683a9ea0c0a5a3104c07ee5fa6faefdb2d22521b7df724785ce007e0e9a5ae4f
5
5
  SHA512:
6
- metadata.gz: 04b3030290ddad933f276d9be48c481fe5df986af908f53cda61051e3501b2e745280d98298f491493fe494e392d7217fb9ff9abad8c01e5890a05f97c71ffc2
7
- data.tar.gz: ae5d9cc0ee3ffc76b69358504ea2c18de02823e69da2f09bf5ab15c8c9cf74b01aedf54956669b48b03c97e8cd997fd34fa82be8b855f136d7f419463498eb96
6
+ metadata.gz: 6cab0b77b7609dbff7d945a43435abf64f204d1896835f98eef8acf24710d74954366f4e71805d5add62e8de1ed9abd1df357201c8dbc894e84b927a6bd2b730
7
+ data.tar.gz: 821f9ec23f3f2bee60a414140b66673be66ed0908cb7b992513fe1f107ed39a6fbf18482faf0bace12581e651e6137b435cef56c963389e0b9ffc3112b0c3a23
data/CHANGELOG.md CHANGED
@@ -1,3 +1,85 @@
1
+ ## Rails 7.1.4.1 (October 15, 2024) ##
2
+
3
+ * No changes.
4
+
5
+
6
+ ## Rails 7.1.4 (August 22, 2024) ##
7
+
8
+ * Improve compatibility for `ActiveSupport::BroadcastLogger`.
9
+
10
+ *Máximo Mussini*
11
+
12
+ * Pass options along to write_entry in handle_expired_entry method.
13
+
14
+ *Graham Cooper*
15
+
16
+ * Fix Active Support configurations deprecations.
17
+
18
+ *fatkodima*
19
+
20
+ * Fix teardown callbacks.
21
+
22
+ *Tristan Starck*
23
+
24
+ * `BacktraceCleaner` silence core internal methods by default.
25
+
26
+ *Jean Boussier*
27
+
28
+ * Fix `delegate_missing_to allow_nil: true` when called with implict self
29
+
30
+ ```ruby
31
+ class Person
32
+ delegate_missing_to :address, allow_nil: true
33
+
34
+ def address
35
+ nil
36
+ end
37
+
38
+ def berliner?
39
+ city == "Berlin"
40
+ end
41
+ end
42
+
43
+ Person.new.city # => nil
44
+ Person.new.berliner? # undefined local variable or method `city' for an instance of Person (NameError)
45
+ ```
46
+
47
+ *Jean Boussier*
48
+
49
+ * Work around a Ruby bug that can cause a VM crash.
50
+
51
+ This would happen if using `TaggerLogger` with a Proc
52
+ formatter on which you called `object_id`.
53
+
54
+ ```
55
+ [BUG] Object ID seen, but not in mapping table: proc
56
+ ```
57
+
58
+ *Jean Boussier*
59
+
60
+ * Fix `ActiveSupport::Notifications.publish_event` to preserve units.
61
+
62
+ This solves the incorrect reporting of time spent running Active Record
63
+ asynchronous queries (by a factor `1000`).
64
+
65
+ *Jean Boussier*
66
+
67
+
68
+ ## Rails 7.1.3.4 (June 04, 2024) ##
69
+
70
+ * No changes.
71
+
72
+
73
+ ## Rails 7.1.3.3 (May 16, 2024) ##
74
+
75
+ * No changes.
76
+
77
+
78
+ ## Rails 7.1.3.2 (February 21, 2024) ##
79
+
80
+ * No changes.
81
+
82
+
1
83
  ## Rails 7.1.3.1 (February 21, 2024) ##
2
84
 
3
85
  * No changes.
@@ -33,6 +33,7 @@ module ActiveSupport
33
33
  class BacktraceCleaner
34
34
  def initialize
35
35
  @filters, @silencers = [], []
36
+ add_core_silencer
36
37
  add_gem_filter
37
38
  add_gem_silencer
38
39
  add_stdlib_silencer
@@ -116,6 +117,10 @@ module ActiveSupport
116
117
  add_filter { |line| line.sub(gems_regexp, gems_result) }
117
118
  end
118
119
 
120
+ def add_core_silencer
121
+ add_silencer { |line| line.include?("<internal:") }
122
+ end
123
+
119
124
  def add_gem_silencer
120
125
  add_silencer { |line| FORMATTED_GEMS_PATTERN.match?(line) }
121
126
  end
@@ -229,6 +229,7 @@ module ActiveSupport
229
229
  private
230
230
  def dispatch(&block)
231
231
  @broadcasts.each { |logger| block.call(logger) }
232
+ true
232
233
  end
233
234
 
234
235
  def method_missing(name, *args, **kwargs, &block)
@@ -1038,7 +1038,8 @@ module ActiveSupport
1038
1038
  # When an entry has a positive :race_condition_ttl defined, put the stale entry back into the cache
1039
1039
  # for a brief period while the entry is being recalculated.
1040
1040
  entry.expires_at = Time.now.to_f + race_ttl
1041
- write_entry(key, entry, expires_in: race_ttl * 2)
1041
+ options[:expires_in] = race_ttl * 2
1042
+ write_entry(key, entry, **options)
1042
1043
  else
1043
1044
  delete_entry(key, **options)
1044
1045
  end
@@ -9,16 +9,19 @@ module ActiveSupport
9
9
  @cache = METHOD_CACHES[namespace]
10
10
  @sources = []
11
11
  @methods = {}
12
+ @canonical_methods = {}
12
13
  end
13
14
 
14
- def define_cached_method(name, as: name)
15
- name = name.to_sym
16
- as = as.to_sym
17
- @methods.fetch(name) do
18
- unless @cache.method_defined?(as)
15
+ def define_cached_method(canonical_name, as: nil)
16
+ canonical_name = canonical_name.to_sym
17
+ as = (as || canonical_name).to_sym
18
+
19
+ @methods.fetch(as) do
20
+ unless @cache.method_defined?(canonical_name) || @canonical_methods[canonical_name]
19
21
  yield @sources
20
22
  end
21
- @methods[name] = as
23
+ @canonical_methods[canonical_name] = true
24
+ @methods[as] = canonical_name
22
25
  end
23
26
  end
24
27
 
@@ -26,8 +29,10 @@ module ActiveSupport
26
29
  unless @sources.empty?
27
30
  @cache.module_eval("# frozen_string_literal: true\n" + @sources.join(";"), path, line)
28
31
  end
29
- @methods.each do |name, as|
30
- owner.define_method(name, @cache.instance_method(as))
32
+ @canonical_methods.clear
33
+
34
+ @methods.each do |as, canonical_name|
35
+ owner.define_method(as, @cache.instance_method(canonical_name))
31
36
  end
32
37
  end
33
38
  end
@@ -52,8 +57,8 @@ module ActiveSupport
52
57
  @namespaces = Hash.new { |h, k| h[k] = MethodSet.new(k) }
53
58
  end
54
59
 
55
- def define_cached_method(name, namespace:, as: name, &block)
56
- @namespaces[namespace].define_cached_method(name, as: as, &block)
60
+ def define_cached_method(canonical_name, namespace:, as: nil, &block)
61
+ @namespaces[namespace].define_cached_method(canonical_name, as: as, &block)
57
62
  end
58
63
 
59
64
  def execute
@@ -317,37 +317,52 @@ class Module
317
317
  # of <tt>object</tt> add or remove instance variables.
318
318
  def delegate_missing_to(target, allow_nil: nil)
319
319
  target = target.to_s
320
- target = "self.#{target}" if DELEGATION_RESERVED_METHOD_NAMES.include?(target)
320
+ target = "self.#{target}" if DELEGATION_RESERVED_METHOD_NAMES.include?(target) || target == "__target"
321
321
 
322
- module_eval <<-RUBY, __FILE__, __LINE__ + 1
323
- def respond_to_missing?(name, include_private = false)
324
- # It may look like an oversight, but we deliberately do not pass
325
- # +include_private+, because they do not get delegated.
322
+ if allow_nil
323
+ module_eval <<~RUBY, __FILE__, __LINE__ + 1
324
+ def respond_to_missing?(name, include_private = false)
325
+ # It may look like an oversight, but we deliberately do not pass
326
+ # +include_private+, because they do not get delegated.
326
327
 
327
- return false if name == :marshal_dump || name == :_dump
328
- #{target}.respond_to?(name) || super
329
- end
328
+ return false if name == :marshal_dump || name == :_dump
329
+ #{target}.respond_to?(name) || super
330
+ end
330
331
 
331
- def method_missing(method, *args, &block)
332
- if #{target}.respond_to?(method)
333
- #{target}.public_send(method, *args, &block)
334
- else
335
- begin
332
+ def method_missing(method, *args, &block)
333
+ __target = #{target}
334
+ if __target.nil? && !nil.respond_to?(method)
335
+ nil
336
+ elsif __target.respond_to?(method)
337
+ __target.public_send(method, *args, &block)
338
+ else
336
339
  super
337
- rescue NoMethodError
338
- if #{target}.nil?
339
- if #{allow_nil == true}
340
- nil
341
- else
342
- raise DelegationError, "\#{method} delegated to #{target}, but #{target} is nil"
343
- end
344
- else
345
- raise
346
- end
347
340
  end
348
341
  end
349
- end
350
- ruby2_keywords(:method_missing)
351
- RUBY
342
+ ruby2_keywords(:method_missing)
343
+ RUBY
344
+ else
345
+ module_eval <<~RUBY, __FILE__, __LINE__ + 1
346
+ def respond_to_missing?(name, include_private = false)
347
+ # It may look like an oversight, but we deliberately do not pass
348
+ # +include_private+, because they do not get delegated.
349
+
350
+ return false if name == :marshal_dump || name == :_dump
351
+ #{target}.respond_to?(name) || super
352
+ end
353
+
354
+ def method_missing(method, *args, &block)
355
+ __target = #{target}
356
+ if __target.nil? && !nil.respond_to?(method)
357
+ raise DelegationError, "\#{method} delegated to #{target}, but #{target} is nil"
358
+ elsif __target.respond_to?(method)
359
+ __target.public_send(method, *args, &block)
360
+ else
361
+ super
362
+ end
363
+ end
364
+ ruby2_keywords(:method_missing)
365
+ RUBY
366
+ end
352
367
  end
353
368
  end
@@ -28,23 +28,32 @@ class Object
28
28
  end
29
29
  end
30
30
 
31
- class Method
32
- # Methods are not duplicable:
33
- #
34
- # method(:puts).duplicable? # => false
35
- # method(:puts).dup # => TypeError: allocator undefined for Method
36
- def duplicable?
37
- false
38
- end
31
+ methods_are_duplicable = begin
32
+ Object.instance_method(:duplicable?).dup
33
+ true
34
+ rescue TypeError
35
+ false
39
36
  end
40
37
 
41
- class UnboundMethod
42
- # Unbound methods are not duplicable:
43
- #
44
- # method(:puts).unbind.duplicable? # => false
45
- # method(:puts).unbind.dup # => TypeError: allocator undefined for UnboundMethod
46
- def duplicable?
47
- false
38
+ unless methods_are_duplicable
39
+ class Method
40
+ # Methods are not duplicable:
41
+ #
42
+ # method(:puts).duplicable? # => false
43
+ # method(:puts).dup # => TypeError: allocator undefined for Method
44
+ def duplicable?
45
+ false
46
+ end
47
+ end
48
+
49
+ class UnboundMethod
50
+ # Unbound methods are not duplicable:
51
+ #
52
+ # method(:puts).unbind.duplicable? # => false
53
+ # method(:puts).unbind.dup # => TypeError: allocator undefined for UnboundMethod
54
+ def duplicable?
55
+ false
56
+ end
48
57
  end
49
58
  end
50
59
 
@@ -9,7 +9,7 @@ module ActiveSupport
9
9
  module VERSION
10
10
  MAJOR = 7
11
11
  MINOR = 1
12
- TINY = 3
12
+ TINY = 4
13
13
  PRE = "1"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
@@ -7,18 +7,28 @@ module ActiveSupport
7
7
  def translate(key, **options)
8
8
  if html_safe_translation_key?(key)
9
9
  html_safe_options = html_escape_translation_options(options)
10
- translation = I18n.translate(key, **html_safe_options)
11
- html_safe_translation(translation)
10
+
11
+ exception = false
12
+ exception_handler = ->(*args) do
13
+ exception = true
14
+ I18n.exception_handler.call(*args)
15
+ end
16
+ translation = I18n.translate(key, **html_safe_options, exception_handler: exception_handler)
17
+ if exception
18
+ translation
19
+ else
20
+ html_safe_translation(translation)
21
+ end
12
22
  else
13
23
  I18n.translate(key, **options)
14
24
  end
15
25
  end
16
26
 
17
- private
18
- def html_safe_translation_key?(key)
19
- /(?:_|\b)html\z/.match?(key)
20
- end
27
+ def html_safe_translation_key?(key)
28
+ /(?:_|\b)html\z/.match?(key)
29
+ end
21
30
 
31
+ private
22
32
  def html_escape_translation_options(options)
23
33
  options.each do |name, value|
24
34
  unless i18n_option?(name) || (name == :count && value.is_a?(Numeric))
@@ -76,7 +76,7 @@ module ActiveSupport
76
76
  when Hash
77
77
  result = {}
78
78
  value.each do |k, v|
79
- k = k.to_s unless String === k
79
+ k = k.to_s unless Symbol === k || String === k
80
80
  result[k] = jsonify(v)
81
81
  end
82
82
  result
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "active_support/core_ext/module/attribute_accessors"
4
4
  require "active_support/core_ext/class/attribute"
5
+ require "active_support/core_ext/enumerable"
5
6
  require "active_support/subscriber"
6
7
  require "active_support/deprecation/proxy_wrappers"
7
8
 
@@ -28,7 +28,7 @@ module ActiveSupport
28
28
 
29
29
  def decode(encoded, url_safe: @url_safe)
30
30
  url_safe ? ::Base64.urlsafe_decode64(encoded) : ::Base64.strict_decode64(encoded)
31
- rescue ArgumentError => error
31
+ rescue StandardError => error
32
32
  throw :invalid_message_format, error
33
33
  end
34
34
 
@@ -104,7 +104,7 @@ module ActiveSupport
104
104
  end
105
105
 
106
106
  class Event
107
- attr_reader :name, :time, :end, :transaction_id
107
+ attr_reader :name, :transaction_id
108
108
  attr_accessor :payload
109
109
 
110
110
  def initialize(name, start, ending, transaction_id, payload)
@@ -119,7 +119,15 @@ module ActiveSupport
119
119
  @allocation_count_finish = 0
120
120
  end
121
121
 
122
- def record
122
+ def time
123
+ @time / 1000.0 if @time
124
+ end
125
+
126
+ def end
127
+ @end / 1000.0 if @end
128
+ end
129
+
130
+ def record # :nodoc:
123
131
  start!
124
132
  begin
125
133
  yield payload if block_given?
@@ -195,7 +203,7 @@ module ActiveSupport
195
203
  #
196
204
  # @event.duration # => 1000.138
197
205
  def duration
198
- self.end - time
206
+ @end - @time
199
207
  end
200
208
 
201
209
  private
@@ -117,11 +117,11 @@ module ActiveSupport
117
117
 
118
118
  initializer "active_support.set_configs" do |app|
119
119
  app.config.active_support.each do |k, v|
120
- if k == "disable_to_s_conversion"
120
+ if k == :disable_to_s_conversion
121
121
  ActiveSupport.deprecator.warn("config.active_support.disable_to_s_conversion is deprecated and will be removed in Rails 7.2.")
122
- elsif k == "remove_deprecated_time_with_zone_name"
122
+ elsif k == :remove_deprecated_time_with_zone_name
123
123
  ActiveSupport.deprecator.warn("config.active_support.remove_deprecated_time_with_zone_name is deprecated and will be removed in Rails 7.2.")
124
- elsif k == "use_rfc4122_namespaced_uuids"
124
+ elsif k == :use_rfc4122_namespaced_uuids
125
125
  ActiveSupport.deprecator.warn("config.active_support.use_rfc4122_namespaced_uuids is deprecated and will be removed in Rails 7.2.")
126
126
  else
127
127
  k = "#{k}="
@@ -45,7 +45,7 @@ module ActiveSupport
45
45
 
46
46
  private
47
47
  def parse_message_for_trace
48
- if source_location_eval?
48
+ if __getobj__.to_s.start_with?("(eval")
49
49
  # If the exception is coming from a call to eval, we need to keep
50
50
  # the path of the file in which eval was called to ensure we can
51
51
  # return the right source fragment to show the location of the
@@ -56,15 +56,5 @@ module ActiveSupport
56
56
  __getobj__.to_s.split("\n")
57
57
  end
58
58
  end
59
-
60
- if SyntaxError.method_defined?(:path) # Ruby 3.3+
61
- def source_location_eval?
62
- __getobj__.path.start_with?("(eval")
63
- end
64
- else # 3.2 and older versions of Ruby
65
- def source_location_eval?
66
- __getobj__.to_s.start_with?("(eval")
67
- end
68
- end
69
59
  end
70
60
  end
@@ -119,6 +119,10 @@ module ActiveSupport
119
119
 
120
120
  if logger.formatter
121
121
  logger.formatter = logger.formatter.clone
122
+
123
+ # Workaround for https://bugs.ruby-lang.org/issues/20250
124
+ # Can be removed when Ruby 3.4 is the least supported version.
125
+ logger.formatter.object_id if logger.formatter.is_a?(Proc)
122
126
  else
123
127
  # Ensure we set a default formatter so we aren't extending nil!
124
128
  logger.formatter = ActiveSupport::Logger::SimpleFormatter.new
@@ -46,6 +46,8 @@ module ActiveSupport
46
46
  run_callbacks :teardown
47
47
  rescue => e
48
48
  self.failures << Minitest::UnexpectedError.new(e)
49
+ rescue Minitest::Assertion => e
50
+ self.failures << e
49
51
  end
50
52
 
51
53
  super
@@ -208,7 +208,9 @@ module ActiveSupport
208
208
  TZInfo::Timezone.get(MAPPING[name] || name)
209
209
  end
210
210
 
211
+ # :stopdoc:
211
212
  alias_method :create, :new
213
+ # :startdoc:
212
214
 
213
215
  # Returns a TimeZone instance with the given name, or +nil+ if no
214
216
  # such TimeZone instance exists. (This exists to support the use of
@@ -296,15 +298,22 @@ module ActiveSupport
296
298
  attr_reader :name
297
299
  attr_reader :tzinfo
298
300
 
301
+ ##
302
+ # :singleton-method: create
303
+ # :call-seq: create(name, utc_offset = nil, tzinfo = nil)
304
+ #
299
305
  # Create a new TimeZone object with the given name and offset. The
300
306
  # offset is the number of seconds that this time zone is offset from UTC
301
307
  # (GMT). Seconds were chosen as the offset unit because that is the unit
302
308
  # that Ruby uses to represent time zone offsets (see Time#utc_offset).
309
+
310
+ # :stopdoc:
303
311
  def initialize(name, utc_offset = nil, tzinfo = nil)
304
312
  @name = name
305
313
  @utc_offset = utc_offset
306
314
  @tzinfo = tzinfo || TimeZone.find_tzinfo(name)
307
315
  end
316
+ # :startdoc:
308
317
 
309
318
  # Returns the offset of this time zone from UTC in seconds.
310
319
  def utc_offset
@@ -32,7 +32,7 @@ require "active_support/broadcast_logger"
32
32
  require "active_support/lazy_load_hooks"
33
33
  require "active_support/core_ext/date_and_time/compatibility"
34
34
 
35
- # :include: activesupport/README.rdoc
35
+ # :include: ../README.rdoc
36
36
  module ActiveSupport
37
37
  extend ActiveSupport::Autoload
38
38
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activesupport
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.3.1
4
+ version: 7.1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-21 00:00:00.000000000 Z
11
+ date: 2024-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -446,12 +446,12 @@ licenses:
446
446
  - MIT
447
447
  metadata:
448
448
  bug_tracker_uri: https://github.com/rails/rails/issues
449
- changelog_uri: https://github.com/rails/rails/blob/v7.1.3.1/activesupport/CHANGELOG.md
450
- documentation_uri: https://api.rubyonrails.org/v7.1.3.1/
449
+ changelog_uri: https://github.com/rails/rails/blob/v7.1.4.1/activesupport/CHANGELOG.md
450
+ documentation_uri: https://api.rubyonrails.org/v7.1.4.1/
451
451
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
452
- source_code_uri: https://github.com/rails/rails/tree/v7.1.3.1/activesupport
452
+ source_code_uri: https://github.com/rails/rails/tree/v7.1.4.1/activesupport
453
453
  rubygems_mfa_required: 'true'
454
- post_install_message:
454
+ post_install_message:
455
455
  rdoc_options:
456
456
  - "--encoding"
457
457
  - UTF-8
@@ -468,8 +468,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
468
468
  - !ruby/object:Gem::Version
469
469
  version: '0'
470
470
  requirements: []
471
- rubygems_version: 3.4.10
472
- signing_key:
471
+ rubygems_version: 3.5.16
472
+ signing_key:
473
473
  specification_version: 4
474
474
  summary: A toolkit of support libraries and Ruby core extensions extracted from the
475
475
  Rails framework.