starscope 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,13 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ require_relative '../test_helper'
2
2
 
3
3
  describe Starscope::FragmentExtractor do
4
4
  module ::Starscope::Lang::Dummy; end
5
5
 
6
6
  before do
7
7
  @extractor = Starscope::FragmentExtractor.new(:Dummy, [
8
- { :frag => "def foo; end\n", :line_no => 12 },
9
- { :frag => "def bar\n", :line_no => 15 },
10
- { :frag => "end\n", :line_no => 29 }
8
+ { frag: "def foo; end\n", line_no: 12 },
9
+ { frag: "def bar\n", line_no: 15 },
10
+ { frag: "end\n", line_no: 29 }
11
11
  ])
12
12
  @reconstructed = "def foo; end\ndef bar\nend"
13
13
  end
@@ -18,8 +18,8 @@ describe Starscope::FragmentExtractor do
18
18
  end
19
19
 
20
20
  it 'must pass along extractor metadata from the child' do
21
- ::Starscope::Lang::Dummy.expects(:extract).returns :a => 1, :b => 3
22
- @extractor.extract(:foo, '---').must_equal :a => 1, :b => 3
21
+ ::Starscope::Lang::Dummy.expects(:extract).returns a: 1, b: 3
22
+ @extractor.extract(:foo, '---').must_equal a: 1, b: 3
23
23
  end
24
24
 
25
25
  it 'must pass along the name from the child' do
@@ -27,12 +27,12 @@ describe Starscope::FragmentExtractor do
27
27
  end
28
28
 
29
29
  it 'must override-merge yielded args based on line number' do
30
- ::Starscope::Lang::Dummy.expects(:extract).yields(:foo, :bar, :line_no => 2, :foo => :bar)
30
+ ::Starscope::Lang::Dummy.expects(:extract).yields(:foo, :bar, line_no: 2, foo: :bar)
31
31
 
32
32
  @extractor.extract(:foo, '---') do |tbl, name, args|
33
33
  tbl.must_equal :foo
34
34
  name.must_equal :bar
35
- args.must_equal :line_no => 15, :foo => :bar
35
+ args.must_equal line_no: 15, foo: :bar
36
36
  end
37
37
  end
38
38
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path('../../../test_helper', __FILE__)
1
+ require_relative '../../test_helper'
2
2
 
3
3
  describe Starscope::Lang::ERB do
4
4
  before do
@@ -20,17 +20,17 @@ describe Starscope::Lang::ERB do
20
20
  end
21
21
 
22
22
  it 'must identify all fragments' do
23
- @frags.must_equal [{ :frag => ' if foo ', :line_no => 1 },
24
- { :frag => ' elsif bar ', :line_no => 3 },
25
- { :frag => ' end ', :line_no => 5 },
26
- { :frag => ' case x', :line_no => 8 },
27
- { :frag => 'when :bar ', :line_no => 9 },
28
- { :frag => ' magic ', :line_no => 9 },
29
- { :frag => ' when :baz', :line_no => 9 },
30
- { :frag => 'when :foo ', :line_no => 10 },
31
- { :frag => ' end ', :line_no => 12 },
32
- { :frag => ' foo ', :line_no => 14 },
33
- { :frag => ' bar ', :line_no => 14 },
34
- { :frag => ' baz ', :line_no => 14 }]
23
+ @frags.must_equal [{ frag: ' if foo ', line_no: 1 },
24
+ { frag: ' elsif bar ', line_no: 3 },
25
+ { frag: ' end ', line_no: 5 },
26
+ { frag: ' case x', line_no: 8 },
27
+ { frag: 'when :bar ', line_no: 9 },
28
+ { frag: ' magic ', line_no: 9 },
29
+ { frag: ' when :baz', line_no: 9 },
30
+ { frag: 'when :foo ', line_no: 10 },
31
+ { frag: ' end ', line_no: 12 },
32
+ { frag: ' foo ', line_no: 14 },
33
+ { frag: ' bar ', line_no: 14 },
34
+ { frag: ' baz ', line_no: 14 }]
35
35
  end
36
36
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path('../../../test_helper', __FILE__)
1
+ require_relative '../../test_helper'
2
2
 
3
3
  describe Starscope::Lang::Go do
4
4
  before do
@@ -0,0 +1,68 @@
1
+ require_relative '../../test_helper'
2
+
3
+ describe Starscope::Lang::Javascript do
4
+ before do
5
+ @db = {}
6
+ Starscope::Lang::Javascript.extract(JAVASCRIPT_EXAMPLE, File.read(JAVASCRIPT_EXAMPLE)) do |tbl, name, args|
7
+ @db[tbl] ||= []
8
+ @db[tbl] << Starscope::DB.normalize_record(JAVASCRIPT_EXAMPLE, name, args)
9
+ end
10
+ end
11
+
12
+ it 'must match js files' do
13
+ Starscope::Lang::Javascript.match_file(JAVASCRIPT_EXAMPLE).must_equal true
14
+ end
15
+
16
+ it 'must not match non-js files' do
17
+ Starscope::Lang::Javascript.match_file(RUBY_SAMPLE).must_equal false
18
+ Starscope::Lang::Javascript.match_file(EMPTY_FILE).must_equal false
19
+ end
20
+
21
+ it 'must identify definitions' do
22
+ @db.keys.must_include :defs
23
+ defs = @db[:defs].map { |x| x[:name][-1] }
24
+
25
+ defs.must_include :Component
26
+ defs.must_include :StyleSheet
27
+ defs.must_include :styles
28
+ defs.must_include :NavigatorRouteMapper
29
+ defs.must_include :LeftButton
30
+ defs.must_include :RightButton
31
+ defs.must_include :_tabItem
32
+ defs.must_include :render
33
+ defs.must_include :setRef
34
+ defs.must_include :route
35
+ defs.must_include :foo
36
+ defs.must_include :MyStat
37
+ defs.must_include :myStatFunc
38
+
39
+ defs.wont_include :setStyle
40
+ defs.wont_include :setState
41
+ defs.wont_include :fontFamily
42
+ defs.wont_include :navigator
43
+ end
44
+
45
+ it 'must only tag static classes once' do
46
+ @db[:defs].count { |x| x[:name][-1] == :MyStat }.must_equal 1
47
+ end
48
+
49
+ it 'must identify endings' do
50
+ @db.keys.must_include :end
51
+ @db[:end].count.must_equal 11
52
+ end
53
+
54
+ it 'must identify function calls' do
55
+ @db.keys.must_include :calls
56
+ calls = @db[:calls].group_by { |x| x[:name][-1] }
57
+
58
+ calls.keys.must_include :create
59
+ calls.keys.must_include :setStyle
60
+ calls.keys.must_include :pop
61
+ calls.keys.must_include :fetchData
62
+ calls.keys.must_include :setState
63
+ calls.keys.must_include :func1
64
+
65
+ calls[:pop].count.must_equal 1
66
+ calls[:_tabItem].count.must_equal 3
67
+ end
68
+ end
@@ -1,4 +1,4 @@
1
- require File.expand_path('../../../test_helper', __FILE__)
1
+ require_relative '../../test_helper'
2
2
 
3
3
  describe Starscope::Lang::Ruby do
4
4
  before do
@@ -1,4 +1,4 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ require_relative '../test_helper'
2
2
 
3
3
  describe Starscope::Output do
4
4
  it 'must be quiet' do
@@ -1,23 +1,23 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ require_relative '../test_helper'
2
2
 
3
3
  describe Starscope::Queryable do
4
4
  SAMPLE_RECORDS = [
5
- { :name => [:"[abc"], :foo => 'baz' },
6
- { :name => [:"not a match"], :foo => 'bar', :x => 'y' },
7
- { :name => [:a, :b, :c, :d], :file => :somefile }
5
+ { name: [:"[abc"], foo: 'baz' },
6
+ { name: [:"not a match"], foo: 'bar', x: 'y' },
7
+ { name: [:a, :b, :c, :d], file: :somefile }
8
8
  ]
9
9
 
10
10
  class MockQuerable
11
11
  include Starscope::Queryable
12
12
  def initialize
13
13
  @tables = {
14
- :mytable => SAMPLE_RECORDS,
15
- :empty_table => []
14
+ mytable: SAMPLE_RECORDS,
15
+ empty_table: []
16
16
  }
17
17
  @meta = {
18
- :files => {
19
- :somefile => {
20
- :lang => :ruby
18
+ files: {
19
+ somefile: {
20
+ lang: :ruby
21
21
  }
22
22
  }
23
23
  }
@@ -47,15 +47,15 @@ describe Starscope::Queryable do
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: starscope
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.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: 2015-09-12 00:00:00.000000000 Z
11
+ date: 2015-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -53,91 +53,119 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.5'
55
55
  - !ruby/object:Gem::Dependency
56
- name: backports
56
+ name: rkelly-remix
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.6'
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
- version: '3.6'
68
+ version: 0.0.7
69
+ - !ruby/object:Gem::Dependency
70
+ name: babel-transpiler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.7'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: sourcemap
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.1'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.1'
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: bundler
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - "~>"
74
102
  - !ruby/object:Gem::Version
75
- version: '1.5'
103
+ version: '1.7'
76
104
  type: :development
77
105
  prerelease: false
78
106
  version_requirements: !ruby/object:Gem::Requirement
79
107
  requirements:
80
108
  - - "~>"
81
109
  - !ruby/object:Gem::Version
82
- version: '1.5'
110
+ version: '1.7'
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: rake
85
113
  requirement: !ruby/object:Gem::Requirement
86
114
  requirements:
87
- - - ">="
115
+ - - "~>"
88
116
  - !ruby/object:Gem::Version
89
- version: '0'
117
+ version: '10.4'
90
118
  type: :development
91
119
  prerelease: false
92
120
  version_requirements: !ruby/object:Gem::Requirement
93
121
  requirements:
94
- - - ">="
122
+ - - "~>"
95
123
  - !ruby/object:Gem::Version
96
- version: '0'
124
+ version: '10.4'
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: pry
99
127
  requirement: !ruby/object:Gem::Requirement
100
128
  requirements:
101
- - - ">="
129
+ - - "~>"
102
130
  - !ruby/object:Gem::Version
103
- version: '0'
131
+ version: 0.10.1
104
132
  type: :development
105
133
  prerelease: false
106
134
  version_requirements: !ruby/object:Gem::Requirement
107
135
  requirements:
108
- - - ">="
136
+ - - "~>"
109
137
  - !ruby/object:Gem::Version
110
- version: '0'
138
+ version: 0.10.1
111
139
  - !ruby/object:Gem::Dependency
112
140
  name: minitest
113
141
  requirement: !ruby/object:Gem::Requirement
114
142
  requirements:
115
- - - ">="
143
+ - - "~>"
116
144
  - !ruby/object:Gem::Version
117
- version: '0'
145
+ version: '5.8'
118
146
  type: :development
119
147
  prerelease: false
120
148
  version_requirements: !ruby/object:Gem::Requirement
121
149
  requirements:
122
- - - ">="
150
+ - - "~>"
123
151
  - !ruby/object:Gem::Version
124
- version: '0'
152
+ version: '5.8'
125
153
  - !ruby/object:Gem::Dependency
126
154
  name: mocha
127
155
  requirement: !ruby/object:Gem::Requirement
128
156
  requirements:
129
- - - ">="
157
+ - - "~>"
130
158
  - !ruby/object:Gem::Version
131
- version: '0'
159
+ version: '1.1'
132
160
  type: :development
133
161
  prerelease: false
134
162
  version_requirements: !ruby/object:Gem::Requirement
135
163
  requirements:
136
- - - ">="
164
+ - - "~>"
137
165
  - !ruby/object:Gem::Version
138
- version: '0'
166
+ version: '1.1'
139
167
  description: |2
140
- Starscope is a code indexer, search and navigation tool for Ruby and Go.
168
+ Starscope is a code indexer, search and navigation tool for Ruby, Golang, and JavaScript.
141
169
  Inspired by the extremely popular Ctags and Cscope utilities, Starscope can
142
170
  answer a lot of questions about a lot of code.
143
171
  email: eapache@gmail.com
@@ -151,7 +179,6 @@ files:
151
179
  - ".travis.yml"
152
180
  - CHANGELOG.md
153
181
  - Gemfile
154
- - Gemfile.lock
155
182
  - LICENSE.txt
156
183
  - README.md
157
184
  - Rakefile
@@ -165,6 +192,7 @@ files:
165
192
  - lib/starscope/fragment_extractor.rb
166
193
  - lib/starscope/langs/erb.rb
167
194
  - lib/starscope/langs/go.rb
195
+ - lib/starscope/langs/javascript.rb
168
196
  - lib/starscope/langs/ruby.rb
169
197
  - lib/starscope/matcher.rb
170
198
  - lib/starscope/output.rb
@@ -182,6 +210,7 @@ files:
182
210
  - test/fixtures/empty
183
211
  - test/fixtures/sample_erb.erb
184
212
  - test/fixtures/sample_golang.go
213
+ - test/fixtures/sample_javascript.js
185
214
  - test/fixtures/sample_ruby.rb
186
215
  - test/functional/starscope_test.rb
187
216
  - test/test_helper.rb
@@ -190,6 +219,7 @@ files:
190
219
  - test/unit/fragment_extractor_test.rb
191
220
  - test/unit/langs/erb_test.rb
192
221
  - test/unit/langs/golang_test.rb
222
+ - test/unit/langs/javascript_test.rb
193
223
  - test/unit/langs/ruby_test.rb
194
224
  - test/unit/output_test.rb
195
225
  - test/unit/queryable_test.rb
@@ -205,7 +235,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
205
235
  requirements:
206
236
  - - ">="
207
237
  - !ruby/object:Gem::Version
208
- version: 1.8.7
238
+ version: 1.9.3
209
239
  required_rubygems_version: !ruby/object:Gem::Requirement
210
240
  requirements:
211
241
  - - ">="
@@ -229,6 +259,7 @@ test_files:
229
259
  - test/fixtures/empty
230
260
  - test/fixtures/sample_erb.erb
231
261
  - test/fixtures/sample_golang.go
262
+ - test/fixtures/sample_javascript.js
232
263
  - test/fixtures/sample_ruby.rb
233
264
  - test/functional/starscope_test.rb
234
265
  - test/test_helper.rb
@@ -237,6 +268,7 @@ test_files:
237
268
  - test/unit/fragment_extractor_test.rb
238
269
  - test/unit/langs/erb_test.rb
239
270
  - test/unit/langs/golang_test.rb
271
+ - test/unit/langs/javascript_test.rb
240
272
  - test/unit/langs/ruby_test.rb
241
273
  - test/unit/output_test.rb
242
274
  - test/unit/queryable_test.rb
@@ -1,41 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- starscope (1.4.1)
5
- backports (~> 3.6)
6
- oj (~> 2.9)
7
- parser (~> 2.2.2)
8
- ruby-progressbar (~> 1.5)
9
-
10
- GEM
11
- remote: https://rubygems.org/
12
- specs:
13
- ast (2.1.0)
14
- backports (3.6.6)
15
- coderay (1.1.0)
16
- metaclass (0.0.4)
17
- method_source (0.8.2)
18
- minitest (5.8.0)
19
- mocha (1.1.0)
20
- metaclass (~> 0.0.1)
21
- oj (2.12.13)
22
- parser (2.2.2.6)
23
- ast (>= 1.1, < 3.0)
24
- pry (0.10.1)
25
- coderay (~> 1.1.0)
26
- method_source (~> 0.8.1)
27
- slop (~> 3.4)
28
- rake (10.4.2)
29
- ruby-progressbar (1.7.5)
30
- slop (3.6.0)
31
-
32
- PLATFORMS
33
- ruby
34
-
35
- DEPENDENCIES
36
- bundler (~> 1.5)
37
- minitest
38
- mocha
39
- pry
40
- rake
41
- starscope!