do_not_use 0.2.0 → 0.3.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
  SHA256:
3
- metadata.gz: b93787f765735c96304881e364255c8c0fe8a664b43bc737a2b43a4ad0e6cbda
4
- data.tar.gz: 3004281bae0b9d14dcd6a255990db6ba301d0798b8f42c09b94efffa1709eebf
3
+ metadata.gz: b6a84ce5ca35c3345bd0186eb4ebb22acf41ac2a5b3ed15f44bc48507ab21e47
4
+ data.tar.gz: 901feb6a401f530262365da4b954987cecf1976c64603a5b8e79e7fdedeb83f2
5
5
  SHA512:
6
- metadata.gz: 690b17642309d4bb33d17b24641df0ab00321db20c6b223765d51ced50a8007e61a12992f51666f0a36f61f3f3f99fface0b2bd8d7735cdb2243bd3ab827b163
7
- data.tar.gz: 6bcd554bc83be5bc8ab01e4e4f95add790b16a0a5609b5377f8b972135fd62a3aef1b5a822541ae7bf6ea893519a63f8aceff77ab0572d9ff8aa91fa9a265ff6
6
+ metadata.gz: dd18475196eb7d2e848b4fd1d68fe9f3799620d6eee1466db218c4a1a42386f7a7bc7ee25b16bad50f836a9911597d46d1a9d570cfac97bbf384a56dbec0d17b
7
+ data.tar.gz: 3c87ad42290d18ec8083c1bdbdc51db2e4bfa63071ff4e8817d87516c52c84574288ce0b4532e9cd4061ed3005bab5a2565297857b9b1e578a9901b48db7556f
@@ -10,7 +10,7 @@ module DoNotUse
10
10
  @tracked_paths = []
11
11
  @ignored_paths = []
12
12
  @enabled = true
13
- @signature_generators = {}
13
+ @signature_generators = []
14
14
  end
15
15
 
16
16
  def exceptions
@@ -10,16 +10,6 @@ module DoNotUse
10
10
  located_in_tracked_path? && !located_in_ignored_path?
11
11
  end
12
12
 
13
- # Custom signature generators registered via gem configuration.
14
- # These generators are only used for instructions located in ignored paths.
15
- #
16
- # This allows users to define signatures for those instructions as they see fit.
17
- def signature_generator
18
- signature_generators.find { |proc, _| proc.call(self) }&.second
19
- end
20
-
21
- delegate :starts_with?, to: :source_path
22
-
23
13
  private
24
14
 
25
15
  attr_reader :source_path
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DoNotUse
4
+ module Signatures
5
+ module CustomSignatures
6
+ class RspecSignature
7
+ class << self
8
+ def call(...)
9
+ new(...).signature
10
+ end
11
+ end
12
+
13
+ def initialize(instruction)
14
+ @instruction = instruction
15
+ end
16
+
17
+ def signature
18
+ return unless receiver < RSpec
19
+
20
+ receiver.module_parents[-4].name
21
+ end
22
+
23
+ private
24
+
25
+ attr_reader :instruction
26
+
27
+ delegate :receiver, to: :instruction, private: true
28
+ end
29
+ end
30
+ end
31
+ end
@@ -9,6 +9,8 @@ module DoNotUse
9
9
 
10
10
  private
11
11
 
12
+ delegate :configuration, to: DoNotUse, private: true
13
+ delegate :signature_generators, to: :configuration, private: true
12
14
  delegate :receiver, :signature_generator, to: :instruction, private: true
13
15
 
14
16
  def parent_module
@@ -16,7 +18,7 @@ module DoNotUse
16
18
  end
17
19
 
18
20
  def custom_signature
19
- signature_generator&.call(instruction)
21
+ signature_generators.lazy.map { |generator| generator.call(instruction) }.find(&:itself)
20
22
  end
21
23
  end
22
24
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DoNotUse
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: do_not_use
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mehmet Emin INAC
@@ -63,6 +63,7 @@ files:
63
63
  - lib/do_not_use/patches/module_patch.rb
64
64
  - lib/do_not_use/signature_builder.rb
65
65
  - lib/do_not_use/signatures/abstract_code.rb
66
+ - lib/do_not_use/signatures/custom_signatures/rspec_signature.rb
66
67
  - lib/do_not_use/signatures/ignored_code.rb
67
68
  - lib/do_not_use/signatures/tracked_code.rb
68
69
  - lib/do_not_use/version.rb
@@ -86,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
87
  - !ruby/object:Gem::Version
87
88
  version: '0'
88
89
  requirements: []
89
- rubygems_version: 4.0.9
90
+ rubygems_version: 4.0.10
90
91
  specification_version: 4
91
92
  summary: Marks methods/attributes as deprecated and captures their usages.
92
93
  test_files: []