deprecation_toolkit 1.0.2 → 1.0.3

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
  SHA1:
3
- metadata.gz: 549482ab71452372bcd8cb88d49dfb9658ff4cc8
4
- data.tar.gz: 6efa4b46880947f5b65ad7b8578dbe7e99c7b21c
3
+ metadata.gz: e01e1ccdad76b3a084e7c5ad013fea98f28fc959
4
+ data.tar.gz: af5cd6abbb05a4ee4ea615b424d00be914b57567
5
5
  SHA512:
6
- metadata.gz: eece757510b9d571b3987534d42025c5a5874d5ac1db64a0f6e7b0f9640ffdfc8eaee3ce248fa47b1cb5da53b458570d40665b0c35fd26471c9790199d9ef5b7
7
- data.tar.gz: be2ccc646aaacdf5ec2a0a0dbf0c2d47431c7118c7f33f8ad77ca0e6bc9152a96da5a5a553637fc12b09bd646d5a6dabbbd565a5579719c87aa7d047587e637a
6
+ metadata.gz: afd8e6cc37cd0bd0e025334752f13bb389a191531a8e0a26de2ecc09f1e9f7086cf796cd56e3a1dd8e1154dbd236c99de913c37aba4f248112b8c335c330e5ea
7
+ data.tar.gz: c24ee0952676a10d928125b1145e293bc5a72a59cf5d6a1624ab1264aa6e29f0913618289e40720c0edd16e0f83e61988aa92febf0457d2973a5d6253d44cbce
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Change log
2
2
 
3
+ ## master (unreleased)
4
+ ### Bug fixes
5
+
6
+ ## 1.0.3 (2018-10-25)
7
+ ### Bug fixes
8
+
9
+ * [#22](https://github.com/Shopify/deprecation_toolkit/pull/22): Fixes `Kernel.warn` not triggering deprecation. (@rmacklin)
3
10
 
4
11
  ## 1.0.2 (2018-10-01)
5
12
  ### New features
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- deprecation_toolkit (1.0.2)
4
+ deprecation_toolkit (1.0.3)
5
5
  activesupport (>= 4.2)
6
6
 
7
7
  GEM
@@ -14,7 +14,7 @@ GEM
14
14
  tzinfo (~> 1.1)
15
15
  ast (2.4.0)
16
16
  concurrent-ruby (1.0.5)
17
- i18n (1.1.0)
17
+ i18n (1.1.1)
18
18
  concurrent-ruby (~> 1.0)
19
19
  jaro_winkler (1.5.1)
20
20
  minitest (5.11.3)
@@ -50,4 +50,4 @@ DEPENDENCIES
50
50
  rubocop
51
51
 
52
52
  BUNDLED WITH
53
- 1.16.5
53
+ 1.16.6
data/README.md CHANGED
@@ -2,15 +2,15 @@
2
2
 
3
3
  ## Introduction
4
4
 
5
- The Deprecation Toolkit is a gem to help you get rid of deprecations in your codebase.
6
- Having deprecations in your application is usually a sign that something will break whenever a third dependency will get updated. The sooner the better to fix them!
7
- Fixing all deprecations at once might be though depending on how big your app is and how much deprecations needs to be fixed. You might have to progressively resolve them while making sure your team doesn't add new one ➰. This is where this gem comes handy!
5
+ Deprecation Toolkit is a gem that helps you get rid of deprecations in your codebase.
6
+ Having deprecations in your application usually means that something will break whenever you upgrade third-party dependencies. The sooner the better to fix them!
7
+ Fixing all deprecations at once might be tough depending on the size of your app and the number of deprecations. You might have to progressively resolve them while making sure your team doesn't add new ones. This is where this gem comes handy!
8
8
 
9
9
 
10
10
  ## How it works
11
11
 
12
12
  The Deprecation Toolkit gem works by using a [shitlist approach](https://confreaks.tv/videos/reddotrubyconf2017-shitlist-driven-development-and-other-tricks-for-working-on-large-codebases).
13
- First, all current existing deprecations in your codebase are recorded into `.yml` files. When running a test that has non-recorded deprecations, the Deprecation Toolkit gem will trigger a behavior of your choice (by default raise an error).
13
+ First, the gem records all existing deprecations into `.yml` files. When running a test that have non-recorded deprecations after the initial recording, Deprecation Toolkit triggers a behavior of your choice (by default it raises an error).
14
14
 
15
15
  ## Recording Deprecations
16
16
 
@@ -25,9 +25,9 @@ rails test <path_to_my_test.rb> -r
25
25
 
26
26
  ### 🔨 `#DeprecationToolkit::Configuration#deprecation_path`
27
27
 
28
- You can control where the recorded deprecations are read and write into. By default, deprecations will be recorded in the `test/deprecations` folder.
28
+ You can control where recorded deprecations are saved and read from. By default, deprecations are recorded in the `test/deprecations` folder.
29
29
 
30
- The `deprecation_path` either accepts a string or a proc. When using a proc, the proc will be passed an argument which is the path of the test file being run.
30
+ The `deprecation_path` either accepts a string or a proc. The proc is called with the path of the running test file.
31
31
 
32
32
  ```ruby
33
33
  DeprecationToolkit::Configuration.deprecation_path = 'test/deprecations'
@@ -42,9 +42,9 @@ end
42
42
 
43
43
  ### 🔨 `#DeprecationToolkit::Configuration#behavior`
44
44
 
45
- Behaviors defines what will happen when a non-recorded deprecations is encountered.
45
+ Behaviors define what happens when non-recorded deprecations are encountered.
46
46
 
47
- Behaviors are class that responds to the `trigger` message.
47
+ Behaviors are classes that have a `.trigger` class method.
48
48
 
49
49
  This gem provides 3 behaviors, the default one being `DeprecationToolkit::Behaviors::Raise`.
50
50
 
@@ -59,7 +59,7 @@ This gem provides 3 behaviors, the default one being `DeprecationToolkit::Behavi
59
59
  DeprecationToolkit::Configuration.behavior = DeprecationToolkit::Behaviors::Record
60
60
  ```
61
61
 
62
- You can also create your own behavior class and perform the logic you want. Your behavior needs to respond to the `.trigger` message.
62
+ You can also create your own behavior class and perform the logic you want. Your behavior needs to respond to `.trigger`.
63
63
 
64
64
  ```ruby
65
65
  class StatsdBehavior
@@ -73,25 +73,22 @@ DeprecationToolkit::Configuration.behavior = StatsdBehavior
73
73
 
74
74
  ### 🔨 `#DeprecationToolkit::Configuration#allowed_deprecations`
75
75
 
76
- If you want to allow some deprecations, this is where you'll configure it. The `allowed_deprecations` configuration accepts an
77
- array of Regexp.
76
+ You can ignore some deprecations using `allowed_deprecations`. `allowed_deprecations` accepts an array of Regexp.
78
77
 
79
- Whenever a deprecation matches one of the regex, the deprecation will be ignored
78
+ Whenever a deprecation matches one of the regex, it is ignored.
80
79
 
81
80
  ```ruby
82
81
  DeprecationToolkit::Configuration.allowed_deprecations = [/Hello World/]
83
82
 
84
- # Let's imagine a third dependency adds a deprecation like this,
85
- # the Deprecation Toolkit will simply ignore it.
86
- ActiveSupport::Deprecation.warn('Hello World')
83
+ ActiveSupport::Deprecation.warn('Hello World') # ignored by Deprecation Toolkit
87
84
  ```
88
85
 
89
86
  ### 🔨 `#DeprecationToolkit::Configuration#warnings_treated_as_deprecation`
90
87
 
91
- Most gems doesn't use `ActiveSupport::Deprecation` to deprecate their code but instead just uses `Kernel#warn` to output
88
+ Most gems don't use `ActiveSupport::Deprecation` to deprecate their code but instead just use `Kernel#warn` to output
92
89
  a message in the console.
93
90
 
94
- The DeprecationToolkit gem allows you to configure which warnings should be treated as deprecations in order for you
91
+ Deprecation Toolkit allows you to configure which warnings should be treated as deprecations in order for you
95
92
  to keep track of them as if they were regular deprecations.
96
93
 
97
94
  ## License
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeprecationToolkit
4
- VERSION = "1.0.2"
4
+ VERSION = "1.0.3"
5
5
  end
@@ -25,17 +25,23 @@ end
25
25
  # Note that the `Warning` module exists in Ruby 2.4 but has a bug https://bugs.ruby-lang.org/issues/12944
26
26
  if RUBY_VERSION < '2.5.0' && RUBY_ENGINE == 'ruby'
27
27
  module Kernel
28
- alias_method :__original_warn, :warn
28
+ class << self
29
+ alias_method :__original_warn, :warn
29
30
 
30
- def warn(*messages)
31
- message = messages.join("\n")
32
- message += "\n" unless message.end_with?("\n")
31
+ def warn(*messages)
32
+ message = messages.join("\n")
33
+ message += "\n" unless message.end_with?("\n")
33
34
 
34
- if DeprecationToolkit::Warning.deprecation_triggered?(message)
35
- ActiveSupport::Deprecation.warn(message)
36
- else
37
- __original_warn(messages)
35
+ if DeprecationToolkit::Warning.deprecation_triggered?(message)
36
+ ActiveSupport::Deprecation.warn(message)
37
+ else
38
+ __original_warn(messages)
39
+ end
38
40
  end
39
41
  end
42
+
43
+ def warn(*messages)
44
+ Kernel.warn(messages)
45
+ end
40
46
  end
41
47
  end
@@ -11,6 +11,21 @@ module DeprecationToolkit
11
11
  autoload :Raise, "deprecation_toolkit/behaviors/raise"
12
12
  autoload :Record, "deprecation_toolkit/behaviors/record"
13
13
  end
14
+
15
+ def self.add_notify_behavior
16
+ notify = ActiveSupport::Deprecation::DEFAULT_BEHAVIORS[:notify]
17
+ behaviors = ActiveSupport::Deprecation.behavior
18
+
19
+ unless behaviors.find { |behavior| behavior == notify }
20
+ ActiveSupport::Deprecation.behavior = behaviors << notify
21
+ end
22
+ end
23
+
24
+ def self.attach_subscriber
25
+ Configuration.attach_to.each do |gem_name|
26
+ DeprecationSubscriber.attach_to gem_name
27
+ end
28
+ end
14
29
  end
15
30
 
16
31
  require "deprecation_toolkit/minitest_hook"
@@ -14,24 +14,7 @@ module Minitest
14
14
  DeprecationToolkit::Configuration.behavior = DeprecationToolkit::Behaviors::Record
15
15
  end
16
16
 
17
- add_notify_behavior
18
- attach_subscriber
19
- end
20
-
21
- private
22
-
23
- def add_notify_behavior
24
- notify = ActiveSupport::Deprecation::DEFAULT_BEHAVIORS[:notify]
25
- behaviors = ActiveSupport::Deprecation.behavior
26
-
27
- unless behaviors.find { |behavior| behavior == notify }
28
- ActiveSupport::Deprecation.behavior = behaviors << notify
29
- end
30
- end
31
-
32
- def attach_subscriber
33
- DeprecationToolkit::Configuration.attach_to.each do |gem_name|
34
- DeprecationToolkit::DeprecationSubscriber.attach_to gem_name
35
- end
17
+ DeprecationToolkit.add_notify_behavior
18
+ DeprecationToolkit.attach_subscriber
36
19
  end
37
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deprecation_toolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-01 00:00:00.000000000 Z
11
+ date: 2018-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport