deprecation_toolkit 2.2.1 → 2.2.3

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: 3584b676fc957381c253538150d205b4a0711efee7ef5b3f5926b4b2674b10a4
4
- data.tar.gz: b44b3fc7c0b2fe3a93cc05f225cd8cb13cb4f6d3d762c5c4a89ac67863c9a4bc
3
+ metadata.gz: 7b57fe6f900e79cc13938de52e802aaff9ab51dfe546d5f9e1cdc0a9ec6c4648
4
+ data.tar.gz: 61ca80ab4fd5d2337b83cba6af0d53dd1af734957487fcf78d1677ca6b2205d0
5
5
  SHA512:
6
- metadata.gz: f20edbb85c72c400f9fb1a6f2e9151fe08d249107f4ac27e2432f29b7c13ceb5222f78dfe2990ec5faf34190fe197096db7065f4be61c55ce199a3a049cf756a
7
- data.tar.gz: 55c16daef83b058df361785d033bffaa4be13efeac27acf77f1fa65bfcd236ccb42e719402f9b965737d31dd3647fa5efd6f87225b8aca2ece519491d8c4f6b7
6
+ metadata.gz: cff2de2f59cb48d1d96b4f39c5c4cdc601d2fdf512d990794e09cf791ef49c7ca8ada4effaa1c19ce0cecc53d535cace10a32eb443abc2a04ac5ca831118dc4c
7
+ data.tar.gz: 9fc7fda9a92dd4f73af1297200b81c20825b5f37529ce8f808c2a3b6e1f777586d0fba83b5982d978222c8f90b9a24e473107456d39d8758df91d775ac821d7b
data/README.md CHANGED
@@ -172,7 +172,22 @@ DEPRECATION_BEHAVIOR="record" bundle exec rspec path/to/file_spec.rb
172
172
 
173
173
  ## Usage without Rails
174
174
 
175
- Without Rails, you'll need to make sure your `ActiveSupport::Deprecation` instances use the [`:notify` behavior](https://api.rubyonrails.org/classes/ActiveSupport/Deprecation/Behavior.html#method-i-behavior-3D).
175
+ Without Rails, you'll need to make sure your `ActiveSupport::Deprecation` instances use the [`:notify` behavior](https://api.rubyonrails.org/classes/ActiveSupport/Deprecation/Behavior.html#method-i-behavior-3D) and the `attach_to` is the underscored version of the deprecator's `gem_name` (this is how the `:notify` behavior works):
176
+
177
+ ```ruby
178
+ # defined in the gem:
179
+ MyGem.deprecator = ActiveSupport::Deprecation.new("2.0", "MyGem::Something")
180
+
181
+ # in the test helper:
182
+ MyGem.deprecator.behavior = :notify
183
+
184
+ DeprecationToolkit::Configuration.configure do |config|
185
+ config.attach_to = MyGem.deprecator.gem_name.underscore.tr("/", "_")
186
+ # or more simply
187
+ # config.attach_to = "my_gem_something"
188
+ config.behavior = :notify
189
+ end
190
+ ```
176
191
 
177
192
  ## License
178
193
 
@@ -34,7 +34,9 @@ module DeprecationToolkit
34
34
  You have introduced new deprecations in the codebase. Fix or record them in order to discard this error.
35
35
  #{record_message}
36
36
 
37
+ ******* The following deprecations were added: *******
37
38
  #{introduced_deprecations.join("\n")}
39
+ ******************************************************
38
40
  EOM
39
41
 
40
42
  super(message)
@@ -57,7 +59,9 @@ module DeprecationToolkit
57
59
  The recorded deprecations needs to be updated to reflect your changes.
58
60
  #{record_message}
59
61
 
62
+ ****** The following deprecations were removed: ******
60
63
  #{removed_deprecations.join("\n")}
64
+ ******************************************************
61
65
  EOM
62
66
 
63
67
  super(message)
@@ -5,8 +5,54 @@ require "active_support/subscriber"
5
5
  module DeprecationToolkit
6
6
  class DeprecationSubscriber < ActiveSupport::Subscriber
7
7
  class << self
8
- def already_attached?
9
- notifier != nil
8
+ def attach_to(gem_name, subscriber = new, notifier = ActiveSupport::Notifications, inherit_all: false)
9
+ return if already_attached_to?(gem_name)
10
+
11
+ super(gem_name, subscriber, notifier, inherit_all: inherit_all)
12
+ end
13
+
14
+ def detach_from(gem_name, notifier = ActiveSupport::Notifications)
15
+ @namespace = gem_name
16
+ @subscriber = find_attached_subscriber(gem_name)
17
+ @notifier = notifier
18
+
19
+ return unless subscriber
20
+
21
+ subscribers.delete(subscriber)
22
+
23
+ # Remove event subscribers of all existing methods on the class.
24
+ fetch_public_methods(subscriber, true).each do |event|
25
+ remove_event_subscriber(event)
26
+ end
27
+
28
+ @notifier = nil unless any_subscribers_attached?
29
+ end
30
+
31
+ private
32
+
33
+ def already_attached_to?(gem_name)
34
+ subscribers.any? do |subscriber|
35
+ attached_subscriber?(subscriber, gem_name)
36
+ end
37
+ end
38
+
39
+ def any_subscribers_attached?
40
+ subscribers.any? do |subscriber|
41
+ subscriber.is_a?(self)
42
+ end
43
+ end
44
+
45
+ def find_attached_subscriber(gem_name)
46
+ subscribers.find do |attached_subscriber|
47
+ attached_subscriber?(attached_subscriber, gem_name)
48
+ end
49
+ end
50
+
51
+ def attached_subscriber?(subscriber, gem_name)
52
+ subscriber.is_a?(self) &&
53
+ subscriber.patterns.keys.any? do |pattern|
54
+ pattern.end_with?(".#{gem_name}")
55
+ end
10
56
  end
11
57
  end
12
58
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeprecationToolkit
4
- VERSION = "2.2.1"
4
+ VERSION = "2.2.3"
5
5
  end
@@ -16,6 +16,9 @@ module DeprecationToolkit
16
16
  autoload :Raise, "deprecation_toolkit/behaviors/raise"
17
17
  autoload :Record, "deprecation_toolkit/behaviors/record"
18
18
  autoload :CIRecordHelper, "deprecation_toolkit/behaviors/ci_record_helper"
19
+ autoload :DeprecationIntroduced, "deprecation_toolkit/behaviors/raise"
20
+ autoload :DeprecationRemoved, "deprecation_toolkit/behaviors/raise"
21
+ autoload :DeprecationMismatch, "deprecation_toolkit/behaviors/raise"
19
22
  end
20
23
 
21
24
  class << self
@@ -32,8 +35,6 @@ module DeprecationToolkit
32
35
  end
33
36
 
34
37
  def attach_subscriber
35
- return if DeprecationSubscriber.already_attached?
36
-
37
38
  Configuration.attach_to.each do |gem_name|
38
39
  DeprecationSubscriber.attach_to(gem_name)
39
40
  end
@@ -14,6 +14,10 @@ module Minitest
14
14
 
15
15
  require "deprecation_toolkit"
16
16
 
17
+ setup_deprecation_toolkit(options)
18
+ end
19
+
20
+ def setup_deprecation_toolkit(options)
17
21
  if options[:record_deprecations]
18
22
  DeprecationToolkit::Configuration.behavior = DeprecationToolkit::Behaviors::Record
19
23
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deprecation_toolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-08-23 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -24,25 +23,14 @@ dependencies:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
25
  version: '6.1'
27
- description:
28
26
  email:
29
27
  - rails@shopify.com
30
28
  executables: []
31
29
  extensions: []
32
30
  extra_rdoc_files: []
33
31
  files:
34
- - ".gitignore"
35
- - ".rspec"
36
- - ".rubocop.yml"
37
- - ".ruby-version"
38
- - CHANGELOG.md
39
- - Gemfile
40
- - Gemfile.lock
41
32
  - LICENSE.txt
42
33
  - README.md
43
- - RELEASE.md
44
- - Rakefile
45
- - deprecation_toolkit.gemspec
46
34
  - lib/deprecation_toolkit.rb
47
35
  - lib/deprecation_toolkit/behaviors/ci_record_helper.rb
48
36
  - lib/deprecation_toolkit/behaviors/disabled.rb
@@ -60,16 +48,14 @@ files:
60
48
  - lib/deprecation_toolkit/warning.rb
61
49
  - lib/minitest/deprecation_toolkit_plugin.rb
62
50
  - lib/tasks/ci_recorder.rake
63
- - shipit.rubygems.yml
64
51
  homepage: https://github.com/shopify/deprecation_toolkit
65
52
  licenses:
66
53
  - MIT
67
54
  metadata:
68
55
  homepage_uri: https://github.com/shopify/deprecation_toolkit
69
- source_code_uri: https://github.com/shopify/deprecation_toolkit
56
+ source_code_uri: https://github.com/Shopify/deprecation_toolkit/tree/v2.2.3
70
57
  changelog_uri: https://github.com/Shopify/deprecation_toolkit/blob/main/CHANGELOG.md
71
58
  allowed_push_host: https://rubygems.org
72
- post_install_message:
73
59
  rdoc_options: []
74
60
  require_paths:
75
61
  - lib
@@ -84,8 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
70
  - !ruby/object:Gem::Version
85
71
  version: '0'
86
72
  requirements: []
87
- rubygems_version: 3.5.17
88
- signing_key:
73
+ rubygems_version: 3.6.8
89
74
  specification_version: 4
90
75
  summary: Deprecation Toolkit around ActiveSupport::Deprecation
91
76
  test_files: []
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- /.byebug_history
10
- gemfiles/*.lock
data/.rspec DELETED
@@ -1,4 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
4
-
data/.rubocop.yml DELETED
@@ -1,15 +0,0 @@
1
- inherit_gem:
2
- rubocop-shopify: rubocop.yml
3
-
4
- AllCops:
5
- SuggestExtensions: false
6
- Exclude:
7
- - gemfiles/vendor/**/*
8
-
9
- Style/MethodCallWithArgsParentheses:
10
- Exclude:
11
- - Gemfile
12
- - gemfiles/*
13
-
14
- Style/CaseEquality:
15
- Enabled: false
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.3.0
data/CHANGELOG.md DELETED
@@ -1,85 +0,0 @@
1
- # Change log
2
-
3
- ## main (unreleased)
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
-
15
- ## 2.0.4 (2023-11-20)
16
-
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)
18
- * [#91](https://github.com/Shopify/deprecation_toolkit/pull/91): Require necessary Active Support core extension. (@etiennebarrie)
19
-
20
- ## 2.0.3 (2023-02-10)
21
-
22
- * [#80](https://github.com/Shopify/deprecation_toolkit/pull/80): Filter out stack trace from Gem::Deprecate deprecation messages (@davidstosik)
23
-
24
- ## 2.0.2 (2023-02-08)
25
-
26
- * [#78](https://github.com/Shopify/deprecation_toolkit/pull/78): Show deprecations without stacktrace. (@shioyama)
27
-
28
- ## 2.0.1 (2022-11-18)
29
-
30
- * [#74](https://github.com/Shopify/deprecation_toolkit/pull/74): Add support for `Rails.application.deprecators`. (@gmcgibbon)
31
-
32
- ## 2.0.0 (2022-03-16)
33
-
34
- * [#58](https://github.com/Shopify/deprecation_toolkit/pull/58): Drop support for Ruby < 2.6 & Active Support < 5.2. (@sambostock)
35
- * [#58](https://github.com/Shopify/deprecation_toolkit/pull/58): Ensure compatibility with Rails 7. (@sambostock)
36
-
37
- ## 1.5.1 (2020-04-28)
38
-
39
- * [#46](https://github.com/Shopify/deprecation_toolkit/pull/46): Handle another two part Ruby 2.7 keyword argument deprecation warning. (@casperisfine)
40
-
41
- ## 1.5.0 (2020-04-14)
42
-
43
- * [#42](https://github.com/Shopify/deprecation_toolkit/pull/42): Fix Minitest plugin kicking in when it shouldn't. (@Edouard-chin)
44
- * [#45](https://github.com/Shopify/deprecation_toolkit/pull/45): Handle two part Ruby 2.7 keyword argument deprecation warning. (@casperisfine)
45
-
46
- ## 1.4.0 (2019-04-29)
47
-
48
- * [#37](https://github.com/Shopify/deprecation_toolkit/pull/37): Add Rspec support. (@andrewmarkle)
49
-
50
- ## 1.3.0 (2019-02-28)
51
-
52
- * [#38](https://github.com/Shopify/deprecation_toolkit/pull/38): Add a way to mark test as flaky. (@Edouard-chin)
53
- * [#39](https://github.com/Shopify/deprecation_toolkit/pull/39): Introduced a way to help recording massive amount of deprecations. (@Edouard-chin)
54
-
55
- ## 1.2.1 (2019-01-09)
56
-
57
- ### Bug fixes
58
- * [#34](https://github.com/Shopify/deprecation_toolkit/pull/34): Fixes SystemStackError with RubyGems v3 and Ruby 2.5+. (@dylanahsmith)
59
-
60
- ## 1.2.0 (2018-11-28)
61
-
62
- ### New features
63
-
64
- * [#30](https://github.com/Shopify/deprecation_toolkit/pull/30): Introduce a `DeprecationMismatch` error class. (@Edouard-chin)
65
- ### Bug fixes
66
- * [#29](https://github.com/Shopify/deprecation_toolkit/pull/29): Fix issue where the error class triggered was incorrect in some circumstances. (@Edouard-chin)
67
-
68
- ## 1.1.0 (2018-11-13)
69
-
70
- ### New features
71
-
72
- * [#28](https://github.com/Shopify/deprecation_toolkit/pull/28): `Configuration.allowed_deprecations` now accepts Procs.
73
- This is useful if you need to whitelist deprecations based on the caller.
74
-
75
- ## 1.0.3 (2018-10-25)
76
-
77
- ### Bug fixes
78
-
79
- * [#22](https://github.com/Shopify/deprecation_toolkit/pull/22): Fixes `Kernel.warn` not triggering deprecation. (@rmacklin)
80
-
81
- ## 1.0.2 (2018-10-01)
82
-
83
- ### New features
84
-
85
- * [#15](https://github.com/Shopify/deprecation_toolkit/pull/15): Add support for ActiveSupport 4.2. (@andrewmarkle)
data/Gemfile DELETED
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- gemspec
6
-
7
- gem "bundler"
8
- gem "minitest"
9
- gem "rake"
10
- gem "rspec"
11
- gem "rubocop-shopify"
12
-
13
- if defined?(@activesupport_gem_requirement) && @activesupport_gem_requirement
14
- # causes Dependabot to ignore the next line
15
- activesupport = "activesupport"
16
- gem activesupport, @activesupport_gem_requirement
17
- end
data/Gemfile.lock DELETED
@@ -1,89 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- deprecation_toolkit (2.2.1)
5
- activesupport (>= 6.1)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activesupport (7.1.3.4)
11
- base64
12
- bigdecimal
13
- concurrent-ruby (~> 1.0, >= 1.0.2)
14
- connection_pool (>= 2.2.5)
15
- drb
16
- i18n (>= 1.6, < 2)
17
- minitest (>= 5.1)
18
- mutex_m
19
- tzinfo (~> 2.0)
20
- ast (2.4.2)
21
- base64 (0.2.0)
22
- bigdecimal (3.1.8)
23
- concurrent-ruby (1.3.3)
24
- connection_pool (2.4.1)
25
- diff-lcs (1.5.1)
26
- drb (2.2.1)
27
- i18n (1.14.5)
28
- concurrent-ruby (~> 1.0)
29
- json (2.7.2)
30
- language_server-protocol (3.17.0.3)
31
- minitest (5.25.1)
32
- mutex_m (0.2.0)
33
- parallel (1.24.0)
34
- parser (3.3.1.0)
35
- ast (~> 2.4.1)
36
- racc
37
- racc (1.7.3)
38
- rainbow (3.1.1)
39
- rake (13.2.1)
40
- regexp_parser (2.9.2)
41
- rexml (3.3.6)
42
- strscan
43
- rspec (3.13.0)
44
- rspec-core (~> 3.13.0)
45
- rspec-expectations (~> 3.13.0)
46
- rspec-mocks (~> 3.13.0)
47
- rspec-core (3.13.0)
48
- rspec-support (~> 3.13.0)
49
- rspec-expectations (3.13.0)
50
- diff-lcs (>= 1.2.0, < 2.0)
51
- rspec-support (~> 3.13.0)
52
- rspec-mocks (3.13.1)
53
- diff-lcs (>= 1.2.0, < 2.0)
54
- rspec-support (~> 3.13.0)
55
- rspec-support (3.13.1)
56
- rubocop (1.63.5)
57
- json (~> 2.3)
58
- language_server-protocol (>= 3.17.0)
59
- parallel (~> 1.10)
60
- parser (>= 3.3.0.2)
61
- rainbow (>= 2.2.2, < 4.0)
62
- regexp_parser (>= 1.8, < 3.0)
63
- rexml (>= 3.2.5, < 4.0)
64
- rubocop-ast (>= 1.31.1, < 2.0)
65
- ruby-progressbar (~> 1.7)
66
- unicode-display_width (>= 2.4.0, < 3.0)
67
- rubocop-ast (1.31.3)
68
- parser (>= 3.3.1.0)
69
- rubocop-shopify (2.15.1)
70
- rubocop (~> 1.51)
71
- ruby-progressbar (1.13.0)
72
- strscan (3.1.0)
73
- tzinfo (2.0.6)
74
- concurrent-ruby (~> 1.0)
75
- unicode-display_width (2.5.0)
76
-
77
- PLATFORMS
78
- ruby
79
-
80
- DEPENDENCIES
81
- bundler
82
- deprecation_toolkit!
83
- minitest
84
- rake
85
- rspec
86
- rubocop-shopify
87
-
88
- BUNDLED WITH
89
- 2.5.10
data/RELEASE.md DELETED
@@ -1,21 +0,0 @@
1
- # Contribution to Deprecation Toolkit
2
-
3
- ## Releasing a new version
4
-
5
- 1. Audit PRs and commits merged since the last release, ensuring **all user fancing changes are documented** in `CHANGELOG.md`.
6
- 2. Based on the changes, determine whether to increment the major, minor, or patch version, adhering to [Semantic Versioning][semver].
7
- 3. Update the gem version string accordingly in `lib/deprecation_toolkit/version.rb`.
8
- 4. Run `bundle install` to update the `Gemfile.lock`.
9
- 5. Insert a new heading in `CHANGELOG.md` containing the version identifier and expected release date (e.g. `## 1.2.3 (1999-12-31)`).
10
- 6. Commit changes on a new branch and open a PR.
11
- 7. **Draft** a [new release][github-new-release] on GitHub, but **do not publish it yet**.
12
- 8. Once you have received approval on your PR, merge it into `main`.
13
- 9. Deploy using the [ShipIt][shipit] UI, and **verify** the new version is available on [RubyGems][rubygems].
14
- 10. Publish the drafted release, tagging the deployed commit (should be `HEAD` of the `main` branch) with a tag of the form `vMAJOR.MINOR.PATCH`.
15
-
16
- If something goes wrong during the deploy process, address it and tag whatever commit was successfully deployed as that version.
17
-
18
- [semver]: https://semver.org
19
- [github-new-release]: https://github.com/Shopify/deprecation_toolkit/releases/new
20
- [shipit]: https://shipit.shopify.io/shopify/deprecation_toolkit/rubygems
21
- [rubygems]: https://rubygems.org/gems/deprecation_toolkit/versions
data/Rakefile DELETED
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rake/testtask"
5
-
6
- Rake::TestTask.new(:test) do |t|
7
- t.libs << "test"
8
- t.libs << "lib"
9
- t.warning = true
10
- t.test_files = FileList["test/**/*_test.rb"]
11
- end
12
-
13
- task(default: :test)
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path("lib", __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require "deprecation_toolkit/version"
6
-
7
- Gem::Specification.new do |spec|
8
- spec.name = "deprecation_toolkit"
9
- spec.version = DeprecationToolkit::VERSION
10
- spec.authors = ["Shopify"]
11
- spec.email = ["rails@shopify.com"]
12
-
13
- spec.summary = "Deprecation Toolkit around ActiveSupport::Deprecation"
14
- spec.homepage = "https://github.com/shopify/deprecation_toolkit"
15
- spec.license = "MIT"
16
-
17
- spec.metadata["homepage_uri"] = spec.homepage
18
- spec.metadata["source_code_uri"] = "https://github.com/shopify/deprecation_toolkit"
19
- spec.metadata["changelog_uri"] = "https://github.com/Shopify/deprecation_toolkit/blob/main/CHANGELOG.md"
20
-
21
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
22
-
23
- spec.required_ruby_version = ">= 3.0.0"
24
-
25
- spec.files = %x(git ls-files -z).split("\x0").reject do |f|
26
- f.match(%r{^(test|spec|\.github|gemfiles)/})
27
- end
28
- spec.require_paths = ["lib"]
29
-
30
- spec.add_runtime_dependency("activesupport", ">= 6.1")
31
- end
data/shipit.rubygems.yml DELETED
@@ -1 +0,0 @@
1
- # using the default shipit config