as_deprecation_tracker 1.4.0 → 1.6.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 +5 -5
- data/.github/workflows/ci.yml +37 -0
- data/CHANGELOG.md +71 -0
- data/LICENSE +1 -1
- data/README.md +24 -1
- data/Rakefile +2 -1
- data/config.ru +1 -0
- data/lib/as_deprecation_tracker/configuration.rb +3 -2
- data/lib/as_deprecation_tracker/railtie.rb +1 -0
- data/lib/as_deprecation_tracker/receiver.rb +4 -3
- data/lib/as_deprecation_tracker/version.rb +2 -1
- data/lib/as_deprecation_tracker/whitelist.rb +3 -2
- data/lib/as_deprecation_tracker/whitelist_entry.rb +6 -4
- data/lib/as_deprecation_tracker/writer.rb +2 -1
- data/lib/as_deprecation_tracker.rb +8 -3
- data/test/as_deprecation_tracker_test.rb +19 -0
- data/test/configuration_test.rb +26 -18
- data/test/internal/config/routes.rb +2 -3
- data/test/railtie_test.rb +1 -0
- data/test/receiver_test.rb +1 -0
- data/test/test_helper.rb +3 -2
- data/test/whitelist_entry_test.rb +3 -2
- data/test/whitelist_test.rb +1 -0
- data/test/writer_test.rb +7 -6
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: afbd5cdcd05ef8e999ba0e809a3f9dd9f47f2379c2d2d1f753a5b308652e6ebb
|
4
|
+
data.tar.gz: cd5f7e4d5934d6f7e8aa67bfbc3487ecc3f21a5498a11ffed3f8bb77223a24dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
6
|
+
and this project adheres to [Semantic Versioning](http://semver.org/).
|
7
|
+
|
8
|
+
## 1.6.0
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
- Fix array splat errors under Ruby 3 (PR thanks to @evgeni)
|
12
|
+
|
13
|
+
## 1.5.0
|
14
|
+
|
15
|
+
### Added
|
16
|
+
- Add `AS_DEPRECATION_DISABLE` environment variable to fully disable ASDT.
|
17
|
+
- Support shorter `ASDT_` prefix for all environment variables.
|
18
|
+
|
19
|
+
## 1.4.1
|
20
|
+
|
21
|
+
### Fixed
|
22
|
+
- Fix YAML safe load error under Ruby 2.0.
|
23
|
+
|
24
|
+
## 1.4.0
|
25
|
+
|
26
|
+
### Added
|
27
|
+
- Add pause!/resume! API to temporarily queue deprecation processing.
|
28
|
+
|
29
|
+
### Fixed
|
30
|
+
- Fix engine root search error when engine name is given as a symbol.
|
31
|
+
|
32
|
+
## 1.3.0
|
33
|
+
|
34
|
+
### Changed
|
35
|
+
- Deprecation messages are matched by prefix, so only the first part of the
|
36
|
+
message needs to be stored on the whitelist entry.
|
37
|
+
|
38
|
+
### Fixed
|
39
|
+
- Fix error loading empty whitelist file.
|
40
|
+
|
41
|
+
## 1.2.0
|
42
|
+
|
43
|
+
### Changed
|
44
|
+
- Multi-line deprecation messages are matched line-by-line, so only the first
|
45
|
+
lines need to be stored in the whitelist entry.
|
46
|
+
- Use safe YAML load on configuration files.
|
47
|
+
|
48
|
+
### Fixed
|
49
|
+
- Fix duplicate entries created during record mode.
|
50
|
+
- Fix Rails 5 callstack compatibility when matching deprecations.
|
51
|
+
- Fix array comparison error when matching entries without callstacks.
|
52
|
+
|
53
|
+
## 1.1.0
|
54
|
+
|
55
|
+
### Added
|
56
|
+
- Add `AS_DEPRECATION_WHITELIST` environment variable to load/write whitelist
|
57
|
+
to a different path.
|
58
|
+
- Load and merge whitelist config files from each Rails engine root.
|
59
|
+
- Add `engine` config option to whitelist, matches engine name.
|
60
|
+
- Add whitelist API to add new entries programmatically.
|
61
|
+
|
62
|
+
### Changed
|
63
|
+
- Raise errors for unknown config options in whitelist.
|
64
|
+
|
65
|
+
### Fixed
|
66
|
+
- Fix callstack matching against whitelist with relative paths.
|
67
|
+
|
68
|
+
## 1.0.0
|
69
|
+
|
70
|
+
### Added
|
71
|
+
- Initial release, supporting raising of exceptions and recording mode.
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -119,6 +119,20 @@ Supported options:
|
|
119
119
|
* `whitelist_file` to customise the location of the whitelist YAML file
|
120
120
|
(defaults to `config/as_deprecation_whitelist.yaml`)
|
121
121
|
|
122
|
+
### Environment variables
|
123
|
+
|
124
|
+
Both `AS_DEPRECATION_` or the shorter `ASDT_` prefixes work with all
|
125
|
+
environment variables listed below.
|
126
|
+
|
127
|
+
* `AS_DEPRECATION_DISABLE` - set to any value will prevent ASDT from monitoring
|
128
|
+
deprecations and throwing exceptions. Rails will use default deprecation
|
129
|
+
behaviour.
|
130
|
+
* `AS_DEPRECATION_RECORD` - set to any value will prevent ASDT from throwing
|
131
|
+
exceptions and will append entries to the `whitelist_file` for every
|
132
|
+
deprecation seen.
|
133
|
+
* `AS_DEPRECATION_WHITELIST` - set to the root or full path of a whitelist
|
134
|
+
configuration file, overrides `whitelist_file`.
|
135
|
+
|
122
136
|
### Pause/resume
|
123
137
|
|
124
138
|
The processing of deprecation warnings can be suspended and resumed via the
|
@@ -129,6 +143,15 @@ initialisation, as deprecation processing can be disabled until the whitelist
|
|
129
143
|
is fully formed. ASDT will queue events while paused and processes them when
|
130
144
|
`resume!` is called.
|
131
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
|
+
|
132
155
|
## License
|
133
156
|
|
134
|
-
Copyright (c) 2016-
|
157
|
+
Copyright (c) 2016-2022 Dominic Cleal. Distributed under the MIT license.
|
data/Rakefile
CHANGED
data/config.ru
CHANGED
@@ -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,9 +7,9 @@ module ASDeprecationTracker
|
|
6
7
|
alias register_behavior? register_behavior
|
7
8
|
|
8
9
|
def initialize
|
9
|
-
@envs = %w
|
10
|
+
@envs = %w[test]
|
10
11
|
@line_tolerance = 10
|
11
|
-
@register_behavior =
|
12
|
+
@register_behavior = ASDeprecationTracker.env('DISABLE').nil?
|
12
13
|
@whitelist_file = File.join('config', 'as_deprecation_whitelist.yaml')
|
13
14
|
end
|
14
15
|
end
|
@@ -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
|
|
@@ -24,7 +25,7 @@ module ASDeprecationTracker
|
|
24
25
|
|
25
26
|
message = event.payload[:message]
|
26
27
|
callstack = event.payload[:callstack].map(&:to_s)
|
27
|
-
if
|
28
|
+
if ASDeprecationTracker.env('RECORD').present?
|
28
29
|
write_deprecation(message, callstack)
|
29
30
|
else
|
30
31
|
raise_deprecation(message, callstack)
|
@@ -41,8 +42,8 @@ module ASDeprecationTracker
|
|
41
42
|
end
|
42
43
|
|
43
44
|
def whitelist_file
|
44
|
-
root = if
|
45
|
-
File.expand_path(
|
45
|
+
root = if ASDeprecationTracker.env('WHITELIST').present?
|
46
|
+
File.expand_path(ASDeprecationTracker.env('WHITELIST'))
|
46
47
|
else
|
47
48
|
Rails.root
|
48
49
|
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
|
|
@@ -21,7 +22,7 @@ module ASDeprecationTracker
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def load_file(path)
|
24
|
-
add_to_list(YAML.
|
25
|
+
add_to_list(YAML.load(File.read(path)) || [])
|
25
26
|
end
|
26
27
|
|
27
28
|
def matches?(deprecation)
|
@@ -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
|
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
|
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
|
|
@@ -8,7 +9,7 @@ module ASDeprecationTracker
|
|
8
9
|
def initialize(filename)
|
9
10
|
@filename = filename
|
10
11
|
@contents = []
|
11
|
-
@contents = YAML.
|
12
|
+
@contents = YAML.load(File.read(filename)) || [] if File.exist?(filename)
|
12
13
|
end
|
13
14
|
|
14
15
|
def add(message, callstack)
|
@@ -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'
|
@@ -15,7 +16,7 @@ module ASDeprecationTracker
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def self.pause!
|
18
|
-
@
|
19
|
+
@paused = true
|
19
20
|
end
|
20
21
|
|
21
22
|
def self.receiver
|
@@ -23,15 +24,19 @@ module ASDeprecationTracker
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def self.resume!
|
26
|
-
@
|
27
|
+
@paused = false
|
27
28
|
@receiver.try!(:process_queue)
|
28
29
|
end
|
29
30
|
|
30
31
|
def self.running?
|
31
|
-
|
32
|
+
env('DISABLE').nil? && !@paused
|
32
33
|
end
|
33
34
|
|
34
35
|
def self.whitelist
|
35
36
|
@whitelist ||= Whitelist.new
|
36
37
|
end
|
38
|
+
|
39
|
+
def self.env(name)
|
40
|
+
ENV.fetch("AS_DEPRECATION_#{name}", ENV.fetch("ASDT_#{name}", nil))
|
41
|
+
end
|
37
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
|
@@ -21,6 +22,18 @@ class ASDeprecationTrackerTest < ASDeprecationTracker::TestCase
|
|
21
22
|
assert_equal config, ASDeprecationTracker.config
|
22
23
|
end
|
23
24
|
|
25
|
+
def test_env_as_deprecation
|
26
|
+
with_env(AS_DEPRECATION_TEST: 'test') do
|
27
|
+
assert_equal 'test', ASDeprecationTracker.env('TEST')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_env_asdt
|
32
|
+
with_env(ASDT_TEST: 'test') do
|
33
|
+
assert_equal 'test', ASDeprecationTracker.env('TEST')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
24
37
|
def test_pause!
|
25
38
|
ASDeprecationTracker.pause!
|
26
39
|
refute ASDeprecationTracker.running?
|
@@ -49,6 +62,12 @@ class ASDeprecationTrackerTest < ASDeprecationTracker::TestCase
|
|
49
62
|
assert_equal true, ASDeprecationTracker.running?
|
50
63
|
end
|
51
64
|
|
65
|
+
def test_running_with_disable_true
|
66
|
+
with_env(AS_DEPRECATION_DISABLE: 'true') do
|
67
|
+
assert_equal false, ASDeprecationTracker.running?
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
52
71
|
def test_whitelist
|
53
72
|
assert_kind_of ASDeprecationTracker::Whitelist, ASDeprecationTracker.whitelist
|
54
73
|
end
|
data/test/configuration_test.rb
CHANGED
@@ -1,46 +1,54 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'test_helper'
|
3
4
|
|
4
5
|
class ConfigurationTest < ASDeprecationTracker::TestCase
|
5
|
-
def setup
|
6
|
-
@config = ASDeprecationTracker::Configuration.new
|
7
|
-
super
|
8
|
-
end
|
9
|
-
|
10
6
|
def test_envs
|
11
|
-
assert_equal ['test'],
|
7
|
+
assert_equal ['test'], config.envs
|
12
8
|
end
|
13
9
|
|
14
10
|
def test_envs=
|
15
|
-
|
16
|
-
assert_equal ['development'],
|
11
|
+
config.envs = ['development']
|
12
|
+
assert_equal ['development'], config.envs
|
17
13
|
end
|
18
14
|
|
19
15
|
def test_line_tolerance
|
20
|
-
assert_equal 10,
|
16
|
+
assert_equal 10, config.line_tolerance
|
21
17
|
end
|
22
18
|
|
23
19
|
def test_line_tolerance=
|
24
|
-
|
25
|
-
assert_equal 42,
|
20
|
+
config.line_tolerance = 42
|
21
|
+
assert_equal 42, config.line_tolerance
|
26
22
|
end
|
27
23
|
|
28
24
|
def test_register_behavior?
|
29
|
-
assert_equal true,
|
25
|
+
assert_equal true, config.register_behavior?
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_running_with_disable_true
|
29
|
+
with_env(AS_DEPRECATION_DISABLE: 'true') do
|
30
|
+
assert_equal false, config.register_behavior?
|
31
|
+
end
|
30
32
|
end
|
31
33
|
|
32
34
|
def test_register_behavior=
|
33
|
-
|
34
|
-
assert_equal false,
|
35
|
+
config.register_behavior = false
|
36
|
+
assert_equal false, config.register_behavior?
|
35
37
|
end
|
36
38
|
|
37
39
|
def test_whitelist_file
|
38
|
-
assert_kind_of String,
|
39
|
-
assert File.exist?(File.join(Rails.root,
|
40
|
+
assert_kind_of String, config.whitelist_file
|
41
|
+
assert File.exist?(File.join(Rails.root, config.whitelist_file))
|
40
42
|
end
|
41
43
|
|
42
44
|
def test_whitelist_file=
|
43
|
-
|
44
|
-
assert_equal 'another_file.yaml',
|
45
|
+
config.whitelist_file = 'another_file.yaml'
|
46
|
+
assert_equal 'another_file.yaml', config.whitelist_file
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def config
|
52
|
+
@config ||= ASDeprecationTracker::Configuration.new
|
45
53
|
end
|
46
54
|
end
|
data/test/railtie_test.rb
CHANGED
data/test/receiver_test.rb
CHANGED
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/
|
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.
|
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
|
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
|
data/test/whitelist_test.rb
CHANGED
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
|
@@ -6,24 +7,24 @@ class WriterTest < ASDeprecationTracker::TestCase
|
|
6
7
|
writer = new_writer
|
7
8
|
ret = writer.add('deprecated call', ['app/models/a.rb:23', 'app/models/b.rb:42'])
|
8
9
|
assert_equal({ 'message' => 'deprecated call', 'callstack' => 'app/models/a.rb:23' }, ret)
|
9
|
-
assert_equal [ret], YAML.
|
10
|
+
assert_equal [ret], YAML.load(writer.contents)
|
10
11
|
end
|
11
12
|
|
12
13
|
def test_add_strips_surrounding
|
13
14
|
writer = new_writer
|
14
15
|
writer.add('DEPRECATION WARNING: deprecated call (called from app/models/a.rb:23)', ['app/models/a.rb:23', 'app/models/b.rb:42'])
|
15
|
-
assert_equal [{ 'message' => 'deprecated call', 'callstack' => 'app/models/a.rb:23' }], YAML.
|
16
|
+
assert_equal [{ 'message' => 'deprecated call', 'callstack' => 'app/models/a.rb:23' }], YAML.load(writer.contents)
|
16
17
|
end
|
17
18
|
|
18
19
|
def test_add_cleans_callstack
|
19
20
|
writer = new_writer
|
20
21
|
Gem.expects(:path).returns(['/home/user/.rvm/gems/ruby-2.3.0'])
|
21
22
|
writer.add('deprecated call', ['/home/user/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.7.1/lib/active_record/relation/finder_methods.rb:280:in `exists?\'', 'app/models/a.rb:23', 'app/models/b.rb:42'])
|
22
|
-
assert_equal [{ 'message' => 'deprecated call', 'callstack' => 'app/models/a.rb:23' }], YAML.
|
23
|
+
assert_equal [{ 'message' => 'deprecated call', 'callstack' => 'app/models/a.rb:23' }], YAML.load(writer.contents)
|
23
24
|
end
|
24
25
|
|
25
26
|
def test_contents_new_file_is_array
|
26
|
-
assert_equal [], YAML.
|
27
|
+
assert_equal [], YAML.load(new_writer('').contents)
|
27
28
|
end
|
28
29
|
|
29
30
|
def test_contents_sorting
|
@@ -35,7 +36,7 @@ class WriterTest < ASDeprecationTracker::TestCase
|
|
35
36
|
{ 'message' => 'deprecated call 1', 'callstack' => 'app/models/a.rb:23' },
|
36
37
|
{ 'message' => 'deprecated call 1', 'callstack' => 'app/models/a.rb:42' },
|
37
38
|
{ 'message' => 'deprecated call 2', 'callstack' => 'app/models/a.rb:23' }
|
38
|
-
], YAML.
|
39
|
+
], YAML.load(writer.contents)
|
39
40
|
end
|
40
41
|
|
41
42
|
def test_contents_sorting_existing_message_without_callstack
|
@@ -45,7 +46,7 @@ class WriterTest < ASDeprecationTracker::TestCase
|
|
45
46
|
assert_equal [
|
46
47
|
{ 'message' => 'deprecated call 1' },
|
47
48
|
{ 'message' => 'deprecated call 1', 'callstack' => 'app/models/a.rb:23' }
|
48
|
-
], YAML.
|
49
|
+
], YAML.load(writer.contents)
|
49
50
|
end
|
50
51
|
|
51
52
|
def test_write_file
|
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.
|
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:
|
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,8 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
+
- ".github/workflows/ci.yml"
|
49
|
+
- CHANGELOG.md
|
48
50
|
- LICENSE
|
49
51
|
- README.md
|
50
52
|
- Rakefile
|
@@ -72,8 +74,9 @@ files:
|
|
72
74
|
homepage: https://github.com/domcleal/as_deprecation_tracker
|
73
75
|
licenses:
|
74
76
|
- MIT
|
75
|
-
metadata:
|
76
|
-
|
77
|
+
metadata:
|
78
|
+
rubygems_mfa_required: 'true'
|
79
|
+
post_install_message:
|
77
80
|
rdoc_options: []
|
78
81
|
require_paths:
|
79
82
|
- lib
|
@@ -88,9 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
91
|
- !ruby/object:Gem::Version
|
89
92
|
version: '0'
|
90
93
|
requirements: []
|
91
|
-
|
92
|
-
|
93
|
-
signing_key:
|
94
|
+
rubygems_version: 3.3.7
|
95
|
+
signing_key:
|
94
96
|
specification_version: 4
|
95
97
|
summary: Track known ActiveSupport deprecation warnings
|
96
98
|
test_files: []
|