deprecation_toolkit 1.5.1 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +50 -0
- data/.github/workflows/cla.yml +26 -0
- data/.rubocop.yml +3 -3
- data/CHANGELOG.md +21 -1
- data/Gemfile +11 -4
- data/Gemfile.lock +47 -45
- data/README.md +11 -9
- data/RELEASE.md +21 -0
- data/deprecation_toolkit.gemspec +6 -11
- data/gemfiles/activesupport_5.2.gemfile +2 -8
- data/gemfiles/activesupport_6.0.gemfile +2 -8
- data/gemfiles/activesupport_6.1.gemfile +5 -0
- data/gemfiles/activesupport_7.0.gemfile +5 -0
- data/gemfiles/activesupport_edge.gemfile +5 -0
- data/lib/deprecation_toolkit/behaviors/ci_record_helper.rb +2 -2
- data/lib/deprecation_toolkit/collector.rb +1 -1
- data/lib/deprecation_toolkit/deprecation_subscriber.rb +1 -1
- data/lib/deprecation_toolkit/rspec_plugin.rb +1 -1
- data/lib/deprecation_toolkit/version.rb +1 -1
- data/lib/deprecation_toolkit/warning.rb +11 -36
- data/lib/deprecation_toolkit.rb +29 -15
- data/lib/minitest/deprecation_toolkit_plugin.rb +3 -2
- data/lib/tasks/ci_recorder.rake +10 -9
- data/spec/deprecation_toolkit/behaviors/disabled_spec.rb +2 -2
- data/spec/deprecation_toolkit/behaviors/raise_spec.rb +4 -4
- data/spec/deprecation_toolkit/behaviors/record_spec.rb +1 -1
- data/spec/rspec/plugin_env_options_spec.rb +3 -3
- data/spec/rspec/plugin_spec.rb +1 -1
- metadata +13 -65
- data/.rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml +0 -1017
- data/.travis.yml +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2d0b00fe8e8b87b77af20209fac4531b7d2faebdecc55a8cdbd1b490cd65089
|
4
|
+
data.tar.gz: 4ed23c378e87023b0303839edaaa99265929c2b4eb5e7c1b56156992c24ba8e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 947cd740128e855612cc94917760cf00160adeda014fb4727153a811ea3e2b4cec4e563c61c02729c4eabdebdbf28307787f727feefa4a76e273c4b534c0fc40
|
7
|
+
data.tar.gz: e46958cb158e2ede1139cabb445462349ceb8bc4de06b4084d6af1f086aacba390e86c9cba7c07a23d074d899cd669ef775c790263632be66b88990164404cd2
|
@@ -0,0 +1,50 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
functionality:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
name: Ruby ${{ matrix.ruby }} / ${{ matrix.gemfile }}
|
9
|
+
strategy:
|
10
|
+
matrix:
|
11
|
+
gemfile: [gemfiles/activesupport_5.2.gemfile, gemfiles/activesupport_6.0.gemfile, gemfiles/activesupport_6.1.gemfile, gemfiles/activesupport_7.0.gemfile, gemfiles/activesupport_edge.gemfile]
|
12
|
+
ruby: ["2.6", "2.7", "3.0", "3.1"]
|
13
|
+
exclude:
|
14
|
+
# Active Support requires Ruby >= 2.7 as of 7.0
|
15
|
+
- gemfile: "gemfiles/activesupport_7.0.gemfile"
|
16
|
+
ruby: "2.6"
|
17
|
+
- gemfile: "gemfiles/activesupport_edge.gemfile"
|
18
|
+
ruby: "2.6"
|
19
|
+
env:
|
20
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
21
|
+
steps:
|
22
|
+
|
23
|
+
- name: Check out code
|
24
|
+
uses: actions/checkout@v3
|
25
|
+
|
26
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
27
|
+
uses: ruby/setup-ruby@v1
|
28
|
+
with:
|
29
|
+
ruby-version: ${{ matrix.ruby }}
|
30
|
+
bundler-cache: true
|
31
|
+
|
32
|
+
- name: Tests
|
33
|
+
run: bundle exec rake test
|
34
|
+
|
35
|
+
- name: Specs
|
36
|
+
run: bundle exec rspec
|
37
|
+
style:
|
38
|
+
runs-on: ubuntu-latest
|
39
|
+
name: Rubocop
|
40
|
+
steps:
|
41
|
+
- name: Check out code
|
42
|
+
uses: actions/checkout@v3
|
43
|
+
|
44
|
+
- uses: ruby/setup-ruby@v1
|
45
|
+
with:
|
46
|
+
ruby-version: "3.1"
|
47
|
+
bundler-cache: true
|
48
|
+
|
49
|
+
- name: RuboCop
|
50
|
+
run: bundle exec rubocop
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: Contributor License Agreement (CLA)
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request_target:
|
5
|
+
types: [opened, synchronize]
|
6
|
+
issue_comment:
|
7
|
+
types: [created]
|
8
|
+
|
9
|
+
permissions:
|
10
|
+
pull-requests: write # to set the label
|
11
|
+
actions: write # to re-run the workflow when a comment is received
|
12
|
+
|
13
|
+
jobs:
|
14
|
+
cla:
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
if: |
|
17
|
+
(github.event.issue.pull_request
|
18
|
+
&& !github.event.issue.pull_request.merged_at
|
19
|
+
&& contains(github.event.comment.body, 'signed')
|
20
|
+
)
|
21
|
+
|| (github.event.pull_request && !github.event.pull_request.merged)
|
22
|
+
steps:
|
23
|
+
- uses: Shopify/shopify-cla-action@v1
|
24
|
+
with:
|
25
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
26
|
+
cla-token: ${{ secrets.CLA_TOKEN }}
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,31 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
-
##
|
3
|
+
## main (unreleased)
|
4
|
+
|
5
|
+
## 2.0.1 (2022-11-18)
|
6
|
+
|
7
|
+
* [#74](https://github.com/Shopify/deprecation_toolkit/pull/74): Add support for `Rails.application.deprecators`. (@gmcgibbon)
|
8
|
+
|
9
|
+
## 2.0.0 (2022-03-16)
|
10
|
+
|
11
|
+
* [#58](https://github.com/Shopify/deprecation_toolkit/pull/58): Drop support for Ruby < 2.6 & Active Support < 5.2. (@sambostock)
|
12
|
+
* [#58](https://github.com/Shopify/deprecation_toolkit/pull/58): Ensure compatibility with Rails 7. (@sambostock)
|
13
|
+
|
14
|
+
## 1.5.1 (2020-04-28)
|
15
|
+
|
16
|
+
* [#46](https://github.com/Shopify/deprecation_toolkit/pull/46): Handle another two part Ruby 2.7 keyword argument deprecation warning. (@casperisfine)
|
17
|
+
|
18
|
+
## 1.5.0 (2020-04-14)
|
19
|
+
|
20
|
+
* [#42](https://github.com/Shopify/deprecation_toolkit/pull/42): Fix Minitest plugin kicking in when it shouldn't. (@Edouard-chin)
|
21
|
+
* [#45](https://github.com/Shopify/deprecation_toolkit/pull/45): Handle two part Ruby 2.7 keyword argument deprecation warning. (@casperisfine)
|
4
22
|
|
5
23
|
## 1.4.0 (2019-04-29)
|
24
|
+
|
6
25
|
* [#37](https://github.com/Shopify/deprecation_toolkit/pull/37): Add Rspec support. (@andrewmarkle)
|
7
26
|
|
8
27
|
## 1.3.0 (2019-02-28)
|
28
|
+
|
9
29
|
* [#38](https://github.com/Shopify/deprecation_toolkit/pull/38): Add a way to mark test as flaky. (@Edouard-chin)
|
10
30
|
* [#39](https://github.com/Shopify/deprecation_toolkit/pull/39): Introduced a way to help recording massive amount of deprecations. (@Edouard-chin)
|
11
31
|
|
data/Gemfile
CHANGED
@@ -1,10 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
source
|
3
|
+
source "https://rubygems.org"
|
4
4
|
|
5
5
|
gemspec
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
10
17
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,69 +1,71 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
deprecation_toolkit (
|
5
|
-
activesupport (>=
|
4
|
+
deprecation_toolkit (2.0.1)
|
5
|
+
activesupport (>= 5.2)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activesupport (
|
10
|
+
activesupport (7.0.4)
|
11
11
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
-
i18n (>=
|
13
|
-
minitest (
|
14
|
-
tzinfo (~>
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
i18n (1.8.2)
|
12
|
+
i18n (>= 1.6, < 2)
|
13
|
+
minitest (>= 5.1)
|
14
|
+
tzinfo (~> 2.0)
|
15
|
+
ast (2.4.2)
|
16
|
+
concurrent-ruby (1.1.10)
|
17
|
+
diff-lcs (1.5.0)
|
18
|
+
i18n (1.12.0)
|
20
19
|
concurrent-ruby (~> 1.0)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
rexml (3.2.
|
29
|
-
rspec (3.
|
30
|
-
rspec-core (~> 3.
|
31
|
-
rspec-expectations (~> 3.
|
32
|
-
rspec-mocks (~> 3.
|
33
|
-
rspec-core (3.
|
34
|
-
rspec-support (~> 3.
|
35
|
-
rspec-expectations (3.
|
20
|
+
minitest (5.15.0)
|
21
|
+
parallel (1.21.0)
|
22
|
+
parser (3.1.1.0)
|
23
|
+
ast (~> 2.4.1)
|
24
|
+
rainbow (3.1.1)
|
25
|
+
rake (13.0.6)
|
26
|
+
regexp_parser (2.2.1)
|
27
|
+
rexml (3.2.5)
|
28
|
+
rspec (3.11.0)
|
29
|
+
rspec-core (~> 3.11.0)
|
30
|
+
rspec-expectations (~> 3.11.0)
|
31
|
+
rspec-mocks (~> 3.11.0)
|
32
|
+
rspec-core (3.11.0)
|
33
|
+
rspec-support (~> 3.11.0)
|
34
|
+
rspec-expectations (3.11.0)
|
36
35
|
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
-
rspec-support (~> 3.
|
38
|
-
rspec-mocks (3.
|
36
|
+
rspec-support (~> 3.11.0)
|
37
|
+
rspec-mocks (3.11.0)
|
39
38
|
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
-
rspec-support (~> 3.
|
41
|
-
rspec-support (3.
|
42
|
-
rubocop (
|
43
|
-
jaro_winkler (~> 1.5.1)
|
39
|
+
rspec-support (~> 3.11.0)
|
40
|
+
rspec-support (3.11.0)
|
41
|
+
rubocop (1.25.1)
|
44
42
|
parallel (~> 1.10)
|
45
|
-
parser (>=
|
43
|
+
parser (>= 3.1.0.0)
|
46
44
|
rainbow (>= 2.2.2, < 4.0)
|
45
|
+
regexp_parser (>= 1.8, < 3.0)
|
47
46
|
rexml
|
47
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
48
48
|
ruby-progressbar (~> 1.7)
|
49
|
-
unicode-display_width (>= 1.4.0, <
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
49
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
50
|
+
rubocop-ast (1.16.0)
|
51
|
+
parser (>= 3.1.1.0)
|
52
|
+
rubocop-shopify (2.5.0)
|
53
|
+
rubocop (~> 1.25)
|
54
|
+
ruby-progressbar (1.11.0)
|
55
|
+
tzinfo (2.0.5)
|
56
|
+
concurrent-ruby (~> 1.0)
|
57
|
+
unicode-display_width (2.1.0)
|
56
58
|
|
57
59
|
PLATFORMS
|
58
60
|
ruby
|
59
61
|
|
60
62
|
DEPENDENCIES
|
61
|
-
bundler
|
63
|
+
bundler
|
62
64
|
deprecation_toolkit!
|
63
|
-
minitest
|
65
|
+
minitest
|
64
66
|
rake
|
65
|
-
rspec
|
66
|
-
rubocop
|
67
|
+
rspec
|
68
|
+
rubocop-shopify
|
67
69
|
|
68
70
|
BUNDLED WITH
|
69
|
-
|
71
|
+
2.2.22
|
data/README.md
CHANGED
@@ -6,10 +6,9 @@ Deprecation Toolkit is a gem that helps you get rid of deprecations in your code
|
|
6
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
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
|
-
|
10
9
|
## How it works
|
11
10
|
|
12
|
-
The Deprecation Toolkit gem works by using a [shitlist approach](https://
|
11
|
+
The Deprecation Toolkit gem works by using a [shitlist approach](https://www.youtube.com/watch?v=20pj_ajDBOg).
|
13
12
|
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
13
|
|
15
14
|
## Recording Deprecations
|
@@ -44,15 +43,13 @@ end
|
|
44
43
|
|
45
44
|
Behaviors define what happens when non-recorded deprecations are encountered.
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
This gem provides 3 behaviors, the default one being `DeprecationToolkit::Behaviors::Raise`.
|
46
|
+
This gem provides 4 behaviors, the default one being `DeprecationToolkit::Behaviors::Raise`.
|
50
47
|
|
51
48
|
* `DeprecationToolkit::Behaviors::Raise` will raise either:
|
52
|
-
- `DeprecationToolkit::DeprecationIntroduced` error if a new deprecation is introduced.
|
53
|
-
- `DeprecationToolkit::DeprecationRemoved` error if a deprecation was removed (compare to the one recorded in the shitlist).
|
49
|
+
- `DeprecationToolkit::Behaviors::DeprecationIntroduced` error if a new deprecation is introduced.
|
50
|
+
- `DeprecationToolkit::Behaviors::DeprecationRemoved` error if a deprecation was removed (compare to the one recorded in the shitlist).
|
54
51
|
* `DeprecationToolkit::Behaviors::Record` will record deprecations.
|
55
|
-
* `DeprecationToolkit::Behaviors::CIRecordHelper` See
|
52
|
+
* `DeprecationToolkit::Behaviors::CIRecordHelper` See separate explanation below.
|
56
53
|
* `DeprecationToolkit::Behaviors::Disabled` will do nothing.
|
57
54
|
- This is useful if you want to disable this gem for a moment without removing the gem from your Gemfile.
|
58
55
|
|
@@ -72,7 +69,7 @@ end
|
|
72
69
|
DeprecationToolkit::Configuration.behavior = StatsdBehavior
|
73
70
|
```
|
74
71
|
|
75
|
-
|
72
|
+
#### DeprecationToolkit::Behaviors::CIRecordHelper
|
76
73
|
|
77
74
|
This is a special type of behaviour meant to help you record deprecations if you have a lof of them.
|
78
75
|
Imagine if you have thousands of tests and need to record deprecations for each on your machine, this is going to take ages.
|
@@ -114,6 +111,11 @@ a message in the console.
|
|
114
111
|
Deprecation Toolkit allows you to configure which warnings should be treated as deprecations in order for you
|
115
112
|
to keep track of them as if they were regular deprecations.
|
116
113
|
|
114
|
+
This setting accepts an array of regular expressions. To match on all warnings, you can provide a empty regex:
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
DeprecationToolkit::Configuration.warnings_treated_as_deprecation = [//]
|
118
|
+
```
|
117
119
|
|
118
120
|
## RSpec
|
119
121
|
|
data/RELEASE.md
ADDED
@@ -0,0 +1,21 @@
|
|
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/deprecation_toolkit.gemspec
CHANGED
@@ -7,7 +7,7 @@ require "deprecation_toolkit/version"
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = "deprecation_toolkit"
|
9
9
|
spec.version = DeprecationToolkit::VERSION
|
10
|
-
spec.authors =
|
10
|
+
spec.authors = ["Shopify"]
|
11
11
|
spec.email = ["rails@shopify.com"]
|
12
12
|
|
13
13
|
spec.summary = "Deprecation Toolkit around ActiveSupport::Deprecation"
|
@@ -16,21 +16,16 @@ Gem::Specification.new do |spec|
|
|
16
16
|
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
18
18
|
spec.metadata["source_code_uri"] = "https://github.com/shopify/deprecation_toolkit"
|
19
|
-
spec.metadata["changelog_uri"] = "https://github.com/Shopify/deprecation_toolkit/blob/
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/Shopify/deprecation_toolkit/blob/main/CHANGELOG.md"
|
20
20
|
|
21
|
-
spec.metadata[
|
21
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
22
22
|
|
23
|
-
spec.required_ruby_version =
|
23
|
+
spec.required_ruby_version = ">= 2.6"
|
24
24
|
|
25
25
|
spec.files = %x(git ls-files -z).split("\x0").reject do |f|
|
26
26
|
f.match(%r{^(test)/})
|
27
27
|
end
|
28
|
-
spec.require_paths =
|
28
|
+
spec.require_paths = ["lib"]
|
29
29
|
|
30
|
-
spec.add_runtime_dependency(
|
31
|
-
|
32
|
-
spec.add_development_dependency("bundler", ">= 1.16")
|
33
|
-
spec.add_development_dependency("rake", "~> 10.0")
|
34
|
-
spec.add_development_dependency("minitest", "~> 5.0")
|
35
|
-
spec.add_development_dependency("rspec", "~> 3.0")
|
30
|
+
spec.add_runtime_dependency("activesupport", ">= 5.2")
|
36
31
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "json"
|
4
4
|
|
5
5
|
module DeprecationToolkit
|
6
6
|
module Behaviors
|
7
7
|
class CIRecordHelper
|
8
8
|
extend ReadWriteHelper
|
9
9
|
|
10
|
-
HEADER =
|
10
|
+
HEADER = "[DeprecationToolkit]"
|
11
11
|
|
12
12
|
def self.trigger(test, current_deprecations, _recorded_deprecations)
|
13
13
|
filename = recorded_deprecations_path(test)
|
@@ -20,7 +20,7 @@ module DeprecationToolkit
|
|
20
20
|
allowed_deprecations, procs = Configuration.allowed_deprecations.partition { |el| el.is_a?(Regexp) }
|
21
21
|
|
22
22
|
allowed_deprecations.any? { |regex| regex =~ payload[:message] } ||
|
23
|
-
|
23
|
+
procs.any? { |proc| proc.call(payload[:message], payload[:callstack]) }
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -4,7 +4,7 @@ module DeprecationToolkit
|
|
4
4
|
module RSpecPlugin
|
5
5
|
RSpec.configure do |config|
|
6
6
|
config.before(:suite) do
|
7
|
-
case ENV[
|
7
|
+
case ENV["DEPRECATION_BEHAVIOR"]
|
8
8
|
when "r", "record", "record-deprecations"
|
9
9
|
DeprecationToolkit::Configuration.behavior = DeprecationToolkit::Behaviors::Record
|
10
10
|
end
|
@@ -43,43 +43,18 @@ module DeprecationToolkit
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
if DeprecationToolkit::Warning.deprecation_triggered?(message)
|
58
|
-
ActiveSupport::Deprecation.warn(message)
|
59
|
-
else
|
60
|
-
__original_warn(messages)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def warn(*messages)
|
66
|
-
Kernel.warn(messages)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
else
|
70
|
-
module DeprecationToolkit
|
71
|
-
module WarningPatch
|
72
|
-
def warn(str)
|
73
|
-
str = DeprecationToolkit::Warning.handle_multipart(str)
|
74
|
-
return unless str
|
75
|
-
|
76
|
-
if DeprecationToolkit::Warning.deprecation_triggered?(str)
|
77
|
-
ActiveSupport::Deprecation.warn(str)
|
78
|
-
else
|
79
|
-
super
|
80
|
-
end
|
46
|
+
module DeprecationToolkit
|
47
|
+
module WarningPatch
|
48
|
+
def warn(str)
|
49
|
+
str = DeprecationToolkit::Warning.handle_multipart(str)
|
50
|
+
return unless str
|
51
|
+
|
52
|
+
if DeprecationToolkit::Warning.deprecation_triggered?(str)
|
53
|
+
ActiveSupport::Deprecation.warn(str)
|
54
|
+
else
|
55
|
+
super
|
81
56
|
end
|
82
57
|
end
|
83
58
|
end
|
84
|
-
Warning.singleton_class.prepend(DeprecationToolkit::WarningPatch)
|
85
59
|
end
|
60
|
+
Warning.singleton_class.prepend(DeprecationToolkit::WarningPatch)
|
data/lib/deprecation_toolkit.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require "active_support"
|
4
|
+
|
5
|
+
load("tasks/ci_recorder.rake")
|
4
6
|
|
5
7
|
module DeprecationToolkit
|
6
8
|
autoload :DeprecationSubscriber, "deprecation_toolkit/deprecation_subscriber"
|
@@ -16,26 +18,38 @@ module DeprecationToolkit
|
|
16
18
|
autoload :CIRecordHelper, "deprecation_toolkit/behaviors/ci_record_helper"
|
17
19
|
end
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
class << self
|
22
|
+
def add_notify_behavior
|
23
|
+
notify = ActiveSupport::Deprecation::DEFAULT_BEHAVIORS[:notify]
|
24
|
+
|
25
|
+
each_deprecator do |deprecator|
|
26
|
+
behaviors = deprecator.behavior
|
22
27
|
|
23
|
-
|
24
|
-
|
28
|
+
unless behaviors.find { |behavior| behavior == notify }
|
29
|
+
deprecator.behavior = (behaviors << notify)
|
30
|
+
end
|
31
|
+
end
|
25
32
|
end
|
26
|
-
end
|
27
33
|
|
28
|
-
|
29
|
-
|
34
|
+
def attach_subscriber
|
35
|
+
return if DeprecationSubscriber.already_attached?
|
30
36
|
|
31
|
-
|
32
|
-
|
37
|
+
Configuration.attach_to.each do |gem_name|
|
38
|
+
DeprecationSubscriber.attach_to(gem_name)
|
39
|
+
end
|
33
40
|
end
|
34
|
-
end
|
35
|
-
end
|
36
41
|
|
37
|
-
|
38
|
-
|
42
|
+
private
|
43
|
+
|
44
|
+
def each_deprecator(&block)
|
45
|
+
if defined?(Rails.application) && Rails.application.respond_to?(:deprecators)
|
46
|
+
Rails.application.deprecators.each(&block)
|
47
|
+
else
|
48
|
+
block.call(ActiveSupport::Deprecation)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
39
52
|
end
|
40
53
|
|
54
|
+
require "deprecation_toolkit/minitest_hook" unless defined? RSpec
|
41
55
|
require "deprecation_toolkit/warning"
|
@@ -12,7 +12,8 @@ module Minitest
|
|
12
12
|
def plugin_deprecation_toolkit_init(options)
|
13
13
|
return unless using_bundler?
|
14
14
|
|
15
|
-
require
|
15
|
+
require "deprecation_toolkit"
|
16
|
+
|
16
17
|
if options[:record_deprecations]
|
17
18
|
DeprecationToolkit::Configuration.behavior = DeprecationToolkit::Behaviors::Record
|
18
19
|
end
|
@@ -24,6 +25,6 @@ module Minitest
|
|
24
25
|
private
|
25
26
|
|
26
27
|
def using_bundler?
|
27
|
-
ENV[
|
28
|
+
ENV["BUNDLE_GEMFILE"]
|
28
29
|
end
|
29
30
|
end
|