starscope 1.5.4 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ruby-ci.yml +26 -0
- data/.rubocop.yml +16 -4
- data/CHANGELOG.md +40 -1
- data/README.md +1 -3
- data/Rakefile +5 -2
- data/bin/starscope +54 -53
- data/doc/LANGUAGE_SUPPORT.md +8 -0
- data/doc/USER_GUIDE.md +14 -4
- data/lib/starscope/db.rb +26 -28
- data/lib/starscope/exportable.rb +37 -33
- data/lib/starscope/fragment_extractor.rb +3 -4
- data/lib/starscope/langs/erb.rb +3 -3
- data/lib/starscope/langs/golang.rb +24 -25
- data/lib/starscope/langs/javascript.rb +4 -2
- data/lib/starscope/langs/ruby.rb +14 -3
- data/lib/starscope/matcher.rb +3 -4
- data/lib/starscope/output.rb +6 -3
- data/lib/starscope/queryable.rb +1 -0
- data/lib/starscope/version.rb +1 -1
- data/starscope.gemspec +17 -14
- data/test/fixtures/sample_golang.go +1 -1
- data/test/fixtures/sample_ruby.rb +2 -0
- data/test/functional/starscope_test.rb +15 -15
- data/test/test_helper.rb +1 -1
- data/test/unit/db_test.rb +50 -50
- data/test/unit/exportable_test.rb +12 -10
- data/test/unit/fragment_extractor_test.rb +12 -11
- data/test/unit/langs/erb_test.rb +17 -17
- data/test/unit/langs/golang_test.rb +55 -55
- data/test/unit/langs/javascript_test.rb +44 -44
- data/test/unit/langs/ruby_test.rb +27 -27
- data/test/unit/output_test.rb +3 -3
- data/test/unit/queryable_test.rb +29 -29
- metadata +63 -35
- data/.travis.yml +0 -10
@@ -10,57 +10,57 @@ describe Starscope::Lang::Ruby do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'must match ruby files' do
|
13
|
-
Starscope::Lang::Ruby.match_file(RUBY_SAMPLE).must_equal true
|
14
|
-
Starscope::Lang::Ruby.match_file('bin/starscope').must_equal true
|
13
|
+
_(Starscope::Lang::Ruby.match_file(RUBY_SAMPLE)).must_equal true
|
14
|
+
_(Starscope::Lang::Ruby.match_file('bin/starscope')).must_equal true
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'must not match non-ruby files' do
|
18
|
-
Starscope::Lang::Ruby.match_file(GOLANG_SAMPLE).must_equal false
|
19
|
-
Starscope::Lang::Ruby.match_file(EMPTY_FILE).must_equal false
|
18
|
+
_(Starscope::Lang::Ruby.match_file(GOLANG_SAMPLE)).must_equal false
|
19
|
+
_(Starscope::Lang::Ruby.match_file(EMPTY_FILE)).must_equal false
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'must identify function definitions' do
|
23
|
-
@db.keys.must_include :defs
|
23
|
+
_(@db.keys).must_include :defs
|
24
24
|
defs = @db[:defs].map { |x| x[:name][-1] }
|
25
25
|
|
26
|
-
defs.must_include :DB
|
27
|
-
defs.must_include :NoTableError
|
28
|
-
defs.must_include :load
|
29
|
-
defs.must_include :update
|
30
|
-
defs.must_include :files_from_path
|
26
|
+
_(defs).must_include :DB
|
27
|
+
_(defs).must_include :NoTableError
|
28
|
+
_(defs).must_include :load
|
29
|
+
_(defs).must_include :update
|
30
|
+
_(defs).must_include :files_from_path
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'must identify constant definitions' do
|
34
|
-
@db[:defs].map { |x| x[:name][-1] }.must_include :PBAR_FORMAT
|
34
|
+
_(@db[:defs].map { |x| x[:name][-1] }).must_include :PBAR_FORMAT
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'must identify endings' do
|
38
|
-
@db.keys.must_include :end
|
39
|
-
@db[:end].count.must_equal 13
|
38
|
+
_(@db.keys).must_include :end
|
39
|
+
_(@db[:end].count).must_equal 13
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'must identify function calls' do
|
43
|
-
@db.keys.must_include :calls
|
43
|
+
_(@db.keys).must_include :calls
|
44
44
|
calls = @db[:calls].group_by { |x| x[:name][-1] }
|
45
45
|
|
46
|
-
calls.keys.must_include :add_file
|
47
|
-
calls.keys.must_include :each
|
48
|
-
calls[:add_file].count.must_equal 3
|
49
|
-
calls[:each].count.must_equal 8
|
46
|
+
_(calls.keys).must_include :add_file
|
47
|
+
_(calls.keys).must_include :each
|
48
|
+
_(calls[:add_file].count).must_equal 3
|
49
|
+
_(calls[:each].count).must_equal 8
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'must identify variable assignments' do
|
53
|
-
@db.keys.must_include :assigns
|
53
|
+
_(@db.keys).must_include :assigns
|
54
54
|
assigns = @db[:assigns].group_by { |x| x[:name][-1] }
|
55
55
|
|
56
|
-
assigns.keys.must_include :pbar
|
57
|
-
assigns.keys.must_include :PBAR_FORMAT
|
58
|
-
assigns.keys.must_include :foo
|
59
|
-
assigns[:pbar].count.must_equal 2
|
60
|
-
assigns[:PBAR_FORMAT].count.must_equal 1
|
61
|
-
assigns[:foo].count.must_equal 1
|
56
|
+
_(assigns.keys).must_include :pbar
|
57
|
+
_(assigns.keys).must_include :PBAR_FORMAT
|
58
|
+
_(assigns.keys).must_include :foo
|
59
|
+
_(assigns[:pbar].count).must_equal 2
|
60
|
+
_(assigns[:PBAR_FORMAT].count).must_equal 1
|
61
|
+
_(assigns[:foo].count).must_equal 1
|
62
62
|
|
63
|
-
assigns.keys.wont_include '='
|
64
|
-
assigns.keys.wont_include
|
63
|
+
_(assigns.keys).wont_include :'='
|
64
|
+
_(assigns.keys).wont_include :<
|
65
65
|
end
|
66
66
|
end
|
data/test/unit/output_test.rb
CHANGED
@@ -6,7 +6,7 @@ describe Starscope::Output do
|
|
6
6
|
out = Starscope::Output.new(:quiet, buf)
|
7
7
|
out.normal('foo')
|
8
8
|
out.extra('foo')
|
9
|
-
buf.size.must_equal 0
|
9
|
+
_(buf.size).must_equal 0
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'must be normal' do
|
@@ -14,7 +14,7 @@ describe Starscope::Output do
|
|
14
14
|
out = Starscope::Output.new(:normal, buf)
|
15
15
|
out.normal('foo')
|
16
16
|
out.extra('foo')
|
17
|
-
buf.size.must_equal 4
|
17
|
+
_(buf.size).must_equal 4
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'must be verbose' do
|
@@ -22,6 +22,6 @@ describe Starscope::Output do
|
|
22
22
|
out = Starscope::Output.new(:verbose, buf)
|
23
23
|
out.normal('foo')
|
24
24
|
out.extra('foo')
|
25
|
-
buf.size.must_equal 8
|
25
|
+
_(buf.size).must_equal 8
|
26
26
|
end
|
27
27
|
end
|
data/test/unit/queryable_test.rb
CHANGED
@@ -1,61 +1,61 @@
|
|
1
1
|
require_relative '../test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
lang: :ruby
|
21
|
-
}
|
3
|
+
SAMPLE_RECORDS = [
|
4
|
+
{ name: [:'[abc'], foo: 'baz' },
|
5
|
+
{ name: [:'not a match'], foo: 'bar', x: 'y' },
|
6
|
+
{ name: %i[a b c d], file: :somefile }
|
7
|
+
].freeze
|
8
|
+
|
9
|
+
class MockQuerable
|
10
|
+
include Starscope::Queryable
|
11
|
+
def initialize
|
12
|
+
@tables = {
|
13
|
+
mytable: SAMPLE_RECORDS,
|
14
|
+
empty_table: []
|
15
|
+
}
|
16
|
+
@meta = {
|
17
|
+
files: {
|
18
|
+
somefile: {
|
19
|
+
lang: :ruby
|
22
20
|
}
|
23
21
|
}
|
24
|
-
|
22
|
+
}
|
25
23
|
end
|
24
|
+
end
|
26
25
|
|
26
|
+
describe Starscope::Queryable do
|
27
27
|
before do
|
28
28
|
@mock = MockQuerable.new
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'must handle empty input' do
|
32
|
-
@mock.query(:empty_table, 'foo').must_be_empty
|
32
|
+
_(@mock.query(:empty_table, 'foo')).must_be_empty
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'must handle scoped queries' do
|
36
|
-
@mock.query(:mytable, 'a::b::').must_equal [SAMPLE_RECORDS[2]]
|
36
|
+
_(@mock.query(:mytable, 'a::b::')).must_equal [SAMPLE_RECORDS[2]]
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'must handle regex queries' do
|
40
|
-
@mock.query(:mytable, 'a[bc]{2}').must_equal [SAMPLE_RECORDS[0]]
|
40
|
+
_(@mock.query(:mytable, 'a[bc]{2}')).must_equal [SAMPLE_RECORDS[0]]
|
41
41
|
|
42
|
-
@mock.query(:mytable, 'a.*d').must_equal [SAMPLE_RECORDS[2]]
|
42
|
+
_(@mock.query(:mytable, 'a.*d')).must_equal [SAMPLE_RECORDS[2]]
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'must handle malformed regexes' do
|
46
|
-
@mock.query(:mytable, '[abc').must_equal [SAMPLE_RECORDS[0]]
|
46
|
+
_(@mock.query(:mytable, '[abc')).must_equal [SAMPLE_RECORDS[0]]
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'must handle simple filters' do
|
50
|
-
@mock.query(:mytable, '.*', foo: 'bar').must_equal [SAMPLE_RECORDS[1]]
|
50
|
+
_(@mock.query(:mytable, '.*', foo: 'bar')).must_equal [SAMPLE_RECORDS[1]]
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'must handle multiple filters' do
|
54
|
-
@mock.query(:mytable, '.*', foo: 'bar', x: 'y').must_equal [SAMPLE_RECORDS[1]]
|
55
|
-
@mock.query(:mytable, '.*', foo: 'bar', x: 'nope').must_be_empty
|
54
|
+
_(@mock.query(:mytable, '.*', foo: 'bar', x: 'y')).must_equal [SAMPLE_RECORDS[1]]
|
55
|
+
_(@mock.query(:mytable, '.*', foo: 'bar', x: 'nope')).must_be_empty
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'must handle filters on file properties' do
|
59
|
-
@mock.query(:mytable, '.*', lang: 'ruby').must_equal [SAMPLE_RECORDS[2]]
|
59
|
+
_(@mock.query(:mytable, '.*', lang: 'ruby')).must_equal [SAMPLE_RECORDS[2]]
|
60
60
|
end
|
61
61
|
end
|
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: starscope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Huus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: babel-transpiler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0.7'
|
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
|
-
version: '
|
26
|
+
version: '0.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: oj
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '3.7'
|
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
|
-
version: '
|
40
|
+
version: '3.7'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: parser
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1
|
47
|
+
version: '3.1'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1
|
54
|
+
version: '3.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rkelly-remix
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,19 +67,19 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.0.7
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: ruby-progressbar
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '1.9'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '1.9'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: sourcemap
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,86 +98,114 @@ dependencies:
|
|
98
98
|
name: bundler
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '1.7'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '1.7'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: minitest
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
117
|
+
version: '5.12'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
124
|
+
version: '5.12'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: mocha
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
131
|
+
version: '1.3'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
138
|
+
version: '1.3'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
140
|
+
name: pry
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
145
|
+
version: '0.11'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
152
|
+
version: '0.11'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
154
|
+
name: rake
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
159
|
+
version: '13.0'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
166
|
+
version: '13.0'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: rubocop
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version:
|
173
|
+
version: 1.25.0
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 1.25.0
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: rubocop-minitest
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: 0.17.1
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: 0.17.1
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: rubocop-rake
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - "~>"
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: 0.6.0
|
174
202
|
type: :development
|
175
203
|
prerelease: false
|
176
204
|
version_requirements: !ruby/object:Gem::Requirement
|
177
205
|
requirements:
|
178
206
|
- - "~>"
|
179
207
|
- !ruby/object:Gem::Version
|
180
|
-
version: 0.
|
208
|
+
version: 0.6.0
|
181
209
|
description: |2
|
182
210
|
Starscope is a code indexer, search and navigation tool for Ruby, Golang, and JavaScript.
|
183
211
|
Inspired by the extremely popular Ctags and Cscope utilities, Starscope can
|
@@ -188,9 +216,9 @@ executables:
|
|
188
216
|
extensions: []
|
189
217
|
extra_rdoc_files: []
|
190
218
|
files:
|
219
|
+
- ".github/workflows/ruby-ci.yml"
|
191
220
|
- ".gitignore"
|
192
221
|
- ".rubocop.yml"
|
193
|
-
- ".travis.yml"
|
194
222
|
- CHANGELOG.md
|
195
223
|
- Gemfile
|
196
224
|
- LICENSE.txt
|
@@ -240,7 +268,8 @@ files:
|
|
240
268
|
homepage: https://github.com/eapache/starscope
|
241
269
|
licenses:
|
242
270
|
- MIT
|
243
|
-
metadata:
|
271
|
+
metadata:
|
272
|
+
rubygems_mfa_required: 'true'
|
244
273
|
post_install_message:
|
245
274
|
rdoc_options: []
|
246
275
|
require_paths:
|
@@ -249,15 +278,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
249
278
|
requirements:
|
250
279
|
- - ">="
|
251
280
|
- !ruby/object:Gem::Version
|
252
|
-
version:
|
281
|
+
version: '2.6'
|
253
282
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
254
283
|
requirements:
|
255
284
|
- - ">="
|
256
285
|
- !ruby/object:Gem::Version
|
257
286
|
version: '0'
|
258
287
|
requirements: []
|
259
|
-
|
260
|
-
rubygems_version: 2.5.1
|
288
|
+
rubygems_version: 3.0.9
|
261
289
|
signing_key:
|
262
290
|
specification_version: 4
|
263
291
|
summary: Smart code search and indexing
|