as_deprecation_tracker 1.5.0 → 1.7.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
- SHA1:
3
- metadata.gz: 423aa104af4ca208621d8c1e8eee3c3fb1c1ed4f
4
- data.tar.gz: 841eec03f2e5fec185ff747b9413978d58d44e3f
2
+ SHA256:
3
+ metadata.gz: 94c74b7722e33f69b5743cbfc62be2865ca4c21cca306debf8074a77a7bffdac
4
+ data.tar.gz: 865ab2109f6932f7d6a3b273c96beca663d30f3620f31b0f24c53da51111f6a6
5
5
  SHA512:
6
- metadata.gz: c135f7983f1fda478172f436ef533aa135ae2dabcceaaca184f851614180ebcd1ffc1545d1cbc02d1fabd9ea466351185aa0c54ac0617299308d1b356b954ae7
7
- data.tar.gz: c6fda97efae671f2e1875905bd694903023322e12441677520405698330b3b7970b7be9ea892399ad8b97f39c8ae169f82433e31260ca19bf84e9c6484804fdc
6
+ metadata.gz: 41e1b084ad9861d787f81595f80051785bba2cecd63510a755d60d0c310159d5185afd1a60f05037d71cbe510f26bb7084b687c21e99cb7daec663c7a83aff9d
7
+ data.tar.gz: 5a4e354638d0097fd9089e09e7a52ebb19b0af04d930717a13641ac091c581befc20bab1133e1e289f8bcde75b13dee425e7457f4d4bff730ad94f7621af888e
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: CI
3
+
4
+ on:
5
+ pull_request:
6
+ push:
7
+
8
+
9
+ concurrency:
10
+ group: ${{ github.ref_name }}
11
+ cancel-in-progress: true
12
+
13
+ jobs:
14
+ ruby:
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ ruby_version:
20
+ - '2.7.6'
21
+ - '3.0.4'
22
+ - '3.1.2'
23
+ rails_version:
24
+ - '6.0.5.1'
25
+ - '6.1.6.1'
26
+ - '7.0.3.1'
27
+ - '7.1.6'
28
+ steps:
29
+ - uses: actions/checkout@v2
30
+ - name: Setup Ruby
31
+ uses: ruby/setup-ruby@v1
32
+ with:
33
+ ruby-version: ${{ matrix.ruby_version }}
34
+ bundler-cache: true
35
+ env:
36
+ RAILS_VERSION: ${{ matrix.rails_version }}
37
+ - name: Run tests
38
+ run: bundle exec rake
data/CHANGELOG.md CHANGED
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
 
8
+ ## 1.7.0
9
+
10
+ ### Fixed
11
+ - Fix compatibility with Rails 7.1 (PR thanks to @lhellebr)
12
+
13
+ ## 1.6.0
14
+
15
+ ### Fixed
16
+ - Fix array splat errors under Ruby 3 (PR thanks to @evgeni)
17
+
8
18
  ## 1.5.0
9
19
 
10
20
  ### Added
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2016-2017 Dominic Cleal
1
+ Copyright (c) 2016-2022 Dominic Cleal
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,3 +1,13 @@
1
+ # This gem is deprecated
2
+
3
+ This gem is no longer maintained and users should consider migrating to
4
+ `deprecation_toolkit` instead, which is more likely to work with newer Ruby and
5
+ Rails versions.
6
+
7
+ * [Shopify: Introducing the deprecation toolkit](https://engineering.shopify.com/blogs/engineering/introducing-the-deprecation-toolkit)
8
+ * [deprecation_toolkit (GitHub)](https://github.com/shopify/deprecation_toolkit)
9
+ * [deprecation_toolkit (RubyGems)](https://rubygems.org/gems/deprecation_toolkit)
10
+
1
11
  # as_deprecation_tracker
2
12
 
3
13
  Tracks known ActiveSupport (Rails) deprecation warnings and catches new issues
@@ -143,6 +153,15 @@ initialisation, as deprecation processing can be disabled until the whitelist
143
153
  is fully formed. ASDT will queue events while paused and processes them when
144
154
  `resume!` is called.
145
155
 
156
+ ## Alternatives
157
+
158
+ Shopify have open-sourced a gem that works very similarly to ASDT and is worth
159
+ a look. It supports more configuration options when seeing a new or removed
160
+ deprecation warning, and also supports `Kernel#warn`.
161
+
162
+ * [Shopify: Introducing the deprecation toolkit](https://engineering.shopify.com/blogs/engineering/introducing-the-deprecation-toolkit)
163
+ * [deprecation_toolkit (GitHub)](https://github.com/shopify/deprecation_toolkit)
164
+
146
165
  ## License
147
166
 
148
- Copyright (c) 2016-2017 Dominic Cleal. Distributed under the MIT license.
167
+ Copyright (c) 2016-2022 Dominic Cleal. Distributed under the MIT license.
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'bundler/gem_tasks'
3
4
  require 'rake/testtask'
4
5
  require 'rubocop/rake_task'
@@ -11,4 +12,4 @@ end
11
12
 
12
13
  RuboCop::RakeTask.new
13
14
 
14
- task default: %w(rubocop test)
15
+ task default: %w[rubocop test]
data/config.ru CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'rubygems'
3
4
  require 'bundler'
4
5
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module ASDeprecationTracker
3
4
  # Maintains configuration for one instance (usually global)
4
5
  class Configuration
@@ -6,7 +7,7 @@ module ASDeprecationTracker
6
7
  alias register_behavior? register_behavior
7
8
 
8
9
  def initialize
9
- @envs = %w(test)
10
+ @envs = %w[test]
10
11
  @line_tolerance = 10
11
12
  @register_behavior = ASDeprecationTracker.env('DISABLE').nil?
12
13
  @whitelist_file = File.join('config', 'as_deprecation_whitelist.yaml')
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'as_deprecation_tracker/receiver'
3
4
 
4
5
  module ASDeprecationTracker
@@ -6,7 +7,16 @@ module ASDeprecationTracker
6
7
  class Railtie < ::Rails::Railtie
7
8
  initializer 'as_deprecation_tracker.deprecation_notifications', after: :load_environment_config, if: -> { ASDeprecationTracker.active? } do
8
9
  Receiver.attach_to :rails, ASDeprecationTracker.receiver
9
- ActiveSupport::Deprecation.behavior = :notify if ASDeprecationTracker.config.register_behavior?
10
+
11
+ if ASDeprecationTracker.config.register_behavior?
12
+ # Rails >= 7.1 deprecates ActiveSupport::Deprecation.behavior= in favor of the
13
+ # per-application deprecators registry; older Rails versions don't have it.
14
+ if Rails.application.respond_to?(:deprecators)
15
+ Rails.application.deprecators.behavior = :notify
16
+ else
17
+ ActiveSupport::Deprecation.behavior = :notify
18
+ end
19
+ end
10
20
 
11
21
  whitelist = ASDeprecationTracker.config.whitelist_file
12
22
  ([Rails.root] + engine_roots).each do |root|
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'active_support/subscriber'
3
4
  require 'as_deprecation_tracker/writer'
4
5
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module ASDeprecationTracker
3
- VERSION = '1.5.0'.freeze
4
+ VERSION = '1.7.0'
4
5
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'as_deprecation_tracker/whitelist_entry'
3
4
 
4
5
  module ASDeprecationTracker
@@ -12,7 +13,7 @@ module ASDeprecationTracker
12
13
  end
13
14
 
14
15
  def add_to_list(*entries)
15
- entries.flatten.each { |entry| @list << WhitelistEntry.new(entry.symbolize_keys) }
16
+ entries.flatten.each { |entry| @list << WhitelistEntry.new(**entry.symbolize_keys) }
16
17
  end
17
18
  alias add add_to_list
18
19
 
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module ASDeprecationTracker
3
4
  # Configuration of a whitelisted (known) deprecation warning matched by data
4
5
  # such as a message and/or callstack
5
6
  class WhitelistEntry
6
- KNOWN_KEYS = %w(callstack engine message).freeze
7
+ KNOWN_KEYS = %w[callstack engine message].freeze
7
8
  MESSAGE_CLEANUP_RE = Regexp.new('\ADEPRECATION WARNING: (.+) \(called from.*')
8
9
  CALLSTACK_FILE_RE = Regexp.new('\A(.*?)(?::(\d+))?(?::in `(.+)\')?\z')
9
10
 
@@ -13,14 +14,13 @@ module ASDeprecationTracker
13
14
  @message = message
14
15
  end
15
16
 
16
- # rubocop:disable Metrics/CyclomaticComplexity
17
17
  def matches?(deprecation)
18
18
  return false if @message.present? && !message_matches?(deprecation[:message])
19
19
  return false if @callstack.present? && !callstack_matches?(deprecation[:callstack])
20
20
  return false if @engine_root.present? && !engine_root_matches?(deprecation[:callstack])
21
+
21
22
  true
22
23
  end
23
- # rubocop:enable Metrics/CyclomaticComplexity
24
24
 
25
25
  private
26
26
 
@@ -60,11 +60,13 @@ module ASDeprecationTracker
60
60
 
61
61
  def line_number_within_tolerance(line1, line2)
62
62
  return true if line1.nil? || line2.nil?
63
+
63
64
  (line1 - line2).abs <= ASDeprecationTracker.config.line_tolerance
64
65
  end
65
66
 
66
67
  def method_name_matches(method1, method2)
67
68
  return true if method1.nil? || method2.nil?
69
+
68
70
  method1 == method2
69
71
  end
70
72
 
@@ -76,7 +78,7 @@ module ASDeprecationTracker
76
78
  ::Rails::Engine.descendants.each do |engine|
77
79
  begin
78
80
  return engine.root.to_s if engine_name.to_s == engine.engine_name.to_s
79
- rescue NoMethodError, RuntimeError # rubocop:disable Lint/HandleExceptions
81
+ rescue NoMethodError, RuntimeError
80
82
  # Ignore failures with singleton engine subclasses etc.
81
83
  end
82
84
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'as_deprecation_tracker/whitelist_entry'
3
4
  require 'rails/backtrace_cleaner'
4
5
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # Entry point, provides constant with access to global configuration only
3
4
  module ASDeprecationTracker
4
5
  require 'as_deprecation_tracker/configuration'
@@ -36,6 +37,6 @@ module ASDeprecationTracker
36
37
  end
37
38
 
38
39
  def self.env(name)
39
- ENV.fetch("AS_DEPRECATION_#{name}", ENV["ASDT_#{name}"])
40
+ ENV.fetch("AS_DEPRECATION_#{name}", ENV.fetch("ASDT_#{name}", nil))
40
41
  end
41
42
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'test_helper'
3
4
 
4
5
  class ASDeprecationTrackerTest < ASDeprecationTracker::TestCase
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'test_helper'
3
4
 
4
5
  class ConfigurationTest < ASDeprecationTracker::TestCase
@@ -1,4 +1,3 @@
1
1
  # frozen_string_literal: true
2
- Rails.application.routes.draw do
3
- #
4
- end
2
+ #
3
+ # No routes in test app
data/test/railtie_test.rb CHANGED
@@ -1,8 +1,14 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'test_helper'
3
4
 
4
5
  class RailtieTest < ASDeprecationTracker::TestCase
5
6
  def test_deprecation_behavior
6
- assert_equal [ActiveSupport::Deprecation::DEFAULT_BEHAVIORS[:notify]], ActiveSupport::Deprecation.behavior
7
+ behavior = if Rails.application.respond_to?(:deprecators)
8
+ ActiveSupport.deprecator.behavior
9
+ else
10
+ ActiveSupport::Deprecation.behavior
11
+ end
12
+ assert_equal [ActiveSupport::Deprecation::DEFAULT_BEHAVIORS[:notify]], behavior
7
13
  end
8
14
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'test_helper'
3
4
 
4
5
  class ReceiverTest < ASDeprecationTracker::TestCase
data/test/test_helper.rb CHANGED
@@ -1,6 +1,11 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'minitest/autorun'
3
- require 'mocha/mini_test'
4
+ require 'mocha/minitest'
5
+ # Rails < 7.1's active_support/logger_thread_safe_level.rb uses Logger without
6
+ # requiring it, relying on something else to have loaded it first. combustion's
7
+ # minimal footprint doesn't happen to, unlike a typical full Rails app.
8
+ require 'logger'
4
9
  require 'combustion'
5
10
 
6
11
  require 'as_deprecation_tracker'
@@ -17,7 +22,7 @@ module ASDeprecationTracker
17
22
  ENV.update(new_env)
18
23
  yield
19
24
  ensure
20
- new_env.keys.each { |k| ENV.delete(k) }
25
+ new_env.each_key { |k| ENV.delete(k) }
21
26
  ENV.update(backup)
22
27
  end
23
28
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'test_helper'
3
4
 
4
5
  class WhitelistEntryTest < ASDeprecationTracker::TestCase
@@ -133,9 +134,9 @@ class WhitelistEntryTest < ASDeprecationTracker::TestCase
133
134
 
134
135
  def entry(overrides = {})
135
136
  entry_hash = default_deprecation.merge(overrides).compact
136
- entry_hash[:callstack].map! { |line| line.sub(Rails.root.to_s + '/', '') } if entry_hash[:callstack].is_a?(Array)
137
+ entry_hash[:callstack].map! { |line| line.sub("#{Rails.root}/", '') } if entry_hash[:callstack].is_a?(Array)
137
138
 
138
139
  ASDeprecationTracker::WhitelistEntry.any_instance.expects(:engine_root).with(overrides[:engine]).returns("/home/user/engines/#{overrides[:engine]}") if overrides.key?(:engine)
139
- ASDeprecationTracker::WhitelistEntry.new(entry_hash)
140
+ ASDeprecationTracker::WhitelistEntry.new(**entry_hash)
140
141
  end
141
142
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'test_helper'
3
4
 
4
5
  class WhitelistTest < ASDeprecationTracker::TestCase
data/test/writer_test.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'test_helper'
3
4
 
4
5
  class WriterTest < ASDeprecationTracker::TestCase
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: as_deprecation_tracker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominic Cleal
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-03 00:00:00.000000000 Z
11
+ date: 2026-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -45,6 +45,7 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - ".github/workflows/ci.yml"
48
49
  - CHANGELOG.md
49
50
  - LICENSE
50
51
  - README.md
@@ -73,8 +74,9 @@ files:
73
74
  homepage: https://github.com/domcleal/as_deprecation_tracker
74
75
  licenses:
75
76
  - MIT
76
- metadata: {}
77
- post_install_message:
77
+ metadata:
78
+ rubygems_mfa_required: 'true'
79
+ post_install_message:
78
80
  rdoc_options: []
79
81
  require_paths:
80
82
  - lib
@@ -89,9 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
91
  - !ruby/object:Gem::Version
90
92
  version: '0'
91
93
  requirements: []
92
- rubyforge_project:
93
- rubygems_version: 2.6.8
94
- signing_key:
94
+ rubygems_version: 3.5.9
95
+ signing_key:
95
96
  specification_version: 4
96
97
  summary: Track known ActiveSupport deprecation warnings
97
98
  test_files: []