starscope 1.5.3 → 1.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -9
- data/.travis.yml +2 -2
- data/CHANGELOG.md +11 -1
- data/bin/starscope +2 -0
- data/lib/starscope/db.rb +266 -264
- data/lib/starscope/exportable.rb +225 -221
- data/lib/starscope/fragment_extractor.rb +18 -16
- data/lib/starscope/langs/erb.rb +34 -32
- data/lib/starscope/langs/golang.rb +176 -174
- data/lib/starscope/langs/javascript.rb +96 -94
- data/lib/starscope/langs/ruby.rb +109 -91
- data/lib/starscope/matcher.rb +1 -2
- data/lib/starscope/output.rb +37 -35
- data/lib/starscope/queryable.rb +31 -29
- data/lib/starscope/version.rb +1 -1
- data/starscope.gemspec +4 -4
- data/test/fixtures/sample_ruby.rb +1 -0
- data/test/unit/exportable_test.rb +17 -4
- data/test/unit/fragment_extractor_test.rb +6 -1
- metadata +40 -40
data/lib/starscope/matcher.rb
CHANGED
data/lib/starscope/output.rb
CHANGED
@@ -1,47 +1,49 @@
|
|
1
1
|
require 'ruby-progressbar'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
module Starscope
|
4
|
+
class Output
|
5
|
+
PBAR_FORMAT = '%t: %c/%C %E ||%b>%i||'.freeze
|
6
|
+
|
7
|
+
def initialize(level, out = STDOUT)
|
8
|
+
@out = out
|
9
|
+
@level = level
|
10
|
+
@pbar = nil
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
def new_pbar(title, num_items)
|
14
|
+
return if @level == :quiet
|
15
|
+
@pbar = ProgressBar.create(title: title, total: num_items,
|
16
|
+
format: PBAR_FORMAT, length: 80,
|
17
|
+
out: @out)
|
18
|
+
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
def inc_pbar
|
21
|
+
@pbar.increment if @pbar
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
def finish_pbar
|
25
|
+
@pbar.finish if @pbar
|
26
|
+
@pbar = nil
|
27
|
+
end
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
def extra(msg)
|
30
|
+
return unless @level == :verbose
|
31
|
+
output(msg)
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
def normal(msg)
|
35
|
+
return if @level == :quiet
|
36
|
+
output(msg)
|
37
|
+
end
|
37
38
|
|
38
|
-
|
39
|
+
private
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
def output(msg)
|
42
|
+
if @pbar
|
43
|
+
@pbar.log(msg)
|
44
|
+
else
|
45
|
+
@out.puts msg
|
46
|
+
end
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
data/lib/starscope/queryable.rb
CHANGED
@@ -1,46 +1,48 @@
|
|
1
1
|
require 'starscope/matcher'
|
2
2
|
|
3
|
-
module Starscope
|
4
|
-
|
5
|
-
tables
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
module Starscope
|
4
|
+
module Queryable
|
5
|
+
def query(tables, value, filters = {})
|
6
|
+
tables = [tables] if tables.is_a?(Symbol)
|
7
|
+
tables.each { |t| raise Starscope::DB::NoTableError, "Table '#{t}' not found" unless @tables[t] }
|
8
|
+
input = Enumerator.new do |y|
|
9
|
+
tables.each do |t|
|
10
|
+
@tables[t].each do |elem|
|
11
|
+
y << elem
|
12
|
+
end
|
11
13
|
end
|
12
14
|
end
|
15
|
+
|
16
|
+
run_query(value, input, filters)
|
13
17
|
end
|
14
18
|
|
15
|
-
|
16
|
-
end
|
19
|
+
private
|
17
20
|
|
18
|
-
|
21
|
+
def run_query(query, input, filters)
|
22
|
+
query = Starscope::Matcher.new(query)
|
23
|
+
filters.each { |k, v| filters[k] = Starscope::Matcher.new(v) }
|
19
24
|
|
20
|
-
|
21
|
-
query = Starscope::Matcher.new(query)
|
22
|
-
filters.each { |k, v| filters[k] = Starscope::Matcher.new(v) }
|
25
|
+
results = input.select { |x| filter(x, filters) }.group_by { |x| match(x, query) }
|
23
26
|
|
24
|
-
|
27
|
+
Starscope::Matcher::MATCH_TYPES.each do |type|
|
28
|
+
next if results[type].nil? || results[type].empty?
|
29
|
+
return results[type]
|
30
|
+
end
|
25
31
|
|
26
|
-
|
27
|
-
next if results[type].nil? || results[type].empty?
|
28
|
-
return results[type]
|
32
|
+
[]
|
29
33
|
end
|
30
34
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
target = record[key] || (@meta[:files][record[:file]] || {})[key]
|
37
|
-
target && filter.match(target.to_s)
|
35
|
+
def filter(record, filters)
|
36
|
+
filters.all? do |key, filter|
|
37
|
+
target = record[key] || (@meta[:files][record[:file]] || {})[key]
|
38
|
+
target && filter.match(target.to_s)
|
39
|
+
end
|
38
40
|
end
|
39
|
-
end
|
40
41
|
|
41
|
-
|
42
|
-
|
42
|
+
def match(record, query)
|
43
|
+
name = record[:name].map(&:to_s).join('::')
|
43
44
|
|
44
|
-
|
45
|
+
query.match(name)
|
46
|
+
end
|
45
47
|
end
|
46
48
|
end
|
data/lib/starscope/version.rb
CHANGED
data/starscope.gemspec
CHANGED
@@ -20,16 +20,16 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.required_ruby_version = '>= 1.9.3'
|
21
21
|
|
22
22
|
gem.add_dependency 'oj', '~> 2.9'
|
23
|
-
gem.add_dependency 'parser', '
|
24
|
-
gem.add_dependency 'ruby-progressbar', '~> 1.
|
23
|
+
gem.add_dependency 'parser', '~> 2.3'
|
24
|
+
gem.add_dependency 'ruby-progressbar', '~> 1.8'
|
25
25
|
gem.add_dependency 'rkelly-remix', '~> 0.0.7'
|
26
26
|
gem.add_dependency 'babel-transpiler', '~> 0.7'
|
27
27
|
gem.add_dependency 'sourcemap', '~> 0.1'
|
28
28
|
|
29
29
|
gem.add_development_dependency 'bundler', '~> 1.7'
|
30
|
-
gem.add_development_dependency 'rake', '~>
|
30
|
+
gem.add_development_dependency 'rake', '~> 11.2'
|
31
31
|
gem.add_development_dependency 'pry', '~> 0.10.1'
|
32
32
|
gem.add_development_dependency 'minitest', '~> 5.8'
|
33
33
|
gem.add_development_dependency 'mocha', '~> 1.1'
|
34
|
-
gem.add_development_dependency 'rubocop', '~> 0.
|
34
|
+
gem.add_development_dependency 'rubocop', '~> 0.39.0'
|
35
35
|
end
|
@@ -8,12 +8,25 @@ describe Starscope::Exportable do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'must export to ctags' do
|
11
|
-
@db.export_to(:ctags, @buf)
|
11
|
+
@db.export_to(:ctags, @buf, '.')
|
12
12
|
@buf.rewind
|
13
13
|
lines = @buf.each_line.to_a
|
14
14
|
lines.must_include(
|
15
15
|
"NoTableError\t" \
|
16
|
-
"
|
16
|
+
"./#{FIXTURES}/sample_ruby.rb\t" \
|
17
|
+
"/^ class NoTableError < StandardError; end$/;\"\t" \
|
18
|
+
"kind:c\t" \
|
19
|
+
"language:Ruby\n"
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'must export to ctags with different path prefixes' do
|
24
|
+
@db.export_to(:ctags, @buf, '../foo')
|
25
|
+
@buf.rewind
|
26
|
+
lines = @buf.each_line.to_a
|
27
|
+
lines.must_include(
|
28
|
+
"NoTableError\t" \
|
29
|
+
"../foo/#{FIXTURES}/sample_ruby.rb\t" \
|
17
30
|
"/^ class NoTableError < StandardError; end$/;\"\t" \
|
18
31
|
"kind:c\t" \
|
19
32
|
"language:Ruby\n"
|
@@ -21,7 +34,7 @@ describe Starscope::Exportable do
|
|
21
34
|
end
|
22
35
|
|
23
36
|
it 'must export to cscope' do
|
24
|
-
@db.export_to(:cscope, @buf)
|
37
|
+
@db.export_to(:cscope, @buf, '.')
|
25
38
|
@buf.rewind
|
26
39
|
lines = @buf.each_line.to_a
|
27
40
|
|
@@ -29,7 +42,7 @@ describe Starscope::Exportable do
|
|
29
42
|
lines.must_include "\tgSunday\n"
|
30
43
|
lines.must_include "\t`add_file\n"
|
31
44
|
lines.must_include "\t}}\n"
|
32
|
-
lines.must_include "
|
45
|
+
lines.must_include "13 class \n"
|
33
46
|
|
34
47
|
lines.wont_include "= [\n"
|
35
48
|
lines.wont_include "4 LANGS = [\n"
|
metadata
CHANGED
@@ -1,183 +1,183 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: starscope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.4
|
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: 2017-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '2.9'
|
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.9'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: parser
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
33
|
+
version: '2.3'
|
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: 2.
|
40
|
+
version: '2.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: ruby-progressbar
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1.
|
47
|
+
version: '1.8'
|
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: '1.8'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rkelly-remix
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 0.0.7
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.0.7
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: babel-transpiler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0.7'
|
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
82
|
version: '0.7'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: sourcemap
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - ~>
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0.1'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - ~>
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0.1'
|
97
97
|
- !ruby/object:Gem::Dependency
|
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
112
|
name: rake
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - ~>
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
117
|
+
version: '11.2'
|
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: '11.2'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: pry
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - ~>
|
129
|
+
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: 0.10.1
|
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
138
|
version: 0.10.1
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: minitest
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- - ~>
|
143
|
+
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '5.8'
|
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
152
|
version: '5.8'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: mocha
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - ~>
|
157
|
+
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: '1.1'
|
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
166
|
version: '1.1'
|
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: 0.
|
173
|
+
version: 0.39.0
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- - ~>
|
178
|
+
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: 0.
|
180
|
+
version: 0.39.0
|
181
181
|
description: |2
|
182
182
|
Starscope is a code indexer, search and navigation tool for Ruby, Golang, and JavaScript.
|
183
183
|
Inspired by the extremely popular Ctags and Cscope utilities, Starscope can
|
@@ -188,9 +188,9 @@ executables:
|
|
188
188
|
extensions: []
|
189
189
|
extra_rdoc_files: []
|
190
190
|
files:
|
191
|
-
- .gitignore
|
192
|
-
- .rubocop.yml
|
193
|
-
- .travis.yml
|
191
|
+
- ".gitignore"
|
192
|
+
- ".rubocop.yml"
|
193
|
+
- ".travis.yml"
|
194
194
|
- CHANGELOG.md
|
195
195
|
- Gemfile
|
196
196
|
- LICENSE.txt
|
@@ -247,17 +247,17 @@ require_paths:
|
|
247
247
|
- lib
|
248
248
|
required_ruby_version: !ruby/object:Gem::Requirement
|
249
249
|
requirements:
|
250
|
-
- -
|
250
|
+
- - ">="
|
251
251
|
- !ruby/object:Gem::Version
|
252
252
|
version: 1.9.3
|
253
253
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
254
254
|
requirements:
|
255
|
-
- -
|
255
|
+
- - ">="
|
256
256
|
- !ruby/object:Gem::Version
|
257
257
|
version: '0'
|
258
258
|
requirements: []
|
259
259
|
rubyforge_project:
|
260
|
-
rubygems_version: 2.
|
260
|
+
rubygems_version: 2.5.1
|
261
261
|
signing_key:
|
262
262
|
specification_version: 4
|
263
263
|
summary: Smart code search and indexing
|