deprecation_collector 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +10 -1
- data/CHANGELOG.md +3 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +25 -8
- data/README.md +14 -0
- data/Rakefile +14 -0
- data/deprecation_collector.gemspec +3 -2
- data/gemfiles/rails_6.gemfile.lock +63 -63
- data/gemfiles/rails_7.gemfile.lock +65 -65
- data/gemfiles/rails_none.gemfile.lock +3 -3
- data/lib/deprecation_collector/deprecation.rb +3 -2
- data/lib/deprecation_collector/version.rb +1 -1
- data/lib/deprecation_collector/web/application.rb +80 -0
- data/lib/deprecation_collector/web/helpers.rb +43 -0
- data/lib/deprecation_collector/web/router.rb +196 -0
- data/lib/deprecation_collector/web/utils.rb +52 -0
- data/lib/deprecation_collector/web/views/index.html.template.rb +95 -0
- data/lib/deprecation_collector/web/views/layout.html.template.rb +18 -0
- data/lib/deprecation_collector/web/views/show.html.template.rb +13 -0
- data/lib/deprecation_collector/web.rb +33 -0
- data/lib/deprecation_collector.rb +10 -3
- metadata +11 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e47433dbbd3b8de0913751e91d7c599ceae4061f33a97e335082f797d3f15a85
|
4
|
+
data.tar.gz: bfd2daa42a714075654550d8c262c5fed7398109c9a6bb0c6167e3c50e9831fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c16f77432e628e0ab52d0753a2083fbba24c9f0b847dba9b93401b6700c88831f6dea334a4ce2f48a85ede6ee3646737075b4aadc419717d024d48a3bc0a82bd
|
7
|
+
data.tar.gz: '025851292e3ba3b80ef8b7e232bb4900eef50a83948b58f2cc70ef1e15ea1cf6f9bd959f126360690cdbcca5a88c926ea04c25733d2aadfb24ef0078359ab8c5'
|
data/.rubocop.yml
CHANGED
@@ -1,7 +1,13 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rspec
|
3
|
+
- rubocop-rake
|
4
|
+
- rubocop-performance
|
5
|
+
|
1
6
|
AllCops:
|
2
7
|
# note additional conf in spec/
|
3
8
|
TargetRubyVersion: 2.5
|
4
9
|
NewCops: enable
|
10
|
+
SuggestExtensions: false
|
5
11
|
Exclude:
|
6
12
|
- gemfiles/*
|
7
13
|
|
@@ -18,6 +24,9 @@ Layout/LineLength:
|
|
18
24
|
|
19
25
|
Metrics/ClassLength: { Max: 230 }
|
20
26
|
Metrics/MethodLength: { Max: 15 }
|
21
|
-
Metrics/AbcSize: { Max:
|
27
|
+
Metrics/AbcSize: { Max: 23 }
|
22
28
|
Metrics/CyclomaticComplexity: { Max: 9 }
|
23
29
|
Metrics/PerceivedComplexity: { Max: 9 }
|
30
|
+
|
31
|
+
RSpec/ExampleLength: { Enabled: false }
|
32
|
+
RSpec/MultipleExpectations: { Enabled: false }
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
== 0.2.0
|
2
|
+
- ability to add custom deprecation fingerprint (for example - controller+action), use `config.fingerprinter`
|
3
|
+
|
1
4
|
== 0.1.0
|
2
5
|
- kinda-breaking: ruby 2.4 was in fact not supported, so changed requirement to 2.5
|
3
6
|
- prevent recursion when deprecation fires in `context_saver` hook
|
data/Gemfile
CHANGED
@@ -20,7 +20,14 @@ unless defined?(Appraisal)
|
|
20
20
|
end
|
21
21
|
|
22
22
|
gem "rails", "~>6.0.0"
|
23
|
+
gem 'simplecov'
|
23
24
|
end
|
24
25
|
|
25
26
|
gem "fakeredis"
|
26
27
|
gem "redis", "~>4.8"
|
28
|
+
|
29
|
+
# for web tests
|
30
|
+
gem 'rack'
|
31
|
+
gem 'webrick'
|
32
|
+
|
33
|
+
gem 'slim' # not used in production, for compiling templates
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
deprecation_collector (0.
|
4
|
+
deprecation_collector (0.3.0)
|
5
5
|
redis (>= 3.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -72,6 +72,7 @@ GEM
|
|
72
72
|
crass (1.0.6)
|
73
73
|
date (3.3.1)
|
74
74
|
diff-lcs (1.5.0)
|
75
|
+
docile (1.4.0)
|
75
76
|
erubi (1.11.0)
|
76
77
|
fakeredis (0.8.0)
|
77
78
|
redis (~> 4.1)
|
@@ -91,7 +92,7 @@ GEM
|
|
91
92
|
marcel (1.0.2)
|
92
93
|
method_source (1.0.0)
|
93
94
|
mini_mime (1.1.2)
|
94
|
-
mini_portile2 (2.8.
|
95
|
+
mini_portile2 (2.8.1)
|
95
96
|
minitest (5.16.3)
|
96
97
|
net-imap (0.3.2)
|
97
98
|
date
|
@@ -103,20 +104,20 @@ GEM
|
|
103
104
|
net-smtp (0.3.3)
|
104
105
|
net-protocol
|
105
106
|
nio4r (2.5.8)
|
106
|
-
nokogiri (1.
|
107
|
+
nokogiri (1.14.0)
|
107
108
|
mini_portile2 (~> 2.8.0)
|
108
109
|
racc (~> 1.4)
|
109
|
-
nokogiri (1.
|
110
|
+
nokogiri (1.14.0-arm64-darwin)
|
110
111
|
racc (~> 1.4)
|
111
|
-
nokogiri (1.
|
112
|
+
nokogiri (1.14.0-x86_64-darwin)
|
112
113
|
racc (~> 1.4)
|
113
|
-
nokogiri (1.
|
114
|
+
nokogiri (1.14.0-x86_64-linux)
|
114
115
|
racc (~> 1.4)
|
115
116
|
parallel (1.22.1)
|
116
117
|
parser (3.1.3.0)
|
117
118
|
ast (~> 2.4.1)
|
118
|
-
racc (1.6.
|
119
|
-
rack (2.2.
|
119
|
+
racc (1.6.2)
|
120
|
+
rack (2.2.7)
|
120
121
|
rack-test (2.0.2)
|
121
122
|
rack (>= 1.3)
|
122
123
|
rails (6.0.6)
|
@@ -187,6 +188,15 @@ GEM
|
|
187
188
|
rubocop-rspec (2.16.0)
|
188
189
|
rubocop (~> 1.33)
|
189
190
|
ruby-progressbar (1.11.0)
|
191
|
+
simplecov (0.22.0)
|
192
|
+
docile (~> 1.1)
|
193
|
+
simplecov-html (~> 0.11)
|
194
|
+
simplecov_json_formatter (~> 0.1)
|
195
|
+
simplecov-html (0.12.3)
|
196
|
+
simplecov_json_formatter (0.1.4)
|
197
|
+
slim (5.1.0)
|
198
|
+
temple (~> 0.10.0)
|
199
|
+
tilt (>= 2.0.6, < 2.2)
|
190
200
|
sprockets (4.1.1)
|
191
201
|
concurrent-ruby (~> 1.0)
|
192
202
|
rack (> 1, < 3)
|
@@ -194,13 +204,16 @@ GEM
|
|
194
204
|
actionpack (>= 5.2)
|
195
205
|
activesupport (>= 5.2)
|
196
206
|
sprockets (>= 3.0.0)
|
207
|
+
temple (0.10.0)
|
197
208
|
thor (1.2.1)
|
198
209
|
thread_safe (0.3.6)
|
210
|
+
tilt (2.1.0)
|
199
211
|
timecop (0.9.6)
|
200
212
|
timeout (0.3.1)
|
201
213
|
tzinfo (1.2.10)
|
202
214
|
thread_safe (~> 0.1)
|
203
215
|
unicode-display_width (2.3.0)
|
216
|
+
webrick (1.8.1)
|
204
217
|
websocket-driver (0.7.5)
|
205
218
|
websocket-extensions (>= 0.1.0)
|
206
219
|
websocket-extensions (0.1.5)
|
@@ -216,6 +229,7 @@ DEPENDENCIES
|
|
216
229
|
appraisal
|
217
230
|
deprecation_collector!
|
218
231
|
fakeredis
|
232
|
+
rack
|
219
233
|
rails (~> 6.0.0)
|
220
234
|
rake (~> 13.0)
|
221
235
|
redis (~> 4.8)
|
@@ -225,7 +239,10 @@ DEPENDENCIES
|
|
225
239
|
rubocop-rails
|
226
240
|
rubocop-rake
|
227
241
|
rubocop-rspec
|
242
|
+
simplecov
|
243
|
+
slim
|
228
244
|
timecop
|
245
|
+
webrick
|
229
246
|
|
230
247
|
BUNDLED WITH
|
231
248
|
2.3.10
|
data/README.md
CHANGED
@@ -37,10 +37,24 @@ Add an initializer with configuration, like
|
|
37
37
|
# this will only be called for new deprecations, return value must be json-compatible
|
38
38
|
{ some: "custom", context: "for example request.id" }
|
39
39
|
end
|
40
|
+
instance.fingerprinter do |deprecation|
|
41
|
+
# this will be added to fingerprint; this will be ignored for recursive deprecations
|
42
|
+
"return_string_here"
|
43
|
+
end
|
40
44
|
end
|
41
45
|
end
|
42
46
|
```
|
43
47
|
|
48
|
+
## Web UI
|
49
|
+
|
50
|
+
Mount the rack app into your routes:
|
51
|
+
```ruby
|
52
|
+
Rails.application.routes.draw do
|
53
|
+
require 'deprecation_collector/web'
|
54
|
+
mount DeprecationCollector::Web => '/deprecations', as: :deprecations
|
55
|
+
end
|
56
|
+
```
|
57
|
+
|
44
58
|
## Development
|
45
59
|
|
46
60
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/Rakefile
CHANGED
@@ -10,3 +10,17 @@ require "rubocop/rake_task"
|
|
10
10
|
RuboCop::RakeTask.new
|
11
11
|
|
12
12
|
task default: %i[spec rubocop]
|
13
|
+
|
14
|
+
task :precompile_templates do
|
15
|
+
require 'slim'
|
16
|
+
# Slim::Template.new { '.lala' }.precompiled_template
|
17
|
+
Dir['lib/deprecation_collector/web/views/*.slim'].each do |file|
|
18
|
+
target = file.sub(/\.slim\z/, '.template.rb')
|
19
|
+
puts "Compiling #{file} -> #{target}"
|
20
|
+
content = Slim::Template.new(file).precompiled_template # maybe send(:precompiled, []) is more correct
|
21
|
+
|
22
|
+
File.write(target, content)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
Rake::Task[:build].enhance [:precompile_templates]
|
@@ -22,9 +22,10 @@ Gem::Specification.new do |spec|
|
|
22
22
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
23
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
24
|
`git ls-files -z`.split("\x0").reject do |f|
|
25
|
-
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
25
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)}) ||
|
26
|
+
f.match(%r{\Alib/deprecation_collector/web/views/.+\.slim\z})
|
26
27
|
end
|
27
|
-
end
|
28
|
+
end + Dir['lib/deprecation_collector/web/views/*.slim'].map { |template| template.sub(/\.slim\z/, '.template.rb') }
|
28
29
|
spec.require_paths = ["lib"]
|
29
30
|
|
30
31
|
spec.add_dependency "redis", ">= 3.0"
|
@@ -1,66 +1,66 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
deprecation_collector (0.
|
4
|
+
deprecation_collector (0.2.0)
|
5
5
|
redis (>= 3.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
actioncable (6.1.7)
|
11
|
-
actionpack (= 6.1.7)
|
12
|
-
activesupport (= 6.1.7)
|
10
|
+
actioncable (6.1.7.1)
|
11
|
+
actionpack (= 6.1.7.1)
|
12
|
+
activesupport (= 6.1.7.1)
|
13
13
|
nio4r (~> 2.0)
|
14
14
|
websocket-driver (>= 0.6.1)
|
15
|
-
actionmailbox (6.1.7)
|
16
|
-
actionpack (= 6.1.7)
|
17
|
-
activejob (= 6.1.7)
|
18
|
-
activerecord (= 6.1.7)
|
19
|
-
activestorage (= 6.1.7)
|
20
|
-
activesupport (= 6.1.7)
|
15
|
+
actionmailbox (6.1.7.1)
|
16
|
+
actionpack (= 6.1.7.1)
|
17
|
+
activejob (= 6.1.7.1)
|
18
|
+
activerecord (= 6.1.7.1)
|
19
|
+
activestorage (= 6.1.7.1)
|
20
|
+
activesupport (= 6.1.7.1)
|
21
21
|
mail (>= 2.7.1)
|
22
|
-
actionmailer (6.1.7)
|
23
|
-
actionpack (= 6.1.7)
|
24
|
-
actionview (= 6.1.7)
|
25
|
-
activejob (= 6.1.7)
|
26
|
-
activesupport (= 6.1.7)
|
22
|
+
actionmailer (6.1.7.1)
|
23
|
+
actionpack (= 6.1.7.1)
|
24
|
+
actionview (= 6.1.7.1)
|
25
|
+
activejob (= 6.1.7.1)
|
26
|
+
activesupport (= 6.1.7.1)
|
27
27
|
mail (~> 2.5, >= 2.5.4)
|
28
28
|
rails-dom-testing (~> 2.0)
|
29
|
-
actionpack (6.1.7)
|
30
|
-
actionview (= 6.1.7)
|
31
|
-
activesupport (= 6.1.7)
|
29
|
+
actionpack (6.1.7.1)
|
30
|
+
actionview (= 6.1.7.1)
|
31
|
+
activesupport (= 6.1.7.1)
|
32
32
|
rack (~> 2.0, >= 2.0.9)
|
33
33
|
rack-test (>= 0.6.3)
|
34
34
|
rails-dom-testing (~> 2.0)
|
35
35
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
36
|
-
actiontext (6.1.7)
|
37
|
-
actionpack (= 6.1.7)
|
38
|
-
activerecord (= 6.1.7)
|
39
|
-
activestorage (= 6.1.7)
|
40
|
-
activesupport (= 6.1.7)
|
36
|
+
actiontext (6.1.7.1)
|
37
|
+
actionpack (= 6.1.7.1)
|
38
|
+
activerecord (= 6.1.7.1)
|
39
|
+
activestorage (= 6.1.7.1)
|
40
|
+
activesupport (= 6.1.7.1)
|
41
41
|
nokogiri (>= 1.8.5)
|
42
|
-
actionview (6.1.7)
|
43
|
-
activesupport (= 6.1.7)
|
42
|
+
actionview (6.1.7.1)
|
43
|
+
activesupport (= 6.1.7.1)
|
44
44
|
builder (~> 3.1)
|
45
45
|
erubi (~> 1.4)
|
46
46
|
rails-dom-testing (~> 2.0)
|
47
47
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
48
|
-
activejob (6.1.7)
|
49
|
-
activesupport (= 6.1.7)
|
48
|
+
activejob (6.1.7.1)
|
49
|
+
activesupport (= 6.1.7.1)
|
50
50
|
globalid (>= 0.3.6)
|
51
|
-
activemodel (6.1.7)
|
52
|
-
activesupport (= 6.1.7)
|
53
|
-
activerecord (6.1.7)
|
54
|
-
activemodel (= 6.1.7)
|
55
|
-
activesupport (= 6.1.7)
|
56
|
-
activestorage (6.1.7)
|
57
|
-
actionpack (= 6.1.7)
|
58
|
-
activejob (= 6.1.7)
|
59
|
-
activerecord (= 6.1.7)
|
60
|
-
activesupport (= 6.1.7)
|
51
|
+
activemodel (6.1.7.1)
|
52
|
+
activesupport (= 6.1.7.1)
|
53
|
+
activerecord (6.1.7.1)
|
54
|
+
activemodel (= 6.1.7.1)
|
55
|
+
activesupport (= 6.1.7.1)
|
56
|
+
activestorage (6.1.7.1)
|
57
|
+
actionpack (= 6.1.7.1)
|
58
|
+
activejob (= 6.1.7.1)
|
59
|
+
activerecord (= 6.1.7.1)
|
60
|
+
activesupport (= 6.1.7.1)
|
61
61
|
marcel (~> 1.0)
|
62
62
|
mini_mime (>= 1.1.0)
|
63
|
-
activesupport (6.1.7)
|
63
|
+
activesupport (6.1.7.1)
|
64
64
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
65
65
|
i18n (>= 1.6, < 2)
|
66
66
|
minitest (>= 5.1)
|
@@ -75,18 +75,18 @@ GEM
|
|
75
75
|
crass (1.0.6)
|
76
76
|
diff-lcs (1.5.0)
|
77
77
|
digest (3.1.1)
|
78
|
-
erubi (1.
|
78
|
+
erubi (1.12.0)
|
79
79
|
fakeredis (0.8.0)
|
80
80
|
redis (~> 4.1)
|
81
81
|
globalid (1.0.0)
|
82
82
|
activesupport (>= 5.0)
|
83
83
|
i18n (1.12.0)
|
84
84
|
concurrent-ruby (~> 1.0)
|
85
|
-
io-wait (0.
|
85
|
+
io-wait (0.3.0)
|
86
86
|
loofah (2.19.1)
|
87
87
|
crass (~> 1.0.2)
|
88
88
|
nokogiri (>= 1.5.9)
|
89
|
-
mail (2.8.0)
|
89
|
+
mail (2.8.0.1)
|
90
90
|
mini_mime (>= 0.1.1)
|
91
91
|
net-imap
|
92
92
|
net-pop
|
@@ -113,33 +113,33 @@ GEM
|
|
113
113
|
racc (~> 1.4)
|
114
114
|
nokogiri (1.12.5-x86_64-linux)
|
115
115
|
racc (~> 1.4)
|
116
|
-
racc (1.6.
|
117
|
-
rack (2.2.
|
116
|
+
racc (1.6.2)
|
117
|
+
rack (2.2.6.1)
|
118
118
|
rack-test (2.0.2)
|
119
119
|
rack (>= 1.3)
|
120
|
-
rails (6.1.7)
|
121
|
-
actioncable (= 6.1.7)
|
122
|
-
actionmailbox (= 6.1.7)
|
123
|
-
actionmailer (= 6.1.7)
|
124
|
-
actionpack (= 6.1.7)
|
125
|
-
actiontext (= 6.1.7)
|
126
|
-
actionview (= 6.1.7)
|
127
|
-
activejob (= 6.1.7)
|
128
|
-
activemodel (= 6.1.7)
|
129
|
-
activerecord (= 6.1.7)
|
130
|
-
activestorage (= 6.1.7)
|
131
|
-
activesupport (= 6.1.7)
|
120
|
+
rails (6.1.7.1)
|
121
|
+
actioncable (= 6.1.7.1)
|
122
|
+
actionmailbox (= 6.1.7.1)
|
123
|
+
actionmailer (= 6.1.7.1)
|
124
|
+
actionpack (= 6.1.7.1)
|
125
|
+
actiontext (= 6.1.7.1)
|
126
|
+
actionview (= 6.1.7.1)
|
127
|
+
activejob (= 6.1.7.1)
|
128
|
+
activemodel (= 6.1.7.1)
|
129
|
+
activerecord (= 6.1.7.1)
|
130
|
+
activestorage (= 6.1.7.1)
|
131
|
+
activesupport (= 6.1.7.1)
|
132
132
|
bundler (>= 1.15.0)
|
133
|
-
railties (= 6.1.7)
|
133
|
+
railties (= 6.1.7.1)
|
134
134
|
sprockets-rails (>= 2.0.0)
|
135
135
|
rails-dom-testing (2.0.3)
|
136
136
|
activesupport (>= 4.2.0)
|
137
137
|
nokogiri (>= 1.6)
|
138
138
|
rails-html-sanitizer (1.4.4)
|
139
139
|
loofah (~> 2.19, >= 2.19.1)
|
140
|
-
railties (6.1.7)
|
141
|
-
actionpack (= 6.1.7)
|
142
|
-
activesupport (= 6.1.7)
|
140
|
+
railties (6.1.7.1)
|
141
|
+
actionpack (= 6.1.7.1)
|
142
|
+
activesupport (= 6.1.7.1)
|
143
143
|
method_source
|
144
144
|
rake (>= 12.2)
|
145
145
|
thor (~> 1.0)
|
@@ -151,16 +151,16 @@ GEM
|
|
151
151
|
rspec-mocks (~> 3.12.0)
|
152
152
|
rspec-core (3.12.0)
|
153
153
|
rspec-support (~> 3.12.0)
|
154
|
-
rspec-expectations (3.12.
|
154
|
+
rspec-expectations (3.12.2)
|
155
155
|
diff-lcs (>= 1.2.0, < 2.0)
|
156
156
|
rspec-support (~> 3.12.0)
|
157
|
-
rspec-mocks (3.12.
|
157
|
+
rspec-mocks (3.12.3)
|
158
158
|
diff-lcs (>= 1.2.0, < 2.0)
|
159
159
|
rspec-support (~> 3.12.0)
|
160
160
|
rspec-support (3.12.0)
|
161
|
-
sprockets (4.
|
161
|
+
sprockets (4.2.0)
|
162
162
|
concurrent-ruby (~> 1.0)
|
163
|
-
rack (
|
163
|
+
rack (>= 2.2.4, < 4)
|
164
164
|
sprockets-rails (3.4.2)
|
165
165
|
actionpack (>= 5.2)
|
166
166
|
activesupport (>= 5.2)
|
@@ -1,73 +1,73 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
deprecation_collector (0.
|
4
|
+
deprecation_collector (0.2.0)
|
5
5
|
redis (>= 3.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
actioncable (7.0.4)
|
11
|
-
actionpack (= 7.0.4)
|
12
|
-
activesupport (= 7.0.4)
|
10
|
+
actioncable (7.0.4.1)
|
11
|
+
actionpack (= 7.0.4.1)
|
12
|
+
activesupport (= 7.0.4.1)
|
13
13
|
nio4r (~> 2.0)
|
14
14
|
websocket-driver (>= 0.6.1)
|
15
|
-
actionmailbox (7.0.4)
|
16
|
-
actionpack (= 7.0.4)
|
17
|
-
activejob (= 7.0.4)
|
18
|
-
activerecord (= 7.0.4)
|
19
|
-
activestorage (= 7.0.4)
|
20
|
-
activesupport (= 7.0.4)
|
15
|
+
actionmailbox (7.0.4.1)
|
16
|
+
actionpack (= 7.0.4.1)
|
17
|
+
activejob (= 7.0.4.1)
|
18
|
+
activerecord (= 7.0.4.1)
|
19
|
+
activestorage (= 7.0.4.1)
|
20
|
+
activesupport (= 7.0.4.1)
|
21
21
|
mail (>= 2.7.1)
|
22
22
|
net-imap
|
23
23
|
net-pop
|
24
24
|
net-smtp
|
25
|
-
actionmailer (7.0.4)
|
26
|
-
actionpack (= 7.0.4)
|
27
|
-
actionview (= 7.0.4)
|
28
|
-
activejob (= 7.0.4)
|
29
|
-
activesupport (= 7.0.4)
|
25
|
+
actionmailer (7.0.4.1)
|
26
|
+
actionpack (= 7.0.4.1)
|
27
|
+
actionview (= 7.0.4.1)
|
28
|
+
activejob (= 7.0.4.1)
|
29
|
+
activesupport (= 7.0.4.1)
|
30
30
|
mail (~> 2.5, >= 2.5.4)
|
31
31
|
net-imap
|
32
32
|
net-pop
|
33
33
|
net-smtp
|
34
34
|
rails-dom-testing (~> 2.0)
|
35
|
-
actionpack (7.0.4)
|
36
|
-
actionview (= 7.0.4)
|
37
|
-
activesupport (= 7.0.4)
|
35
|
+
actionpack (7.0.4.1)
|
36
|
+
actionview (= 7.0.4.1)
|
37
|
+
activesupport (= 7.0.4.1)
|
38
38
|
rack (~> 2.0, >= 2.2.0)
|
39
39
|
rack-test (>= 0.6.3)
|
40
40
|
rails-dom-testing (~> 2.0)
|
41
41
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
42
|
-
actiontext (7.0.4)
|
43
|
-
actionpack (= 7.0.4)
|
44
|
-
activerecord (= 7.0.4)
|
45
|
-
activestorage (= 7.0.4)
|
46
|
-
activesupport (= 7.0.4)
|
42
|
+
actiontext (7.0.4.1)
|
43
|
+
actionpack (= 7.0.4.1)
|
44
|
+
activerecord (= 7.0.4.1)
|
45
|
+
activestorage (= 7.0.4.1)
|
46
|
+
activesupport (= 7.0.4.1)
|
47
47
|
globalid (>= 0.6.0)
|
48
48
|
nokogiri (>= 1.8.5)
|
49
|
-
actionview (7.0.4)
|
50
|
-
activesupport (= 7.0.4)
|
49
|
+
actionview (7.0.4.1)
|
50
|
+
activesupport (= 7.0.4.1)
|
51
51
|
builder (~> 3.1)
|
52
52
|
erubi (~> 1.4)
|
53
53
|
rails-dom-testing (~> 2.0)
|
54
54
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
55
|
-
activejob (7.0.4)
|
56
|
-
activesupport (= 7.0.4)
|
55
|
+
activejob (7.0.4.1)
|
56
|
+
activesupport (= 7.0.4.1)
|
57
57
|
globalid (>= 0.3.6)
|
58
|
-
activemodel (7.0.4)
|
59
|
-
activesupport (= 7.0.4)
|
60
|
-
activerecord (7.0.4)
|
61
|
-
activemodel (= 7.0.4)
|
62
|
-
activesupport (= 7.0.4)
|
63
|
-
activestorage (7.0.4)
|
64
|
-
actionpack (= 7.0.4)
|
65
|
-
activejob (= 7.0.4)
|
66
|
-
activerecord (= 7.0.4)
|
67
|
-
activesupport (= 7.0.4)
|
58
|
+
activemodel (7.0.4.1)
|
59
|
+
activesupport (= 7.0.4.1)
|
60
|
+
activerecord (7.0.4.1)
|
61
|
+
activemodel (= 7.0.4.1)
|
62
|
+
activesupport (= 7.0.4.1)
|
63
|
+
activestorage (7.0.4.1)
|
64
|
+
actionpack (= 7.0.4.1)
|
65
|
+
activejob (= 7.0.4.1)
|
66
|
+
activerecord (= 7.0.4.1)
|
67
|
+
activesupport (= 7.0.4.1)
|
68
68
|
marcel (~> 1.0)
|
69
69
|
mini_mime (>= 1.1.0)
|
70
|
-
activesupport (7.0.4)
|
70
|
+
activesupport (7.0.4.1)
|
71
71
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
72
72
|
i18n (>= 1.6, < 2)
|
73
73
|
minitest (>= 5.1)
|
@@ -79,9 +79,9 @@ GEM
|
|
79
79
|
builder (3.2.4)
|
80
80
|
concurrent-ruby (1.1.10)
|
81
81
|
crass (1.0.6)
|
82
|
-
date (3.3.
|
82
|
+
date (3.3.3)
|
83
83
|
diff-lcs (1.5.0)
|
84
|
-
erubi (1.
|
84
|
+
erubi (1.12.0)
|
85
85
|
fakeredis (0.8.0)
|
86
86
|
redis (~> 4.1)
|
87
87
|
globalid (1.0.0)
|
@@ -91,7 +91,7 @@ GEM
|
|
91
91
|
loofah (2.19.1)
|
92
92
|
crass (~> 1.0.2)
|
93
93
|
nokogiri (>= 1.5.9)
|
94
|
-
mail (2.8.0)
|
94
|
+
mail (2.8.0.1)
|
95
95
|
mini_mime (>= 0.1.1)
|
96
96
|
net-imap
|
97
97
|
net-pop
|
@@ -99,8 +99,8 @@ GEM
|
|
99
99
|
marcel (1.0.2)
|
100
100
|
method_source (1.0.0)
|
101
101
|
mini_mime (1.1.2)
|
102
|
-
minitest (5.
|
103
|
-
net-imap (0.3.
|
102
|
+
minitest (5.17.0)
|
103
|
+
net-imap (0.3.4)
|
104
104
|
date
|
105
105
|
net-protocol
|
106
106
|
net-pop (0.1.2)
|
@@ -110,36 +110,36 @@ GEM
|
|
110
110
|
net-smtp (0.3.3)
|
111
111
|
net-protocol
|
112
112
|
nio4r (2.5.8)
|
113
|
-
nokogiri (1.
|
113
|
+
nokogiri (1.14.0-x86_64-darwin)
|
114
114
|
racc (~> 1.4)
|
115
|
-
nokogiri (1.
|
115
|
+
nokogiri (1.14.0-x86_64-linux)
|
116
116
|
racc (~> 1.4)
|
117
|
-
racc (1.6.
|
118
|
-
rack (2.2.
|
117
|
+
racc (1.6.2)
|
118
|
+
rack (2.2.6.1)
|
119
119
|
rack-test (2.0.2)
|
120
120
|
rack (>= 1.3)
|
121
|
-
rails (7.0.4)
|
122
|
-
actioncable (= 7.0.4)
|
123
|
-
actionmailbox (= 7.0.4)
|
124
|
-
actionmailer (= 7.0.4)
|
125
|
-
actionpack (= 7.0.4)
|
126
|
-
actiontext (= 7.0.4)
|
127
|
-
actionview (= 7.0.4)
|
128
|
-
activejob (= 7.0.4)
|
129
|
-
activemodel (= 7.0.4)
|
130
|
-
activerecord (= 7.0.4)
|
131
|
-
activestorage (= 7.0.4)
|
132
|
-
activesupport (= 7.0.4)
|
121
|
+
rails (7.0.4.1)
|
122
|
+
actioncable (= 7.0.4.1)
|
123
|
+
actionmailbox (= 7.0.4.1)
|
124
|
+
actionmailer (= 7.0.4.1)
|
125
|
+
actionpack (= 7.0.4.1)
|
126
|
+
actiontext (= 7.0.4.1)
|
127
|
+
actionview (= 7.0.4.1)
|
128
|
+
activejob (= 7.0.4.1)
|
129
|
+
activemodel (= 7.0.4.1)
|
130
|
+
activerecord (= 7.0.4.1)
|
131
|
+
activestorage (= 7.0.4.1)
|
132
|
+
activesupport (= 7.0.4.1)
|
133
133
|
bundler (>= 1.15.0)
|
134
|
-
railties (= 7.0.4)
|
134
|
+
railties (= 7.0.4.1)
|
135
135
|
rails-dom-testing (2.0.3)
|
136
136
|
activesupport (>= 4.2.0)
|
137
137
|
nokogiri (>= 1.6)
|
138
138
|
rails-html-sanitizer (1.4.4)
|
139
139
|
loofah (~> 2.19, >= 2.19.1)
|
140
|
-
railties (7.0.4)
|
141
|
-
actionpack (= 7.0.4)
|
142
|
-
activesupport (= 7.0.4)
|
140
|
+
railties (7.0.4.1)
|
141
|
+
actionpack (= 7.0.4.1)
|
142
|
+
activesupport (= 7.0.4.1)
|
143
143
|
method_source
|
144
144
|
rake (>= 12.2)
|
145
145
|
thor (~> 1.0)
|
@@ -152,10 +152,10 @@ GEM
|
|
152
152
|
rspec-mocks (~> 3.12.0)
|
153
153
|
rspec-core (3.12.0)
|
154
154
|
rspec-support (~> 3.12.0)
|
155
|
-
rspec-expectations (3.12.
|
155
|
+
rspec-expectations (3.12.2)
|
156
156
|
diff-lcs (>= 1.2.0, < 2.0)
|
157
157
|
rspec-support (~> 3.12.0)
|
158
|
-
rspec-mocks (3.12.
|
158
|
+
rspec-mocks (3.12.3)
|
159
159
|
diff-lcs (>= 1.2.0, < 2.0)
|
160
160
|
rspec-support (~> 3.12.0)
|
161
161
|
rspec-support (3.12.0)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
deprecation_collector (0.
|
4
|
+
deprecation_collector (0.2.0)
|
5
5
|
redis (>= 3.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -22,10 +22,10 @@ GEM
|
|
22
22
|
rspec-mocks (~> 3.12.0)
|
23
23
|
rspec-core (3.12.0)
|
24
24
|
rspec-support (~> 3.12.0)
|
25
|
-
rspec-expectations (3.12.
|
25
|
+
rspec-expectations (3.12.2)
|
26
26
|
diff-lcs (>= 1.2.0, < 2.0)
|
27
27
|
rspec-support (~> 3.12.0)
|
28
|
-
rspec-mocks (3.12.
|
28
|
+
rspec-mocks (3.12.3)
|
29
29
|
diff-lcs (>= 1.2.0, < 2.0)
|
30
30
|
rspec-support (~> 3.12.0)
|
31
31
|
rspec-support (3.12.0)
|
@@ -4,7 +4,7 @@ class DeprecationCollector
|
|
4
4
|
# :nodoc:
|
5
5
|
class Deprecation
|
6
6
|
attr_reader :message, :realm, :gem_traceline, :app_traceline, :occurences, :first_timestamp, :full_backtrace
|
7
|
-
attr_accessor :context
|
7
|
+
attr_accessor :context, :custom_fingerprint
|
8
8
|
|
9
9
|
CLEANUP_REGEXES = {
|
10
10
|
# rails views generated methods names are unique per-worker
|
@@ -55,7 +55,8 @@ class DeprecationCollector
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def digest_base
|
58
|
-
"1:#{RUBY_VERSION}:#{defined?(Rails) && Rails.version}:#{message_for_digest}:#{gem_traceline}:#{app_traceline}"
|
58
|
+
"1:#{RUBY_VERSION}:#{defined?(Rails) && Rails.version}:#{message_for_digest}:#{gem_traceline}:#{app_traceline}" \
|
59
|
+
"#{":#{custom_fingerprint}" if custom_fingerprint}"
|
59
60
|
end
|
60
61
|
|
61
62
|
def as_json(_options = {})
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'router'
|
4
|
+
require_relative 'helpers'
|
5
|
+
require 'pp'
|
6
|
+
|
7
|
+
class DeprecationCollector
|
8
|
+
class Web
|
9
|
+
class Application
|
10
|
+
extend Web::Router
|
11
|
+
helpers Helpers
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
unless defined?(Temple::Utils) || ENV['DEPRECATION_COLLECTOR_RELOAD_WEB_TEMPLATES']
|
15
|
+
# used for escaping in compiled slim templates
|
16
|
+
require_relative 'utils'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def call(env)
|
21
|
+
self.class.call(env)
|
22
|
+
end
|
23
|
+
|
24
|
+
root do # index
|
25
|
+
@deprecations = collector_instance.read_each.to_a
|
26
|
+
@deprecations = @deprecations.sort_by { |dep| dep[:message] } unless params[:sort] == '0'
|
27
|
+
|
28
|
+
if params[:reject]
|
29
|
+
@deprecations = @deprecations.reject { |dep| dep[:message].match?(Regexp.union(Array(params[:reject]))) }
|
30
|
+
end
|
31
|
+
|
32
|
+
if params[:realm]
|
33
|
+
@deprecations = @deprecations.select { |dep| dep[:realm].match?(Regexp.union(Array(params[:realm]))) }
|
34
|
+
end
|
35
|
+
|
36
|
+
render slim: "index.html"
|
37
|
+
end
|
38
|
+
|
39
|
+
get '/dump.json' do
|
40
|
+
render json: collector_instance.read_each.to_a
|
41
|
+
end
|
42
|
+
|
43
|
+
get '/:id' do # show
|
44
|
+
@deprecation = collector_instance.read_one(params[:id])
|
45
|
+
render slim: "show.html"
|
46
|
+
end
|
47
|
+
|
48
|
+
delete '/all' do
|
49
|
+
collector_instance.flush_redis
|
50
|
+
redirect_to deprecations_path
|
51
|
+
end
|
52
|
+
|
53
|
+
post '/enable' do
|
54
|
+
collector_instance.enable
|
55
|
+
redirect_to deprecations_path
|
56
|
+
end
|
57
|
+
|
58
|
+
delete '/disable' do
|
59
|
+
collector_instance.disable
|
60
|
+
redirect_to deprecations_path
|
61
|
+
end
|
62
|
+
|
63
|
+
# NB: order for wildcards is important
|
64
|
+
delete '/:id' do # destroy
|
65
|
+
collector_instance.delete_deprecations([params[:id]])
|
66
|
+
redirect_to deprecations_path
|
67
|
+
end
|
68
|
+
|
69
|
+
post '/trigger' do # trigger
|
70
|
+
trigger_kwargs_error_warning({ foo: nil }) if RUBY_VERSION.start_with?('2.7')
|
71
|
+
trigger_rails_deprecation
|
72
|
+
collector_instance.collect(
|
73
|
+
"TestFoo#assign_attributes called (test attr_spy) trigger_rails_deprecation", caller_locations, :attr_spy
|
74
|
+
)
|
75
|
+
collector_instance.write_to_redis(force: true)
|
76
|
+
redirect_to deprecations_path
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class DeprecationCollector
|
4
|
+
class Web
|
5
|
+
module Helpers
|
6
|
+
def collector_instance
|
7
|
+
@collector_instance || DeprecationCollector.instance
|
8
|
+
end
|
9
|
+
|
10
|
+
def root_path
|
11
|
+
# request.base_url ?
|
12
|
+
"#{env["SCRIPT_NAME"]}/"
|
13
|
+
end
|
14
|
+
|
15
|
+
def current_path
|
16
|
+
@current_path ||= request.path_info.gsub(/^\//, "")
|
17
|
+
end
|
18
|
+
|
19
|
+
def deprecations_path
|
20
|
+
"#{root_path}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def deprecation_path(id)
|
24
|
+
"#{root_path}#{id}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def enable_deprecations_path
|
28
|
+
"#{root_path}enable"
|
29
|
+
end
|
30
|
+
|
31
|
+
def disable_deprecations_path
|
32
|
+
"#{root_path}disable"
|
33
|
+
end
|
34
|
+
|
35
|
+
def trigger_kwargs_error_warning(foo: nil); end
|
36
|
+
|
37
|
+
def trigger_rails_deprecation
|
38
|
+
return unless defined?(ActiveSupport::Deprecation)
|
39
|
+
-> { ActiveSupport::Deprecation.warn("Test deprecation") } []
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,196 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class DeprecationCollector
|
4
|
+
class Web
|
5
|
+
module Router
|
6
|
+
HTTP_METHODS = %w[GET HEAD POST PUT PATCH DELETE].freeze
|
7
|
+
HTTP_METHODS.each do |http_method|
|
8
|
+
const_set http_method, http_method
|
9
|
+
class_eval <<~RUBY, __FILE__, __LINE__+1
|
10
|
+
def #{http_method.downcase}(path, &block)
|
11
|
+
route(#{http_method}, path, &block)
|
12
|
+
end
|
13
|
+
RUBY
|
14
|
+
end
|
15
|
+
|
16
|
+
def root(&block)
|
17
|
+
route(GET, '/', &block)
|
18
|
+
end
|
19
|
+
|
20
|
+
def route(method, path, &block)
|
21
|
+
((@routes ||= {})[method] ||= []) << Route.new(method, path, block)
|
22
|
+
end
|
23
|
+
|
24
|
+
def helpers(mod = nil, &block)
|
25
|
+
return ActionContext.class_eval(&block) if block
|
26
|
+
ActionContext.send(:include, mod)
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
ROUTE_PARAMS = "rack.route_params"
|
31
|
+
PATH_INFO = "PATH_INFO"
|
32
|
+
|
33
|
+
def match(env)
|
34
|
+
request = ::Rack::Request.new(env)
|
35
|
+
request_method = request.request_method
|
36
|
+
request_method = request.params["_method"] if request.params["_method"]
|
37
|
+
|
38
|
+
path_info = ::Rack::Utils.unescape env[PATH_INFO]
|
39
|
+
path_info = "/" if path_info == "" # some buggy servers may pass empty root path
|
40
|
+
|
41
|
+
@routes[request_method.upcase]&.find do |route|
|
42
|
+
params = route.match(request_method, path_info)
|
43
|
+
next unless params
|
44
|
+
env[ROUTE_PARAMS] = params
|
45
|
+
break ActionContext.new(request, &route.block)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def call(env)
|
50
|
+
action = match(env)
|
51
|
+
unless action
|
52
|
+
return [
|
53
|
+
404,
|
54
|
+
{"content-type" => "text/plain", "x-cascade" => "pass"},
|
55
|
+
["Not Found #{env["REQUEST_METHOD"].inspect} #{env[PATH_INFO].inspect}"]
|
56
|
+
]
|
57
|
+
end
|
58
|
+
|
59
|
+
resp = catch(:halt) do
|
60
|
+
action.call(env)
|
61
|
+
ensure
|
62
|
+
end
|
63
|
+
|
64
|
+
return resp if resp.is_a?(Array) # raw rack responses (redirects etc.)
|
65
|
+
|
66
|
+
# rendered content goes here
|
67
|
+
headers = {
|
68
|
+
"content-type" => "text/html",
|
69
|
+
"cache-control" => "private, no-store",
|
70
|
+
# TODO:
|
71
|
+
# "content-language" => action.locale,
|
72
|
+
# "content-security-policy" => CSP_HEADER
|
73
|
+
}
|
74
|
+
# we'll let Rack calculate Content-Length for us.
|
75
|
+
[200, headers, [resp]]
|
76
|
+
end
|
77
|
+
|
78
|
+
class Route
|
79
|
+
attr_accessor :request_method, :pattern, :block
|
80
|
+
|
81
|
+
NAMED_SEGMENTS_PATTERN = /\/([^\/]*):([^.:$\/]+)/
|
82
|
+
|
83
|
+
def initialize(request_method, pattern, block)
|
84
|
+
@request_method = request_method
|
85
|
+
@pattern = pattern
|
86
|
+
@block = block
|
87
|
+
end
|
88
|
+
|
89
|
+
def matcher
|
90
|
+
@matcher ||= compile_matcher
|
91
|
+
end
|
92
|
+
|
93
|
+
def compile_matcher
|
94
|
+
return pattern unless pattern.match?(NAMED_SEGMENTS_PATTERN)
|
95
|
+
regex_pattern = pattern.gsub(NAMED_SEGMENTS_PATTERN, '/\1(?<\2>[^$/]+)') # /some/:id => /some/(?<id>[^$/]+)
|
96
|
+
|
97
|
+
Regexp.new("\\A#{regex_pattern}\\Z")
|
98
|
+
end
|
99
|
+
|
100
|
+
def match(request_method, path)
|
101
|
+
case matcher
|
102
|
+
when String
|
103
|
+
{} if path == matcher
|
104
|
+
else
|
105
|
+
path_match = path.match(matcher)
|
106
|
+
path_match&.named_captures&.transform_keys(&:to_sym)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
class ActionContext
|
112
|
+
attr_accessor :request
|
113
|
+
|
114
|
+
def initialize(request, &block)
|
115
|
+
@request = request
|
116
|
+
@block = block
|
117
|
+
end
|
118
|
+
|
119
|
+
def call(env)
|
120
|
+
instance_exec(&@block)
|
121
|
+
end
|
122
|
+
|
123
|
+
def env
|
124
|
+
request.env
|
125
|
+
end
|
126
|
+
|
127
|
+
def route_params
|
128
|
+
env[Router::ROUTE_PARAMS]
|
129
|
+
end
|
130
|
+
|
131
|
+
def params
|
132
|
+
@params ||= Hash.new { |hash, key| hash[key.to_s] if Symbol === key }
|
133
|
+
.merge!(request.params)
|
134
|
+
.merge!(route_params.transform_keys(&:to_s))
|
135
|
+
end
|
136
|
+
|
137
|
+
def halt(res)
|
138
|
+
throw :halt, [res, {"content-type" => "text/plain"}, [res.to_s]]
|
139
|
+
end
|
140
|
+
|
141
|
+
def redirect_to(location)
|
142
|
+
throw :halt, [302, {"location" => "#{request.base_url}#{location}"}, []]
|
143
|
+
end
|
144
|
+
|
145
|
+
def render(plain: nil, html: nil, json: nil, erb: nil, slim: nil, status: 200, locals: nil, layout: 'layout.html.slim')
|
146
|
+
raise ArgumentError, "provide exactly one render format" unless [plain, html, json, erb, slim].compact.size == 1
|
147
|
+
|
148
|
+
return [status, {"content-type" => "application/json"}, [JSON.generate(json)]] if json
|
149
|
+
return [status, {"content-type" => "text/plain"}, [plain.to_s]] if plain
|
150
|
+
|
151
|
+
_define_locals(locals) if locals
|
152
|
+
template = "#{erb}.erb" if erb
|
153
|
+
template = "#{slim}.slim" if slim
|
154
|
+
html = render_template(template) if template
|
155
|
+
html = render_template(layout) { html } if layout
|
156
|
+
|
157
|
+
return [status, {"content-type" => "text/html"}, [html.to_s]] if html
|
158
|
+
end
|
159
|
+
|
160
|
+
VIEW_PATH = "#{__dir__}/views"
|
161
|
+
|
162
|
+
def render_template(template, &block)
|
163
|
+
original_template_name = File.join(VIEW_PATH, template.to_s)
|
164
|
+
template = template.gsub(/\.slim\z/, '.template.rb')
|
165
|
+
template_method_name = "_template_#{template.gsub(/[^\w]/, '_')}"
|
166
|
+
template_filename = File.join(VIEW_PATH, template.to_s)
|
167
|
+
|
168
|
+
if ENV['DEPRECATION_COLLECTOR_RELOAD_WEB_TEMPLATES']
|
169
|
+
require 'slim'
|
170
|
+
puts "Recompiling #{original_template_name}"
|
171
|
+
ActionContext.class_eval { undef_method(template_method_name) } if respond_to?(template_method_name)
|
172
|
+
if original_template_name.end_with?('.slim')
|
173
|
+
File.write(template_filename, Slim::Template.new(original_template_name).precompiled_template)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
unless respond_to?(template_method_name)
|
178
|
+
src = File.read(template_filename)
|
179
|
+
src = ERB.new(src).src if template_filename.end_with?('.erb')
|
180
|
+
ActionContext.class_eval <<-RUBY, template_filename.gsub(/\.template\.rb\z/, '.slim'), 1
|
181
|
+
def #{template_method_name}; #{src}
|
182
|
+
end
|
183
|
+
RUBY
|
184
|
+
end
|
185
|
+
|
186
|
+
send(template_method_name, &block)
|
187
|
+
end
|
188
|
+
|
189
|
+
private
|
190
|
+
def _define_locals(locals)
|
191
|
+
locals&.each { |k, v| define_singleton_method(k) { v } unless singleton_methods.include?(k) }
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
|
2
|
+
begin
|
3
|
+
require 'cgi/escape'
|
4
|
+
rescue LoadError
|
5
|
+
end
|
6
|
+
|
7
|
+
module Temple
|
8
|
+
# @api public
|
9
|
+
module Utils
|
10
|
+
extend self
|
11
|
+
|
12
|
+
# Returns an escaped copy of `html`.
|
13
|
+
# Strings which are declared as html_safe are not escaped.
|
14
|
+
#
|
15
|
+
# @param html [String] The string to escape
|
16
|
+
# @return [String] The escaped string
|
17
|
+
def escape_html_safe(html)
|
18
|
+
s = html.to_s
|
19
|
+
s.html_safe? || html.html_safe? ? s : escape_html(s)
|
20
|
+
end
|
21
|
+
|
22
|
+
if defined?(CGI.escapeHTML)
|
23
|
+
# Returns an escaped copy of `html`.
|
24
|
+
#
|
25
|
+
# @param html [String] The string to escape
|
26
|
+
# @return [String] The escaped string
|
27
|
+
def escape_html(html)
|
28
|
+
CGI.escapeHTML(html.to_s)
|
29
|
+
end
|
30
|
+
else
|
31
|
+
# Used by escape_html
|
32
|
+
# @api private
|
33
|
+
ESCAPE_HTML = {
|
34
|
+
'&' => '&',
|
35
|
+
'"' => '"',
|
36
|
+
'\'' => ''',
|
37
|
+
'<' => '<',
|
38
|
+
'>' => '>'
|
39
|
+
}.freeze
|
40
|
+
|
41
|
+
ESCAPE_HTML_PATTERN = Regexp.union(*ESCAPE_HTML.keys)
|
42
|
+
|
43
|
+
# Returns an escaped copy of `html`.
|
44
|
+
#
|
45
|
+
# @param html [String] The string to escape
|
46
|
+
# @return [String] The escaped string
|
47
|
+
def escape_html(html)
|
48
|
+
html.to_s.gsub(ESCAPE_HTML_PATTERN, ESCAPE_HTML)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
_buf = ''; _buf << ("<header><h1>Deprecations</h1><a class=\"btn btn-primary\" data-method=\"post\"".freeze);
|
2
|
+
;
|
3
|
+
;
|
4
|
+
; _slim_codeattributes1 = deprecation_path(:trigger); if _slim_codeattributes1; if _slim_codeattributes1 == true; _buf << (" href=\"\"".freeze); else; _buf << (" href=\"".freeze); _buf << ((::Temple::Utils.escape_html((_slim_codeattributes1))).to_s); _buf << ("\"".freeze); end; end; _buf << (" rel=\"nofollow\">Trigger a couple</a> <a class=\"btn btn-danger\" data-confirm=\"Sure?\" data-method=\"delete\"".freeze);
|
5
|
+
; _slim_codeattributes2 = deprecation_path(:all); if _slim_codeattributes2; if _slim_codeattributes2 == true; _buf << (" href=\"\"".freeze); else; _buf << (" href=\"".freeze); _buf << ((::Temple::Utils.escape_html((_slim_codeattributes2))).to_s); _buf << ("\"".freeze); end; end; _buf << (" rel=\"nofollow\"><i class=\"bi bi-trash\"></i>Delete all </a> ".freeze);
|
6
|
+
;
|
7
|
+
;
|
8
|
+
;
|
9
|
+
; if DeprecationCollector.instance.enabled_in_redis?;
|
10
|
+
;
|
11
|
+
;
|
12
|
+
;
|
13
|
+
; _buf << ("<a class=\"btn btn-danger\" data-confirm=\"Sure? Will need to restart workers after enabling\" data-method=\"delete\"".freeze); _slim_codeattributes3 = disable_deprecations_path; if _slim_codeattributes3; if _slim_codeattributes3 == true; _buf << (" href=\"\"".freeze); else; _buf << (" href=\"".freeze); _buf << ((::Temple::Utils.escape_html((_slim_codeattributes3))).to_s); _buf << ("\"".freeze); end; end; _buf << (" rel=\"nofollow\">Disable</a> ".freeze);
|
14
|
+
; else;
|
15
|
+
;
|
16
|
+
;
|
17
|
+
; _buf << ("<a class=\"btn btn-secondary\" data-method=\"post\"".freeze); _slim_codeattributes4 = enable_deprecations_path; if _slim_codeattributes4; if _slim_codeattributes4 == true; _buf << (" href=\"\"".freeze); else; _buf << (" href=\"".freeze); _buf << ((::Temple::Utils.escape_html((_slim_codeattributes4))).to_s); _buf << ("\"".freeze); end; end; _buf << (" rel=\"nofollow\">Turn on (after workers restart)</a> ".freeze);
|
18
|
+
;
|
19
|
+
; end; _buf << ("</header><main><table class=\"table table-striped\"><tr><th>Count</th><th>Message</th><th>Location</th><th>Ruby/Rails</th></tr>".freeze);
|
20
|
+
;
|
21
|
+
;
|
22
|
+
;
|
23
|
+
;
|
24
|
+
;
|
25
|
+
;
|
26
|
+
;
|
27
|
+
; total = 0;
|
28
|
+
; @deprecations.each do |deprecation|;
|
29
|
+
; total += 1;
|
30
|
+
; _buf << ("<tr".freeze); _slim_codeattributes5 = deprecation[:digest]; if _slim_codeattributes5; if _slim_codeattributes5 == true; _buf << (" data-digest=\"\"".freeze); else; _buf << (" data-digest=\"".freeze); _buf << ((::Temple::Utils.escape_html((_slim_codeattributes5))).to_s); _buf << ("\"".freeze); end; end; _buf << ("><td><a".freeze);
|
31
|
+
;
|
32
|
+
; _slim_codeattributes6 = deprecation_path(deprecation[:digest]); if _slim_codeattributes6; if _slim_codeattributes6 == true; _buf << (" href=\"\"".freeze); else; _buf << (" href=\"".freeze); _buf << ((::Temple::Utils.escape_html((_slim_codeattributes6))).to_s); _buf << ("\"".freeze); end; end; _buf << (">".freeze); _buf << ((::Temple::Utils.escape_html((deprecation[:count]))).to_s);
|
33
|
+
; _buf << ("</a><br />".freeze);
|
34
|
+
; if deprecation[:message].include?("Using the last argument as keyword parameters is deprecated") || \
|
35
|
+
deprecation[:message].include?("Passing the keyword argument as the last hash parameter is deprecated");
|
36
|
+
; _buf << ("<div class=\"badge bg-secondary\">kwargs</div> ".freeze);
|
37
|
+
; end; if deprecation[:message].include?("trigger_kwargs_error_warning") || \
|
38
|
+
deprecation[:message].include?("trigger_rails_deprecation");
|
39
|
+
; _buf << ("<div class=\"badge bg-success\">test</div> ".freeze);
|
40
|
+
; end; if deprecation[:realm] && deprecation[:realm] != 'rails';
|
41
|
+
; _buf << ("<div class=\"badge bg-secondary\">".freeze); _buf << ((::Temple::Utils.escape_html((deprecation[:realm]))).to_s);
|
42
|
+
; _buf << ("</div> ".freeze); end; deprecation.dig(:notes, :tags)&.each do |tag|;
|
43
|
+
; _buf << ("<div class=\"badge bg-secondary\">".freeze); _buf << ((::Temple::Utils.escape_html((tag))).to_s);
|
44
|
+
;
|
45
|
+
; _buf << ("</div> ".freeze); end; _buf << ("</td><td>".freeze);
|
46
|
+
;
|
47
|
+
; msg = deprecation[:message]
|
48
|
+
delete_prefixes = Gem.path + [defined?(Rails) && Rails.root.to_s].compact
|
49
|
+
delete_prefixes.each { |path| msg.gsub!(path, '') }
|
50
|
+
;
|
51
|
+
; _buf << ("<div class=\"card text-dark bg-light\"><pre class=\"pre-scrollable\" style=\"overflow: auto; max-width: 700px; max-height: 200px; font-size: 11px\"><code>".freeze);
|
52
|
+
;
|
53
|
+
; _buf << ((::Temple::Utils.escape_html((msg.delete_prefix("DEPRECATION WARNING: ")))).to_s);
|
54
|
+
; _buf << ("</code></pre></div>".freeze); if deprecation.dig(:notes, :comment);
|
55
|
+
; _buf << ((::Temple::Utils.escape_html((deprecation.dig(:notes, :comment)))).to_s);
|
56
|
+
;
|
57
|
+
; end; if deprecation.dig(:context, :action);
|
58
|
+
; _buf << ("<div class=\"small controller\">".freeze); _buf << ((::Temple::Utils.escape_html((deprecation.dig(:context, :action)))).to_s);
|
59
|
+
; _buf << ("</div>".freeze); elsif deprecation.dig(:context, :params, :controller);
|
60
|
+
; _buf << ("<div class=\"small controller\">".freeze); _buf << ((::Temple::Utils.escape_html((deprecation.dig(:context, :params).slice(:controller, :action).values.join('#')))).to_s);
|
61
|
+
; _buf << ("</div>".freeze); end; _buf << ("</td><td>".freeze);
|
62
|
+
; if deprecation[:gem_traceline];
|
63
|
+
; _buf << ((::Temple::Utils.escape_html((deprecation[:gem_traceline]))).to_s);
|
64
|
+
; _buf << ("<br>".freeze);
|
65
|
+
; end; if deprecation[:app_traceline];
|
66
|
+
; location, function = deprecation[:app_traceline].split(':in `', 2);
|
67
|
+
; _buf << ("<code class=\"code_location\" style=\"cursor: pointer\">".freeze); _buf << ((::Temple::Utils.escape_html((location))).to_s);
|
68
|
+
; _buf << ("</code> ".freeze); _buf << ((::Temple::Utils.escape_html((function.delete_suffix("'")))).to_s);
|
69
|
+
; end; _buf << ("</td><td><div class=\"small ruby\">".freeze);
|
70
|
+
; _buf << ((::Temple::Utils.escape_html((deprecation[:ruby_version]))).to_s);
|
71
|
+
; _buf << ("</div><div class=\"small rails\">".freeze); _buf << ((::Temple::Utils.escape_html((deprecation[:rails_version]))).to_s);
|
72
|
+
;
|
73
|
+
; _buf << ("</div><a data-confirm=\"Delete?\" data-method=\"delete\"".freeze); _slim_codeattributes7 = deprecation_path(deprecation[:digest]); if _slim_codeattributes7; if _slim_codeattributes7 == true; _buf << (" href=\"\"".freeze); else; _buf << (" href=\"".freeze); _buf << ((::Temple::Utils.escape_html((_slim_codeattributes7))).to_s); _buf << ("\"".freeze); end; end; _buf << (" rel=\"nofollow\" title=\"Delete\"><i class=\"bi bi-trash\"></i></a></td></tr>".freeze);
|
74
|
+
;
|
75
|
+
; end; if total.zero?;
|
76
|
+
; _buf << ("<tr><td".freeze);
|
77
|
+
; _slim_codeattributes8 = 4; if _slim_codeattributes8; if _slim_codeattributes8 == true; _buf << (" colspan=\"\"".freeze); else; _buf << (" colspan=\"".freeze); _buf << ((::Temple::Utils.escape_html((_slim_codeattributes8))).to_s); _buf << ("\"".freeze); end; end; _buf << ("><p>Looks like there're no deprecations</p><p>You can try <a data-method=\"post\"".freeze);
|
78
|
+
;
|
79
|
+
;
|
80
|
+
;
|
81
|
+
; _slim_codeattributes9 = deprecation_path(:trigger); if _slim_codeattributes9; if _slim_codeattributes9 == true; _buf << (" href=\"\"".freeze); else; _buf << (" href=\"".freeze); _buf << ((::Temple::Utils.escape_html((_slim_codeattributes9))).to_s); _buf << ("\"".freeze); end; end; _buf << (" rel=\"nofollow\">trigger a couple</a></p></td></tr>".freeze);
|
82
|
+
;
|
83
|
+
; end; _buf << ("</table></main><footer>".freeze);
|
84
|
+
; if total > 3;
|
85
|
+
; _buf << ((::Temple::Utils.escape_html((total))).to_s);
|
86
|
+
; _buf << (" deprecations ".freeze);
|
87
|
+
;
|
88
|
+
; end; _buf << ("</footer><script>document.querySelectorAll('.code_location').forEach(function(elem){\n elem.addEventListener('click', function () {\n console.log(\"Copying\", elem.innerText)\n navigator.clipboard.writeText(elem.innerText);\n }, false);\n});</script>".freeze);
|
89
|
+
;
|
90
|
+
;
|
91
|
+
;
|
92
|
+
;
|
93
|
+
;
|
94
|
+
;
|
95
|
+
; _buf
|
@@ -0,0 +1,18 @@
|
|
1
|
+
_buf = ''; _buf << ("<!DOCTYPE html><html><head><meta charset=\"utf-8\" /><meta content=\"IE=edge;chrome=1\" http-equiv=\"X-UA-Compatible\" /><title>".freeze);
|
2
|
+
;
|
3
|
+
;
|
4
|
+
;
|
5
|
+
;
|
6
|
+
;
|
7
|
+
; _buf << ((::Temple::Utils.escape_html(("Deprecations"))).to_s);
|
8
|
+
; _buf << ("</title><meta content=\"\" name=\"description\" /><meta content=\"width=device-width\" name=\"viewport\" /><link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css\" rel=\"stylesheet\" /><link href=\"https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.2/font/bootstrap-icons.css\" rel=\"stylesheet\" /></head><body><div class=\"container-fluid\">".freeze);
|
9
|
+
;
|
10
|
+
;
|
11
|
+
;
|
12
|
+
;
|
13
|
+
;
|
14
|
+
;
|
15
|
+
; _buf << ((yield).to_s);
|
16
|
+
;
|
17
|
+
; _buf << ("</div><script src=\"https://cdn.jsdelivr.net/npm/rails-ujs@5.2.8-1/lib/assets/compiled/rails-ujs.min.js\"></script></body></html>".freeze);
|
18
|
+
; _buf
|
@@ -0,0 +1,13 @@
|
|
1
|
+
_buf = ''; _buf << ("<header class=\"mb-3\"><h1>Deprecation</h1><a class=\"btn btn-secondary\"".freeze);
|
2
|
+
;
|
3
|
+
;
|
4
|
+
; _slim_codeattributes1 = deprecations_path; if _slim_codeattributes1; if _slim_codeattributes1 == true; _buf << (" href=\"\"".freeze); else; _buf << (" href=\"".freeze); _buf << ((::Temple::Utils.escape_html((_slim_codeattributes1))).to_s); _buf << ("\"".freeze); end; end; _buf << (">Back</a><a class=\"btn btn-danger\" data-confirm=\"Delete?\" data-method=\"delete\"".freeze);
|
5
|
+
; _slim_codeattributes2 = deprecation_path(@deprecation[:digest]); if _slim_codeattributes2; if _slim_codeattributes2 == true; _buf << (" href=\"\"".freeze); else; _buf << (" href=\"".freeze); _buf << ((::Temple::Utils.escape_html((_slim_codeattributes2))).to_s); _buf << ("\"".freeze); end; end; _buf << (" rel=\"nofollow\" title=\"Delete\"><span class=\"glyphicon glyphicon-trash insalesicon-trash\"></span>Delete</a></header><main><div class=\"card text-dark bg-light p-3\"><pre><code>".freeze);
|
6
|
+
;
|
7
|
+
;
|
8
|
+
;
|
9
|
+
;
|
10
|
+
;
|
11
|
+
;
|
12
|
+
; _buf << ((::Temple::Utils.escape_html((@deprecation.pretty_inspect))).to_s);
|
13
|
+
; _buf << ("</code></pre></div></main>".freeze); _buf
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "erb"
|
4
|
+
require "rack/content_length"
|
5
|
+
require "rack/builder"
|
6
|
+
|
7
|
+
require_relative 'web/application'
|
8
|
+
|
9
|
+
class DeprecationCollector
|
10
|
+
class Web
|
11
|
+
def self.call(env)
|
12
|
+
@app ||= new
|
13
|
+
@app.call(env)
|
14
|
+
end
|
15
|
+
|
16
|
+
def call(env)
|
17
|
+
app.call(env)
|
18
|
+
end
|
19
|
+
|
20
|
+
def app
|
21
|
+
@app ||= build
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def build
|
26
|
+
::Rack::Builder.new do
|
27
|
+
# use Rack::Static etc goes here
|
28
|
+
|
29
|
+
run Web::Application.new
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -57,7 +57,7 @@ class DeprecationCollector
|
|
57
57
|
:write_interval, :write_interval_jitter,
|
58
58
|
:app_revision, :app_root,
|
59
59
|
:print_to_stderr, :print_recurring
|
60
|
-
attr_writer :redis, :context_saver
|
60
|
+
attr_writer :redis, :context_saver, :fingerprinter
|
61
61
|
|
62
62
|
def initialize(mutex: nil)
|
63
63
|
# on cruby hash itself is threadsafe, but we need to prevent races
|
@@ -88,11 +88,17 @@ class DeprecationCollector
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def context_saver(&block)
|
91
|
-
return @context_saver unless
|
91
|
+
return @context_saver unless block
|
92
92
|
|
93
93
|
@context_saver = block
|
94
94
|
end
|
95
95
|
|
96
|
+
def fingerprinter(&block)
|
97
|
+
return @fingerprinter unless block
|
98
|
+
|
99
|
+
@fingerprinter = block
|
100
|
+
end
|
101
|
+
|
96
102
|
def app_root_prefix
|
97
103
|
"#{app_root}/"
|
98
104
|
end
|
@@ -243,9 +249,10 @@ class DeprecationCollector
|
|
243
249
|
def store_deprecation(deprecation, allow_context: true)
|
244
250
|
return if deprecation.ignored?
|
245
251
|
|
246
|
-
fresh = !@deprecations.key?(deprecation.digest)
|
247
252
|
deprecation.context = context_saver.call if context_saver && allow_context
|
253
|
+
deprecation.custom_fingerprint = fingerprinter.call(deprecation) if fingerprinter && allow_context
|
248
254
|
|
255
|
+
fresh = !@deprecations.key?(deprecation.digest)
|
249
256
|
@deprecations_mutex.synchronize do
|
250
257
|
(@deprecations[deprecation.digest] ||= deprecation).touch
|
251
258
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deprecation_collector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vasily Fedoseyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -67,6 +67,14 @@ files:
|
|
67
67
|
- lib/deprecation_collector/collectors.rb
|
68
68
|
- lib/deprecation_collector/deprecation.rb
|
69
69
|
- lib/deprecation_collector/version.rb
|
70
|
+
- lib/deprecation_collector/web.rb
|
71
|
+
- lib/deprecation_collector/web/application.rb
|
72
|
+
- lib/deprecation_collector/web/helpers.rb
|
73
|
+
- lib/deprecation_collector/web/router.rb
|
74
|
+
- lib/deprecation_collector/web/utils.rb
|
75
|
+
- lib/deprecation_collector/web/views/index.html.template.rb
|
76
|
+
- lib/deprecation_collector/web/views/layout.html.template.rb
|
77
|
+
- lib/deprecation_collector/web/views/show.html.template.rb
|
70
78
|
- sig/deprecation_collector.rbs
|
71
79
|
homepage: https://github.com/Vasfed/deprecation_collector
|
72
80
|
licenses:
|
@@ -90,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
98
|
- !ruby/object:Gem::Version
|
91
99
|
version: '0'
|
92
100
|
requirements: []
|
93
|
-
rubygems_version: 3.
|
101
|
+
rubygems_version: 3.4.1
|
94
102
|
signing_key:
|
95
103
|
specification_version: 4
|
96
104
|
summary: Collector for ruby/rails deprecations and warnings, suitable for production
|