deprecation_collector 0.4.0 → 0.5.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 +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +4 -4
- data/Gemfile.lock +1 -1
- data/Rakefile +5 -4
- data/deprecation_collector.gemspec +1 -1
- data/gemfiles/rails_6.gemfile.lock +1 -1
- data/gemfiles/rails_7.gemfile.lock +1 -1
- data/gemfiles/rails_none.gemfile.lock +1 -1
- data/lib/deprecation_collector/deprecation.rb +2 -1
- data/lib/deprecation_collector/storage.rb +212 -0
- data/lib/deprecation_collector/version.rb +1 -1
- data/lib/deprecation_collector/web/application.rb +27 -19
- data/lib/deprecation_collector/web/helpers.rb +31 -16
- data/lib/deprecation_collector/web/router.rb +69 -52
- data/lib/deprecation_collector/web/utils.rb +10 -7
- data/lib/deprecation_collector/web/views/index.html.template.rb +18 -7
- data/lib/deprecation_collector/web/views/show.html.template.rb +72 -3
- data/lib/deprecation_collector/web.rb +3 -1
- data/lib/deprecation_collector.rb +85 -118
- metadata +7 -6
@@ -2,19 +2,20 @@
|
|
2
2
|
|
3
3
|
class DeprecationCollector
|
4
4
|
class Web
|
5
|
+
# :nodoc:
|
5
6
|
module Router
|
6
7
|
HTTP_METHODS = %w[GET HEAD POST PUT PATCH DELETE].freeze
|
7
8
|
HTTP_METHODS.each do |http_method|
|
8
9
|
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
|
10
|
+
class_eval <<~RUBY, __FILE__, __LINE__ + 1
|
11
|
+
def #{http_method.downcase}(path, &block) # def get(path, &block)
|
12
|
+
route(#{http_method}, path, &block) # route('GET', path, &block)
|
13
|
+
end # end
|
13
14
|
RUBY
|
14
15
|
end
|
15
16
|
|
16
17
|
def root(&block)
|
17
|
-
route(GET,
|
18
|
+
route(GET, "/", &block)
|
18
19
|
end
|
19
20
|
|
20
21
|
def route(method, path, &block)
|
@@ -23,10 +24,10 @@ class DeprecationCollector
|
|
23
24
|
|
24
25
|
def helpers(mod = nil, &block)
|
25
26
|
return ActionContext.class_eval(&block) if block
|
27
|
+
|
26
28
|
ActionContext.send(:include, mod)
|
27
29
|
end
|
28
30
|
|
29
|
-
|
30
31
|
ROUTE_PARAMS = "rack.route_params"
|
31
32
|
PATH_INFO = "PATH_INFO"
|
32
33
|
|
@@ -39,35 +40,33 @@ class DeprecationCollector
|
|
39
40
|
path_info = "/" if path_info == "" # some buggy servers may pass empty root path
|
40
41
|
|
41
42
|
@routes[request_method.upcase]&.find do |route|
|
42
|
-
params = route.match(request_method, path_info)
|
43
|
+
params = route.match(request_method.upcase, path_info)
|
43
44
|
next unless params
|
45
|
+
|
44
46
|
env[ROUTE_PARAMS] = params
|
45
47
|
break ActionContext.new(request, &route.block)
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
49
|
-
def call(env, application=nil)
|
51
|
+
def call(env, application = nil)
|
50
52
|
action = match(env)
|
51
53
|
unless action
|
52
54
|
return [
|
53
55
|
404,
|
54
|
-
{"content-type" => "text/plain", "x-cascade" => "pass"},
|
56
|
+
{ "content-type" => "text/plain", "x-cascade" => "pass" },
|
55
57
|
["Not Found #{env["REQUEST_METHOD"].inspect} #{env[PATH_INFO].inspect}"]
|
56
58
|
]
|
57
59
|
end
|
58
60
|
|
59
|
-
resp = catch(:halt)
|
60
|
-
action.call(env, application)
|
61
|
-
ensure
|
62
|
-
end
|
61
|
+
resp = catch(:halt) { action.call(env, application) }
|
63
62
|
|
64
63
|
return resp if resp.is_a?(Array) # raw rack responses (redirects etc.)
|
65
64
|
|
66
65
|
# rendered content goes here
|
67
66
|
headers = {
|
68
67
|
"content-type" => "text/html",
|
69
|
-
"cache-control" => "private, no-store"
|
70
|
-
# TODO:
|
68
|
+
"cache-control" => "private, no-store"
|
69
|
+
# TODO: locale/csp
|
71
70
|
# "content-language" => action.locale,
|
72
71
|
# "content-security-policy" => CSP_HEADER
|
73
72
|
}
|
@@ -75,10 +74,11 @@ class DeprecationCollector
|
|
75
74
|
[200, headers, [resp]]
|
76
75
|
end
|
77
76
|
|
77
|
+
# :nodoc:
|
78
78
|
class Route
|
79
79
|
attr_accessor :request_method, :pattern, :block
|
80
80
|
|
81
|
-
NAMED_SEGMENTS_PATTERN =
|
81
|
+
NAMED_SEGMENTS_PATTERN = %r{/([^/]*):([^.:$/]+)}.freeze
|
82
82
|
|
83
83
|
def initialize(request_method, pattern, block)
|
84
84
|
@request_method = request_method
|
@@ -92,12 +92,15 @@ class DeprecationCollector
|
|
92
92
|
|
93
93
|
def compile_matcher
|
94
94
|
return pattern unless pattern.match?(NAMED_SEGMENTS_PATTERN)
|
95
|
-
regex_pattern = pattern.gsub(NAMED_SEGMENTS_PATTERN, '/\1(?<\2>[^$/]+)') # /some/:id => /some/(?<id>[^$/]+)
|
96
95
|
|
96
|
+
regex_pattern = pattern.gsub(NAMED_SEGMENTS_PATTERN, '/\1(?<\2>[^$/]+)') # /some/:id => /some/(?<id>[^$/]+)
|
97
97
|
Regexp.new("\\A#{regex_pattern}\\Z")
|
98
98
|
end
|
99
99
|
|
100
100
|
def match(request_method, path)
|
101
|
+
# this is actually not needed because of groupping by method, but just in case:
|
102
|
+
return unless self.request_method == request_method
|
103
|
+
|
101
104
|
case matcher
|
102
105
|
when String
|
103
106
|
{} if path == matcher
|
@@ -108,6 +111,7 @@ class DeprecationCollector
|
|
108
111
|
end
|
109
112
|
end
|
110
113
|
|
114
|
+
# :nodoc:
|
111
115
|
class ActionContext
|
112
116
|
attr_accessor :request
|
113
117
|
|
@@ -116,7 +120,7 @@ class DeprecationCollector
|
|
116
120
|
@block = block
|
117
121
|
end
|
118
122
|
|
119
|
-
def call(
|
123
|
+
def call(_env, application)
|
120
124
|
@web = application.web
|
121
125
|
instance_exec(&@block)
|
122
126
|
end
|
@@ -130,27 +134,30 @@ class DeprecationCollector
|
|
130
134
|
end
|
131
135
|
|
132
136
|
def params
|
133
|
-
@params ||= Hash.new { |hash, key| hash[key.to_s] if Symbol
|
134
|
-
|
135
|
-
|
137
|
+
@params ||= Hash.new { |hash, key| hash[key.to_s] if key.is_a?(Symbol) }
|
138
|
+
.merge!(request.params)
|
139
|
+
.merge!(route_params.transform_keys(&:to_s))
|
136
140
|
end
|
137
141
|
|
138
|
-
def halt(res, content=nil)
|
139
|
-
throw :halt, [res, {"content-type" => "text/plain"}, [content || res.to_s]]
|
142
|
+
def halt(res, content = nil)
|
143
|
+
throw :halt, [res, { "content-type" => "text/plain" }, [content || res.to_s]]
|
140
144
|
end
|
141
145
|
|
142
146
|
def redirect_to(location)
|
143
|
-
throw :halt, [302, {"location" => "#{request.base_url}#{location}"}, []]
|
147
|
+
throw :halt, [302, { "location" => "#{request.base_url}#{location}" }, []]
|
144
148
|
end
|
145
149
|
|
146
|
-
def render(plain: nil, html: nil, json: nil, erb: nil, slim: nil,
|
147
|
-
|
150
|
+
def render(plain: nil, html: nil, json: nil, erb: nil, slim: nil, # rubocop:disable Metrics
|
151
|
+
status: 200, locals: nil, layout: "layout.html.slim")
|
152
|
+
unless [plain, html, json, erb, slim].compact.size == 1
|
153
|
+
raise ArgumentError, "provide exactly one render format"
|
154
|
+
end
|
148
155
|
|
149
156
|
if json
|
150
157
|
json = JSON.generate(json) unless json.is_a?(String)
|
151
|
-
return [status, {"content-type" => "application/json"}, [json]]
|
158
|
+
return [status, { "content-type" => "application/json" }, [json]]
|
152
159
|
end
|
153
|
-
return [status, {"content-type" => "text/plain"}, [plain.to_s]] if plain
|
160
|
+
return [status, { "content-type" => "text/plain" }, [plain.to_s]] if plain
|
154
161
|
|
155
162
|
_define_locals(locals) if locals
|
156
163
|
template = "#{erb}.erb" if erb
|
@@ -159,44 +166,54 @@ class DeprecationCollector
|
|
159
166
|
html = render_template(layout) { html } if layout
|
160
167
|
|
161
168
|
color_scheme_headers = {
|
162
|
-
|
163
|
-
|
164
|
-
|
169
|
+
"Accept-CH" => "Sec-CH-Prefers-Color-Scheme",
|
170
|
+
"Vary" => "Sec-CH-Prefers-Color-Scheme",
|
171
|
+
"Critical-CH" => "Sec-CH-Prefers-Color-Scheme"
|
165
172
|
}
|
166
173
|
|
167
|
-
return [status, {"content-type" => "text/html"}.merge(color_scheme_headers), [html.to_s]] if html
|
174
|
+
return [status, { "content-type" => "text/html" }.merge(color_scheme_headers), [html.to_s]] if html
|
168
175
|
end
|
169
176
|
|
170
177
|
VIEW_PATH = "#{__dir__}/views"
|
171
178
|
|
172
179
|
def render_template(template, &block)
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
template_filename = File.join(VIEW_PATH, template.to_s)
|
177
|
-
|
178
|
-
if ENV['DEPRECATION_COLLECTOR_RELOAD_WEB_TEMPLATES']
|
179
|
-
require 'slim'
|
180
|
-
puts "Recompiling #{original_template_name}"
|
181
|
-
ActionContext.class_eval { undef_method(template_method_name) } if respond_to?(template_method_name)
|
182
|
-
if original_template_name.end_with?('.slim')
|
183
|
-
File.write(template_filename, Slim::Template.new(original_template_name).precompiled_template)
|
184
|
-
end
|
185
|
-
end
|
180
|
+
template_target = template.gsub(/\.slim\z/, ".template.rb")
|
181
|
+
template_method_name = "_template_#{template_target.gsub(/[^\w]/, "_")}"
|
182
|
+
template_filename = File.join(VIEW_PATH, template_target.to_s)
|
186
183
|
|
187
|
-
|
188
|
-
|
189
|
-
src = ERB.new(src).src if template_filename.end_with?('.erb')
|
190
|
-
ActionContext.class_eval <<-RUBY, template_filename.gsub(/\.template\.rb\z/, '.slim'), 1
|
191
|
-
def #{template_method_name}; #{src}
|
192
|
-
end
|
193
|
-
RUBY
|
184
|
+
if ENV["DEPRECATION_COLLECTOR_RELOAD_WEB_TEMPLATES"]
|
185
|
+
_recompile_template(template, template_filename, template_method_name)
|
194
186
|
end
|
195
187
|
|
188
|
+
_load_template(template_filename, template_method_name) unless respond_to?(template_method_name)
|
189
|
+
|
196
190
|
send(template_method_name, &block)
|
197
191
|
end
|
198
192
|
|
199
193
|
private
|
194
|
+
|
195
|
+
def _load_template(template_filename, template_method_name)
|
196
|
+
src = File.read(template_filename)
|
197
|
+
src = ERB.new(src).src if template_filename.end_with?(".erb")
|
198
|
+
src = <<-RUBY
|
199
|
+
def #{template_method_name}; #{src}
|
200
|
+
end
|
201
|
+
RUBY
|
202
|
+
ActionContext.class_eval(src, template_filename.gsub(/\.template\.rb\z/, ".slim"), 1)
|
203
|
+
end
|
204
|
+
|
205
|
+
def _recompile_template(template, template_filename, template_method_name)
|
206
|
+
original_template_name = File.join(VIEW_PATH, template.to_s)
|
207
|
+
puts "Recompiling #{original_template_name}"
|
208
|
+
ActionContext.class_eval { undef_method(template_method_name) } if respond_to?(template_method_name)
|
209
|
+
|
210
|
+
if original_template_name.end_with?(".slim")
|
211
|
+
require "slim"
|
212
|
+
File.write(template_filename, Slim::Template.new(original_template_name).precompiled_template)
|
213
|
+
end
|
214
|
+
template_method_name
|
215
|
+
end
|
216
|
+
|
200
217
|
def _define_locals(locals)
|
201
218
|
locals&.each { |k, v| define_singleton_method(k) { v } unless singleton_methods.include?(k) }
|
202
219
|
end
|
@@ -1,13 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
begin
|
3
|
-
|
4
|
+
# this is stdgem in ruby 2.7+
|
5
|
+
require "cgi/escape"
|
4
6
|
rescue LoadError
|
7
|
+
# optional dependency not present
|
5
8
|
end
|
6
9
|
|
7
10
|
module Temple
|
8
11
|
# @api public
|
9
12
|
module Utils
|
10
|
-
extend self
|
13
|
+
extend self # rubocop:disable Style/ModuleFunction
|
11
14
|
|
12
15
|
# Returns an escaped copy of `html`.
|
13
16
|
# Strings which are declared as html_safe are not escaped.
|
@@ -31,11 +34,11 @@ module Temple
|
|
31
34
|
# Used by escape_html
|
32
35
|
# @api private
|
33
36
|
ESCAPE_HTML = {
|
34
|
-
|
35
|
-
'"'
|
36
|
-
'
|
37
|
-
|
38
|
-
|
37
|
+
"&" => "&",
|
38
|
+
'"' => """,
|
39
|
+
"'" => "'",
|
40
|
+
"<" => "<",
|
41
|
+
">" => ">"
|
39
42
|
}.freeze
|
40
43
|
|
41
44
|
ESCAPE_HTML_PATTERN = Regexp.union(*ESCAPE_HTML.keys)
|
@@ -6,7 +6,8 @@ _buf = ''; _buf << ("<header class=\"mb-3\"><h1>Deprecations</h1><a class=\"btn
|
|
6
6
|
;
|
7
7
|
;
|
8
8
|
;
|
9
|
-
; if DeprecationCollector.instance.
|
9
|
+
; if DeprecationCollector.instance.storage.support_disabling?;
|
10
|
+
; if DeprecationCollector.instance.storage.enabled?;
|
10
11
|
;
|
11
12
|
;
|
12
13
|
;
|
@@ -16,7 +17,7 @@ _buf = ''; _buf << ("<header class=\"mb-3\"><h1>Deprecations</h1><a class=\"btn
|
|
16
17
|
;
|
17
18
|
; _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
|
;
|
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
|
+
; end; 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
|
;
|
21
22
|
;
|
22
23
|
;
|
@@ -25,8 +26,10 @@ _buf = ''; _buf << ("<header class=\"mb-3\"><h1>Deprecations</h1><a class=\"btn
|
|
25
26
|
;
|
26
27
|
;
|
27
28
|
; total = 0;
|
29
|
+
; by_realm = Hash.new(0);
|
28
30
|
; @deprecations.each do |deprecation|;
|
29
31
|
; total += 1;
|
32
|
+
; by_realm[deprecation[:realm]] += 1;
|
30
33
|
; _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
34
|
;
|
32
35
|
; _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);
|
@@ -49,16 +52,16 @@ msg.delete_prefix!("warning: ")
|
|
49
52
|
; _buf << ("<pre class=\"pre-scrollable p-1\" style=\"overflow: auto; max-width: 700px; max-height: 200px; font-size: 11px\"><code>".freeze);
|
50
53
|
; _buf << ((::Temple::Utils.escape_html((msg))).to_s);
|
51
54
|
; _buf << ("</code></pre>".freeze); else;
|
52
|
-
; _buf << ("<div class=\"
|
55
|
+
; _buf << ("<div class=\"msg\">".freeze); _buf << ((::Temple::Utils.escape_html((msg))).to_s);
|
53
56
|
; _buf << ("</div>".freeze); end; if deprecation.dig(:notes, :comment);
|
54
57
|
; _buf << ((::Temple::Utils.escape_html((deprecation.dig(:notes, :comment)))).to_s);
|
55
58
|
;
|
56
59
|
; end; if deprecation.dig(:context, :action);
|
57
|
-
; _buf << ("<
|
58
|
-
; _buf << ("</
|
59
|
-
; _buf << ("<
|
60
|
+
; _buf << ("<i class=\"small controller\">".freeze); _buf << ((::Temple::Utils.escape_html((deprecation.dig(:context, :action)))).to_s);
|
61
|
+
; _buf << ("</i>".freeze); elsif deprecation.dig(:context, :params, :controller);
|
62
|
+
; _buf << ("<i class=\"small controller\">".freeze); _buf << ((::Temple::Utils.escape_html((deprecation.dig(:context, :params).slice(:controller, :action).values.join('#')))).to_s);
|
60
63
|
;
|
61
|
-
; _buf << ("</
|
64
|
+
; _buf << ("</i>".freeze); end; _buf << ("</td><td class=\"small\">".freeze);
|
62
65
|
; if deprecation[:gem_traceline];
|
63
66
|
; _buf << ("<div class=\"gem_location\">".freeze);
|
64
67
|
; location, function = deprecation[:gem_traceline].split(':in `', 2);
|
@@ -94,6 +97,14 @@ msg.delete_prefix!("warning: ")
|
|
94
97
|
; if total > 3;
|
95
98
|
; _buf << ((::Temple::Utils.escape_html((total))).to_s);
|
96
99
|
; _buf << (" deprecations ".freeze);
|
100
|
+
; end; by_realm.each_pair do |realm, count|;
|
101
|
+
; _buf << ("<a class=\"btn btn-sm btn-outline-secondary\" href=\"?realm=".freeze); _buf << ((::Temple::Utils.escape_html((realm))).to_s); _buf << ("\">".freeze);
|
102
|
+
; _buf << ((::Temple::Utils.escape_html((realm))).to_s);
|
103
|
+
; _buf << (" <div".freeze); _temple_html_attributeremover2 = ''; _temple_html_attributemerger2 = []; _temple_html_attributemerger2[0] = "badge"; _temple_html_attributemerger2[1] = ''; _slim_codeattributes13 = (count == 0 ? 'bg-success' : 'bg-secondary'); if Array === _slim_codeattributes13; _slim_codeattributes13 = _slim_codeattributes13.flatten; _slim_codeattributes13.map!(&:to_s); _slim_codeattributes13.reject!(&:empty?); _temple_html_attributemerger2[1] << ((::Temple::Utils.escape_html((_slim_codeattributes13.join(" ")))).to_s); else; _temple_html_attributemerger2[1] << ((::Temple::Utils.escape_html((_slim_codeattributes13))).to_s); end; _temple_html_attributemerger2[1]; _temple_html_attributeremover2 << ((_temple_html_attributemerger2.reject(&:empty?).join(" ")).to_s); _temple_html_attributeremover2; if !_temple_html_attributeremover2.empty?; _buf << (" class=\"".freeze); _buf << ((_temple_html_attributeremover2).to_s); _buf << ("\"".freeze); end; _buf << (">".freeze); _buf << ((::Temple::Utils.escape_html((count))).to_s);
|
104
|
+
; _buf << ("</div> </a> ".freeze); end; if params[:realm] && params[:realm] != '';
|
105
|
+
; _buf << ("<a class=\"btn btn-sm btn-outline-primary\" href=\"?realm=\">Other realms </a> ".freeze);
|
106
|
+
;
|
107
|
+
;
|
97
108
|
; end; _buf << ("</footer><style>.code_location {\n cursor: pointer;\n}</style><script>document.querySelectorAll('.code_location').forEach(function(elem){\n elem.addEventListener('click', function () {\n let textToCopy = elem.getAttribute('data-copy-value');\n if(!textToCopy) textToCopy = elem.innerText;\n console.log(\"Copying\", textToCopy)\n navigator.clipboard.writeText(textToCopy);\n }, false);\n});</script>".freeze);
|
98
109
|
;
|
99
110
|
;
|
@@ -2,12 +2,81 @@ _buf = ''; _buf << ("<header class=\"mb-3\"><h1>Deprecation</h1><a class=\"btn b
|
|
2
2
|
;
|
3
3
|
;
|
4
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><
|
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><dl class=\"row\"><dt>Message</dt><dd><code>".freeze);
|
6
6
|
;
|
7
7
|
;
|
8
8
|
;
|
9
9
|
;
|
10
10
|
;
|
11
11
|
;
|
12
|
-
;
|
13
|
-
; _buf << (
|
12
|
+
;
|
13
|
+
; _buf << ((::Temple::Utils.escape_html((@deprecation[:message]))).to_s);
|
14
|
+
; _buf << ("</code></dd><dt>First time</dt><dd>".freeze);
|
15
|
+
;
|
16
|
+
;
|
17
|
+
; _buf << ((::Temple::Utils.escape_html((@deprecation[:first_timestamp]&.yield_self { |time| Time.at(time) }))).to_s);
|
18
|
+
;
|
19
|
+
; _buf << ("</dd>".freeze); if @deprecation[:count] > 1;
|
20
|
+
; _buf << ("<dt>Count</dt><dd>".freeze);
|
21
|
+
; _buf << ((::Temple::Utils.escape_html((@deprecation[:count]))).to_s);
|
22
|
+
;
|
23
|
+
; _buf << ("</dd>".freeze); end; _buf << ("<dt>Realm</dt><dd>".freeze);
|
24
|
+
; _buf << ((::Temple::Utils.escape_html((@deprecation[:realm]))).to_s);
|
25
|
+
;
|
26
|
+
; _buf << ("</dd>".freeze); if @deprecation[:ruby_version];
|
27
|
+
; _buf << ("<dt>Ruby</dt><dd>".freeze);
|
28
|
+
; _buf << ((::Temple::Utils.escape_html((@deprecation[:ruby_version]))).to_s);
|
29
|
+
; _buf << ("</dd>".freeze); end; if @deprecation[:rails_version];
|
30
|
+
; _buf << ("<dt>Rails</dt><dd>".freeze);
|
31
|
+
; _buf << ((::Temple::Utils.escape_html((@deprecation[:rails_version]))).to_s);
|
32
|
+
;
|
33
|
+
; _buf << ("</dd>".freeze); end; if @deprecation[:revision];
|
34
|
+
; _buf << ("<dt>Revision</dt><dd>".freeze);
|
35
|
+
; _buf << ((::Temple::Utils.escape_html((@deprecation[:revision]))).to_s);
|
36
|
+
; _buf << ("</dd>".freeze); end; if @deprecation[:hostname];
|
37
|
+
; _buf << ("<dt>Hostname</dt><dd>".freeze);
|
38
|
+
; _buf << ((::Temple::Utils.escape_html((@deprecation[:hostname]))).to_s);
|
39
|
+
;
|
40
|
+
; _buf << ("</dd>".freeze); end; if @deprecation[:context];
|
41
|
+
; _buf << ("<dt>Context</dt><dd><div class=\"card p-3\"><pre><code>".freeze);
|
42
|
+
;
|
43
|
+
;
|
44
|
+
;
|
45
|
+
; _buf << ((::Temple::Utils.escape_html((JSON.pretty_generate(@deprecation[:context])))).to_s);
|
46
|
+
;
|
47
|
+
; _buf << ("</code></pre></div></dd>".freeze); end; if @deprecation[:app_traceline];
|
48
|
+
; _buf << ("<dt>App traceline</dt><dd>".freeze);
|
49
|
+
;
|
50
|
+
; location, function = @deprecation[:app_traceline].split(':in `', 2);
|
51
|
+
; _buf << ("<code class=\"code_location\">".freeze); _buf << ((::Temple::Utils.escape_html((location))).to_s);
|
52
|
+
; _buf << ("</code> <i>".freeze); _buf << ((::Temple::Utils.escape_html((function.delete_suffix("'")))).to_s);
|
53
|
+
;
|
54
|
+
; _buf << ("</i></dd>".freeze); end; if @deprecation[:gem_traceline];
|
55
|
+
; _buf << ("<dt>Gem traceline</dt><dd>".freeze);
|
56
|
+
;
|
57
|
+
; location, function = @deprecation[:gem_traceline].split(':in `', 2);
|
58
|
+
; full_gemname = location.delete_prefix('/gems/').gsub(%r{/.*}, '');
|
59
|
+
; location_in_gem = location.delete_prefix("/gems/#{full_gemname}/");
|
60
|
+
; _buf << ("<i>".freeze); _buf << ((::Temple::Utils.escape_html((full_gemname))).to_s);
|
61
|
+
; _buf << ("</i> <code class=\"code_location\"".freeze); _slim_codeattributes3 = location_in_gem; if _slim_codeattributes3; if _slim_codeattributes3 == true; _buf << (" data-copy-value=\"\"".freeze); else; _buf << (" data-copy-value=\"".freeze); _buf << ((::Temple::Utils.escape_html((_slim_codeattributes3))).to_s); _buf << ("\"".freeze); end; end; _buf << (">".freeze); _buf << ((::Temple::Utils.escape_html((location_in_gem.delete_prefix('lib/')))).to_s);
|
62
|
+
; _buf << ("</code> <i>".freeze); _buf << ((::Temple::Utils.escape_html((function.delete_suffix("'")))).to_s);
|
63
|
+
;
|
64
|
+
; _buf << ("</i></dd>".freeze); end; if @deprecation[:full_backtrace];
|
65
|
+
; _buf << ("<dt>Backtrace</dt><dd>".freeze);
|
66
|
+
;
|
67
|
+
; @deprecation[:full_backtrace].each do |trace_line|;
|
68
|
+
; _buf << ("<div class=\"trace-line\">".freeze);
|
69
|
+
; location, function = trace_line.split(':in `', 2);
|
70
|
+
; _buf << ("<code class=\"code_location\">".freeze); _buf << ((::Temple::Utils.escape_html((location))).to_s);
|
71
|
+
; _buf << ("</code> <i>".freeze); _buf << ((::Temple::Utils.escape_html((function.delete_suffix("'")))).to_s);
|
72
|
+
;
|
73
|
+
; _buf << ("</i></div>".freeze); end; _buf << ("</dd>".freeze); end; fields_to_reject = %i[message first_timestamp count realm app_traceline gem_traceline full_backtrace ruby_version rails_version context revision hostname digest_base digest].to_set;
|
74
|
+
; additional_data = @deprecation.reject { |key,_val| fields_to_reject.include?(key) };
|
75
|
+
; if additional_data.size > 0;
|
76
|
+
; _buf << ("<dt>Additional data <div class=\"card p-3\"><pre><code>".freeze);
|
77
|
+
;
|
78
|
+
;
|
79
|
+
;
|
80
|
+
; _buf << ((::Temple::Utils.escape_html((JSON.pretty_generate additional_data))).to_s);
|
81
|
+
; _buf << ("</code></pre></div></dt>".freeze); end; _buf << ("</dl><a".freeze); _slim_codeattributes4 = deprecation_path(params[:id], format: 'json'); 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 << (">Raw json</a></main>".freeze);
|
82
|
+
; _buf
|
@@ -4,9 +4,10 @@ require "erb"
|
|
4
4
|
require "rack/content_length"
|
5
5
|
require "rack/builder"
|
6
6
|
|
7
|
-
require_relative
|
7
|
+
require_relative "web/application"
|
8
8
|
|
9
9
|
class DeprecationCollector
|
10
|
+
# rack app with a html interface to deprecation collector with a persistent storage like redis
|
10
11
|
class Web
|
11
12
|
attr_accessor :import_enabled
|
12
13
|
|
@@ -28,6 +29,7 @@ class DeprecationCollector
|
|
28
29
|
end
|
29
30
|
|
30
31
|
private
|
32
|
+
|
31
33
|
def build
|
32
34
|
web = self
|
33
35
|
::Rack::Builder.new do
|