deprecation_toolkit 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +3 -3
- data/README.md +14 -17
- data/lib/deprecation_toolkit/version.rb +1 -1
- data/lib/deprecation_toolkit/warning.rb +14 -8
- data/lib/deprecation_toolkit.rb +15 -0
- data/lib/minitest/deprecation_toolkit_plugin.rb +2 -19
- 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: e01e1ccdad76b3a084e7c5ad013fea98f28fc959
|
4
|
+
data.tar.gz: af5cd6abbb05a4ee4ea615b424d00be914b57567
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afd8e6cc37cd0bd0e025334752f13bb389a191531a8e0a26de2ecc09f1e9f7086cf796cd56e3a1dd8e1154dbd236c99de913c37aba4f248112b8c335c330e5ea
|
7
|
+
data.tar.gz: c24ee0952676a10d928125b1145e293bc5a72a59cf5d6a1624ab1264aa6e29f0913618289e40720c0edd16e0f83e61988aa92febf0457d2973a5d6253d44cbce
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## master (unreleased)
|
4
|
+
### Bug fixes
|
5
|
+
|
6
|
+
## 1.0.3 (2018-10-25)
|
7
|
+
### Bug fixes
|
8
|
+
|
9
|
+
* [#22](https://github.com/Shopify/deprecation_toolkit/pull/22): Fixes `Kernel.warn` not triggering deprecation. (@rmacklin)
|
3
10
|
|
4
11
|
## 1.0.2 (2018-10-01)
|
5
12
|
### New features
|
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.0.3)
|
5
5
|
activesupport (>= 4.2)
|
6
6
|
|
7
7
|
GEM
|
@@ -14,7 +14,7 @@ GEM
|
|
14
14
|
tzinfo (~> 1.1)
|
15
15
|
ast (2.4.0)
|
16
16
|
concurrent-ruby (1.0.5)
|
17
|
-
i18n (1.1.
|
17
|
+
i18n (1.1.1)
|
18
18
|
concurrent-ruby (~> 1.0)
|
19
19
|
jaro_winkler (1.5.1)
|
20
20
|
minitest (5.11.3)
|
@@ -50,4 +50,4 @@ DEPENDENCIES
|
|
50
50
|
rubocop
|
51
51
|
|
52
52
|
BUNDLED WITH
|
53
|
-
1.16.
|
53
|
+
1.16.6
|
data/README.md
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
## Introduction
|
4
4
|
|
5
|
-
|
6
|
-
Having deprecations in your application
|
7
|
-
Fixing all deprecations at once might be
|
5
|
+
Deprecation Toolkit is a gem that helps you get rid of deprecations in your codebase.
|
6
|
+
Having deprecations in your application usually means that something will break whenever you upgrade third-party dependencies. The sooner the better to fix them!
|
7
|
+
Fixing all deprecations at once might be tough depending on the size of your app and the number of deprecations. You might have to progressively resolve them while making sure your team doesn't add new ones. This is where this gem comes handy!
|
8
8
|
|
9
9
|
|
10
10
|
## How it works
|
11
11
|
|
12
12
|
The Deprecation Toolkit gem works by using a [shitlist approach](https://confreaks.tv/videos/reddotrubyconf2017-shitlist-driven-development-and-other-tricks-for-working-on-large-codebases).
|
13
|
-
First, all
|
13
|
+
First, the gem records all existing deprecations into `.yml` files. When running a test that have non-recorded deprecations after the initial recording, Deprecation Toolkit triggers a behavior of your choice (by default it raises an error).
|
14
14
|
|
15
15
|
## Recording Deprecations
|
16
16
|
|
@@ -25,9 +25,9 @@ rails test <path_to_my_test.rb> -r
|
|
25
25
|
|
26
26
|
### 🔨 `#DeprecationToolkit::Configuration#deprecation_path`
|
27
27
|
|
28
|
-
You can control where
|
28
|
+
You can control where recorded deprecations are saved and read from. By default, deprecations are recorded in the `test/deprecations` folder.
|
29
29
|
|
30
|
-
The `deprecation_path` either accepts a string or a proc.
|
30
|
+
The `deprecation_path` either accepts a string or a proc. The proc is called with the path of the running test file.
|
31
31
|
|
32
32
|
```ruby
|
33
33
|
DeprecationToolkit::Configuration.deprecation_path = 'test/deprecations'
|
@@ -42,9 +42,9 @@ end
|
|
42
42
|
|
43
43
|
### 🔨 `#DeprecationToolkit::Configuration#behavior`
|
44
44
|
|
45
|
-
Behaviors
|
45
|
+
Behaviors define what happens when non-recorded deprecations are encountered.
|
46
46
|
|
47
|
-
Behaviors are
|
47
|
+
Behaviors are classes that have a `.trigger` class method.
|
48
48
|
|
49
49
|
This gem provides 3 behaviors, the default one being `DeprecationToolkit::Behaviors::Raise`.
|
50
50
|
|
@@ -59,7 +59,7 @@ This gem provides 3 behaviors, the default one being `DeprecationToolkit::Behavi
|
|
59
59
|
DeprecationToolkit::Configuration.behavior = DeprecationToolkit::Behaviors::Record
|
60
60
|
```
|
61
61
|
|
62
|
-
You can also create your own behavior class and perform the logic you want. Your behavior needs to respond to
|
62
|
+
You can also create your own behavior class and perform the logic you want. Your behavior needs to respond to `.trigger`.
|
63
63
|
|
64
64
|
```ruby
|
65
65
|
class StatsdBehavior
|
@@ -73,25 +73,22 @@ DeprecationToolkit::Configuration.behavior = StatsdBehavior
|
|
73
73
|
|
74
74
|
### 🔨 `#DeprecationToolkit::Configuration#allowed_deprecations`
|
75
75
|
|
76
|
-
|
77
|
-
array of Regexp.
|
76
|
+
You can ignore some deprecations using `allowed_deprecations`. `allowed_deprecations` accepts an array of Regexp.
|
78
77
|
|
79
|
-
Whenever a deprecation matches one of the regex,
|
78
|
+
Whenever a deprecation matches one of the regex, it is ignored.
|
80
79
|
|
81
80
|
```ruby
|
82
81
|
DeprecationToolkit::Configuration.allowed_deprecations = [/Hello World/]
|
83
82
|
|
84
|
-
|
85
|
-
# the Deprecation Toolkit will simply ignore it.
|
86
|
-
ActiveSupport::Deprecation.warn('Hello World')
|
83
|
+
ActiveSupport::Deprecation.warn('Hello World') # ignored by Deprecation Toolkit
|
87
84
|
```
|
88
85
|
|
89
86
|
### 🔨 `#DeprecationToolkit::Configuration#warnings_treated_as_deprecation`
|
90
87
|
|
91
|
-
Most gems
|
88
|
+
Most gems don't use `ActiveSupport::Deprecation` to deprecate their code but instead just use `Kernel#warn` to output
|
92
89
|
a message in the console.
|
93
90
|
|
94
|
-
|
91
|
+
Deprecation Toolkit allows you to configure which warnings should be treated as deprecations in order for you
|
95
92
|
to keep track of them as if they were regular deprecations.
|
96
93
|
|
97
94
|
## License
|
@@ -25,17 +25,23 @@ end
|
|
25
25
|
# Note that the `Warning` module exists in Ruby 2.4 but has a bug https://bugs.ruby-lang.org/issues/12944
|
26
26
|
if RUBY_VERSION < '2.5.0' && RUBY_ENGINE == 'ruby'
|
27
27
|
module Kernel
|
28
|
-
|
28
|
+
class << self
|
29
|
+
alias_method :__original_warn, :warn
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
def warn(*messages)
|
32
|
+
message = messages.join("\n")
|
33
|
+
message += "\n" unless message.end_with?("\n")
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
if DeprecationToolkit::Warning.deprecation_triggered?(message)
|
36
|
+
ActiveSupport::Deprecation.warn(message)
|
37
|
+
else
|
38
|
+
__original_warn(messages)
|
39
|
+
end
|
38
40
|
end
|
39
41
|
end
|
42
|
+
|
43
|
+
def warn(*messages)
|
44
|
+
Kernel.warn(messages)
|
45
|
+
end
|
40
46
|
end
|
41
47
|
end
|
data/lib/deprecation_toolkit.rb
CHANGED
@@ -11,6 +11,21 @@ module DeprecationToolkit
|
|
11
11
|
autoload :Raise, "deprecation_toolkit/behaviors/raise"
|
12
12
|
autoload :Record, "deprecation_toolkit/behaviors/record"
|
13
13
|
end
|
14
|
+
|
15
|
+
def self.add_notify_behavior
|
16
|
+
notify = ActiveSupport::Deprecation::DEFAULT_BEHAVIORS[:notify]
|
17
|
+
behaviors = ActiveSupport::Deprecation.behavior
|
18
|
+
|
19
|
+
unless behaviors.find { |behavior| behavior == notify }
|
20
|
+
ActiveSupport::Deprecation.behavior = behaviors << notify
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.attach_subscriber
|
25
|
+
Configuration.attach_to.each do |gem_name|
|
26
|
+
DeprecationSubscriber.attach_to gem_name
|
27
|
+
end
|
28
|
+
end
|
14
29
|
end
|
15
30
|
|
16
31
|
require "deprecation_toolkit/minitest_hook"
|
@@ -14,24 +14,7 @@ module Minitest
|
|
14
14
|
DeprecationToolkit::Configuration.behavior = DeprecationToolkit::Behaviors::Record
|
15
15
|
end
|
16
16
|
|
17
|
-
add_notify_behavior
|
18
|
-
attach_subscriber
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def add_notify_behavior
|
24
|
-
notify = ActiveSupport::Deprecation::DEFAULT_BEHAVIORS[:notify]
|
25
|
-
behaviors = ActiveSupport::Deprecation.behavior
|
26
|
-
|
27
|
-
unless behaviors.find { |behavior| behavior == notify }
|
28
|
-
ActiveSupport::Deprecation.behavior = behaviors << notify
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def attach_subscriber
|
33
|
-
DeprecationToolkit::Configuration.attach_to.each do |gem_name|
|
34
|
-
DeprecationToolkit::DeprecationSubscriber.attach_to gem_name
|
35
|
-
end
|
17
|
+
DeprecationToolkit.add_notify_behavior
|
18
|
+
DeprecationToolkit.attach_subscriber
|
36
19
|
end
|
37
20
|
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.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|