deprecation_collector 0.2.0 → 0.4.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.
@@ -1,73 +1,73 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- deprecation_collector (0.2.0)
4
+ deprecation_collector (0.4.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.1)
11
- actionpack (= 7.0.4.1)
12
- activesupport (= 7.0.4.1)
10
+ actioncable (7.0.4.3)
11
+ actionpack (= 7.0.4.3)
12
+ activesupport (= 7.0.4.3)
13
13
  nio4r (~> 2.0)
14
14
  websocket-driver (>= 0.6.1)
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)
15
+ actionmailbox (7.0.4.3)
16
+ actionpack (= 7.0.4.3)
17
+ activejob (= 7.0.4.3)
18
+ activerecord (= 7.0.4.3)
19
+ activestorage (= 7.0.4.3)
20
+ activesupport (= 7.0.4.3)
21
21
  mail (>= 2.7.1)
22
22
  net-imap
23
23
  net-pop
24
24
  net-smtp
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)
25
+ actionmailer (7.0.4.3)
26
+ actionpack (= 7.0.4.3)
27
+ actionview (= 7.0.4.3)
28
+ activejob (= 7.0.4.3)
29
+ activesupport (= 7.0.4.3)
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.1)
36
- actionview (= 7.0.4.1)
37
- activesupport (= 7.0.4.1)
35
+ actionpack (7.0.4.3)
36
+ actionview (= 7.0.4.3)
37
+ activesupport (= 7.0.4.3)
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.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)
42
+ actiontext (7.0.4.3)
43
+ actionpack (= 7.0.4.3)
44
+ activerecord (= 7.0.4.3)
45
+ activestorage (= 7.0.4.3)
46
+ activesupport (= 7.0.4.3)
47
47
  globalid (>= 0.6.0)
48
48
  nokogiri (>= 1.8.5)
49
- actionview (7.0.4.1)
50
- activesupport (= 7.0.4.1)
49
+ actionview (7.0.4.3)
50
+ activesupport (= 7.0.4.3)
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.1)
56
- activesupport (= 7.0.4.1)
55
+ activejob (7.0.4.3)
56
+ activesupport (= 7.0.4.3)
57
57
  globalid (>= 0.3.6)
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)
58
+ activemodel (7.0.4.3)
59
+ activesupport (= 7.0.4.3)
60
+ activerecord (7.0.4.3)
61
+ activemodel (= 7.0.4.3)
62
+ activesupport (= 7.0.4.3)
63
+ activestorage (7.0.4.3)
64
+ actionpack (= 7.0.4.3)
65
+ activejob (= 7.0.4.3)
66
+ activerecord (= 7.0.4.3)
67
+ activesupport (= 7.0.4.3)
68
68
  marcel (~> 1.0)
69
69
  mini_mime (>= 1.1.0)
70
- activesupport (7.0.4.1)
70
+ activesupport (7.0.4.3)
71
71
  concurrent-ruby (~> 1.0, >= 1.0.2)
72
72
  i18n (>= 1.6, < 2)
73
73
  minitest (>= 5.1)
@@ -77,21 +77,21 @@ GEM
77
77
  rake
78
78
  thor (>= 0.14.0)
79
79
  builder (3.2.4)
80
- concurrent-ruby (1.1.10)
80
+ concurrent-ruby (1.2.2)
81
81
  crass (1.0.6)
82
82
  date (3.3.3)
83
83
  diff-lcs (1.5.0)
84
84
  erubi (1.12.0)
85
- fakeredis (0.8.0)
86
- redis (~> 4.1)
87
- globalid (1.0.0)
85
+ fakeredis (0.9.1)
86
+ redis (~> 4.8)
87
+ globalid (1.1.0)
88
88
  activesupport (>= 5.0)
89
- i18n (1.12.0)
89
+ i18n (1.13.0)
90
90
  concurrent-ruby (~> 1.0)
91
- loofah (2.19.1)
91
+ loofah (2.20.0)
92
92
  crass (~> 1.0.2)
93
93
  nokogiri (>= 1.5.9)
94
- mail (2.8.0.1)
94
+ mail (2.8.1)
95
95
  mini_mime (>= 0.1.1)
96
96
  net-imap
97
97
  net-pop
@@ -99,7 +99,7 @@ GEM
99
99
  marcel (1.0.2)
100
100
  method_source (1.0.0)
101
101
  mini_mime (1.1.2)
102
- minitest (5.17.0)
102
+ minitest (5.18.0)
103
103
  net-imap (0.3.4)
104
104
  date
105
105
  net-protocol
@@ -109,65 +109,71 @@ GEM
109
109
  timeout
110
110
  net-smtp (0.3.3)
111
111
  net-protocol
112
- nio4r (2.5.8)
113
- nokogiri (1.14.0-x86_64-darwin)
112
+ nio4r (2.5.9)
113
+ nokogiri (1.14.3-x86_64-darwin)
114
114
  racc (~> 1.4)
115
- nokogiri (1.14.0-x86_64-linux)
115
+ nokogiri (1.14.3-x86_64-linux)
116
116
  racc (~> 1.4)
117
117
  racc (1.6.2)
118
- rack (2.2.6.1)
119
- rack-test (2.0.2)
118
+ rack (2.2.7)
119
+ rack-test (2.1.0)
120
120
  rack (>= 1.3)
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)
121
+ rails (7.0.4.3)
122
+ actioncable (= 7.0.4.3)
123
+ actionmailbox (= 7.0.4.3)
124
+ actionmailer (= 7.0.4.3)
125
+ actionpack (= 7.0.4.3)
126
+ actiontext (= 7.0.4.3)
127
+ actionview (= 7.0.4.3)
128
+ activejob (= 7.0.4.3)
129
+ activemodel (= 7.0.4.3)
130
+ activerecord (= 7.0.4.3)
131
+ activestorage (= 7.0.4.3)
132
+ activesupport (= 7.0.4.3)
133
133
  bundler (>= 1.15.0)
134
- railties (= 7.0.4.1)
134
+ railties (= 7.0.4.3)
135
135
  rails-dom-testing (2.0.3)
136
136
  activesupport (>= 4.2.0)
137
137
  nokogiri (>= 1.6)
138
- rails-html-sanitizer (1.4.4)
138
+ rails-html-sanitizer (1.5.0)
139
139
  loofah (~> 2.19, >= 2.19.1)
140
- railties (7.0.4.1)
141
- actionpack (= 7.0.4.1)
142
- activesupport (= 7.0.4.1)
140
+ railties (7.0.4.3)
141
+ actionpack (= 7.0.4.3)
142
+ activesupport (= 7.0.4.3)
143
143
  method_source
144
144
  rake (>= 12.2)
145
145
  thor (~> 1.0)
146
146
  zeitwerk (~> 2.5)
147
147
  rake (13.0.6)
148
- redis (4.8.0)
148
+ redis (4.8.1)
149
149
  rspec (3.12.0)
150
150
  rspec-core (~> 3.12.0)
151
151
  rspec-expectations (~> 3.12.0)
152
152
  rspec-mocks (~> 3.12.0)
153
- rspec-core (3.12.0)
153
+ rspec-core (3.12.2)
154
154
  rspec-support (~> 3.12.0)
155
- rspec-expectations (3.12.2)
155
+ rspec-expectations (3.12.3)
156
156
  diff-lcs (>= 1.2.0, < 2.0)
157
157
  rspec-support (~> 3.12.0)
158
- rspec-mocks (3.12.3)
158
+ rspec-mocks (3.12.5)
159
159
  diff-lcs (>= 1.2.0, < 2.0)
160
160
  rspec-support (~> 3.12.0)
161
161
  rspec-support (3.12.0)
162
+ slim (5.1.0)
163
+ temple (~> 0.10.0)
164
+ tilt (>= 2.0.6, < 2.2)
165
+ temple (0.10.0)
162
166
  thor (1.2.1)
167
+ tilt (2.1.0)
163
168
  timecop (0.9.6)
164
- timeout (0.3.1)
165
- tzinfo (2.0.5)
169
+ timeout (0.3.2)
170
+ tzinfo (2.0.6)
166
171
  concurrent-ruby (~> 1.0)
172
+ webrick (1.8.1)
167
173
  websocket-driver (0.7.5)
168
174
  websocket-extensions (>= 0.1.0)
169
175
  websocket-extensions (0.1.5)
170
- zeitwerk (2.6.6)
176
+ zeitwerk (2.6.7)
171
177
 
172
178
  PLATFORMS
173
179
  x86_64-darwin-21
@@ -177,11 +183,15 @@ DEPENDENCIES
177
183
  appraisal
178
184
  deprecation_collector!
179
185
  fakeredis
186
+ rack
187
+ rack-test
180
188
  rails (~> 7.0)
181
189
  rake (~> 13.0)
182
190
  redis (~> 4.8)
183
191
  rspec (~> 3.0)
192
+ slim
184
193
  timecop
194
+ webrick
185
195
 
186
196
  BUNDLED WITH
187
197
  2.3.10
@@ -7,5 +7,8 @@ gem "rspec", "~> 3.0"
7
7
  gem "timecop"
8
8
  gem "fakeredis"
9
9
  gem "redis", "~>4.8"
10
+ gem "rack"
11
+ gem "webrick"
12
+ gem "slim"
10
13
 
11
14
  gemspec path: "../"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- deprecation_collector (0.2.0)
4
+ deprecation_collector (0.4.0)
5
5
  redis (>= 3.0)
6
6
 
7
7
  GEM
@@ -12,25 +12,34 @@ GEM
12
12
  rake
13
13
  thor (>= 0.14.0)
14
14
  diff-lcs (1.5.0)
15
- fakeredis (0.8.0)
16
- redis (~> 4.1)
15
+ fakeredis (0.9.1)
16
+ redis (~> 4.8)
17
+ rack (3.0.7)
18
+ rack-test (2.1.0)
19
+ rack (>= 1.3)
17
20
  rake (13.0.6)
18
- redis (4.8.0)
21
+ redis (4.8.1)
19
22
  rspec (3.12.0)
20
23
  rspec-core (~> 3.12.0)
21
24
  rspec-expectations (~> 3.12.0)
22
25
  rspec-mocks (~> 3.12.0)
23
- rspec-core (3.12.0)
26
+ rspec-core (3.12.2)
24
27
  rspec-support (~> 3.12.0)
25
- rspec-expectations (3.12.2)
28
+ rspec-expectations (3.12.3)
26
29
  diff-lcs (>= 1.2.0, < 2.0)
27
30
  rspec-support (~> 3.12.0)
28
- rspec-mocks (3.12.3)
31
+ rspec-mocks (3.12.5)
29
32
  diff-lcs (>= 1.2.0, < 2.0)
30
33
  rspec-support (~> 3.12.0)
31
34
  rspec-support (3.12.0)
35
+ slim (5.1.0)
36
+ temple (~> 0.10.0)
37
+ tilt (>= 2.0.6, < 2.2)
38
+ temple (0.10.0)
32
39
  thor (1.2.1)
40
+ tilt (2.1.0)
33
41
  timecop (0.9.6)
42
+ webrick (1.8.1)
34
43
 
35
44
  PLATFORMS
36
45
  x86_64-darwin-21
@@ -40,10 +49,14 @@ DEPENDENCIES
40
49
  appraisal
41
50
  deprecation_collector!
42
51
  fakeredis
52
+ rack
53
+ rack-test
43
54
  rake (~> 13.0)
44
55
  redis (~> 4.8)
45
56
  rspec (~> 3.0)
57
+ slim
46
58
  timecop
59
+ webrick
47
60
 
48
61
  BUNDLED WITH
49
62
  2.3.10
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class DeprecationCollector
4
- VERSION = "0.2.0"
4
+ VERSION = "0.4.0"
5
5
  end
@@ -0,0 +1,94 @@
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
+ attr_reader :web
14
+ def initialize(web)
15
+ @web = web
16
+ unless defined?(Temple::Utils) || ENV['DEPRECATION_COLLECTOR_RELOAD_WEB_TEMPLATES']
17
+ # used for escaping in compiled slim templates
18
+ require_relative 'utils'
19
+ end
20
+ end
21
+
22
+ def call(env)
23
+ self.class.call(env, self)
24
+ end
25
+
26
+ root do # index
27
+ @deprecations = collector_instance.read_each.to_a.compact
28
+ @deprecations = @deprecations.sort_by { |dep| dep[:message] } unless params[:sort] == '0'
29
+
30
+ if params[:reject]
31
+ @deprecations = @deprecations.reject { |dep| dep[:message].match?(Regexp.union(Array(params[:reject]))) }
32
+ end
33
+
34
+ if params[:realm]
35
+ @deprecations = @deprecations.select { |dep| dep[:realm].match?(Regexp.union(Array(params[:realm]))) }
36
+ end
37
+
38
+ render slim: "index.html"
39
+ end
40
+
41
+ get '/dump.json' do
42
+ render json: collector_instance.dump
43
+ end
44
+
45
+ get '/import' do
46
+ return "Import not enabled" unless import_enabled?
47
+
48
+ render slim: "import.html"
49
+ end
50
+
51
+ post '/import' do
52
+ halt 422, "need multipart json file" unless env['CONTENT_TYPE']&.start_with?('multipart/form-data') && params.dig(:file, :tempfile)
53
+ collector_instance.import_dump(File.read(params[:file][:tempfile]))
54
+ redirect_to deprecations_path
55
+ end
56
+
57
+ get '/:id' do # show
58
+ @deprecation = collector_instance.read_one(params[:id])
59
+ render slim: "show.html"
60
+ end
61
+
62
+ delete '/all' do
63
+ collector_instance.flush_redis
64
+ redirect_to deprecations_path
65
+ end
66
+
67
+ post '/enable' do
68
+ collector_instance.enable
69
+ redirect_to deprecations_path
70
+ end
71
+
72
+ delete '/disable' do
73
+ collector_instance.disable
74
+ redirect_to deprecations_path
75
+ end
76
+
77
+ # NB: order for wildcards is important
78
+ delete '/:id' do # destroy
79
+ collector_instance.delete_deprecations([params[:id]])
80
+ redirect_to deprecations_path
81
+ end
82
+
83
+ post '/trigger' do # trigger
84
+ trigger_kwargs_error_warning({ foo: nil }) if RUBY_VERSION.start_with?('2.7')
85
+ trigger_rails_deprecation
86
+ collector_instance.collect(
87
+ "TestFoo#assign_attributes called (test attr_spy) trigger_rails_deprecation", caller_locations, :attr_spy
88
+ )
89
+ collector_instance.write_to_redis(force: true)
90
+ redirect_to deprecations_path
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,76 @@
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 import_enabled?
11
+ @web.import_enabled
12
+ end
13
+
14
+ def root_path
15
+ # request.base_url ?
16
+ "#{env["SCRIPT_NAME"]}/"
17
+ end
18
+
19
+ def current_path
20
+ @current_path ||= request.path_info.gsub(/^\//, "")
21
+ end
22
+
23
+ def deprecations_path
24
+ "#{root_path}"
25
+ end
26
+
27
+ def deprecation_path(id)
28
+ "#{root_path}#{id}"
29
+ end
30
+
31
+ def enable_deprecations_path
32
+ "#{root_path}enable"
33
+ end
34
+
35
+ def disable_deprecations_path
36
+ "#{root_path}disable"
37
+ end
38
+
39
+ def dump_deprecations_path
40
+ "#{root_path}dump.json"
41
+ end
42
+
43
+ def import_deprecations_path
44
+ "#{root_path}import"
45
+ end
46
+
47
+ def trigger_kwargs_error_warning(foo: nil); end
48
+
49
+ def trigger_rails_deprecation
50
+ return unless defined?(ActiveSupport::Deprecation)
51
+ -> { ActiveSupport::Deprecation.warn("Test deprecation") } []
52
+ end
53
+
54
+ def current_color_theme
55
+ return 'dark' if params['dark']
56
+ return 'light' if params['light']
57
+ return 'dark' if request.get_header('HTTP_Sec_CH_Prefers_Color_Scheme').to_s.downcase.include?("dark")
58
+ 'auto'
59
+ end
60
+
61
+ def deprecation_tags(deprecation)
62
+ {}.tap do |tags|
63
+ tags[:kwargs] = 'bg-secondary' if deprecation[:message].include?("Using the last argument as keyword parameters is deprecated") ||
64
+ deprecation[:message].include?("Passing the keyword argument as the last hash parameter is deprecated")
65
+
66
+ tags[:test] = 'bg-success' if deprecation[:message].include?("trigger_kwargs_error_warning") ||
67
+ deprecation[:message].include?("trigger_rails_deprecation")
68
+
69
+ tags[deprecation[:realm]] = 'bg-secondary' if deprecation[:realm] && deprecation[:realm] != 'rails'
70
+
71
+ deprecation.dig(:notes, :tags)&.each { |tag| tags[tag] = 'bg-secondary' }
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end