deprecation_collector 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +10 -0
- data/deprecation_collector.gemspec +1 -3
- data/lib/deprecation_collector/collectors.rb +32 -6
- data/lib/deprecation_collector/version.rb +1 -1
- data/lib/deprecation_collector/web/helpers.rb +6 -1
- data/lib/deprecation_collector/web/router.rb +2 -0
- data/lib/deprecation_collector.rb +2 -2
- metadata +2 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26bc69b0016762d0f5e8546f48177a7b2d90334bc8f4c995853c51e814386731
|
4
|
+
data.tar.gz: d059f4d6985f9136305160d0e0a6ffe184a6ac1a927e31959241e525974d78ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a4609b79edbf7f54aa11538a7201595951ced8194d2a65fd01f4ef9be21cc75719fb27c1e0debbfcad5be2fc5407a9e8a04a6b398e7af2bc19c196461017437
|
7
|
+
data.tar.gz: 70f742f7dbd0525ee444c5aa076ccd241f1b8b5acd7c20a10b8778e838a40b3ba383dffd2b58b8776da6bc978583775f16104e89db5d1f1746bfe03e6e1ef8a3
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -55,6 +55,16 @@ Rails.application.routes.draw do
|
|
55
55
|
end
|
56
56
|
```
|
57
57
|
|
58
|
+
usually it's a good idea to secure the ui in some way, you can use rails route constraint (actual check will depend on your app):
|
59
|
+
```ruby
|
60
|
+
Rails.application.routes.draw do
|
61
|
+
constraints(->(request) { request.session[:admin] }) do
|
62
|
+
require 'deprecation_collector/web'
|
63
|
+
mount DeprecationCollector::Web => '/deprecations', as: :deprecations
|
64
|
+
end
|
65
|
+
end
|
66
|
+
```
|
67
|
+
|
58
68
|
## Development
|
59
69
|
|
60
70
|
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.
|
@@ -18,10 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.metadata["source_code_uri"] = "https://github.com/Vasfed/deprecation_collector"
|
19
19
|
spec.metadata["changelog_uri"] = "https://github.com/Vasfed/deprecation_collector/blob/main/CHANGELOG.md"
|
20
20
|
|
21
|
-
spec.files = Dir[
|
21
|
+
spec.files = Dir["lib/**/*", "sig/**/*", "*.md", "*.txt", "*.gemspec"].select { |filename| File.file?(filename) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
24
|
spec.add_dependency "redis", ">= 3.0"
|
25
|
-
spec.add_development_dependency "appraisal"
|
26
|
-
spec.add_development_dependency "rack-test"
|
27
25
|
end
|
@@ -2,6 +2,27 @@
|
|
2
2
|
|
3
3
|
# :nodoc:
|
4
4
|
class DeprecationCollector
|
5
|
+
ACTIVE_SUPPORT_BEHAVIORS = {
|
6
|
+
rails71: ->(message, callstack, deprecator) do
|
7
|
+
# TODO: use deprecator.gem_name, deprecator.deprecation_horizon
|
8
|
+
DeprecationCollector.collect(message, callstack, :rails)
|
9
|
+
ActiveSupport::Deprecation::DEFAULT_BEHAVIORS[stock_activesupport_behavior].call(message, callstack, deprecator)
|
10
|
+
end,
|
11
|
+
legacy: ->(message, callstack, deprecation_horizon, gem_name) do
|
12
|
+
DeprecationCollector.collect(message, callstack, :rails)
|
13
|
+
ActiveSupport::Deprecation::DEFAULT_BEHAVIORS[stock_activesupport_behavior].call(
|
14
|
+
message, callstack, deprecation_horizon, gem_name
|
15
|
+
)
|
16
|
+
end
|
17
|
+
}.freeze
|
18
|
+
|
19
|
+
# for intercepting deprecations from deprecators not installed in Rails.application.deprecators
|
20
|
+
module ActiveSupportDeprecationCollectionPatch
|
21
|
+
def behavior
|
22
|
+
@behavior ||= [DeprecationCollector::ACTIVE_SUPPORT_BEHAVIORS[:rails71]]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
5
26
|
class << self
|
6
27
|
protected
|
7
28
|
|
@@ -18,12 +39,17 @@ class DeprecationCollector
|
|
18
39
|
|
19
40
|
def tap_activesupport
|
20
41
|
# TODO: a more polite hook
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
42
|
+
# not polite to turn off all other possible behaviors, but otherwise may get duplicate calls
|
43
|
+
if Rails.respond_to?(:gem_version) && Rails.gem_version >= "7.1"
|
44
|
+
Rails.application.deprecators.behavior = ACTIVE_SUPPORT_BEHAVIORS[:rails71] if Rails.application&.deprecators
|
45
|
+
# Rails.application.deprecators.behavior only captures new-style deprecations, but we need all:
|
46
|
+
if ActiveSupport::Deprecation.respond_to?(:_instance)
|
47
|
+
ActiveSupport::Deprecation._instance.behavior = ACTIVE_SUPPORT_BEHAVIORS[:rails71]
|
48
|
+
end
|
49
|
+
# collect deprecations from deprecators that are not installed in `Rails.application.deprecators`
|
50
|
+
ActiveSupport::Deprecation.prepend(ActiveSupportDeprecationCollectionPatch)
|
51
|
+
else
|
52
|
+
ActiveSupport::Deprecation.behavior = ACTIVE_SUPPORT_BEHAVIORS[:legacy]
|
27
53
|
end
|
28
54
|
end
|
29
55
|
|
@@ -50,7 +50,10 @@ class DeprecationCollector
|
|
50
50
|
def trigger_rails_deprecation
|
51
51
|
return unless defined?(ActiveSupport::Deprecation)
|
52
52
|
|
53
|
-
|
53
|
+
deprecator = ActiveSupport::Deprecation
|
54
|
+
deprecator = ActiveSupport::Deprecation.new("0.0", "deprecation_collector") if Rails.gem_version >= "7.1"
|
55
|
+
|
56
|
+
-> { deprecator.warn("Test deprecation") } []
|
54
57
|
end
|
55
58
|
|
56
59
|
def current_color_theme
|
@@ -65,6 +68,8 @@ class DeprecationCollector
|
|
65
68
|
msg = deprecation[:message].to_s
|
66
69
|
return :kwargs if msg.include?("Using the last argument as keyword parameters is deprecated") ||
|
67
70
|
msg.include?("Passing the keyword argument as the last hash parameter is deprecated")
|
71
|
+
|
72
|
+
nil
|
68
73
|
end
|
69
74
|
|
70
75
|
def test_deprecation?(deprecation)
|
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.7.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-
|
11
|
+
date: 2023-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -24,34 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: appraisal
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rack-test
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
27
|
description: Collects and aggregates warnings and deprecations. Optimized for production
|
56
28
|
environment.
|
57
29
|
email:
|