deprecation_toolkit 2.2.2 → 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: 6764813c0b9b8522fa1e755f59e4f3e7137fa229a24e5b96ae05fbcbd53efdc7
4
- data.tar.gz: 5e570bcbf742061e36c5aeb4b1073a3ba546c47e5caefaba2b1d33abaaf1c037
3
+ metadata.gz: 7b57fe6f900e79cc13938de52e802aaff9ab51dfe546d5f9e1cdc0a9ec6c4648
4
+ data.tar.gz: 61ca80ab4fd5d2337b83cba6af0d53dd1af734957487fcf78d1677ca6b2205d0
5
5
  SHA512:
6
- metadata.gz: 9c851ca5d25bdaed7522be6f1736766bd92a66f454993ec060c048fe6f09feb9f28d3d7c608ba248a31492b8c6656782871507d6e9fd138af85e03b53446dda7
7
- data.tar.gz: f8ba1b548b6cde09de40768dce5f2b79ba23dd3bf69620cc6255520efc6fe11c4f8839978d7f0d1ecfa1f0c77307ddf2743cd219d1834ae181f3f762d2f3a80a
6
+ metadata.gz: cff2de2f59cb48d1d96b4f39c5c4cdc601d2fdf512d990794e09cf791ef49c7ca8ada4effaa1c19ce0cecc53d535cace10a32eb443abc2a04ac5ca831118dc4c
7
+ data.tar.gz: 9fc7fda9a92dd4f73af1297200b81c20825b5f37529ce8f808c2a3b6e1f777586d0fba83b5982d978222c8f90b9a24e473107456d39d8758df91d775ac821d7b
@@ -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.2"
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,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.2
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-01-23 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: activesupport
@@ -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.2
56
+ source_code_uri: https://github.com/Shopify/deprecation_toolkit/tree/v2.2.3
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: []
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  requirements: []
73
- rubygems_version: 3.6.2
73
+ rubygems_version: 3.6.8
74
74
  specification_version: 4
75
75
  summary: Deprecation Toolkit around ActiveSupport::Deprecation
76
76
  test_files: []