deprecation_toolkit 2.0.4 → 2.2.0

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: 304db5daebe7343f9d4150f079eb498d5c20978ea461c3fe82f2377d42464d2a
4
- data.tar.gz: bcd740c82a01dc7c3782cdef1705a3ee829fdade6684d75ea2537e5601a8007d
3
+ metadata.gz: 562db3c54971f9c7513f6777b6b351325772a467f3a12b9467aee8ae09faea7b
4
+ data.tar.gz: 5d8bfeb8af3b883747c4b72a168e7504080f9e87260b65a67f9ecabe99071016
5
5
  SHA512:
6
- metadata.gz: 67e7401a039080b8ece8449290ec34fa8595540654dac74cabd45084040f07f526d81a14b4c4fb0f1232bfb62a5f4cdb132080388c236d6b47bf2237c180d9f5
7
- data.tar.gz: 042f87488783ea236fa740138b659ebf03dd9befa00a5a8681817103620719e1d73cb57324d9e6e6d23ce67b1a8c0feb3d852ff313bd2030305ab774403e147e
6
+ metadata.gz: 4a801c1cd12e35a705b89ecb7e3f2863be8ef488f29efb8537f7a858d86f68355cd571f22e4b16cd8b50b3c08b7b63e6ac187a12e9bcda184f268b41695b2a14
7
+ data.tar.gz: 940e38840d651bd4cb2432b8d99c0cbdd78257fc8a5cce2175c60fbd40c0bca45a4ad66e6201e3699fdaaf4b6867c7c02257762dec942e1a3b1e29fd89bef9b0
data/.rubocop.yml CHANGED
@@ -11,3 +11,6 @@ Style/MethodCallWithArgsParentheses:
11
11
  Exclude:
12
12
  - Gemfile
13
13
  - gemfiles/*
14
+
15
+ Style/CaseEquality:
16
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## main (unreleased)
4
4
 
5
+ ## 2.2.0 (2024-02-05)
6
+
7
+ * Restore Rails 6.1 compatibility.
8
+ * Accept anything that responds to `===` in `Configuration.warnings_treated_as_deprecation`.
9
+
10
+ ## 2.1.0 (2024-01-19)
11
+
12
+ * [#99](https://github.com/Shopify/deprecation_toolkit/pull/99): Fix `Warning.warn` hook to accept a category.
13
+ * [#95](https://github.com/Shopify/deprecation_toolkit/pull/95): Allow configuration of deprecation file paths and file names.
14
+
5
15
  ## 2.0.4 (2023-11-20)
6
16
 
7
17
  * [#90](https://github.com/Shopify/deprecation_toolkit/pull/90) & [#93](https://github.com/Shopify/deprecation_toolkit/pull/93): Stop using deprecated behavior from Active Support. (@etiennebarrie)
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- deprecation_toolkit (2.0.4)
5
- activesupport (>= 5.2)
4
+ deprecation_toolkit (2.2.0)
5
+ activesupport (>= 6.1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -117,6 +117,39 @@ This setting accepts an array of regular expressions. To match on all warnings,
117
117
  DeprecationToolkit::Configuration.warnings_treated_as_deprecation = [//]
118
118
  ```
119
119
 
120
+ In addition to regexps, anything that responds to `===` can be a matcher, for instance a proc:
121
+
122
+ ```ruby
123
+ DeprecationToolkit::Configuration.warnings_treated_as_deprecation = [
124
+ ->(warning) { !warning.match?(/not a deprecation/)}
125
+ ]
126
+ ```
127
+
128
+ ### 🔨 `#DeprecationToolkit::Configuration#deprecation_file_path_format`
129
+
130
+ DeprecationToolkit allows you to choose the file path format for deprecation files.
131
+
132
+ For Minitest, it defaults to using class name so the following code would correspond to `#{deprecation_path}/deprecation_toolkit/behaviors/raise_test.yml`
133
+
134
+ ```ruby
135
+ module DeprecationToolkit
136
+ module Behaviors
137
+ class RaiseTest < ActiveSupport::TestCase
138
+ end
139
+ end
140
+ end
141
+ ```
142
+
143
+ For rspec if defaults to the file location with spec removed. `/spec/models/user_spec.rb` would correspond to `/models/user.yml`.
144
+
145
+ If you have a specific use case you can configure this with a custom format using a proc. The proc is called with an instance of the test.
146
+
147
+ ```ruby
148
+ Configuration.deprecation_file_path_format = -> (test) do
149
+ Kernel.const_source_location(test.class.name)[0].sub(%r{^./test/}, "").sub(/_test.rb$/, "")
150
+ end
151
+ ```
152
+
120
153
  ## RSpec
121
154
 
122
155
  By default Deprecation Toolkit uses Minitest as its test runner. To use Deprecation Toolkit with RSpec you'll have to configure it.
@@ -27,5 +27,5 @@ Gem::Specification.new do |spec|
27
27
  end
28
28
  spec.require_paths = ["lib"]
29
29
 
30
- spec.add_runtime_dependency("activesupport", ">= 5.2")
30
+ spec.add_runtime_dependency("activesupport", ">= 6.1")
31
31
  end
@@ -12,5 +12,14 @@ module DeprecationToolkit
12
12
  config_accessor(:deprecation_path) { "test/deprecations" }
13
13
  config_accessor(:test_runner) { :minitest }
14
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
22
+ end
23
+ end
15
24
  end
16
25
  end
@@ -48,12 +48,7 @@ module DeprecationToolkit
48
48
  Configuration.deprecation_path
49
49
  end
50
50
 
51
- path =
52
- if DeprecationToolkit::Configuration.test_runner == :rspec
53
- test.example_group.file_path.sub(%r{^./spec/}, "").sub(/_spec.rb$/, "")
54
- else
55
- test.class.name.underscore
56
- end
51
+ path = Configuration.deprecation_file_path_format.call(test)
57
52
 
58
53
  Pathname(deprecation_folder).join("#{path}.yml")
59
54
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeprecationToolkit
4
- VERSION = "2.0.4"
4
+ VERSION = "2.2.0"
5
5
  end
@@ -38,7 +38,7 @@ module DeprecationToolkit
38
38
  end
39
39
 
40
40
  def deprecation_triggered?(str)
41
- DeprecationToolkit::Configuration.warnings_treated_as_deprecation.any? { |warning| warning =~ str }
41
+ DeprecationToolkit::Configuration.warnings_treated_as_deprecation.any? { |warning| warning === str }
42
42
  end
43
43
 
44
44
  def deprecator
@@ -52,7 +52,7 @@ end
52
52
 
53
53
  module DeprecationToolkit
54
54
  module WarningPatch
55
- def warn(str)
55
+ def warn(str, *)
56
56
  str = DeprecationToolkit::Warning.handle_multipart(str)
57
57
  return unless str
58
58
 
@@ -62,6 +62,7 @@ module DeprecationToolkit
62
62
  super
63
63
  end
64
64
  end
65
+ ruby2_keywords :warn
65
66
  end
66
67
  end
67
68
  Warning.singleton_class.prepend(DeprecationToolkit::WarningPatch)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deprecation_toolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-28 00:00:00.000000000 Z
11
+ date: 2024-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.2'
19
+ version: '6.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '5.2'
26
+ version: '6.1'
27
27
  description:
28
28
  email:
29
29
  - rails@shopify.com
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  requirements: []
86
- rubygems_version: 3.4.21
86
+ rubygems_version: 3.5.5
87
87
  signing_key:
88
88
  specification_version: 4
89
89
  summary: Deprecation Toolkit around ActiveSupport::Deprecation