starscope 1.0.4 → 1.1.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 +7 -0
- data/.gitignore +0 -1
- data/CHANGELOG.md +24 -1
- data/Gemfile.lock +6 -6
- data/README.md +8 -0
- data/Rakefile +1 -2
- data/bin/starscope +42 -24
- data/doc/DB_FORMAT.md +42 -0
- data/doc/LANGUAGE_SUPPORT.md +80 -0
- data/doc/USER_GUIDE.md +135 -0
- data/lib/starscope/db.rb +135 -83
- data/lib/starscope/langs/coffeescript.rb +1 -1
- data/lib/starscope/langs/go.rb +3 -0
- data/lib/starscope/langs/ruby.rb +11 -11
- data/lib/starscope/output.rb +16 -9
- data/lib/starscope/version.rb +1 -1
- data/test/fixtures/db_old.json.gz +0 -0
- data/test/{files → fixtures}/empty +0 -0
- data/test/{files → fixtures}/sample_golang.go +4 -0
- data/test/{files → fixtures}/sample_ruby.rb +0 -0
- data/test/functional/test_starscope.rb +35 -0
- data/test/test_helper.rb +5 -3
- data/test/{lib → unit}/test_db.rb +25 -18
- data/test/{lib → unit}/test_golang.rb +2 -0
- data/test/{lib → unit}/test_matcher.rb +0 -0
- data/test/{lib → unit}/test_record.rb +2 -2
- data/test/{lib → unit}/test_ruby.rb +0 -0
- metadata +36 -52
- data/test/files/db_old.json.gz +0 -0
- data/test/lib/test_starscope.rb +0 -33
Binary file
|
File without changes
|
File without changes
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
class TestStarScope < Minitest::Test
|
4
|
+
|
5
|
+
BASE = "bundle exec bin/starscope --quiet"
|
6
|
+
EXTRACT = "#{BASE} --no-read --no-write #{FIXTURES}"
|
7
|
+
|
8
|
+
def test_help
|
9
|
+
`#{BASE} -h`.each_line do |line|
|
10
|
+
assert line.length <= 80
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_version
|
15
|
+
assert_equal StarScope::VERSION, `#{BASE} -v`.chomp
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_summary
|
19
|
+
lines = `#{EXTRACT} -s`.lines.to_a
|
20
|
+
assert_equal lines.length, 6
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_dump
|
24
|
+
lines = `#{EXTRACT} -d requires`.lines.to_a
|
25
|
+
assert_equal 'date', lines[1].split.first
|
26
|
+
assert_equal 'zlib', lines[2].split.first
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_query
|
30
|
+
`#{EXTRACT} -q calls,add_file`.each_line do |line|
|
31
|
+
assert_equal ["StarScope", "DB", "add_file"], line.split[0..2]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -2,6 +2,8 @@ require 'minitest/autorun'
|
|
2
2
|
require 'minitest/pride'
|
3
3
|
require File.expand_path('../../lib/starscope.rb', __FILE__)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
FIXTURES="test/fixtures"
|
6
|
+
|
7
|
+
GOLANG_SAMPLE = "#{FIXTURES}/sample_golang.go"
|
8
|
+
RUBY_SAMPLE = "#{FIXTURES}/sample_ruby.rb"
|
9
|
+
EMPTY_FILE = "#{FIXTURES}/empty"
|
@@ -22,7 +22,7 @@ describe StarScope::DB do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
before do
|
25
|
-
@db = StarScope::DB.new(
|
25
|
+
@db = StarScope::DB.new(:quiet)
|
26
26
|
end
|
27
27
|
|
28
28
|
it "must raise on invalid tables" do
|
@@ -30,16 +30,16 @@ describe StarScope::DB do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it "must add paths" do
|
33
|
-
paths = [GOLANG_SAMPLE,
|
33
|
+
paths = [GOLANG_SAMPLE, "#{FIXTURES}/**/*"]
|
34
34
|
@db.add_paths(paths)
|
35
35
|
@db.instance_eval('@meta[:paths]').must_equal paths
|
36
36
|
validate(@db)
|
37
37
|
end
|
38
38
|
|
39
39
|
it "must add excludes" do
|
40
|
-
paths = [GOLANG_SAMPLE,
|
40
|
+
paths = [GOLANG_SAMPLE, "#{FIXTURES}/**/*"]
|
41
41
|
@db.add_paths(paths)
|
42
|
-
@db.add_excludes([
|
42
|
+
@db.add_excludes(["#{FIXTURES}/**"])
|
43
43
|
files = @db.instance_eval('@meta[:files]').keys
|
44
44
|
files.wont_include RUBY_SAMPLE
|
45
45
|
files.wont_include GOLANG_SAMPLE
|
@@ -49,20 +49,20 @@ describe StarScope::DB do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it "must pick up new files in old paths" do
|
52
|
-
@db.instance_eval(
|
52
|
+
@db.instance_eval("@meta[:paths] = [\"#{FIXTURES}/**/*\"]")
|
53
53
|
@db.update
|
54
54
|
validate(@db)
|
55
55
|
end
|
56
56
|
|
57
57
|
it "must remove old files in existing paths" do
|
58
|
-
@db.instance_eval(
|
59
|
-
@db.instance_eval(
|
58
|
+
@db.instance_eval("@meta[:paths] = [\"#{FIXTURES}/**/*\"]")
|
59
|
+
@db.instance_eval("@meta[:files] = {\"#{FIXTURES}/foo\" => {:last_updated=>1}}")
|
60
60
|
@db.update
|
61
|
-
@db.instance_eval(
|
61
|
+
@db.instance_eval("@meta[:files]").keys.wont_include "#{FIXTURES}/foo"
|
62
62
|
end
|
63
63
|
|
64
64
|
it "must update stale existing files" do
|
65
|
-
@db.instance_eval(
|
65
|
+
@db.instance_eval("@meta[:paths] = [\"#{FIXTURES}/**/*\"]")
|
66
66
|
@db.instance_eval("@meta[:files] = {\"#{GOLANG_SAMPLE}\" => {:last_updated=>1}}")
|
67
67
|
@db.instance_eval("@tables[:defs] = [{:file => \"#{GOLANG_SAMPLE}\"}]")
|
68
68
|
@db.update
|
@@ -70,17 +70,17 @@ describe StarScope::DB do
|
|
70
70
|
end
|
71
71
|
|
72
72
|
it "must load an old DB file" do
|
73
|
-
@db.load(
|
74
|
-
@db.instance_eval('@meta[:paths]').must_equal [
|
73
|
+
@db.load("#{FIXTURES}/db_old.json.gz")
|
74
|
+
@db.instance_eval('@meta[:paths]').must_equal ["#{FIXTURES}/**/*"]
|
75
75
|
validate(@db)
|
76
76
|
end
|
77
77
|
|
78
78
|
it "must round-trip a database" do
|
79
79
|
file = Tempfile.new('starscope_test')
|
80
80
|
begin
|
81
|
-
@db.add_paths([
|
81
|
+
@db.add_paths(["#{FIXTURES}"])
|
82
82
|
@db.save(file.path)
|
83
|
-
tmp = StarScope::DB.new(
|
83
|
+
tmp = StarScope::DB.new(:quiet)
|
84
84
|
tmp.load(file.path)
|
85
85
|
validate(tmp)
|
86
86
|
ensure
|
@@ -92,11 +92,11 @@ describe StarScope::DB do
|
|
92
92
|
it "must export to ctags" do
|
93
93
|
file = Tempfile.new('starscope_test')
|
94
94
|
begin
|
95
|
-
@db.add_paths([
|
95
|
+
@db.add_paths(["#{FIXTURES}"])
|
96
96
|
@db.export_ctags(file)
|
97
97
|
file.rewind
|
98
98
|
lines = file.lines.to_a
|
99
|
-
lines.must_include "NoTableError\
|
99
|
+
lines.must_include "NoTableError\t#{FIXTURES}/sample_ruby.rb\t/^ class NoTableError < StandardError; end$/;\"\tkind:c\n"
|
100
100
|
ensure
|
101
101
|
file.close
|
102
102
|
file.unlink
|
@@ -106,13 +106,20 @@ describe StarScope::DB do
|
|
106
106
|
it "must export to cscope" do
|
107
107
|
file = Tempfile.new('starscope_test')
|
108
108
|
begin
|
109
|
-
@db.add_paths([
|
109
|
+
@db.add_paths(["#{FIXTURES}"])
|
110
110
|
@db.export_cscope(file)
|
111
111
|
file.rewind
|
112
112
|
lines = file.lines.to_a
|
113
|
-
|
113
|
+
|
114
|
+
lines.must_include "\t@#{FIXTURES}/sample_golang.go\n"
|
114
115
|
lines.must_include "\tgSunday\n"
|
115
116
|
lines.must_include "\t`add_file\n"
|
117
|
+
lines.must_include "\t}}\n"
|
118
|
+
lines.must_include "13 class \n"
|
119
|
+
|
120
|
+
lines.wont_include "= [\n"
|
121
|
+
lines.wont_include "4 LANGS = [\n"
|
122
|
+
lines.wont_include "116 tmpdb[entry[:file]][entry[:line_no]] ||= []\n"
|
116
123
|
ensure
|
117
124
|
file.close
|
118
125
|
file.unlink
|
@@ -120,7 +127,7 @@ describe StarScope::DB do
|
|
120
127
|
end
|
121
128
|
|
122
129
|
it "must run queries" do
|
123
|
-
@db.add_paths([
|
130
|
+
@db.add_paths(["#{FIXTURES}"])
|
124
131
|
@db.query(:calls, "abc").must_equal []
|
125
132
|
@db.query(:defs, "xyz").must_equal []
|
126
133
|
@db.query(:calls, "add_file").length.must_equal 3
|
@@ -48,10 +48,12 @@ class TestGolang < Minitest::Test
|
|
48
48
|
assert calls.keys.include? :b
|
49
49
|
assert calls.keys.include? :c
|
50
50
|
assert calls.keys.include? :ttt
|
51
|
+
assert calls.keys.include? :Errorf
|
51
52
|
assert calls[:a].count == 3
|
52
53
|
assert calls[:b].count == 4
|
53
54
|
assert calls[:c].count == 4
|
54
55
|
assert calls[:ttt].count == 2
|
56
|
+
assert calls[:Errorf].count == 2
|
55
57
|
end
|
56
58
|
|
57
59
|
def test_variable_assigns
|
File without changes
|
@@ -19,7 +19,7 @@ describe StarScope::Record do
|
|
19
19
|
rec = StarScope::Record.build(GOLANG_SAMPLE, :a, {:line_no => 1})
|
20
20
|
rec[:line].must_equal "package main"
|
21
21
|
|
22
|
-
rec = StarScope::Record.build(GOLANG_SAMPLE, :a, {:line_no =>
|
22
|
+
rec = StarScope::Record.build(GOLANG_SAMPLE, :a, {:line_no => 66})
|
23
23
|
rec[:line].must_equal "\tfmt.Println(t)"
|
24
24
|
|
25
25
|
rec = StarScope::Record.build(RUBY_SAMPLE, :a, {:line_no => 1})
|
@@ -28,7 +28,7 @@ describe StarScope::Record do
|
|
28
28
|
rec = StarScope::Record.build(RUBY_SAMPLE, :a, {:line_no => 163})
|
29
29
|
rec[:line].must_equal "end"
|
30
30
|
|
31
|
-
rec = StarScope::Record.build(GOLANG_SAMPLE, :a, {:line_no =>
|
31
|
+
rec = StarScope::Record.build(GOLANG_SAMPLE, :a, {:line_no => 67})
|
32
32
|
rec[:line].must_equal "}"
|
33
33
|
end
|
34
34
|
|
File without changes
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: starscope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Evan Huus
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-
|
11
|
+
date: 2014-07-16 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: oj
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: parser
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: ruby-progressbar
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ~>
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ~>
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,7 +55,6 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: bundler
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ~>
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,7 +62,6 @@ dependencies:
|
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ~>
|
76
67
|
- !ruby/object:Gem::Version
|
@@ -78,49 +69,43 @@ dependencies:
|
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: rake
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - '>='
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - '>='
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: pry
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - '>='
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - '>='
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: minitest
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - '>='
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: '0'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- -
|
108
|
+
- - '>='
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: '0'
|
126
111
|
description: A tool like the venerable cscope, but for ruby, golang and other languages
|
@@ -139,6 +124,9 @@ files:
|
|
139
124
|
- README.md
|
140
125
|
- Rakefile
|
141
126
|
- bin/starscope
|
127
|
+
- doc/DB_FORMAT.md
|
128
|
+
- doc/LANGUAGE_SUPPORT.md
|
129
|
+
- doc/USER_GUIDE.md
|
142
130
|
- lib/starscope.rb
|
143
131
|
- lib/starscope/db.rb
|
144
132
|
- lib/starscope/langs/coffeescript.rb
|
@@ -149,54 +137,50 @@ files:
|
|
149
137
|
- lib/starscope/record.rb
|
150
138
|
- lib/starscope/version.rb
|
151
139
|
- starscope.gemspec
|
152
|
-
- test/
|
153
|
-
- test/
|
154
|
-
- test/
|
155
|
-
- test/
|
156
|
-
- test/
|
157
|
-
- test/lib/test_golang.rb
|
158
|
-
- test/lib/test_matcher.rb
|
159
|
-
- test/lib/test_record.rb
|
160
|
-
- test/lib/test_ruby.rb
|
161
|
-
- test/lib/test_starscope.rb
|
140
|
+
- test/fixtures/db_old.json.gz
|
141
|
+
- test/fixtures/empty
|
142
|
+
- test/fixtures/sample_golang.go
|
143
|
+
- test/fixtures/sample_ruby.rb
|
144
|
+
- test/functional/test_starscope.rb
|
162
145
|
- test/test_helper.rb
|
146
|
+
- test/unit/test_db.rb
|
147
|
+
- test/unit/test_golang.rb
|
148
|
+
- test/unit/test_matcher.rb
|
149
|
+
- test/unit/test_record.rb
|
150
|
+
- test/unit/test_ruby.rb
|
163
151
|
homepage: https://github.com/eapache/starscope
|
164
152
|
licenses:
|
165
153
|
- MIT
|
154
|
+
metadata: {}
|
166
155
|
post_install_message:
|
167
156
|
rdoc_options: []
|
168
157
|
require_paths:
|
169
158
|
- lib
|
170
159
|
required_ruby_version: !ruby/object:Gem::Requirement
|
171
|
-
none: false
|
172
160
|
requirements:
|
173
|
-
- -
|
161
|
+
- - '>='
|
174
162
|
- !ruby/object:Gem::Version
|
175
163
|
version: 1.8.7
|
176
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
|
-
none: false
|
178
165
|
requirements:
|
179
|
-
- -
|
166
|
+
- - '>='
|
180
167
|
- !ruby/object:Gem::Version
|
181
168
|
version: '0'
|
182
|
-
segments:
|
183
|
-
- 0
|
184
|
-
hash: -1535830419513548498
|
185
169
|
requirements: []
|
186
170
|
rubyforge_project:
|
187
|
-
rubygems_version:
|
171
|
+
rubygems_version: 2.0.14
|
188
172
|
signing_key:
|
189
|
-
specification_version:
|
173
|
+
specification_version: 4
|
190
174
|
summary: A code indexer and analyzer
|
191
175
|
test_files:
|
192
|
-
- test/
|
193
|
-
- test/
|
194
|
-
- test/
|
195
|
-
- test/
|
196
|
-
- test/
|
197
|
-
- test/lib/test_golang.rb
|
198
|
-
- test/lib/test_matcher.rb
|
199
|
-
- test/lib/test_record.rb
|
200
|
-
- test/lib/test_ruby.rb
|
201
|
-
- test/lib/test_starscope.rb
|
176
|
+
- test/fixtures/db_old.json.gz
|
177
|
+
- test/fixtures/empty
|
178
|
+
- test/fixtures/sample_golang.go
|
179
|
+
- test/fixtures/sample_ruby.rb
|
180
|
+
- test/functional/test_starscope.rb
|
202
181
|
- test/test_helper.rb
|
182
|
+
- test/unit/test_db.rb
|
183
|
+
- test/unit/test_golang.rb
|
184
|
+
- test/unit/test_matcher.rb
|
185
|
+
- test/unit/test_record.rb
|
186
|
+
- test/unit/test_ruby.rb
|
data/test/files/db_old.json.gz
DELETED
Binary file
|