code_analyzer 0.1.0 → 0.1.1
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.
- data/lib/code_analyzer/sexp.rb +5 -2
- data/lib/code_analyzer/version.rb +1 -1
- data/spec/code_analyzer/sexp_spec.rb +14 -0
- metadata +7 -17
data/lib/code_analyzer/sexp.rb
CHANGED
@@ -17,14 +17,17 @@ class Sexp
|
|
17
17
|
case sexp_type
|
18
18
|
when :def, :defs, :command, :command_call, :call, :fcall, :method_add_arg, :method_add_block,
|
19
19
|
:var_ref, :vcall, :const_ref, :const_path_ref, :class, :module, :if, :unless, :elsif, :ifop, :binary,
|
20
|
-
:alias, :symbol_literal, :symbol, :aref, :hash, :assoc_new, :string_literal
|
20
|
+
:alias, :symbol_literal, :symbol, :aref, :hash, :assoc_new, :string_literal,
|
21
|
+
:massign
|
21
22
|
self[1].line
|
22
23
|
when :assoclist_from_args, :bare_assoc_hash
|
23
24
|
self[1][0].line
|
24
|
-
when :string_add
|
25
|
+
when :string_add, :opassign
|
25
26
|
self[2].line
|
26
27
|
when :array
|
27
28
|
array_values.first.line
|
29
|
+
when :mlhs_add
|
30
|
+
self.last.line
|
28
31
|
else
|
29
32
|
self.last.first if self.last.is_a? Array
|
30
33
|
end
|
@@ -10,6 +10,12 @@ describe Sexp do
|
|
10
10
|
end
|
11
11
|
alias :test_new :test
|
12
12
|
CONST = { foo: :bar }
|
13
|
+
def massign
|
14
|
+
a, b = 10, 20
|
15
|
+
end
|
16
|
+
def opassign(a, b)
|
17
|
+
a+= b
|
18
|
+
end
|
13
19
|
end
|
14
20
|
EOF
|
15
21
|
@node = parse_content(content)
|
@@ -38,6 +44,14 @@ describe Sexp do
|
|
38
44
|
it "should return hash line" do
|
39
45
|
@node.grep_node(sexp_type: :hash).line.should == 6
|
40
46
|
end
|
47
|
+
|
48
|
+
it "should return massign line" do
|
49
|
+
@node.grep_node(sexp_type: :massign).line.should == 8
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should return opassign line" do
|
53
|
+
@node.grep_node(sexp_type: :opassign).line.should == 11
|
54
|
+
end
|
41
55
|
end
|
42
56
|
|
43
57
|
describe "grep_nodes" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code_analyzer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sexp_processor
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70274611483180 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,15 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
24
|
+
version_requirements: *70274611483180
|
30
25
|
- !ruby/object:Gem::Dependency
|
31
26
|
name: rspec
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
27
|
+
requirement: &70274611482560 !ruby/object:Gem::Requirement
|
33
28
|
none: false
|
34
29
|
requirements:
|
35
30
|
- - ! '>='
|
@@ -37,12 +32,7 @@ dependencies:
|
|
37
32
|
version: '0'
|
38
33
|
type: :development
|
39
34
|
prerelease: false
|
40
|
-
version_requirements:
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
35
|
+
version_requirements: *70274611482560
|
46
36
|
description: a code analyzer tool which extracted from rails_best_practices, it helps
|
47
37
|
you easily build your own code analyzer tool.
|
48
38
|
email:
|
@@ -96,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
86
|
version: '0'
|
97
87
|
requirements: []
|
98
88
|
rubyforge_project:
|
99
|
-
rubygems_version: 1.8.
|
89
|
+
rubygems_version: 1.8.17
|
100
90
|
signing_key:
|
101
91
|
specification_version: 3
|
102
92
|
summary: a code analyzer helps you build your own code analyzer tool.
|