deprecation_collector 0.2.0 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21042fb4a7a9045647774128efd65fd4a27b182b6122738a0407da13af1b8786
4
- data.tar.gz: eef445a5a47d88e3b7dc55f90ee07f9cfda0539b2a059ce7bc5286773a5d17e3
3
+ metadata.gz: e47433dbbd3b8de0913751e91d7c599ceae4061f33a97e335082f797d3f15a85
4
+ data.tar.gz: bfd2daa42a714075654550d8c262c5fed7398109c9a6bb0c6167e3c50e9831fc
5
5
  SHA512:
6
- metadata.gz: a0309b7c02fcfe4f458feed01b3f3dd37d8510269c8b5b1296cbc545be250d73bb232bdd6a0d8a41595cadf2e268baefa60b0c0158eb87bb8bb186072560056c
7
- data.tar.gz: 736342d4de1fef5b3326f1866f01b22e4642792a013853b849ed1ba42a32e68bc93c843f332d83b824e6f7a840b3364dc83acbfaf2f1c34c4e634bbfc21c94ff
6
+ metadata.gz: c16f77432e628e0ab52d0753a2083fbba24c9f0b847dba9b93401b6700c88831f6dea334a4ce2f48a85ede6ee3646737075b4aadc419717d024d48a3bc0a82bd
7
+ data.tar.gz: '025851292e3ba3b80ef8b7e232bb4900eef50a83948b58f2cc70ef1e15ea1cf6f9bd959f126360690cdbcca5a88c926ea04c25733d2aadfb24ef0078359ab8c5'
data/Gemfile CHANGED
@@ -25,3 +25,9 @@ end
25
25
 
26
26
  gem "fakeredis"
27
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.2.0)
4
+ deprecation_collector (0.3.0)
5
5
  redis (>= 3.0)
6
6
 
7
7
  GEM
@@ -117,7 +117,7 @@ GEM
117
117
  parser (3.1.3.0)
118
118
  ast (~> 2.4.1)
119
119
  racc (1.6.2)
120
- rack (2.2.4)
120
+ rack (2.2.7)
121
121
  rack-test (2.0.2)
122
122
  rack (>= 1.3)
123
123
  rails (6.0.6)
@@ -194,6 +194,9 @@ GEM
194
194
  simplecov_json_formatter (~> 0.1)
195
195
  simplecov-html (0.12.3)
196
196
  simplecov_json_formatter (0.1.4)
197
+ slim (5.1.0)
198
+ temple (~> 0.10.0)
199
+ tilt (>= 2.0.6, < 2.2)
197
200
  sprockets (4.1.1)
198
201
  concurrent-ruby (~> 1.0)
199
202
  rack (> 1, < 3)
@@ -201,13 +204,16 @@ GEM
201
204
  actionpack (>= 5.2)
202
205
  activesupport (>= 5.2)
203
206
  sprockets (>= 3.0.0)
207
+ temple (0.10.0)
204
208
  thor (1.2.1)
205
209
  thread_safe (0.3.6)
210
+ tilt (2.1.0)
206
211
  timecop (0.9.6)
207
212
  timeout (0.3.1)
208
213
  tzinfo (1.2.10)
209
214
  thread_safe (~> 0.1)
210
215
  unicode-display_width (2.3.0)
216
+ webrick (1.8.1)
211
217
  websocket-driver (0.7.5)
212
218
  websocket-extensions (>= 0.1.0)
213
219
  websocket-extensions (0.1.5)
@@ -223,6 +229,7 @@ DEPENDENCIES
223
229
  appraisal
224
230
  deprecation_collector!
225
231
  fakeredis
232
+ rack
226
233
  rails (~> 6.0.0)
227
234
  rake (~> 13.0)
228
235
  redis (~> 4.8)
@@ -233,7 +240,9 @@ DEPENDENCIES
233
240
  rubocop-rake
234
241
  rubocop-rspec
235
242
  simplecov
243
+ slim
236
244
  timecop
245
+ webrick
237
246
 
238
247
  BUNDLED WITH
239
248
  2.3.10
data/README.md CHANGED
@@ -45,6 +45,16 @@ Add an initializer with configuration, like
45
45
  end
46
46
  ```
47
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
+
48
58
  ## Development
49
59
 
50
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,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class DeprecationCollector
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
@@ -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
+ '&' => '&amp;',
35
+ '"' => '&quot;',
36
+ '\'' => '&#39;',
37
+ '<' => '&lt;',
38
+ '>' => '&gt;'
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
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.2.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: 2023-01-17 00:00:00.000000000 Z
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: