deprecation_collector 0.6.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e119a79e2c879e9e0ec02476523620eab84c6ae4c354d382207cd8be6bde7a9a
4
- data.tar.gz: e2f7f495ee705f5dada2456b425fa739a9a67b801dce461c86e5f4a04c6266d0
3
+ metadata.gz: 7d5a792b37d7fef7db54b766c8486202f0058019c3fbe668dc62a3b0845cdd18
4
+ data.tar.gz: e9bf64acfd1113253f65b24d85927e4a1c8ccb6252d2286d8589f09ac6ed0d25
5
5
  SHA512:
6
- metadata.gz: 8857214426445395aa62c0c56dae0d598d5f673f2d1b8d42bd00a7a8ba1ef037513ca5449a93c182f0556ef45fe6e6345bd798ffa2137a7e78f92f5f1902f0a1
7
- data.tar.gz: 9de452b1a5d98b40777ac59224e57a134368ae91c9c24ecc7d792a199c66fd5f92c22d62689c6cadbc409d3d330057d4c487e50f6100dc697ea5295b83761066
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['lib/**/*', 'sig/**/*', '*.md', '*.txt', '*.gemspec'].select { |f| File.file?(f) }
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
- ActiveSupport::Deprecation.behavior = lambda do |message, callstack, deprecation_horizon, gem_name|
22
- # not polite to turn off all other possible behaviors, but otherwise may get duplicate calls
23
- DeprecationCollector.collect(message, callstack, :rails)
24
- ActiveSupport::Deprecation::DEFAULT_BEHAVIORS[stock_activesupport_behavior].call(
25
- message, callstack, deprecation_horizon, gem_name
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class DeprecationCollector
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.1"
5
5
  end
@@ -50,7 +50,10 @@ class DeprecationCollector
50
50
  def trigger_rails_deprecation
51
51
  return unless defined?(ActiveSupport::Deprecation)
52
52
 
53
- -> { ActiveSupport::Deprecation.warn("Test deprecation") } []
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)
@@ -172,6 +172,8 @@ class DeprecationCollector
172
172
  }
173
173
 
174
174
  return [status, { "content-type" => "text/html" }.merge(color_scheme_headers), [html.to_s]] if html
175
+
176
+ nil
175
177
  end
176
178
 
177
179
  VIEW_PATH = "#{__dir__}/views"
@@ -44,10 +44,10 @@ class DeprecationCollector
44
44
 
45
45
  yield instance if block_given?
46
46
  instance.fetch_known_digests
47
-
48
- install_collectors
49
47
  end
50
48
 
49
+ install_collectors
50
+
51
51
  @instance
52
52
  end
53
53
 
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.6.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-09-21 00:00:00.000000000 Z
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.4.10
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