deprecation_collector 0.6.0 → 0.7.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/CHANGELOG.md +7 -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 +3 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d5a792b37d7fef7db54b766c8486202f0058019c3fbe668dc62a3b0845cdd18
|
4
|
+
data.tar.gz: e9bf64acfd1113253f65b24d85927e4a1c8ccb6252d2286d8589f09ac6ed0d25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8a04a651d8ba60c16c88c1c9e094929567b7bfae8a0f15884aeb0c673cfff8ec351dd444a7daa28b3431e08a9ed29ebe22d4bb64406d8e8fec6dc39f2bcd5b3
|
7
|
+
data.tar.gz: 5619c9376153423a2573a18cc16bfa37ea5c1053eab7c79d782c66a44bdaea97cf6d2ecac5e7f0f3a6ba2ed74eec3fd6fd594289ed1d228010c7b29dec5fa4e5
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 0.7.1
|
2
|
+
- fix ruby 2.7 on rails 7.1
|
3
|
+
|
4
|
+
== 0.7.0
|
5
|
+
- support for Rails 7.1
|
6
|
+
- make install critical section smaller to prevent installation deprecations preventing installation
|
7
|
+
|
1
8
|
== 0.6.0
|
2
9
|
- added active_record storage
|
3
10
|
- redis dependency will become optional in v1.0
|
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 >= Gem::Version.new("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 >= Gem::Version.new("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.1
|
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-30 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:
|
@@ -106,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
78
|
- !ruby/object:Gem::Version
|
107
79
|
version: '0'
|
108
80
|
requirements: []
|
109
|
-
rubygems_version: 3.
|
81
|
+
rubygems_version: 3.1.6
|
110
82
|
signing_key:
|
111
83
|
specification_version: 4
|
112
84
|
summary: Collector for ruby/rails deprecations and warnings, suitable for production
|