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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cd9585ab8fa23daa27c71cfc11fcf41ebc6a371c
4
- data.tar.gz: dec2c2a121cc1fb3f3ab9bd9bafdccc1f865ad72
3
+ metadata.gz: cc91be8df398812d74758f0f52b4fb5314debcbe
4
+ data.tar.gz: 908249e99886cd2546e40a59d6a68cbe379ed2df
5
5
  SHA512:
6
- metadata.gz: 43c329a1bdfd59df278b325ff65e1d9d879b9ee8dfa0e12195a5db39a63b516ef928e3ef8a7b0c5166f3e6e79e16612a05871d08d10709a81d2340514618eaf8
7
- data.tar.gz: 1365f7a6b810c2ec97447d8efeb52d4c055f9f9a62dd688ba9587baa6308c11f365a7db9b0e2e1c73d078c9c47b8c6337d3bfb337097a97471ab596346ea538a
6
+ metadata.gz: a2854512c5126c80f7c33dd118ec0577adfab4adeba60c823eaa47602933eee4fc81c3c91a6b9483f927a262de8cae58524e5a7d4138475c5f718e0552310b97
7
+ data.tar.gz: ad6e1a064157c087b9b081c0aa889af10f85f337d47eb9beab4c52a141f9143265f0a406338cae3c6c50a0cbf9c5055750625f991e00a9fd256465eae54d51d1
data/README.md CHANGED
@@ -53,7 +53,7 @@ The basics:
53
53
 
54
54
  Or, add this to your Gemfile:
55
55
 
56
- gem 'zombie_scout', github: 'danbernier/zombie_scout'
56
+ gem 'zombie_scout'
57
57
 
58
58
  ## Usage
59
59
 
@@ -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?(:"on_#{method_name}", true)
38
- send(:"on_#{method_name}", args, node)
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 on_attr_reader(args, node)
47
+ def handle_attr_reader(args, node)
48
48
  args.each do |arg|
49
- attr_method_name = symbol(arg)
50
- stash_method(attr_method_name, node)
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 on_attr_writer(args, node)
55
+ def handle_attr_writer(args, node)
55
56
  args.each do |arg|
56
- attr_method_name = symbol(arg)
57
- stash_method(:"#{attr_method_name}=", node)
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 on_attr_accessor(args, node)
63
+ def handle_attr_accessor(args, node)
62
64
  args.each do |arg|
63
- attr_method_name = symbol(arg)
64
- stash_method(attr_method_name, node)
65
- stash_method(:"#{attr_method_name}=", node)
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 on_def_delegators(args, node)
72
+ def handle_def_delegators(args, node)
70
73
  args.drop(1).each do |arg|
71
- attr_method_name = symbol(arg)
72
- stash_method(attr_method_name, node)
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 on_def_delegator(args, node)
77
- attr_method_name = symbol(args.last)
78
- stash_method(attr_method_name, node)
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 on_scope(args, node)
82
- attr_method_name = symbol(args.first)
83
- stash_method(attr_method_name, node)
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 symbol(node)
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)
@@ -1,3 +1,3 @@
1
1
  module ZombieScout
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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
- let(:ruby_code) {
36
- "class Book
37
- attr_reader :title, :author
38
- end"
39
- }
40
-
41
- it 'can find attr_readers' do
42
- expect(zombies.map(&:name)).to eq(%i[author title])
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
- let(:ruby_code) {
48
- "class Book
49
- attr_writer :title, :author
50
- end"
51
- }
52
- it 'can find attr_writers' do
53
- expect(zombies.map(&:name)).to eq(%i[author= title=])
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
- let(:ruby_code) {
59
- "class Book
60
- attr_accessor :title, :author
61
- end"
62
- }
63
- it 'can find attr_accessors' do
64
- expect(zombies.map(&:name)).to eq(%i[author author= title title=])
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.1
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-26 00:00:00.000000000 Z
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.1.10
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