deprecation_toolkit 2.2.4 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 928c5fd8932b5f69fd9a51ea255ff5db6977fedc011c9ff211de0e3d73f4cc4e
4
- data.tar.gz: f514ee0194329683cad36aa454280acaa0a8ecd84ba02d698b45b7b1c84cf0f8
3
+ metadata.gz: 4e0fdc8f5fbba44721aa51696b6f183771568af945b846d53edbcacc84b3aeb4
4
+ data.tar.gz: dffb18987c119ab631d2d6d503e56b87b884cb8bfd683e2c99a786961d205fa9
5
5
  SHA512:
6
- metadata.gz: 65c66a322df4cfcd5977531d5b0fa60221c096d8d36e7e653b2c9f6d571e175d1fa6a868b53d85c63c80e768a115b7813f65494a61697d96a9456c786a4267e9
7
- data.tar.gz: 149af66da445071b2b586373cffaf03f43d24b59210d102529b70024a8b5c94bdc5d465270ed2e25709e86133ebae43ba43946e4941fe888677c0d9ae1776257
6
+ metadata.gz: de19002fca2ba8619af71a0dc485b225bde5d5414f04f9b43e9a869e49612994d8c1c66bd4a3ab93353341f44ce986f1df2af8dd5fe59b8aa557938c3f1265ec
7
+ data.tar.gz: c55e0e431a1585c1ea24fcd460b0a6a06153f788462093257196891302875f27ea15c6b2671d30c4bd5b2258572c7c7900cdf569fca200fc92e8f3ab3fcf0495
@@ -1,24 +1,46 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/configurable"
4
-
5
3
  module DeprecationToolkit
6
- class Configuration
7
- include ActiveSupport::Configurable
8
-
9
- config_accessor(:allowed_deprecations) { [] }
10
- config_accessor(:attach_to) { [:rails] }
11
- config_accessor(:behavior) { Behaviors::Raise }
12
- config_accessor(:deprecation_path) { "test/deprecations" }
13
- config_accessor(:test_runner) { :minitest }
14
- config_accessor(:warnings_treated_as_deprecation) { [] }
15
- config_accessor(:deprecation_file_path_format) do
16
- proc do |test|
17
- if DeprecationToolkit::Configuration.test_runner == :rspec
18
- test.example_group.file_path.sub(%r{^./spec/}, "").sub(/_spec.rb$/, "")
19
- else
20
- test.class.name.underscore
21
- end
4
+ module Configuration
5
+ @allowed_deprecations = []
6
+ singleton_class.attr_accessor(:allowed_deprecations)
7
+
8
+ @attach_to = [:rails]
9
+ singleton_class.attr_accessor(:attach_to)
10
+
11
+ @behavior = Behaviors::Raise
12
+ singleton_class.attr_accessor(:behavior)
13
+
14
+ @deprecation_path = "test/deprecations"
15
+ singleton_class.attr_accessor(:deprecation_path)
16
+
17
+ @test_runner = :minitest
18
+ singleton_class.attr_accessor(:test_runner)
19
+
20
+ @warnings_treated_as_deprecation = []
21
+ singleton_class.attr_accessor(:warnings_treated_as_deprecation)
22
+
23
+ @deprecation_file_path_format = proc do |test|
24
+ if DeprecationToolkit::Configuration.test_runner == :rspec
25
+ test.example_group.file_path.sub(%r{^./spec/}, "").sub(/_spec.rb$/, "")
26
+ else
27
+ test.class.name.underscore
28
+ end
29
+ end
30
+ singleton_class.attr_accessor(:deprecation_file_path_format)
31
+
32
+ @deprecation_test_name_normalize = proc do |test_name|
33
+ test_name
34
+ end
35
+ singleton_class.attr_accessor(:deprecation_test_name_normalize)
36
+
37
+ class << self
38
+ def configure
39
+ yield self
40
+ end
41
+
42
+ def config
43
+ self
22
44
  end
23
45
  end
24
46
  end
@@ -2,6 +2,10 @@
2
2
 
3
3
  require "minitest"
4
4
 
5
+ if Minitest.respond_to?(:load) && !Minitest.extensions.include?("deprecation_toolkit")
6
+ Minitest.load(:deprecation_toolkit)
7
+ end
8
+
5
9
  module DeprecationToolkit
6
10
  module Minitest
7
11
  def trigger_deprecation_toolkit_behavior
@@ -9,7 +9,22 @@ module DeprecationToolkit
9
9
  module ReadWriteHelper
10
10
  def read(test)
11
11
  deprecation_file = Bundler.root.join(recorded_deprecations_path(test))
12
- YAML.load(deprecation_file.read).fetch(test_name(test), [])
12
+ data = YAML.load(deprecation_file.read)
13
+ name = test_name(test)
14
+
15
+ # Fast path: exact match
16
+ return data[name] if data.key?(name)
17
+
18
+ # Fallback: match by normalized name (handles tag addition/removal)
19
+ normalized_name = normalized_test_name(name)
20
+ return data[normalized_name] if data.key?(normalized_name)
21
+
22
+ # Fallback: iterate over all normalized keys
23
+ data.each do |key, deprecations|
24
+ return deprecations if normalized_test_name(key) == normalized_name
25
+ end
26
+
27
+ []
13
28
  rescue Errno::ENOENT
14
29
  []
15
30
  end
@@ -19,6 +34,10 @@ module DeprecationToolkit
19
34
  updated_deprecations = original_deprecations.dup
20
35
 
21
36
  deprecations_to_record.each do |test, deprecation_to_record|
37
+ # Remove any stale key that normalizes to the same name
38
+ normalized = normalized_test_name(test)
39
+ updated_deprecations.delete_if { |key, _| key != test && normalized_test_name(key) == normalized }
40
+
22
41
  if deprecation_to_record.any?
23
42
  updated_deprecations[test] = deprecation_to_record
24
43
  else
@@ -63,5 +82,9 @@ module DeprecationToolkit
63
82
  test.name
64
83
  end
65
84
  end
85
+
86
+ def normalized_test_name(name)
87
+ DeprecationToolkit::Configuration.deprecation_test_name_normalize.call(name)
88
+ end
66
89
  end
67
90
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeprecationToolkit
4
- VERSION = "2.2.4"
4
+ VERSION = "2.4.0"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deprecation_toolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.4
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
10
+ date: 2026-05-07 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activesupport
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: '6.1'
18
+ version: '7.0'
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: '6.1'
25
+ version: '7.0'
26
26
  email:
27
27
  - rails@shopify.com
28
28
  executables: []
@@ -53,7 +53,7 @@ licenses:
53
53
  - MIT
54
54
  metadata:
55
55
  homepage_uri: https://github.com/shopify/deprecation_toolkit
56
- source_code_uri: https://github.com/Shopify/deprecation_toolkit/tree/v2.2.4
56
+ source_code_uri: https://github.com/Shopify/deprecation_toolkit/tree/v2.4.0
57
57
  changelog_uri: https://github.com/Shopify/deprecation_toolkit/blob/main/CHANGELOG.md
58
58
  allowed_push_host: https://rubygems.org
59
59
  rdoc_options: []
@@ -63,14 +63,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - ">="
65
65
  - !ruby/object:Gem::Version
66
- version: 3.0.0
66
+ version: 3.3.0
67
67
  required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  requirements:
69
69
  - - ">="
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  requirements: []
73
- rubygems_version: 3.7.1
73
+ rubygems_version: 3.6.2
74
74
  specification_version: 4
75
75
  summary: Deprecation Toolkit around ActiveSupport::Deprecation
76
76
  test_files: []