as_deprecation_tracker 1.4.1 → 1.5.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
2
  SHA1:
3
- metadata.gz: 9f7afb9114abb2b1eb8342ce87fad1e76f398261
4
- data.tar.gz: ed0827eecdeb1d66f8db27dc8ac733e789bc80d8
3
+ metadata.gz: 423aa104af4ca208621d8c1e8eee3c3fb1c1ed4f
4
+ data.tar.gz: 841eec03f2e5fec185ff747b9413978d58d44e3f
5
5
  SHA512:
6
- metadata.gz: 14c349e5c726f6ba9fc390bc43f86f274623174997522791e082cdda207583d46083058c8def4ea096c0aaa3725c1ec3c15b9848d5c5826c93933d3ee54a22f4
7
- data.tar.gz: 0c0aba7080bc8074e1df57a37f9130cf1f2be22ccc2a2d3a1626ae1c5a78ef47e2875f7cae6469342af9abcba5507a5c67d8c719dd41570848763ccafa0db0ca
6
+ metadata.gz: c135f7983f1fda478172f436ef533aa135ae2dabcceaaca184f851614180ebcd1ffc1545d1cbc02d1fabd9ea466351185aa0c54ac0617299308d1b356b954ae7
7
+ data.tar.gz: c6fda97efae671f2e1875905bd694903023322e12441677520405698330b3b7970b7be9ea892399ad8b97f39c8ae169f82433e31260ca19bf84e9c6484804fdc
@@ -0,0 +1,66 @@
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.5.0
9
+
10
+ ### Added
11
+ - Add `AS_DEPRECATION_DISABLE` environment variable to fully disable ASDT.
12
+ - Support shorter `ASDT_` prefix for all environment variables.
13
+
14
+ ## 1.4.1
15
+
16
+ ### Fixed
17
+ - Fix YAML safe load error under Ruby 2.0.
18
+
19
+ ## 1.4.0
20
+
21
+ ### Added
22
+ - Add pause!/resume! API to temporarily queue deprecation processing.
23
+
24
+ ### Fixed
25
+ - Fix engine root search error when engine name is given as a symbol.
26
+
27
+ ## 1.3.0
28
+
29
+ ### Changed
30
+ - Deprecation messages are matched by prefix, so only the first part of the
31
+ message needs to be stored on the whitelist entry.
32
+
33
+ ### Fixed
34
+ - Fix error loading empty whitelist file.
35
+
36
+ ## 1.2.0
37
+
38
+ ### Changed
39
+ - Multi-line deprecation messages are matched line-by-line, so only the first
40
+ lines need to be stored in the whitelist entry.
41
+ - Use safe YAML load on configuration files.
42
+
43
+ ### Fixed
44
+ - Fix duplicate entries created during record mode.
45
+ - Fix Rails 5 callstack compatibility when matching deprecations.
46
+ - Fix array comparison error when matching entries without callstacks.
47
+
48
+ ## 1.1.0
49
+
50
+ ### Added
51
+ - Add `AS_DEPRECATION_WHITELIST` environment variable to load/write whitelist
52
+ to a different path.
53
+ - Load and merge whitelist config files from each Rails engine root.
54
+ - Add `engine` config option to whitelist, matches engine name.
55
+ - Add whitelist API to add new entries programmatically.
56
+
57
+ ### Changed
58
+ - Raise errors for unknown config options in whitelist.
59
+
60
+ ### Fixed
61
+ - Fix callstack matching against whitelist with relative paths.
62
+
63
+ ## 1.0.0
64
+
65
+ ### Added
66
+ - Initial release, supporting raising of exceptions and recording mode.
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
@@ -15,7 +15,7 @@ module ASDeprecationTracker
15
15
  end
16
16
 
17
17
  def self.pause!
18
- @running = false
18
+ @paused = true
19
19
  end
20
20
 
21
21
  def self.receiver
@@ -23,15 +23,19 @@ module ASDeprecationTracker
23
23
  end
24
24
 
25
25
  def self.resume!
26
- @running = true
26
+ @paused = false
27
27
  @receiver.try!(:process_queue)
28
28
  end
29
29
 
30
30
  def self.running?
31
- @running.nil? || @running
31
+ env('DISABLE').nil? && !@paused
32
32
  end
33
33
 
34
34
  def self.whitelist
35
35
  @whitelist ||= Whitelist.new
36
36
  end
37
+
38
+ def self.env(name)
39
+ ENV.fetch("AS_DEPRECATION_#{name}", ENV["ASDT_#{name}"])
40
+ end
37
41
  end
@@ -8,7 +8,7 @@ module ASDeprecationTracker
8
8
  def initialize
9
9
  @envs = %w(test)
10
10
  @line_tolerance = 10
11
- @register_behavior = true
11
+ @register_behavior = ASDeprecationTracker.env('DISABLE').nil?
12
12
  @whitelist_file = File.join('config', 'as_deprecation_whitelist.yaml')
13
13
  end
14
14
  end
@@ -24,7 +24,7 @@ module ASDeprecationTracker
24
24
 
25
25
  message = event.payload[:message]
26
26
  callstack = event.payload[:callstack].map(&:to_s)
27
- if ENV['AS_DEPRECATION_RECORD'].present?
27
+ if ASDeprecationTracker.env('RECORD').present?
28
28
  write_deprecation(message, callstack)
29
29
  else
30
30
  raise_deprecation(message, callstack)
@@ -41,8 +41,8 @@ module ASDeprecationTracker
41
41
  end
42
42
 
43
43
  def whitelist_file
44
- root = if ENV['AS_DEPRECATION_WHITELIST'].present?
45
- File.expand_path(ENV['AS_DEPRECATION_WHITELIST'])
44
+ root = if ASDeprecationTracker.env('WHITELIST').present?
45
+ File.expand_path(ASDeprecationTracker.env('WHITELIST'))
46
46
  else
47
47
  Rails.root
48
48
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ASDeprecationTracker
3
- VERSION = '1.4.1'.freeze
3
+ VERSION = '1.5.0'.freeze
4
4
  end
@@ -21,6 +21,18 @@ class ASDeprecationTrackerTest < ASDeprecationTracker::TestCase
21
21
  assert_equal config, ASDeprecationTracker.config
22
22
  end
23
23
 
24
+ def test_env_as_deprecation
25
+ with_env(AS_DEPRECATION_TEST: 'test') do
26
+ assert_equal 'test', ASDeprecationTracker.env('TEST')
27
+ end
28
+ end
29
+
30
+ def test_env_asdt
31
+ with_env(ASDT_TEST: 'test') do
32
+ assert_equal 'test', ASDeprecationTracker.env('TEST')
33
+ end
34
+ end
35
+
24
36
  def test_pause!
25
37
  ASDeprecationTracker.pause!
26
38
  refute ASDeprecationTracker.running?
@@ -49,6 +61,12 @@ class ASDeprecationTrackerTest < ASDeprecationTracker::TestCase
49
61
  assert_equal true, ASDeprecationTracker.running?
50
62
  end
51
63
 
64
+ def test_running_with_disable_true
65
+ with_env(AS_DEPRECATION_DISABLE: 'true') do
66
+ assert_equal false, ASDeprecationTracker.running?
67
+ end
68
+ end
69
+
52
70
  def test_whitelist
53
71
  assert_kind_of ASDeprecationTracker::Whitelist, ASDeprecationTracker.whitelist
54
72
  end
@@ -2,45 +2,52 @@
2
2
  require 'test_helper'
3
3
 
4
4
  class ConfigurationTest < ASDeprecationTracker::TestCase
5
- def setup
6
- @config = ASDeprecationTracker::Configuration.new
7
- super
8
- end
9
-
10
5
  def test_envs
11
- assert_equal ['test'], @config.envs
6
+ assert_equal ['test'], config.envs
12
7
  end
13
8
 
14
9
  def test_envs=
15
- @config.envs = ['development']
16
- assert_equal ['development'], @config.envs
10
+ config.envs = ['development']
11
+ assert_equal ['development'], config.envs
17
12
  end
18
13
 
19
14
  def test_line_tolerance
20
- assert_equal 10, @config.line_tolerance
15
+ assert_equal 10, config.line_tolerance
21
16
  end
22
17
 
23
18
  def test_line_tolerance=
24
- @config.line_tolerance = 42
25
- assert_equal 42, @config.line_tolerance
19
+ config.line_tolerance = 42
20
+ assert_equal 42, config.line_tolerance
26
21
  end
27
22
 
28
23
  def test_register_behavior?
29
- assert_equal true, @config.register_behavior?
24
+ assert_equal true, config.register_behavior?
25
+ end
26
+
27
+ def test_running_with_disable_true
28
+ with_env(AS_DEPRECATION_DISABLE: 'true') do
29
+ assert_equal false, config.register_behavior?
30
+ end
30
31
  end
31
32
 
32
33
  def test_register_behavior=
33
- @config.register_behavior = false
34
- assert_equal false, @config.register_behavior?
34
+ config.register_behavior = false
35
+ assert_equal false, config.register_behavior?
35
36
  end
36
37
 
37
38
  def test_whitelist_file
38
- assert_kind_of String, @config.whitelist_file
39
- assert File.exist?(File.join(Rails.root, @config.whitelist_file))
39
+ assert_kind_of String, config.whitelist_file
40
+ assert File.exist?(File.join(Rails.root, config.whitelist_file))
40
41
  end
41
42
 
42
43
  def test_whitelist_file=
43
- @config.whitelist_file = 'another_file.yaml'
44
- assert_equal 'another_file.yaml', @config.whitelist_file
44
+ config.whitelist_file = 'another_file.yaml'
45
+ assert_equal 'another_file.yaml', config.whitelist_file
46
+ end
47
+
48
+ private
49
+
50
+ def config
51
+ @config ||= ASDeprecationTracker::Configuration.new
45
52
  end
46
53
  end
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.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominic Cleal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-27 00:00:00.000000000 Z
11
+ date: 2017-04-03 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
+ - CHANGELOG.md
48
49
  - LICENSE
49
50
  - README.md
50
51
  - Rakefile