as_deprecation_tracker 1.5.0 → 1.6.0

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
- SHA1:
3
- metadata.gz: 423aa104af4ca208621d8c1e8eee3c3fb1c1ed4f
4
- data.tar.gz: 841eec03f2e5fec185ff747b9413978d58d44e3f
2
+ SHA256:
3
+ metadata.gz: afbd5cdcd05ef8e999ba0e809a3f9dd9f47f2379c2d2d1f753a5b308652e6ebb
4
+ data.tar.gz: cd5f7e4d5934d6f7e8aa67bfbc3487ecc3f21a5498a11ffed3f8bb77223a24dd
5
5
  SHA512:
6
- metadata.gz: c135f7983f1fda478172f436ef533aa135ae2dabcceaaca184f851614180ebcd1ffc1545d1cbc02d1fabd9ea466351185aa0c54ac0617299308d1b356b954ae7
7
- data.tar.gz: c6fda97efae671f2e1875905bd694903023322e12441677520405698330b3b7970b7be9ea892399ad8b97f39c8ae169f82433e31260ca19bf84e9c6484804fdc
6
+ metadata.gz: 9ea16660167a5744c86895f2722cc85af01acda3b93f3ec8eef5bd4b470c6f4168037d8105b798b64c809b08353282d872f9707925c5b8ec76d48c59cedb5dab
7
+ data.tar.gz: b22dabfa1a44820bd2c30a98b5c6ee9c1c674bd88e4f1c96f4dcc5c7f384b370a29d0a79a0ed016f2ace836fdcdf69933a0951192a16a66910e6040ed9206b6d
@@ -0,0 +1,37 @@
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
+ steps:
28
+ - uses: actions/checkout@v2
29
+ - name: Setup Ruby
30
+ uses: ruby/setup-ruby@v1
31
+ with:
32
+ ruby-version: ${{ matrix.ruby_version }}
33
+ bundler-cache: true
34
+ env:
35
+ RAILS_VERSION: ${{ matrix.rails_version }}
36
+ - name: Run tests
37
+ run: bundle exec rake
data/CHANGELOG.md CHANGED
@@ -5,6 +5,11 @@ 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.6.0
9
+
10
+ ### Fixed
11
+ - Fix array splat errors under Ruby 3 (PR thanks to @evgeni)
12
+
8
13
  ## 1.5.0
9
14
 
10
15
  ### 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
@@ -143,6 +143,15 @@ initialisation, as deprecation processing can be disabled until the whitelist
143
143
  is fully formed. ASDT will queue events while paused and processes them when
144
144
  `resume!` is called.
145
145
 
146
+ ## Alternatives
147
+
148
+ Shopify have open-sourced a gem that works very similarly to ASDT and is worth
149
+ a look. It supports more configuration options when seeing a new or removed
150
+ deprecation warning, and also supports `Kernel#warn`.
151
+
152
+ * [Shopify: Introducing the deprecation toolkit](https://engineering.shopify.com/blogs/engineering/introducing-the-deprecation-toolkit)
153
+ * [deprecation_toolkit (GitHub)](https://github.com/shopify/deprecation_toolkit)
154
+
146
155
  ## License
147
156
 
148
- Copyright (c) 2016-2017 Dominic Cleal. Distributed under the MIT license.
157
+ 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
@@ -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.6.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,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'test_helper'
3
4
 
4
5
  class RailtieTest < ASDeprecationTracker::TestCase
@@ -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,7 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'minitest/autorun'
3
- require 'mocha/mini_test'
4
+ require 'mocha/minitest'
4
5
  require 'combustion'
5
6
 
6
7
  require 'as_deprecation_tracker'
@@ -17,7 +18,7 @@ module ASDeprecationTracker
17
18
  ENV.update(new_env)
18
19
  yield
19
20
  ensure
20
- new_env.keys.each { |k| ENV.delete(k) }
21
+ new_env.each_key { |k| ENV.delete(k) }
21
22
  ENV.update(backup)
22
23
  end
23
24
  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.6.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: 2022-07-24 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.3.7
95
+ signing_key:
95
96
  specification_version: 4
96
97
  summary: Track known ActiveSupport deprecation warnings
97
98
  test_files: []