deprecation_toolkit 2.2.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -1
- data/.ruby-version +1 -0
- data/Gemfile.lock +44 -38
- data/README.md +8 -4
- data/deprecation_toolkit.gemspec +1 -1
- data/lib/deprecation_toolkit/behaviors/ci_record_helper.rb +3 -2
- data/lib/deprecation_toolkit/behaviors/disabled.rb +4 -2
- data/lib/deprecation_toolkit/behaviors/raise.rb +4 -2
- data/lib/deprecation_toolkit/behaviors/record.rb +3 -2
- data/lib/deprecation_toolkit/collector.rb +1 -5
- data/lib/deprecation_toolkit/deprecation_subscriber.rb +11 -6
- data/lib/deprecation_toolkit/test_triggerer.rb +3 -1
- data/lib/deprecation_toolkit/version.rb +1 -1
- data/lib/deprecation_toolkit/warning.rb +6 -3
- data/lib/deprecation_toolkit.rb +1 -1
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3584b676fc957381c253538150d205b4a0711efee7ef5b3f5926b4b2674b10a4
|
4
|
+
data.tar.gz: b44b3fc7c0b2fe3a93cc05f225cd8cb13cb4f6d3d762c5c4a89ac67863c9a4bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f20edbb85c72c400f9fb1a6f2e9151fe08d249107f4ac27e2432f29b7c13ceb5222f78dfe2990ec5faf34190fe197096db7065f4be61c55ce199a3a049cf756a
|
7
|
+
data.tar.gz: 55c16daef83b058df361785d033bffaa4be13efeac27acf77f1fa65bfcd236ccb42e719402f9b965737d31dd3647fa5efd6f87225b8aca2ece519491d8c4f6b7
|
data/.rubocop.yml
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.3.0
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
deprecation_toolkit (2.2.
|
4
|
+
deprecation_toolkit (2.2.1)
|
5
5
|
activesupport (>= 6.1)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activesupport (7.1.
|
10
|
+
activesupport (7.1.3.4)
|
11
11
|
base64
|
12
12
|
bigdecimal
|
13
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
@@ -19,54 +19,60 @@ GEM
|
|
19
19
|
tzinfo (~> 2.0)
|
20
20
|
ast (2.4.2)
|
21
21
|
base64 (0.2.0)
|
22
|
-
bigdecimal (3.1.
|
23
|
-
concurrent-ruby (1.
|
22
|
+
bigdecimal (3.1.8)
|
23
|
+
concurrent-ruby (1.3.3)
|
24
24
|
connection_pool (2.4.1)
|
25
|
-
diff-lcs (1.5.
|
26
|
-
drb (2.2.
|
27
|
-
|
28
|
-
i18n (1.14.1)
|
25
|
+
diff-lcs (1.5.1)
|
26
|
+
drb (2.2.1)
|
27
|
+
i18n (1.14.5)
|
29
28
|
concurrent-ruby (~> 1.0)
|
30
|
-
|
29
|
+
json (2.7.2)
|
30
|
+
language_server-protocol (3.17.0.3)
|
31
|
+
minitest (5.25.1)
|
31
32
|
mutex_m (0.2.0)
|
32
|
-
parallel (1.
|
33
|
-
parser (3.
|
33
|
+
parallel (1.24.0)
|
34
|
+
parser (3.3.1.0)
|
34
35
|
ast (~> 2.4.1)
|
36
|
+
racc
|
37
|
+
racc (1.7.3)
|
35
38
|
rainbow (3.1.1)
|
36
|
-
rake (13.
|
37
|
-
regexp_parser (2.2
|
38
|
-
rexml (3.
|
39
|
-
|
40
|
-
|
41
|
-
rspec-
|
42
|
-
rspec-
|
43
|
-
|
44
|
-
|
45
|
-
|
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)
|
46
50
|
diff-lcs (>= 1.2.0, < 2.0)
|
47
|
-
rspec-support (~> 3.
|
48
|
-
rspec-mocks (3.
|
51
|
+
rspec-support (~> 3.13.0)
|
52
|
+
rspec-mocks (3.13.1)
|
49
53
|
diff-lcs (>= 1.2.0, < 2.0)
|
50
|
-
rspec-support (~> 3.
|
51
|
-
rspec-support (3.
|
52
|
-
rubocop (1.
|
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)
|
53
59
|
parallel (~> 1.10)
|
54
|
-
parser (>= 3.
|
60
|
+
parser (>= 3.3.0.2)
|
55
61
|
rainbow (>= 2.2.2, < 4.0)
|
56
62
|
regexp_parser (>= 1.8, < 3.0)
|
57
|
-
rexml
|
58
|
-
rubocop-ast (>= 1.
|
63
|
+
rexml (>= 3.2.5, < 4.0)
|
64
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
59
65
|
ruby-progressbar (~> 1.7)
|
60
|
-
unicode-display_width (>=
|
61
|
-
rubocop-ast (1.
|
62
|
-
parser (>= 3.
|
63
|
-
rubocop-shopify (2.
|
64
|
-
rubocop (~> 1.
|
65
|
-
ruby-progressbar (1.
|
66
|
-
|
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)
|
67
73
|
tzinfo (2.0.6)
|
68
74
|
concurrent-ruby (~> 1.0)
|
69
|
-
unicode-display_width (2.
|
75
|
+
unicode-display_width (2.5.0)
|
70
76
|
|
71
77
|
PLATFORMS
|
72
78
|
ruby
|
@@ -80,4 +86,4 @@ DEPENDENCIES
|
|
80
86
|
rubocop-shopify
|
81
87
|
|
82
88
|
BUNDLED WITH
|
83
|
-
2.
|
89
|
+
2.5.10
|
data/README.md
CHANGED
@@ -57,16 +57,16 @@ This gem provides 4 behaviors, the default one being `DeprecationToolkit::Behavi
|
|
57
57
|
DeprecationToolkit::Configuration.behavior = DeprecationToolkit::Behaviors::Record
|
58
58
|
```
|
59
59
|
|
60
|
-
You can also create your own behavior
|
60
|
+
You can also create your own behavior object and perform the logic you want. Your behavior needs to respond to `trigger`.
|
61
61
|
|
62
62
|
```ruby
|
63
63
|
class StatsdBehavior
|
64
|
-
def
|
64
|
+
def trigger(test, deprecations, recorded_deprecations)
|
65
65
|
# Could send some statsd event for example
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
DeprecationToolkit::Configuration.behavior = StatsdBehavior
|
69
|
+
DeprecationToolkit::Configuration.behavior = StatsdBehavior.new
|
70
70
|
```
|
71
71
|
|
72
72
|
#### DeprecationToolkit::Behaviors::CIRecordHelper
|
@@ -75,7 +75,7 @@ This is a special type of behaviour meant to help you record deprecations if you
|
|
75
75
|
Imagine if you have thousands of tests and need to record deprecations for each on your machine, this is going to take ages.
|
76
76
|
Recording deprecations on CI with the regular `Record` behavior isn't possible because of the way CI parallelize test in multiple container (Multiple tests from the same file runs in parallel in diferrent machines, the deprecation files that get created are then splitted. Regrouping them is a nightmare.)
|
77
77
|
|
78
|
-
This
|
78
|
+
This behavior will output a JSON representation of your deprecations. Your CI should have a way to download the log generated from the test run. Download it on your locale machine. Finally run the rake task `FILEPATH=<path_to_downloaded_log> deprecation_toolkit:record_from_ci_output`.
|
79
79
|
This task will parse your CI log and grab the output generated by the DeprecationToolkit and will finally convert everything back to YML files.
|
80
80
|
|
81
81
|
### 🔨 `#DeprecationToolkit::Configuration#allowed_deprecations`
|
@@ -170,6 +170,10 @@ It's possible to record deprecations while running your specs by adding an ENV['
|
|
170
170
|
DEPRECATION_BEHAVIOR="record" bundle exec rspec path/to/file_spec.rb
|
171
171
|
```
|
172
172
|
|
173
|
+
## Usage without Rails
|
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).
|
176
|
+
|
173
177
|
## License
|
174
178
|
|
175
179
|
Deprecation Toolkit is licensed under the [MIT license](LICENSE.txt).
|
data/deprecation_toolkit.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
22
22
|
|
23
|
-
spec.required_ruby_version = ">=
|
23
|
+
spec.required_ruby_version = ">= 3.0.0"
|
24
24
|
|
25
25
|
spec.files = %x(git ls-files -z).split("\x0").reject do |f|
|
26
26
|
f.match(%r{^(test|spec|\.github|gemfiles)/})
|
@@ -4,12 +4,13 @@ require "json"
|
|
4
4
|
|
5
5
|
module DeprecationToolkit
|
6
6
|
module Behaviors
|
7
|
-
|
7
|
+
module CIRecordHelper
|
8
|
+
extend self
|
8
9
|
extend ReadWriteHelper
|
9
10
|
|
10
11
|
HEADER = "[DeprecationToolkit]"
|
11
12
|
|
12
|
-
def
|
13
|
+
def trigger(test, current_deprecations, _recorded_deprecations)
|
13
14
|
filename = recorded_deprecations_path(test)
|
14
15
|
|
15
16
|
to_output = {
|
@@ -2,8 +2,10 @@
|
|
2
2
|
|
3
3
|
module DeprecationToolkit
|
4
4
|
module Behaviors
|
5
|
-
|
6
|
-
|
5
|
+
module Raise
|
6
|
+
extend self
|
7
|
+
|
8
|
+
def trigger(_test, current_deprecations, recorded_deprecations)
|
7
9
|
error_class = if current_deprecations.size > recorded_deprecations.size
|
8
10
|
DeprecationIntroduced
|
9
11
|
elsif current_deprecations.size < recorded_deprecations.size
|
@@ -2,10 +2,11 @@
|
|
2
2
|
|
3
3
|
module DeprecationToolkit
|
4
4
|
module Behaviors
|
5
|
-
|
5
|
+
module Record
|
6
|
+
extend self
|
6
7
|
extend ReadWriteHelper
|
7
8
|
|
8
|
-
def
|
9
|
+
def trigger(test, collector, _)
|
9
10
|
deprecation_file = recorded_deprecations_path(test)
|
10
11
|
|
11
12
|
write(deprecation_file, test_name(test) => collector.deprecations_without_stacktrace)
|
@@ -65,11 +65,7 @@ module DeprecationToolkit
|
|
65
65
|
private
|
66
66
|
|
67
67
|
def active_support_deprecation_sub_params
|
68
|
-
|
69
|
-
[/\W\s\(called from .*\)$/, ""]
|
70
|
-
else
|
71
|
-
[/ \(called from .*\)$/, ""]
|
72
|
-
end
|
68
|
+
[/ \(called from .*\)$/, ""]
|
73
69
|
end
|
74
70
|
|
75
71
|
def gem_deprecate_sub_params
|
@@ -4,8 +4,10 @@ require "active_support/subscriber"
|
|
4
4
|
|
5
5
|
module DeprecationToolkit
|
6
6
|
class DeprecationSubscriber < ActiveSupport::Subscriber
|
7
|
-
|
8
|
-
|
7
|
+
class << self
|
8
|
+
def already_attached?
|
9
|
+
notifier != nil
|
10
|
+
end
|
9
11
|
end
|
10
12
|
|
11
13
|
def deprecation(event)
|
@@ -17,10 +19,13 @@ module DeprecationToolkit
|
|
17
19
|
private
|
18
20
|
|
19
21
|
def deprecation_allowed?(payload)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
Configuration.allowed_deprecations.any? do |rule|
|
23
|
+
if rule.is_a?(Regexp)
|
24
|
+
rule.match?(payload[:message])
|
25
|
+
else
|
26
|
+
rule.call(payload[:message], payload[:callstack])
|
27
|
+
end
|
28
|
+
end
|
24
29
|
end
|
25
30
|
end
|
26
31
|
end
|
@@ -2,7 +2,9 @@
|
|
2
2
|
|
3
3
|
module DeprecationToolkit
|
4
4
|
module TestTriggerer
|
5
|
-
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def trigger_deprecation_toolkit_behavior(test)
|
6
8
|
current_deprecations = DeprecationToolkit::Collector.new(DeprecationToolkit::Collector.deprecations)
|
7
9
|
recorded_deprecations = DeprecationToolkit::Collector.load(test)
|
8
10
|
if !recorded_deprecations.flaky? && current_deprecations != recorded_deprecations
|
@@ -48,11 +48,13 @@ module DeprecationToolkit
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
51
|
-
end
|
52
51
|
|
53
|
-
module DeprecationToolkit
|
54
52
|
module WarningPatch
|
55
53
|
def warn(str, *)
|
54
|
+
if Configuration.warnings_treated_as_deprecation.empty?
|
55
|
+
return super
|
56
|
+
end
|
57
|
+
|
56
58
|
str = DeprecationToolkit::Warning.handle_multipart(str)
|
57
59
|
return unless str
|
58
60
|
|
@@ -64,5 +66,6 @@ module DeprecationToolkit
|
|
64
66
|
end
|
65
67
|
ruby2_keywords :warn
|
66
68
|
end
|
69
|
+
|
70
|
+
::Warning.singleton_class.prepend(WarningPatch)
|
67
71
|
end
|
68
|
-
Warning.singleton_class.prepend(DeprecationToolkit::WarningPatch)
|
data/lib/deprecation_toolkit.rb
CHANGED
@@ -44,7 +44,7 @@ module DeprecationToolkit
|
|
44
44
|
def each_deprecator(&block)
|
45
45
|
if defined?(Rails.application) && Rails.application.respond_to?(:deprecators)
|
46
46
|
Rails.application.deprecators.each(&block)
|
47
|
-
|
47
|
+
elsif ActiveSupport::Deprecation.respond_to?(:behavior)
|
48
48
|
block.call(ActiveSupport::Deprecation)
|
49
49
|
end
|
50
50
|
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: 2.2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '6.1'
|
27
|
-
description:
|
27
|
+
description:
|
28
28
|
email:
|
29
29
|
- rails@shopify.com
|
30
30
|
executables: []
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- ".gitignore"
|
35
35
|
- ".rspec"
|
36
36
|
- ".rubocop.yml"
|
37
|
+
- ".ruby-version"
|
37
38
|
- CHANGELOG.md
|
38
39
|
- Gemfile
|
39
40
|
- Gemfile.lock
|
@@ -68,7 +69,7 @@ metadata:
|
|
68
69
|
source_code_uri: https://github.com/shopify/deprecation_toolkit
|
69
70
|
changelog_uri: https://github.com/Shopify/deprecation_toolkit/blob/main/CHANGELOG.md
|
70
71
|
allowed_push_host: https://rubygems.org
|
71
|
-
post_install_message:
|
72
|
+
post_install_message:
|
72
73
|
rdoc_options: []
|
73
74
|
require_paths:
|
74
75
|
- lib
|
@@ -76,15 +77,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
77
|
requirements:
|
77
78
|
- - ">="
|
78
79
|
- !ruby/object:Gem::Version
|
79
|
-
version:
|
80
|
+
version: 3.0.0
|
80
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
82
|
requirements:
|
82
83
|
- - ">="
|
83
84
|
- !ruby/object:Gem::Version
|
84
85
|
version: '0'
|
85
86
|
requirements: []
|
86
|
-
rubygems_version: 3.5.
|
87
|
-
signing_key:
|
87
|
+
rubygems_version: 3.5.17
|
88
|
+
signing_key:
|
88
89
|
specification_version: 4
|
89
90
|
summary: Deprecation Toolkit around ActiveSupport::Deprecation
|
90
91
|
test_files: []
|