do_not_use 0.1.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 +4 -4
- data/README.md +1 -1
- data/lib/do_not_use/configuration.rb +1 -1
- data/lib/do_not_use/instruction.rb +4 -4
- data/lib/do_not_use/location.rb +0 -8
- data/lib/do_not_use/signatures/custom_signatures/rspec_signature.rb +31 -0
- data/lib/do_not_use/signatures/ignored_code.rb +3 -1
- data/lib/do_not_use/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b6a84ce5ca35c3345bd0186eb4ebb22acf41ac2a5b3ed15f44bc48507ab21e47
|
|
4
|
+
data.tar.gz: 901feb6a401f530262365da4b954987cecf1976c64603a5b8e79e7fdedeb83f2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dd18475196eb7d2e848b4fd1d68fe9f3799620d6eee1466db218c4a1a42386f7a7bc7ee25b16bad50f836a9911597d46d1a9d570cfac97bbf384a56dbec0d17b
|
|
7
|
+
data.tar.gz: 3c87ad42290d18ec8083c1bdbdc51db2e4bfa63071ff4e8817d87516c52c84574288ce0b4532e9cd4061ed3005bab5a2565297857b9b1e578a9901b48db7556f
|
data/README.md
CHANGED
|
@@ -112,7 +112,7 @@ DoNotUse.configure do |config|
|
|
|
112
112
|
config.ignored_paths << Rails.root.join("spec") # The paths which you don't want to track.
|
|
113
113
|
config.exceptions_yaml_path = Rails.root.join("exceptions.yaml") # The YAML file path where you specify existing usages of the deprecated APIs.
|
|
114
114
|
config.signature_generators = {
|
|
115
|
-
Rails.root.join("spec", "models") => Proc.new { |instruction| ... }
|
|
115
|
+
Proc.new { |location| location.starts_with?(Rails.root.join("spec", "models").to_s) } => Proc.new { |instruction| ... }
|
|
116
116
|
} # Helps you configure how the instruction signatures are generated for the ignored paths.
|
|
117
117
|
end
|
|
118
118
|
```
|
|
@@ -34,6 +34,10 @@ module DoNotUse
|
|
|
34
34
|
!location.track? && inherited_method?
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
def location
|
|
38
|
+
@location ||= Location.new(source_path)
|
|
39
|
+
end
|
|
40
|
+
|
|
37
41
|
delegate :frame_type, to: :binding
|
|
38
42
|
delegate :signature_generator, to: :location
|
|
39
43
|
|
|
@@ -52,10 +56,6 @@ module DoNotUse
|
|
|
52
56
|
Location.new(receiver_source_path.first)
|
|
53
57
|
end
|
|
54
58
|
|
|
55
|
-
def location
|
|
56
|
-
@location ||= Location.new(source_path)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
59
|
def inherited_method?
|
|
60
60
|
receiver != method_owner
|
|
61
61
|
end
|
data/lib/do_not_use/location.rb
CHANGED
|
@@ -10,14 +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 { |path, _| source_path.starts_with?(path) }&.second
|
|
19
|
-
end
|
|
20
|
-
|
|
21
13
|
private
|
|
22
14
|
|
|
23
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
|
-
|
|
21
|
+
signature_generators.lazy.map { |generator| generator.call(instruction) }.find(&:itself)
|
|
20
22
|
end
|
|
21
23
|
end
|
|
22
24
|
end
|
data/lib/do_not_use/version.rb
CHANGED
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.
|
|
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.
|
|
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: []
|