zombie_scout 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/zombie_scout/method_finder.rb +32 -23
- data/lib/zombie_scout/version.rb +1 -1
- data/spec/zombie_scout/method_finder_spec.rb +61 -23
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc91be8df398812d74758f0f52b4fb5314debcbe
|
4
|
+
data.tar.gz: 908249e99886cd2546e40a59d6a68cbe379ed2df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2854512c5126c80f7c33dd118ec0577adfab4adeba60c823eaa47602933eee4fc81c3c91a6b9483f927a262de8cae58524e5a7d4138475c5f718e0552310b97
|
7
|
+
data.tar.gz: ad6e1a064157c087b9b081c0aa889af10f85f337d47eb9beab4c52a141f9143265f0a406338cae3c6c50a0cbf9c5055750625f991e00a9fd256465eae54d51d1
|
data/README.md
CHANGED
@@ -34,8 +34,8 @@ module ZombieScout
|
|
34
34
|
|
35
35
|
def on_send(node)
|
36
36
|
receiver, method_name, *args = *node
|
37
|
-
if respond_to?(:"
|
38
|
-
send(:"
|
37
|
+
if respond_to?(:"handle_#{method_name}", true)
|
38
|
+
send(:"handle_#{method_name}", args, node)
|
39
39
|
elsif receiver.nil? # Then it's a private method call
|
40
40
|
@private_method_calls << method_name
|
41
41
|
process_all(args)
|
@@ -44,47 +44,56 @@ module ZombieScout
|
|
44
44
|
|
45
45
|
private
|
46
46
|
|
47
|
-
def
|
47
|
+
def handle_attr_reader(args, node)
|
48
48
|
args.each do |arg|
|
49
|
-
|
50
|
-
|
49
|
+
if_symbol(arg) do |attr_method_name|
|
50
|
+
stash_method(attr_method_name, node)
|
51
|
+
end
|
51
52
|
end
|
52
53
|
end
|
53
54
|
|
54
|
-
def
|
55
|
+
def handle_attr_writer(args, node)
|
55
56
|
args.each do |arg|
|
56
|
-
|
57
|
-
|
57
|
+
if_symbol(arg) do |attr_method_name|
|
58
|
+
stash_method(:"#{attr_method_name}=", node)
|
59
|
+
end
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
61
|
-
def
|
63
|
+
def handle_attr_accessor(args, node)
|
62
64
|
args.each do |arg|
|
63
|
-
|
64
|
-
|
65
|
-
|
65
|
+
if_symbol(arg) do |attr_method_name|
|
66
|
+
stash_method(attr_method_name, node)
|
67
|
+
stash_method(:"#{attr_method_name}=", node)
|
68
|
+
end
|
66
69
|
end
|
67
70
|
end
|
68
71
|
|
69
|
-
def
|
72
|
+
def handle_def_delegators(args, node)
|
70
73
|
args.drop(1).each do |arg|
|
71
|
-
|
72
|
-
|
74
|
+
if_symbol(arg) do |attr_method_name|
|
75
|
+
stash_method(attr_method_name, node)
|
76
|
+
end
|
73
77
|
end
|
74
78
|
end
|
75
79
|
|
76
|
-
def
|
77
|
-
|
78
|
-
|
80
|
+
def handle_def_delegator(args, node)
|
81
|
+
if_symbol(args.last) do |attr_method_name|
|
82
|
+
stash_method(attr_method_name, node)
|
83
|
+
end
|
79
84
|
end
|
80
85
|
|
81
|
-
def
|
82
|
-
|
83
|
-
|
86
|
+
def handle_scope(args, node)
|
87
|
+
if_symbol(args.first) do |attr_method_name|
|
88
|
+
stash_method(attr_method_name, node)
|
89
|
+
end
|
84
90
|
end
|
85
91
|
|
86
|
-
def
|
87
|
-
SymbolExtracter.new.process(node)
|
92
|
+
def if_symbol(node)
|
93
|
+
maybe_symbol = SymbolExtracter.new.process(node)
|
94
|
+
if maybe_symbol.is_a? Symbol
|
95
|
+
yield maybe_symbol
|
96
|
+
end
|
88
97
|
end
|
89
98
|
|
90
99
|
def stash_method(method_name, node)
|
data/lib/zombie_scout/version.rb
CHANGED
@@ -32,41 +32,79 @@ describe ZombieScout::MethodFinder, '#find_methods' do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
context 'when a ruby file has attr_readers' do
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
35
|
+
context "when they're declared with symbols, the normal way" do
|
36
|
+
let(:ruby_code) {
|
37
|
+
"class Book
|
38
|
+
attr_reader :title, :author
|
39
|
+
end"
|
40
|
+
}
|
41
|
+
it 'can find attr_readers' do
|
42
|
+
expect(zombies.map(&:name)).to eq(%i[author title])
|
43
|
+
end
|
44
|
+
end
|
45
|
+
context "when they're declare with a splat from an array of symbols" do
|
46
|
+
let(:ruby_code) {
|
47
|
+
"class Book
|
48
|
+
attributes = %i(title author)
|
49
|
+
attr_reader *attributes
|
50
|
+
end"
|
51
|
+
}
|
52
|
+
it 'will ignore them' do
|
53
|
+
expect(zombies).to be_empty
|
54
|
+
end
|
43
55
|
end
|
44
56
|
end
|
45
57
|
|
46
58
|
context 'when a ruby file has attr_writers' do
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
59
|
+
context "when they're declared with symbols, the normal way" do
|
60
|
+
let(:ruby_code) {
|
61
|
+
"class Book
|
62
|
+
attr_writer :title, :author
|
63
|
+
end"
|
64
|
+
}
|
65
|
+
it 'can find attr_writers' do
|
66
|
+
expect(zombies.map(&:name)).to eq(%i[author= title=])
|
67
|
+
end
|
68
|
+
end
|
69
|
+
context "when they're declare with a splat from an array of symbols" do
|
70
|
+
let(:ruby_code) {
|
71
|
+
"class Book
|
72
|
+
attributes = %i(title author)
|
73
|
+
attr_reader *attributes
|
74
|
+
end"
|
75
|
+
}
|
76
|
+
it 'will ignore them' do
|
77
|
+
expect(zombies).to be_empty
|
78
|
+
end
|
54
79
|
end
|
55
80
|
end
|
56
81
|
|
57
82
|
context 'when a ruby file has attr_accessors' do
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
83
|
+
context "when they're declared with symbols, the normal way" do
|
84
|
+
let(:ruby_code) {
|
85
|
+
"class Book
|
86
|
+
attr_accessor :title, :author
|
87
|
+
end"
|
88
|
+
}
|
89
|
+
it 'can find attr_accessors' do
|
90
|
+
expect(zombies.map(&:name)).to eq(%i[author author= title title=])
|
91
|
+
end
|
92
|
+
end
|
93
|
+
context "when they're declare with a splat from an array of symbols" do
|
94
|
+
let(:ruby_code) {
|
95
|
+
"class Book
|
96
|
+
attributes = %i(title author)
|
97
|
+
attr_accessor *attributes
|
98
|
+
end"
|
99
|
+
}
|
100
|
+
it 'will ignore them' do
|
101
|
+
expect(zombies).to be_empty
|
102
|
+
end
|
65
103
|
end
|
66
104
|
end
|
67
105
|
|
68
106
|
context 'when a ruby file uses Forwardable::def_delegator' do
|
69
|
-
let(:ruby_code) {
|
107
|
+
let(:ruby_code) {
|
70
108
|
"class RecordCollection
|
71
109
|
extend Forwardable
|
72
110
|
def_delegator :@records, :[], :record_number
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zombie_scout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Bernier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '2.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: thor
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0.18'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.18'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.5'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.5'
|
55
55
|
description: "zombie_scout finds methods in classes in your ruby project, \nand then
|
@@ -61,11 +61,11 @@ executables:
|
|
61
61
|
extensions: []
|
62
62
|
extra_rdoc_files: []
|
63
63
|
files:
|
64
|
-
- .gitignore
|
65
|
-
- .rspec
|
66
|
-
- .ruby-gemset
|
67
|
-
- .ruby-version
|
68
|
-
- .travis.yml
|
64
|
+
- ".gitignore"
|
65
|
+
- ".rspec"
|
66
|
+
- ".ruby-gemset"
|
67
|
+
- ".ruby-version"
|
68
|
+
- ".travis.yml"
|
69
69
|
- Gemfile
|
70
70
|
- Gemfile.lock
|
71
71
|
- LICENSE
|
@@ -95,17 +95,17 @@ require_paths:
|
|
95
95
|
- lib
|
96
96
|
required_ruby_version: !ruby/object:Gem::Requirement
|
97
97
|
requirements:
|
98
|
-
- -
|
98
|
+
- - ">="
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: '0'
|
101
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- -
|
103
|
+
- - ">="
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
107
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
108
|
+
rubygems_version: 2.2.2
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: Find dead methods in your Ruby app
|