code_analyzer 0.3.2 → 0.4.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/.ruby-version +1 -1
- data/lib/code_analyzer/sexp.rb +6 -6
- data/lib/code_analyzer/version.rb +1 -1
- data/spec/code_analyzer/sexp_spec.rb +11 -11
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3723a944cc80445e3d5dc42360bf001e1bf66221
|
4
|
+
data.tar.gz: 37a887ceee61cdb1fb1e8227112e102e06b0e047
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f308e1967ea4b8dffb44d338bb691445587fcfaffc46c33bdad729e8cec169cd8f93aacd36d5cabc72d1f1c451a75b91647f336508aca4acf43359a11e9aaa92
|
7
|
+
data.tar.gz: be8452dc9cc7f9a39519af9df1c80a678485a10ce22ebc6e3997283befadf1a9c298725ac6fc5ab6a9592d6d40319b6b2f6cc0828342983345a19308fcf8b0cb
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.0.0
|
1
|
+
ruby-2.0.0
|
data/lib/code_analyzer/sexp.rb
CHANGED
@@ -13,22 +13,22 @@ class Sexp
|
|
13
13
|
#
|
14
14
|
# s(:@ident, "test", s(2, 12)
|
15
15
|
# => 2
|
16
|
-
def
|
16
|
+
def line_number
|
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,
|
20
20
|
:if, :unless, :elsif, :ifop, :if_mod, :unless_mod, :binary,
|
21
21
|
:alias, :symbol_literal, :symbol, :aref, :hash, :assoc_new, :string_literal,
|
22
22
|
:massign
|
23
|
-
self[1].
|
23
|
+
self[1].line_number
|
24
24
|
when :assoclist_from_args, :bare_assoc_hash
|
25
|
-
self[1][0].
|
25
|
+
self[1][0].line_number
|
26
26
|
when :string_add, :opassign
|
27
|
-
self[2].
|
27
|
+
self[2].line_number
|
28
28
|
when :array
|
29
|
-
array_values.first.
|
29
|
+
array_values.first.line_number
|
30
30
|
when :mlhs_add
|
31
|
-
self.last.
|
31
|
+
self.last.line_number
|
32
32
|
else
|
33
33
|
self.last.first if self.last.is_a? Array
|
34
34
|
end
|
@@ -28,47 +28,47 @@ describe Sexp do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should return class line" do
|
31
|
-
@node.grep_node(sexp_type: :class).
|
31
|
+
@node.grep_node(sexp_type: :class).line_number.should == 1
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should return def line" do
|
35
|
-
@node.grep_node(sexp_type: :def).
|
35
|
+
@node.grep_node(sexp_type: :def).line_number.should == 2
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should return const line" do
|
39
|
-
@node.grep_node(sexp_type: :const_ref).
|
39
|
+
@node.grep_node(sexp_type: :const_ref).line_number.should == 1
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should return const path line" do
|
43
|
-
@node.grep_node(sexp_type: :const_path_ref).
|
43
|
+
@node.grep_node(sexp_type: :const_path_ref).line_number.should == 3
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should return alias line" do
|
47
|
-
@node.grep_node(sexp_type: :alias).
|
47
|
+
@node.grep_node(sexp_type: :alias).line_number.should == 5
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should return hash line" do
|
51
|
-
@node.grep_node(sexp_type: :hash).
|
51
|
+
@node.grep_node(sexp_type: :hash).line_number.should == 6
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should return massign line" do
|
55
|
-
@node.grep_node(sexp_type: :massign).
|
55
|
+
@node.grep_node(sexp_type: :massign).line_number.should == 8
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should return opassign line" do
|
59
|
-
@node.grep_node(sexp_type: :opassign).
|
59
|
+
@node.grep_node(sexp_type: :opassign).line_number.should == 11
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should return if line" do
|
63
|
-
expect(@node.grep_node(sexp_type: :if).
|
63
|
+
expect(@node.grep_node(sexp_type: :if).line_number).to eq 14
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should return elsif line" do
|
67
|
-
expect(@node.grep_node(sexp_type: :elsif).
|
67
|
+
expect(@node.grep_node(sexp_type: :elsif).line_number).to eq 16
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should return if_mod line" do
|
71
|
-
expect(@node.grep_node(sexp_type: :if_mod).
|
71
|
+
expect(@node.grep_node(sexp_type: :if_mod).line_number).to eq 15
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code_analyzer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sexp_processor
|
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
108
|
version: '0'
|
109
109
|
requirements: []
|
110
110
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.0.
|
111
|
+
rubygems_version: 2.0.6
|
112
112
|
signing_key:
|
113
113
|
specification_version: 4
|
114
114
|
summary: a code analyzer helps you build your own code analyzer tool.
|