warning_signs 0.0.1
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 +7 -0
- data/.github/dependabot.yml +11 -0
- data/.github/workflows/main.yml +32 -0
- data/.gitignore +19 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +153 -0
- data/README.md +122 -0
- data/Rakefile +8 -0
- data/bin/console +10 -0
- data/bin/setup +6 -0
- data/lib/warning_signs/deprecation.rb +29 -0
- data/lib/warning_signs/environment.rb +10 -0
- data/lib/warning_signs/handler.rb +79 -0
- data/lib/warning_signs/rails_deprecation_catcher.rb +9 -0
- data/lib/warning_signs/railtie.rb +9 -0
- data/lib/warning_signs/ruby_deprecation_catcher.rb +11 -0
- data/lib/warning_signs/version.rb +3 -0
- data/lib/warning_signs/world.rb +54 -0
- data/lib/warning_signs.rb +20 -0
- data/warning_signs.gemspec +43 -0
- metadata +207 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 55b5a8c89a3c99603f0b3878a341c8ab5cce9833a364ae43e6fa6e2f4a601b77
|
|
4
|
+
data.tar.gz: 288ec53101a4c0fcfc17b326521ed49b88bfb081e642795c6667d0adbdf687c9
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: b6bbbff2c40d7299d8f559172a929d549f31ed5b1555262cae957d6958450e7fc9cadd87e4d6adcb23c15f9e16a0590336b9e036b54cbddcd32b097baf3e4929
|
|
7
|
+
data.tar.gz: c24f89c8d34ff9ea560998af85d6ae6385945e35fdb6d5acd0a01a3258e5bb09186308d730760bc7b9f2657628d673d1776c5bf00e9b08bc8eba545999efe92d
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
|
3
|
+
# Please see the documentation for all configuration options:
|
|
4
|
+
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
|
5
|
+
|
|
6
|
+
version: 2
|
|
7
|
+
updates:
|
|
8
|
+
- package-ecosystem: "bundler"
|
|
9
|
+
directory: "/"
|
|
10
|
+
schedule:
|
|
11
|
+
interval: "daily"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Ruby
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
pull_request:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
name: Ruby ${{ matrix.ruby }}
|
|
14
|
+
strategy:
|
|
15
|
+
matrix:
|
|
16
|
+
ruby:
|
|
17
|
+
- "3.2"
|
|
18
|
+
- "3.1"
|
|
19
|
+
- "3.0"
|
|
20
|
+
- "2.7"
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v2
|
|
24
|
+
- name: Set up Ruby
|
|
25
|
+
uses: ruby/setup-ruby@v1
|
|
26
|
+
with:
|
|
27
|
+
ruby-version: ${{ matrix.ruby }}
|
|
28
|
+
bundler-cache: true
|
|
29
|
+
- name: StandardRB Linter
|
|
30
|
+
run: bundle exec standardrb
|
|
31
|
+
- name: Run the default task
|
|
32
|
+
run: bundle exec rake
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.0.6
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
warning_signs (0.0.1)
|
|
5
|
+
awesome_print
|
|
6
|
+
railties
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
actionpack (7.0.4.3)
|
|
12
|
+
actionview (= 7.0.4.3)
|
|
13
|
+
activesupport (= 7.0.4.3)
|
|
14
|
+
rack (~> 2.0, >= 2.2.0)
|
|
15
|
+
rack-test (>= 0.6.3)
|
|
16
|
+
rails-dom-testing (~> 2.0)
|
|
17
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
|
18
|
+
actionview (7.0.4.3)
|
|
19
|
+
activesupport (= 7.0.4.3)
|
|
20
|
+
builder (~> 3.1)
|
|
21
|
+
erubi (~> 1.4)
|
|
22
|
+
rails-dom-testing (~> 2.0)
|
|
23
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
24
|
+
activesupport (7.0.4.3)
|
|
25
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
26
|
+
i18n (>= 1.6, < 2)
|
|
27
|
+
minitest (>= 5.1)
|
|
28
|
+
tzinfo (~> 2.0)
|
|
29
|
+
ast (2.4.2)
|
|
30
|
+
awesome_print (1.9.2)
|
|
31
|
+
builder (3.2.4)
|
|
32
|
+
byebug (11.1.3)
|
|
33
|
+
coderay (1.1.3)
|
|
34
|
+
concurrent-ruby (1.2.2)
|
|
35
|
+
crass (1.0.6)
|
|
36
|
+
diff-lcs (1.5.0)
|
|
37
|
+
docile (1.4.0)
|
|
38
|
+
erubi (1.12.0)
|
|
39
|
+
i18n (1.13.0)
|
|
40
|
+
concurrent-ruby (~> 1.0)
|
|
41
|
+
json (2.6.3)
|
|
42
|
+
language_server-protocol (3.17.0.3)
|
|
43
|
+
lint_roller (1.0.0)
|
|
44
|
+
loofah (2.20.0)
|
|
45
|
+
crass (~> 1.0.2)
|
|
46
|
+
nokogiri (>= 1.5.9)
|
|
47
|
+
method_source (1.0.0)
|
|
48
|
+
minitest (5.18.0)
|
|
49
|
+
nokogiri (1.14.3-arm64-darwin)
|
|
50
|
+
racc (~> 1.4)
|
|
51
|
+
parallel (1.23.0)
|
|
52
|
+
parser (3.2.2.1)
|
|
53
|
+
ast (~> 2.4.1)
|
|
54
|
+
pry (0.14.2)
|
|
55
|
+
coderay (~> 1.1)
|
|
56
|
+
method_source (~> 1.0)
|
|
57
|
+
pry-byebug (3.10.1)
|
|
58
|
+
byebug (~> 11.0)
|
|
59
|
+
pry (>= 0.13, < 0.15)
|
|
60
|
+
racc (1.6.2)
|
|
61
|
+
rack (2.2.7)
|
|
62
|
+
rack-test (2.1.0)
|
|
63
|
+
rack (>= 1.3)
|
|
64
|
+
rails-dom-testing (2.0.3)
|
|
65
|
+
activesupport (>= 4.2.0)
|
|
66
|
+
nokogiri (>= 1.6)
|
|
67
|
+
rails-html-sanitizer (1.5.0)
|
|
68
|
+
loofah (~> 2.19, >= 2.19.1)
|
|
69
|
+
railties (7.0.4.3)
|
|
70
|
+
actionpack (= 7.0.4.3)
|
|
71
|
+
activesupport (= 7.0.4.3)
|
|
72
|
+
method_source
|
|
73
|
+
rake (>= 12.2)
|
|
74
|
+
thor (~> 1.0)
|
|
75
|
+
zeitwerk (~> 2.5)
|
|
76
|
+
rainbow (3.1.1)
|
|
77
|
+
rake (12.3.3)
|
|
78
|
+
regexp_parser (2.8.0)
|
|
79
|
+
rexml (3.2.5)
|
|
80
|
+
rspec (3.12.0)
|
|
81
|
+
rspec-core (~> 3.12.0)
|
|
82
|
+
rspec-expectations (~> 3.12.0)
|
|
83
|
+
rspec-mocks (~> 3.12.0)
|
|
84
|
+
rspec-collection_matchers (1.2.0)
|
|
85
|
+
rspec-expectations (>= 2.99.0.beta1)
|
|
86
|
+
rspec-core (3.12.2)
|
|
87
|
+
rspec-support (~> 3.12.0)
|
|
88
|
+
rspec-expectations (3.12.3)
|
|
89
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
90
|
+
rspec-support (~> 3.12.0)
|
|
91
|
+
rspec-mocks (3.12.5)
|
|
92
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
93
|
+
rspec-support (~> 3.12.0)
|
|
94
|
+
rspec-support (3.12.0)
|
|
95
|
+
rspec_junit_formatter (0.6.0)
|
|
96
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
|
97
|
+
rubocop (1.50.2)
|
|
98
|
+
json (~> 2.3)
|
|
99
|
+
parallel (~> 1.10)
|
|
100
|
+
parser (>= 3.2.0.0)
|
|
101
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
102
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
103
|
+
rexml (>= 3.2.5, < 4.0)
|
|
104
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
|
105
|
+
ruby-progressbar (~> 1.7)
|
|
106
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
|
107
|
+
rubocop-ast (1.28.0)
|
|
108
|
+
parser (>= 3.2.1.0)
|
|
109
|
+
rubocop-performance (1.16.0)
|
|
110
|
+
rubocop (>= 1.7.0, < 2.0)
|
|
111
|
+
rubocop-ast (>= 0.4.0)
|
|
112
|
+
ruby-progressbar (1.13.0)
|
|
113
|
+
simplecov (0.17.1)
|
|
114
|
+
docile (~> 1.1)
|
|
115
|
+
json (>= 1.8, < 3)
|
|
116
|
+
simplecov-html (~> 0.10.0)
|
|
117
|
+
simplecov-html (0.10.2)
|
|
118
|
+
standard (1.28.0)
|
|
119
|
+
language_server-protocol (~> 3.17.0.2)
|
|
120
|
+
lint_roller (~> 1.0)
|
|
121
|
+
rubocop (~> 1.50.2)
|
|
122
|
+
standard-custom (~> 1.0.0)
|
|
123
|
+
standard-performance (~> 1.0.1)
|
|
124
|
+
standard-custom (1.0.0)
|
|
125
|
+
lint_roller (~> 1.0)
|
|
126
|
+
standard-performance (1.0.1)
|
|
127
|
+
lint_roller (~> 1.0)
|
|
128
|
+
rubocop-performance (~> 1.16.0)
|
|
129
|
+
thor (1.2.1)
|
|
130
|
+
tzinfo (2.0.6)
|
|
131
|
+
concurrent-ruby (~> 1.0)
|
|
132
|
+
unicode-display_width (2.4.2)
|
|
133
|
+
yard (0.9.34)
|
|
134
|
+
zeitwerk (2.6.8)
|
|
135
|
+
|
|
136
|
+
PLATFORMS
|
|
137
|
+
arm64-darwin-22
|
|
138
|
+
x86_64-darwin-21
|
|
139
|
+
x86_64-linux
|
|
140
|
+
|
|
141
|
+
DEPENDENCIES
|
|
142
|
+
pry-byebug
|
|
143
|
+
rake (~> 12.0)
|
|
144
|
+
rspec (~> 3.4)
|
|
145
|
+
rspec-collection_matchers
|
|
146
|
+
rspec_junit_formatter
|
|
147
|
+
simplecov (~> 0.17.0)
|
|
148
|
+
standard (>= 1.0)
|
|
149
|
+
warning_signs!
|
|
150
|
+
yard
|
|
151
|
+
|
|
152
|
+
BUNDLED WITH
|
|
153
|
+
2.4.10
|
data/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# Warning Signs ⚠️⚠️
|
|
2
|
+
|
|
3
|
+
The Warning Signs gem builds upon the ideas of the
|
|
4
|
+
[Ruby Warning Gem](https://github.com/jeremyevans/ruby-warning)
|
|
5
|
+
and [Stop Ignoring Your Ruby and Rails Deprecations](https://blog.testdouble.com/posts/2023-04-24-stop-ignoring-your-ruby-and-rails-deprecations/).
|
|
6
|
+
|
|
7
|
+
The idea is to provide an easily-configurable way to manage deprecation
|
|
8
|
+
warnings from Ruby and Rails to support your upgrade tool.
|
|
9
|
+
|
|
10
|
+
## Installing Warning Signs
|
|
11
|
+
|
|
12
|
+
To install Warning Signs add
|
|
13
|
+
|
|
14
|
+
`gem "warning_signs"`
|
|
15
|
+
|
|
16
|
+
to your gemfile, you will most likely want it to be in all environments, but
|
|
17
|
+
under some use cases, you may not need it in production.
|
|
18
|
+
|
|
19
|
+
## Using Warning Signs
|
|
20
|
+
|
|
21
|
+
The Warning Signs gem looks for a `.warning_sign.yml` file when the Rails
|
|
22
|
+
application starts. If it does not find the file, it will not load and the
|
|
23
|
+
processing of deprecations will be unaffected.
|
|
24
|
+
|
|
25
|
+
You should remove any environment settings in Rails that are managing
|
|
26
|
+
`config.active_support.deprecation`, or at least those that are not
|
|
27
|
+
set to `:notify` -- use WarningSigns to handle those settings...
|
|
28
|
+
|
|
29
|
+
Warning Signs allows you to define _handlers_ in the YAML file. A handler
|
|
30
|
+
consists of the following:
|
|
31
|
+
|
|
32
|
+
* Patterns to match, which can be specified with `only` to match the
|
|
33
|
+
patterns specified and no others, or with `except` to match all patterns
|
|
34
|
+
except the given ones. If no patterns are specified, all patterns match.
|
|
35
|
+
* A source, either `ruby` for deprecations triggered with Ruby's `Warn`
|
|
36
|
+
module, or `rails` for deprecations triggered with Rails'
|
|
37
|
+
`ActiveSupport::Deprecation`. If a source is not specified, the handler
|
|
38
|
+
matches both sources.
|
|
39
|
+
* Environments and behaviors. An environment is either the name of a Rails
|
|
40
|
+
environment, the special word `all` which matches all environments, or the
|
|
41
|
+
special word `other`, which matches any environment not specifically
|
|
42
|
+
invoked.
|
|
43
|
+
* Each environment can specify one or more behaviors:
|
|
44
|
+
* `log` sends a message to the Rails logger
|
|
45
|
+
* `stderr` sends a message to the standard error stream
|
|
46
|
+
* `raise` raises an exception
|
|
47
|
+
* `ignore` does nothing
|
|
48
|
+
|
|
49
|
+
Handlers are matched in order. If no handler applies to a deprecation
|
|
50
|
+
warning, Ruby warnings is ignored, Rails warnings are passed through
|
|
51
|
+
the ActiveSupport notification mechanism.
|
|
52
|
+
|
|
53
|
+
The following sample logs all deprecation warnings:
|
|
54
|
+
|
|
55
|
+
```yaml
|
|
56
|
+
handlers:
|
|
57
|
+
- environment: all
|
|
58
|
+
behavior: log
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Multiple environments need to be handled in a nested list. This example
|
|
62
|
+
raises exceptions in the test environment, but logs in other environments
|
|
63
|
+
|
|
64
|
+
```yaml
|
|
65
|
+
handlers:
|
|
66
|
+
- environments:
|
|
67
|
+
- environment: test
|
|
68
|
+
behavior: raise
|
|
69
|
+
- environment: other
|
|
70
|
+
behavior: log
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
This example raises exceptions for Ruby deprecations, but ignores Rails
|
|
74
|
+
deprecations:
|
|
75
|
+
|
|
76
|
+
```yaml
|
|
77
|
+
handlers:
|
|
78
|
+
- source: ruby
|
|
79
|
+
environment: all
|
|
80
|
+
behavior: raise
|
|
81
|
+
- source: rails
|
|
82
|
+
environment: all
|
|
83
|
+
behavior: ignore
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
A common pattern is to focus only on specific deprecations and ignore others.
|
|
87
|
+
For example, this setting file would raise on Ruby keyword argument
|
|
88
|
+
deprecations and ignore other ruby deprecations
|
|
89
|
+
|
|
90
|
+
```yaml
|
|
91
|
+
handlers:
|
|
92
|
+
- source: ruby
|
|
93
|
+
only:
|
|
94
|
+
- "Using the last argument as keyword parameters is deprecated"
|
|
95
|
+
- "Passing the keyword argument as the last hash parameter is deprecated"
|
|
96
|
+
- "Splitting the last argument into positional and keyword parameters is deprecated"
|
|
97
|
+
environment: all
|
|
98
|
+
behavior: log
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Patterns are matched if the deprecation message contains the pattern as a
|
|
102
|
+
substring
|
|
103
|
+
|
|
104
|
+
Another pattern is to have a list of ignored deprecations and then remove
|
|
105
|
+
messages one by one and manage them individually.
|
|
106
|
+
|
|
107
|
+
In this case, the `except` pattern is used to excuse those known patterns
|
|
108
|
+
from the list. Other patterns will raise in test, or log in other environments.
|
|
109
|
+
|
|
110
|
+
```yaml
|
|
111
|
+
handlers:
|
|
112
|
+
- source: rails
|
|
113
|
+
except:
|
|
114
|
+
- "Class level methods will no longer inherit scoping from `create!` in"
|
|
115
|
+
- "Uniqueness validator will no longer enforce case sensitive comparison"
|
|
116
|
+
- "app/models/user.rb"
|
|
117
|
+
environments:
|
|
118
|
+
- environment: test
|
|
119
|
+
behavior: raise
|
|
120
|
+
- environment: other
|
|
121
|
+
behavior: log
|
|
122
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/setup
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module WarningSigns
|
|
2
|
+
class Deprecation
|
|
3
|
+
attr_accessor :message, :source
|
|
4
|
+
|
|
5
|
+
def initialize(message, source:)
|
|
6
|
+
@message = message
|
|
7
|
+
@source = source.to_s.downcase.inquiry
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def handler
|
|
11
|
+
World.instance.handler_for(self)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def behavior
|
|
15
|
+
handler&.environment&.behavior
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def invoke
|
|
19
|
+
case behavior
|
|
20
|
+
when "raise"
|
|
21
|
+
raise UnhandledDeprecationError, message
|
|
22
|
+
when "log"
|
|
23
|
+
Rails.logger.warn(message)
|
|
24
|
+
when "stderr"
|
|
25
|
+
$stderr.puts(message) # standard:disable Style/StderrPuts
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
module WarningSigns
|
|
2
|
+
class Handler
|
|
3
|
+
attr_accessor :behavior, :environments, :except, :only, :source
|
|
4
|
+
|
|
5
|
+
def self.from_hash(hash)
|
|
6
|
+
new(**hash.symbolize_keys)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def initialize(
|
|
10
|
+
behavior: "ignore",
|
|
11
|
+
environment: nil,
|
|
12
|
+
except: [],
|
|
13
|
+
only: [],
|
|
14
|
+
source: "any",
|
|
15
|
+
environments: []
|
|
16
|
+
)
|
|
17
|
+
@behavior = behavior.to_s.downcase.inquiry
|
|
18
|
+
@except = except
|
|
19
|
+
@only = only
|
|
20
|
+
@environments = environments.map { Environment.new(**_1.symbolize_keys) }
|
|
21
|
+
if environment.present?
|
|
22
|
+
@environments << Environment.new(environment: environment, behavior: behavior)
|
|
23
|
+
end
|
|
24
|
+
@source = source.to_s.downcase.inquiry
|
|
25
|
+
raise InvalidHandlerError unless valid?
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def valid?
|
|
29
|
+
except.empty? || only.empty?
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def known_source?(deprecation_source)
|
|
33
|
+
deprecation_source.in?(%w[ruby rails])
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def match?(deprecation)
|
|
37
|
+
source_match?(deprecation.source) &&
|
|
38
|
+
pattern_match?(deprecation.message)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def pattern_match?(message)
|
|
42
|
+
only_match?(message) && except_match?(message)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def source_match?(deprecation_source)
|
|
46
|
+
return known_source?(deprecation_source) if source.any?
|
|
47
|
+
source == deprecation_source
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def only_match?(message)
|
|
51
|
+
return true if only.empty?
|
|
52
|
+
only.any? do |only_pattern|
|
|
53
|
+
message.include?(only_pattern)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def except_match?(message)
|
|
58
|
+
return true if except.empty?
|
|
59
|
+
except.none? do |only_pattern|
|
|
60
|
+
message.include?(only_pattern)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def enabled_for_ruby?
|
|
65
|
+
source.ruby? || source.all?
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def enabled_for_rails?
|
|
69
|
+
source.rails? || source.all?
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def environment(current: nil)
|
|
73
|
+
current ||= Rails.env
|
|
74
|
+
environments.find { _1.environment == current } ||
|
|
75
|
+
environments.find { _1.environment.all? } ||
|
|
76
|
+
environments.find { _1.environment.other? }
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module WarningSigns
|
|
2
|
+
module RubyDeprecationCatcher
|
|
3
|
+
def warn(message)
|
|
4
|
+
Deprecation.new(augmented_message(message), source: "ruby").invoke
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def augmented_message(message)
|
|
8
|
+
"RUBY DEPRECATION WARNING: #{message} called from #{caller_locations(2..2).first}"
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
module WarningSigns
|
|
2
|
+
class World
|
|
3
|
+
include Singleton
|
|
4
|
+
attr_accessor :handlers
|
|
5
|
+
|
|
6
|
+
def self.from_file(filename)
|
|
7
|
+
from_hash(YAML.load_file(filename))
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.from_hash(hash)
|
|
11
|
+
instance.clear
|
|
12
|
+
instance.handlers = hash["handlers"].map { Handler.from_hash(_1) }
|
|
13
|
+
instance.one_time_set_up
|
|
14
|
+
instance
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def initialize
|
|
18
|
+
@initialized = false
|
|
19
|
+
clear
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def handler_for(deprecation)
|
|
23
|
+
handlers.find { _1.match?(deprecation) }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def clear
|
|
27
|
+
@handlers = []
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def enabled_for_rails?
|
|
31
|
+
handlers.any? { !_1.enabled_for_rails? }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def enabled_for_ruby?
|
|
35
|
+
handlers.any? { !_1.enabled_for_ruby? }
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def one_time_set_up
|
|
39
|
+
return if @initialized
|
|
40
|
+
ruby_set_up
|
|
41
|
+
rails_set_up
|
|
42
|
+
@initialized = true
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def ruby_set_up
|
|
46
|
+
Warning[:deprecated] = true
|
|
47
|
+
Warning.extend(WarningSigns::RubyDeprecationCatcher)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def rails_set_up
|
|
51
|
+
ActiveSupport::Deprecation.behavior = :notify
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "yaml"
|
|
4
|
+
require "rails/railtie"
|
|
5
|
+
require "active_support/all"
|
|
6
|
+
require "awesome_print"
|
|
7
|
+
|
|
8
|
+
require "zeitwerk"
|
|
9
|
+
loader = Zeitwerk::Loader.for_gem
|
|
10
|
+
loader.setup
|
|
11
|
+
|
|
12
|
+
module WarningSigns
|
|
13
|
+
SAMPLE_CONSTANT = "foobar"
|
|
14
|
+
|
|
15
|
+
class InvalidHandlerError < StandardError; end
|
|
16
|
+
|
|
17
|
+
class UnhandledDeprecationError < StandardError; end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
loader.eager_load
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/warning_signs/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "warning_signs"
|
|
7
|
+
spec.version = WarningSigns::VERSION
|
|
8
|
+
spec.authors = ["Noel Rappin"]
|
|
9
|
+
spec.email = ["noelrap@hey.com"]
|
|
10
|
+
|
|
11
|
+
spec.summary = "A gem for managing ruby and rails deprecation warnings"
|
|
12
|
+
spec.description = "A gem for managing ruby and rails deprecation warnings"
|
|
13
|
+
spec.homepage = "https://github.com/noelrappin/warning_signs"
|
|
14
|
+
|
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7")
|
|
16
|
+
|
|
17
|
+
spec.metadata = {
|
|
18
|
+
"github_repo" => spec.homepage,
|
|
19
|
+
"homepage_uri" => spec.homepage,
|
|
20
|
+
"source_code_uri" => spec.homepage
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
26
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
27
|
+
end
|
|
28
|
+
spec.bindir = "exe"
|
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
30
|
+
spec.require_paths = ["lib"]
|
|
31
|
+
|
|
32
|
+
spec.add_development_dependency "pry-byebug"
|
|
33
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
|
34
|
+
spec.add_development_dependency "rspec", "~> 3.4"
|
|
35
|
+
spec.add_development_dependency "rspec-collection_matchers"
|
|
36
|
+
spec.add_development_dependency "rspec_junit_formatter"
|
|
37
|
+
spec.add_development_dependency "standard", ">= 1.0"
|
|
38
|
+
spec.add_development_dependency "simplecov", "~> 0.17.0"
|
|
39
|
+
spec.add_development_dependency "yard"
|
|
40
|
+
|
|
41
|
+
spec.add_runtime_dependency "awesome_print"
|
|
42
|
+
spec.add_runtime_dependency "railties"
|
|
43
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: warning_signs
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Noel Rappin
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2023-05-01 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: pry-byebug
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '12.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '12.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.4'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.4'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rspec-collection_matchers
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rspec_junit_formatter
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: standard
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '1.0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '1.0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: simplecov
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: 0.17.0
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: 0.17.0
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: yard
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: awesome_print
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - ">="
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0'
|
|
132
|
+
type: :runtime
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - ">="
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0'
|
|
139
|
+
- !ruby/object:Gem::Dependency
|
|
140
|
+
name: railties
|
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - ">="
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: '0'
|
|
146
|
+
type: :runtime
|
|
147
|
+
prerelease: false
|
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - ">="
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: '0'
|
|
153
|
+
description: A gem for managing ruby and rails deprecation warnings
|
|
154
|
+
email:
|
|
155
|
+
- noelrap@hey.com
|
|
156
|
+
executables: []
|
|
157
|
+
extensions: []
|
|
158
|
+
extra_rdoc_files: []
|
|
159
|
+
files:
|
|
160
|
+
- ".github/dependabot.yml"
|
|
161
|
+
- ".github/workflows/main.yml"
|
|
162
|
+
- ".gitignore"
|
|
163
|
+
- ".rspec"
|
|
164
|
+
- ".ruby-version"
|
|
165
|
+
- CHANGELOG.md
|
|
166
|
+
- Gemfile
|
|
167
|
+
- Gemfile.lock
|
|
168
|
+
- README.md
|
|
169
|
+
- Rakefile
|
|
170
|
+
- bin/console
|
|
171
|
+
- bin/setup
|
|
172
|
+
- lib/warning_signs.rb
|
|
173
|
+
- lib/warning_signs/deprecation.rb
|
|
174
|
+
- lib/warning_signs/environment.rb
|
|
175
|
+
- lib/warning_signs/handler.rb
|
|
176
|
+
- lib/warning_signs/rails_deprecation_catcher.rb
|
|
177
|
+
- lib/warning_signs/railtie.rb
|
|
178
|
+
- lib/warning_signs/ruby_deprecation_catcher.rb
|
|
179
|
+
- lib/warning_signs/version.rb
|
|
180
|
+
- lib/warning_signs/world.rb
|
|
181
|
+
- warning_signs.gemspec
|
|
182
|
+
homepage: https://github.com/noelrappin/warning_signs
|
|
183
|
+
licenses: []
|
|
184
|
+
metadata:
|
|
185
|
+
github_repo: https://github.com/noelrappin/warning_signs
|
|
186
|
+
homepage_uri: https://github.com/noelrappin/warning_signs
|
|
187
|
+
source_code_uri: https://github.com/noelrappin/warning_signs
|
|
188
|
+
post_install_message:
|
|
189
|
+
rdoc_options: []
|
|
190
|
+
require_paths:
|
|
191
|
+
- lib
|
|
192
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
193
|
+
requirements:
|
|
194
|
+
- - ">="
|
|
195
|
+
- !ruby/object:Gem::Version
|
|
196
|
+
version: '2.7'
|
|
197
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
|
+
requirements:
|
|
199
|
+
- - ">="
|
|
200
|
+
- !ruby/object:Gem::Version
|
|
201
|
+
version: '0'
|
|
202
|
+
requirements: []
|
|
203
|
+
rubygems_version: 3.2.33
|
|
204
|
+
signing_key:
|
|
205
|
+
specification_version: 4
|
|
206
|
+
summary: A gem for managing ruby and rails deprecation warnings
|
|
207
|
+
test_files: []
|