deprecation_toolkit 2.2.0 → 2.2.1

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
  SHA256:
3
- metadata.gz: 562db3c54971f9c7513f6777b6b351325772a467f3a12b9467aee8ae09faea7b
4
- data.tar.gz: 5d8bfeb8af3b883747c4b72a168e7504080f9e87260b65a67f9ecabe99071016
3
+ metadata.gz: 3584b676fc957381c253538150d205b4a0711efee7ef5b3f5926b4b2674b10a4
4
+ data.tar.gz: b44b3fc7c0b2fe3a93cc05f225cd8cb13cb4f6d3d762c5c4a89ac67863c9a4bc
5
5
  SHA512:
6
- metadata.gz: 4a801c1cd12e35a705b89ecb7e3f2863be8ef488f29efb8537f7a858d86f68355cd571f22e4b16cd8b50b3c08b7b63e6ac187a12e9bcda184f268b41695b2a14
7
- data.tar.gz: 940e38840d651bd4cb2432b8d99c0cbdd78257fc8a5cce2175c60fbd40c0bca45a4ad66e6201e3699fdaaf4b6867c7c02257762dec942e1a3b1e29fd89bef9b0
6
+ metadata.gz: f20edbb85c72c400f9fb1a6f2e9151fe08d249107f4ac27e2432f29b7c13ceb5222f78dfe2990ec5faf34190fe197096db7065f4be61c55ce199a3a049cf756a
7
+ data.tar.gz: 55c16daef83b058df361785d033bffaa4be13efeac27acf77f1fa65bfcd236ccb42e719402f9b965737d31dd3647fa5efd6f87225b8aca2ece519491d8c4f6b7
data/.rubocop.yml CHANGED
@@ -2,7 +2,6 @@ inherit_gem:
2
2
  rubocop-shopify: rubocop.yml
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 2.6
6
5
  SuggestExtensions: false
7
6
  Exclude:
8
7
  - gemfiles/vendor/**/*
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.3.0
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- deprecation_toolkit (2.2.0)
4
+ deprecation_toolkit (2.2.1)
5
5
  activesupport (>= 6.1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (7.1.2)
10
+ activesupport (7.1.3.4)
11
11
  base64
12
12
  bigdecimal
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
@@ -19,54 +19,60 @@ GEM
19
19
  tzinfo (~> 2.0)
20
20
  ast (2.4.2)
21
21
  base64 (0.2.0)
22
- bigdecimal (3.1.4)
23
- concurrent-ruby (1.2.2)
22
+ bigdecimal (3.1.8)
23
+ concurrent-ruby (1.3.3)
24
24
  connection_pool (2.4.1)
25
- diff-lcs (1.5.0)
26
- drb (2.2.0)
27
- ruby2_keywords
28
- i18n (1.14.1)
25
+ diff-lcs (1.5.1)
26
+ drb (2.2.1)
27
+ i18n (1.14.5)
29
28
  concurrent-ruby (~> 1.0)
30
- minitest (5.20.0)
29
+ json (2.7.2)
30
+ language_server-protocol (3.17.0.3)
31
+ minitest (5.25.1)
31
32
  mutex_m (0.2.0)
32
- parallel (1.21.0)
33
- parser (3.1.1.0)
33
+ parallel (1.24.0)
34
+ parser (3.3.1.0)
34
35
  ast (~> 2.4.1)
36
+ racc
37
+ racc (1.7.3)
35
38
  rainbow (3.1.1)
36
- rake (13.0.6)
37
- regexp_parser (2.2.1)
38
- rexml (3.2.5)
39
- rspec (3.11.0)
40
- rspec-core (~> 3.11.0)
41
- rspec-expectations (~> 3.11.0)
42
- rspec-mocks (~> 3.11.0)
43
- rspec-core (3.11.0)
44
- rspec-support (~> 3.11.0)
45
- rspec-expectations (3.11.0)
39
+ rake (13.2.1)
40
+ regexp_parser (2.9.2)
41
+ rexml (3.3.6)
42
+ strscan
43
+ rspec (3.13.0)
44
+ rspec-core (~> 3.13.0)
45
+ rspec-expectations (~> 3.13.0)
46
+ rspec-mocks (~> 3.13.0)
47
+ rspec-core (3.13.0)
48
+ rspec-support (~> 3.13.0)
49
+ rspec-expectations (3.13.0)
46
50
  diff-lcs (>= 1.2.0, < 2.0)
47
- rspec-support (~> 3.11.0)
48
- rspec-mocks (3.11.0)
51
+ rspec-support (~> 3.13.0)
52
+ rspec-mocks (3.13.1)
49
53
  diff-lcs (>= 1.2.0, < 2.0)
50
- rspec-support (~> 3.11.0)
51
- rspec-support (3.11.0)
52
- rubocop (1.25.1)
54
+ rspec-support (~> 3.13.0)
55
+ rspec-support (3.13.1)
56
+ rubocop (1.63.5)
57
+ json (~> 2.3)
58
+ language_server-protocol (>= 3.17.0)
53
59
  parallel (~> 1.10)
54
- parser (>= 3.1.0.0)
60
+ parser (>= 3.3.0.2)
55
61
  rainbow (>= 2.2.2, < 4.0)
56
62
  regexp_parser (>= 1.8, < 3.0)
57
- rexml
58
- rubocop-ast (>= 1.15.1, < 2.0)
63
+ rexml (>= 3.2.5, < 4.0)
64
+ rubocop-ast (>= 1.31.1, < 2.0)
59
65
  ruby-progressbar (~> 1.7)
60
- unicode-display_width (>= 1.4.0, < 3.0)
61
- rubocop-ast (1.16.0)
62
- parser (>= 3.1.1.0)
63
- rubocop-shopify (2.5.0)
64
- rubocop (~> 1.25)
65
- ruby-progressbar (1.11.0)
66
- ruby2_keywords (0.0.5)
66
+ unicode-display_width (>= 2.4.0, < 3.0)
67
+ rubocop-ast (1.31.3)
68
+ parser (>= 3.3.1.0)
69
+ rubocop-shopify (2.15.1)
70
+ rubocop (~> 1.51)
71
+ ruby-progressbar (1.13.0)
72
+ strscan (3.1.0)
67
73
  tzinfo (2.0.6)
68
74
  concurrent-ruby (~> 1.0)
69
- unicode-display_width (2.1.0)
75
+ unicode-display_width (2.5.0)
70
76
 
71
77
  PLATFORMS
72
78
  ruby
@@ -80,4 +86,4 @@ DEPENDENCIES
80
86
  rubocop-shopify
81
87
 
82
88
  BUNDLED WITH
83
- 2.4.4
89
+ 2.5.10
data/README.md CHANGED
@@ -57,16 +57,16 @@ This gem provides 4 behaviors, the default one being `DeprecationToolkit::Behavi
57
57
  DeprecationToolkit::Configuration.behavior = DeprecationToolkit::Behaviors::Record
58
58
  ```
59
59
 
60
- You can also create your own behavior class and perform the logic you want. Your behavior needs to respond to `.trigger`.
60
+ You can also create your own behavior object and perform the logic you want. Your behavior needs to respond to `trigger`.
61
61
 
62
62
  ```ruby
63
63
  class StatsdBehavior
64
- def self.trigger(test, deprecations, recorded_deprecations)
64
+ def trigger(test, deprecations, recorded_deprecations)
65
65
  # Could send some statsd event for example
66
66
  end
67
67
  end
68
68
 
69
- DeprecationToolkit::Configuration.behavior = StatsdBehavior
69
+ DeprecationToolkit::Configuration.behavior = StatsdBehavior.new
70
70
  ```
71
71
 
72
72
  #### DeprecationToolkit::Behaviors::CIRecordHelper
@@ -75,7 +75,7 @@ This is a special type of behaviour meant to help you record deprecations if you
75
75
  Imagine if you have thousands of tests and need to record deprecations for each on your machine, this is going to take ages.
76
76
  Recording deprecations on CI with the regular `Record` behavior isn't possible because of the way CI parallelize test in multiple container (Multiple tests from the same file runs in parallel in diferrent machines, the deprecation files that get created are then splitted. Regrouping them is a nightmare.)
77
77
 
78
- This behaviour will output a JSON representation of your deprecations. Your CI should have a way to download the log generated from the test run. Download it on your locale machine. Finally run the rake task `FILEPATH=<path_to_downloaded_log> deprecation_toolkit:record_from_ci_output`.
78
+ This behavior will output a JSON representation of your deprecations. Your CI should have a way to download the log generated from the test run. Download it on your locale machine. Finally run the rake task `FILEPATH=<path_to_downloaded_log> deprecation_toolkit:record_from_ci_output`.
79
79
  This task will parse your CI log and grab the output generated by the DeprecationToolkit and will finally convert everything back to YML files.
80
80
 
81
81
  ### 🔨 `#DeprecationToolkit::Configuration#allowed_deprecations`
@@ -170,6 +170,10 @@ It's possible to record deprecations while running your specs by adding an ENV['
170
170
  DEPRECATION_BEHAVIOR="record" bundle exec rspec path/to/file_spec.rb
171
171
  ```
172
172
 
173
+ ## Usage without Rails
174
+
175
+ Without Rails, you'll need to make sure your `ActiveSupport::Deprecation` instances use the [`:notify` behavior](https://api.rubyonrails.org/classes/ActiveSupport/Deprecation/Behavior.html#method-i-behavior-3D).
176
+
173
177
  ## License
174
178
 
175
179
  Deprecation Toolkit is licensed under the [MIT license](LICENSE.txt).
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.metadata["allowed_push_host"] = "https://rubygems.org"
22
22
 
23
- spec.required_ruby_version = ">= 2.7"
23
+ spec.required_ruby_version = ">= 3.0.0"
24
24
 
25
25
  spec.files = %x(git ls-files -z).split("\x0").reject do |f|
26
26
  f.match(%r{^(test|spec|\.github|gemfiles)/})
@@ -4,12 +4,13 @@ require "json"
4
4
 
5
5
  module DeprecationToolkit
6
6
  module Behaviors
7
- class CIRecordHelper
7
+ module CIRecordHelper
8
+ extend self
8
9
  extend ReadWriteHelper
9
10
 
10
11
  HEADER = "[DeprecationToolkit]"
11
12
 
12
- def self.trigger(test, current_deprecations, _recorded_deprecations)
13
+ def trigger(test, current_deprecations, _recorded_deprecations)
13
14
  filename = recorded_deprecations_path(test)
14
15
 
15
16
  to_output = {
@@ -2,8 +2,10 @@
2
2
 
3
3
  module DeprecationToolkit
4
4
  module Behaviors
5
- class Disabled
6
- def self.trigger(*)
5
+ module Disabled
6
+ extend self
7
+
8
+ def trigger(*)
7
9
  end
8
10
  end
9
11
  end
@@ -2,8 +2,10 @@
2
2
 
3
3
  module DeprecationToolkit
4
4
  module Behaviors
5
- class Raise
6
- def self.trigger(_test, current_deprecations, recorded_deprecations)
5
+ module Raise
6
+ extend self
7
+
8
+ def trigger(_test, current_deprecations, recorded_deprecations)
7
9
  error_class = if current_deprecations.size > recorded_deprecations.size
8
10
  DeprecationIntroduced
9
11
  elsif current_deprecations.size < recorded_deprecations.size
@@ -2,10 +2,11 @@
2
2
 
3
3
  module DeprecationToolkit
4
4
  module Behaviors
5
- class Record
5
+ module Record
6
+ extend self
6
7
  extend ReadWriteHelper
7
8
 
8
- def self.trigger(test, collector, _)
9
+ def trigger(test, collector, _)
9
10
  deprecation_file = recorded_deprecations_path(test)
10
11
 
11
12
  write(deprecation_file, test_name(test) => collector.deprecations_without_stacktrace)
@@ -65,11 +65,7 @@ module DeprecationToolkit
65
65
  private
66
66
 
67
67
  def active_support_deprecation_sub_params
68
- if ActiveSupport.gem_version.to_s < "5.0"
69
- [/\W\s\(called from .*\)$/, ""]
70
- else
71
- [/ \(called from .*\)$/, ""]
72
- end
68
+ [/ \(called from .*\)$/, ""]
73
69
  end
74
70
 
75
71
  def gem_deprecate_sub_params
@@ -4,8 +4,10 @@ require "active_support/subscriber"
4
4
 
5
5
  module DeprecationToolkit
6
6
  class DeprecationSubscriber < ActiveSupport::Subscriber
7
- def self.already_attached?
8
- notifier != nil
7
+ class << self
8
+ def already_attached?
9
+ notifier != nil
10
+ end
9
11
  end
10
12
 
11
13
  def deprecation(event)
@@ -17,10 +19,13 @@ module DeprecationToolkit
17
19
  private
18
20
 
19
21
  def deprecation_allowed?(payload)
20
- allowed_deprecations, procs = Configuration.allowed_deprecations.partition { |el| el.is_a?(Regexp) }
21
-
22
- allowed_deprecations.any? { |regex| regex =~ payload[:message] } ||
23
- procs.any? { |proc| proc.call(payload[:message], payload[:callstack]) }
22
+ Configuration.allowed_deprecations.any? do |rule|
23
+ if rule.is_a?(Regexp)
24
+ rule.match?(payload[:message])
25
+ else
26
+ rule.call(payload[:message], payload[:callstack])
27
+ end
28
+ end
24
29
  end
25
30
  end
26
31
  end
@@ -2,7 +2,9 @@
2
2
 
3
3
  module DeprecationToolkit
4
4
  module TestTriggerer
5
- def self.trigger_deprecation_toolkit_behavior(test)
5
+ extend self
6
+
7
+ def trigger_deprecation_toolkit_behavior(test)
6
8
  current_deprecations = DeprecationToolkit::Collector.new(DeprecationToolkit::Collector.deprecations)
7
9
  recorded_deprecations = DeprecationToolkit::Collector.load(test)
8
10
  if !recorded_deprecations.flaky? && current_deprecations != recorded_deprecations
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeprecationToolkit
4
- VERSION = "2.2.0"
4
+ VERSION = "2.2.1"
5
5
  end
@@ -48,11 +48,13 @@ module DeprecationToolkit
48
48
  end
49
49
  end
50
50
  end
51
- end
52
51
 
53
- module DeprecationToolkit
54
52
  module WarningPatch
55
53
  def warn(str, *)
54
+ if Configuration.warnings_treated_as_deprecation.empty?
55
+ return super
56
+ end
57
+
56
58
  str = DeprecationToolkit::Warning.handle_multipart(str)
57
59
  return unless str
58
60
 
@@ -64,5 +66,6 @@ module DeprecationToolkit
64
66
  end
65
67
  ruby2_keywords :warn
66
68
  end
69
+
70
+ ::Warning.singleton_class.prepend(WarningPatch)
67
71
  end
68
- Warning.singleton_class.prepend(DeprecationToolkit::WarningPatch)
@@ -44,7 +44,7 @@ module DeprecationToolkit
44
44
  def each_deprecator(&block)
45
45
  if defined?(Rails.application) && Rails.application.respond_to?(:deprecators)
46
46
  Rails.application.deprecators.each(&block)
47
- else
47
+ elsif ActiveSupport::Deprecation.respond_to?(:behavior)
48
48
  block.call(ActiveSupport::Deprecation)
49
49
  end
50
50
  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: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-05 00:00:00.000000000 Z
11
+ date: 2024-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '6.1'
27
- description:
27
+ description:
28
28
  email:
29
29
  - rails@shopify.com
30
30
  executables: []
@@ -34,6 +34,7 @@ files:
34
34
  - ".gitignore"
35
35
  - ".rspec"
36
36
  - ".rubocop.yml"
37
+ - ".ruby-version"
37
38
  - CHANGELOG.md
38
39
  - Gemfile
39
40
  - Gemfile.lock
@@ -68,7 +69,7 @@ metadata:
68
69
  source_code_uri: https://github.com/shopify/deprecation_toolkit
69
70
  changelog_uri: https://github.com/Shopify/deprecation_toolkit/blob/main/CHANGELOG.md
70
71
  allowed_push_host: https://rubygems.org
71
- post_install_message:
72
+ post_install_message:
72
73
  rdoc_options: []
73
74
  require_paths:
74
75
  - lib
@@ -76,15 +77,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
76
77
  requirements:
77
78
  - - ">="
78
79
  - !ruby/object:Gem::Version
79
- version: '2.7'
80
+ version: 3.0.0
80
81
  required_rubygems_version: !ruby/object:Gem::Requirement
81
82
  requirements:
82
83
  - - ">="
83
84
  - !ruby/object:Gem::Version
84
85
  version: '0'
85
86
  requirements: []
86
- rubygems_version: 3.5.5
87
- signing_key:
87
+ rubygems_version: 3.5.17
88
+ signing_key:
88
89
  specification_version: 4
89
90
  summary: Deprecation Toolkit around ActiveSupport::Deprecation
90
91
  test_files: []