deprecation_toolkit 1.0.3 → 1.1.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 +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +3 -3
- data/README.md +14 -1
- data/lib/deprecation_toolkit.rb +2 -0
- data/lib/deprecation_toolkit/deprecation_subscriber.rb +10 -3
- data/lib/deprecation_toolkit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a142310e36ffb312bd50a257a82260477fc8940
|
4
|
+
data.tar.gz: ca2b082fddc00a195c72e081eac71512d358b7dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '038a0936b7029bd2b73b557fa0a43ce6d4b22dfdb92bb98ca9d1c06dd5084528f74809244944b717dbcc41cecde1cba3b358b707fece9a6d62fa3e88b9a96c57'
|
7
|
+
data.tar.gz: e2af9e16220b684ca29b79426918aed40c7cdb79ca90f85a72f0a9f7185dab4c21bb15d9cd279c322ccf78ad64f72d2e16462a6fa5abcc0d02e1c5b263781684
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,11 @@
|
|
3
3
|
## master (unreleased)
|
4
4
|
### Bug fixes
|
5
5
|
|
6
|
+
## 1.1.0 (2018-11-13)
|
7
|
+
### New Features
|
8
|
+
* [#28](https://github.com/Shopify/deprecation_toolkit/pull/28): `Configuration.allowed_deprecations now accepts Procs.
|
9
|
+
This is useful if you need to whitelist deprecations based on the caller.
|
10
|
+
|
6
11
|
## 1.0.3 (2018-10-25)
|
7
12
|
### Bug fixes
|
8
13
|
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
deprecation_toolkit (1.0
|
4
|
+
deprecation_toolkit (1.1.0)
|
5
5
|
activesupport (>= 4.2)
|
6
6
|
|
7
7
|
GEM
|
@@ -13,7 +13,7 @@ GEM
|
|
13
13
|
minitest (~> 5.1)
|
14
14
|
tzinfo (~> 1.1)
|
15
15
|
ast (2.4.0)
|
16
|
-
concurrent-ruby (1.
|
16
|
+
concurrent-ruby (1.1.3)
|
17
17
|
i18n (1.1.1)
|
18
18
|
concurrent-ruby (~> 1.0)
|
19
19
|
jaro_winkler (1.5.1)
|
@@ -50,4 +50,4 @@ DEPENDENCIES
|
|
50
50
|
rubocop
|
51
51
|
|
52
52
|
BUNDLED WITH
|
53
|
-
1.
|
53
|
+
1.17.1
|
data/README.md
CHANGED
@@ -73,7 +73,7 @@ DeprecationToolkit::Configuration.behavior = StatsdBehavior
|
|
73
73
|
|
74
74
|
### 🔨 `#DeprecationToolkit::Configuration#allowed_deprecations`
|
75
75
|
|
76
|
-
You can ignore some deprecations using `allowed_deprecations`. `allowed_deprecations` accepts an array of Regexp.
|
76
|
+
You can ignore some deprecations using `allowed_deprecations`. `allowed_deprecations` accepts an array of Regexp and Procs.
|
77
77
|
|
78
78
|
Whenever a deprecation matches one of the regex, it is ignored.
|
79
79
|
|
@@ -83,6 +83,19 @@ DeprecationToolkit::Configuration.allowed_deprecations = [/Hello World/]
|
|
83
83
|
ActiveSupport::Deprecation.warn('Hello World') # ignored by Deprecation Toolkit
|
84
84
|
```
|
85
85
|
|
86
|
+
When passing procs, each proc will get passed the deprecation message and the callstack.
|
87
|
+
This is useful if you want to whitelist deprecations based on the caller.
|
88
|
+
|
89
|
+
```ruby
|
90
|
+
DeprecationToolkit::Configuration.allowed_deprecations = [
|
91
|
+
->(message, stack) { message ~= 'Foo' && stack.first.label == 'method_triggering_deprecation' }
|
92
|
+
]
|
93
|
+
|
94
|
+
def method_triggering_deprecation
|
95
|
+
ActiveSupport::Deprecation.warn('Foo') # Ignored by the the DeprecationToolkit
|
96
|
+
end
|
97
|
+
```
|
98
|
+
|
86
99
|
### 🔨 `#DeprecationToolkit::Configuration#warnings_treated_as_deprecation`
|
87
100
|
|
88
101
|
Most gems don't use `ActiveSupport::Deprecation` to deprecate their code but instead just use `Kernel#warn` to output
|
data/lib/deprecation_toolkit.rb
CHANGED
@@ -4,16 +4,23 @@ require "active_support/subscriber"
|
|
4
4
|
|
5
5
|
module DeprecationToolkit
|
6
6
|
class DeprecationSubscriber < ActiveSupport::Subscriber
|
7
|
+
def self.already_attached?
|
8
|
+
notifier != nil
|
9
|
+
end
|
10
|
+
|
7
11
|
def deprecation(event)
|
8
12
|
message = event.payload[:message]
|
9
13
|
|
10
|
-
Collector.collect(message) unless deprecation_allowed?(
|
14
|
+
Collector.collect(message) unless deprecation_allowed?(event.payload)
|
11
15
|
end
|
12
16
|
|
13
17
|
private
|
14
18
|
|
15
|
-
def deprecation_allowed?(
|
16
|
-
Configuration.allowed_deprecations.
|
19
|
+
def deprecation_allowed?(payload)
|
20
|
+
allowed_deprecations, procs = Configuration.allowed_deprecations.partition { |el| el.is_a?(Regexp) }
|
21
|
+
|
22
|
+
allowed_deprecations.any? { |regex| regex =~ payload[:message] } ||
|
23
|
+
procs.any? { |proc| proc.call(payload[:message], payload[:callstack]) }
|
17
24
|
end
|
18
25
|
end
|
19
26
|
end
|
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: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|