starscope 1.6.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d71f7d9d5748e9df63987f08669e56866a5669a7877a5b78bec7274ae6b11e3b
4
- data.tar.gz: a037cc0b16644f69a37c1d9a00f076a036353cb84cbcaef39e17f864af2c70eb
3
+ metadata.gz: b664cd1fd9107436e9a2bf94a21c00249ed8970b905b34c8649eba4cca7336c7
4
+ data.tar.gz: 39aa4d99d25f820db321b1c5b58d9e8662ed45812a8636c047df52f25a9d38b1
5
5
  SHA512:
6
- metadata.gz: 85d4390356102ec0dfc658fa99bb8816a197f48f990abe56fd5b1df7ac85d3d1ffdd93666ca463ca9c42a362ae81a369cc81fa700c83729a9e73a9ba1e431730
7
- data.tar.gz: 6cb4cc84d760ba1e5114f2401878e9312eff5e1b7d30ae7b3c4feec10a76c0f87f1f3d00de59417aee8e5e57aa2eb9744ae6a851303b964d9b8edaf8fcec3dad
6
+ metadata.gz: 1fb43999baa94336ac2265045f0e7a06e18070d2199489bdc489155bc9baf03b9541922c8a9791b6d3a9578cda6cd2a75d20076a73b86d0d9481d2ae9659da05
7
+ data.tar.gz: a9ee933fffe03daf2b50f017499b188da833305da02012283823c771c5daa10e7c9a293486925f30afde29342e192a5bfbd1606ced1c8f20e848741eac839f27
@@ -2,9 +2,9 @@ name: Ruby CI
2
2
 
3
3
  on:
4
4
  push:
5
- branches: [ master ]
5
+ branches: [ main ]
6
6
  pull_request:
7
- branches: [ master ]
7
+ branches: [ main ]
8
8
 
9
9
  jobs:
10
10
  test:
data/.gitignore CHANGED
@@ -2,6 +2,7 @@
2
2
  *.rbc
3
3
  .starscope.db
4
4
  .bundle
5
+ .byebug_history
5
6
  .config
6
7
  Gemfile.lock
7
8
  coverage
data/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ v1.6.1 (2022-08-07)
5
+ -------------------
6
+
7
+ * Support for extracting javascript blocks from vue files.
8
+ * Print a newline when exiting from line-mode via interrupt.
9
+ * Support for Ruby 3.x "def foo = ..." method syntax (#192).
10
+ * Don't generate conflicting `read` and `defs` entries for class and module
11
+ definitions (#176).
12
+
4
13
  v1.6.0 (2022-02-10)
5
14
  -------------------
6
15
 
data/bin/starscope CHANGED
@@ -298,6 +298,7 @@ if options[:linemode]
298
298
  end
299
299
  end
300
300
  rescue Interrupt
301
+ puts
301
302
  exit
302
303
  end
303
304
  end
@@ -1,4 +1,4 @@
1
- require 'parser/current'
1
+ require 'parser/ruby31'
2
2
 
3
3
  module Starscope
4
4
  module Lang
@@ -29,7 +29,7 @@ module Starscope
29
29
  buffer = Parser::Source::Buffer.new(path, 1)
30
30
  buffer.source = contents.force_encoding(Encoding::UTF_8)
31
31
 
32
- parser = Parser::CurrentRuby.new(Builder.new)
32
+ parser = Parser::Ruby31.new(Builder.new)
33
33
  parser.diagnostics.ignore_warnings = true
34
34
  parser.diagnostics.all_errors_are_fatal = false
35
35
 
@@ -41,12 +41,15 @@ module Starscope
41
41
  extract_node(tree, scope, &block)
42
42
 
43
43
  new_scope = []
44
+ child_nodes = tree.children
45
+
44
46
  if %i[class module].include? tree.type
45
47
  new_scope = scoped_name(tree.children[0], scope)
46
48
  scope += new_scope
49
+ child_nodes = child_nodes[1..] # module and class constant definitions are not "read"s
47
50
  end
48
51
 
49
- tree.children.each { |node| extract_tree(node, scope, &block) if node.is_a? AST::Node }
52
+ child_nodes.each { |node| extract_tree(node, scope, &block) if node.is_a? AST::Node }
50
53
 
51
54
  scope.pop(new_scope.count)
52
55
  end
@@ -70,7 +73,12 @@ module Starscope
70
73
  when :def
71
74
  yield :defs, scope + [node.children[0]],
72
75
  line_no: loc.line, type: :func, col: loc.name.column
73
- yield :end, :end, line_no: loc.end.line, type: :func, col: loc.end.column
76
+ if loc.end
77
+ yield :end, :end, line_no: loc.end.line, type: :func, col: loc.end.column
78
+ else
79
+ # ruby 3.x syntax for "def foo = ..."
80
+ yield :end, :end, line_no: loc.line, type: :func, col: loc.expression.end.column
81
+ end
74
82
 
75
83
  when :defs
76
84
  yield :defs, scope + [node.children[1]],
@@ -0,0 +1,32 @@
1
+ module Starscope
2
+ module Lang
3
+ module Vue
4
+ VERSION = 1
5
+
6
+ SCRIPT_START = '<script>'.freeze
7
+ SCRIPT_END = '</script>'.freeze
8
+
9
+ def self.match_file(name)
10
+ name.end_with?('.vue')
11
+ end
12
+
13
+ def self.extract(_path, contents)
14
+ in_script = false
15
+
16
+ contents.lines.each_with_index do |line, line_no|
17
+ line_no += 1 # zero-index to one-index
18
+
19
+ if in_script
20
+ if line.strip == SCRIPT_END
21
+ in_script = false
22
+ else
23
+ yield Starscope::DB::FRAGMENT, :Javascript, frag: line, line_no: line_no
24
+ end
25
+ elsif line.strip == SCRIPT_START
26
+ in_script = true
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,3 +1,3 @@
1
1
  module Starscope
2
- VERSION = '1.6.0'.freeze
2
+ VERSION = '1.6.1'.freeze
3
3
  end
data/starscope.gemspec CHANGED
@@ -27,9 +27,9 @@ Gem::Specification.new do |gem|
27
27
  gem.add_dependency 'sourcemap', '~> 0.1'
28
28
 
29
29
  gem.add_development_dependency 'bundler', '>= 1.7'
30
+ gem.add_development_dependency 'byebug', '~> 11.1'
30
31
  gem.add_development_dependency 'minitest', '~> 5.12'
31
32
  gem.add_development_dependency 'mocha', '~> 1.3'
32
- gem.add_development_dependency 'pry', '~> 0.11'
33
33
  gem.add_development_dependency 'rake', '~> 13.0'
34
34
  gem.add_development_dependency 'rubocop', '~> 1.25.0'
35
35
  gem.add_development_dependency 'rubocop-minitest', '~> 0.17.1'
@@ -164,3 +164,6 @@ class Starscope::DB
164
164
  end
165
165
 
166
166
  puts __ENCODING__
167
+
168
+ # Ruby 3.x syntax
169
+ def get_lastfile(dirpath) = Dir.glob("#{ dirpath }/*").reject { |i| File.directory?(i) }.sort.last
@@ -0,0 +1,48 @@
1
+ <template>
2
+ <div class="container">
3
+ <span>
4
+ <a
5
+ href="https://www.markdownguide.org/cheat-sheet/"
6
+ target="_blank"
7
+ style="padding-left: 6px; padding-bottom: 0px;"
8
+ >Markdown </a>
9
+ {{ descriptionLinkingVerb }} supported.
10
+ </span>
11
+ </div>
12
+ </template>
13
+
14
+ <script>
15
+ import marked from 'marked';
16
+
17
+ export default {
18
+ props: {
19
+ placeholderText: {
20
+ type: String,
21
+ default: 'This field supports Markdown. Try it out!'
22
+ }
23
+ },
24
+ computed: {
25
+ markdown() {
26
+ return marked(this.value || '');
27
+ }
28
+ },
29
+ methods: {
30
+ handleChange(e) {
31
+ this.$emit('change', e.target.value);
32
+ }
33
+ }
34
+ }
35
+ </script>
36
+
37
+ <style scoped>
38
+ @import "../shared/style.css";
39
+ </style>
40
+
41
+ <style>
42
+ .container {
43
+ overflow: auto;
44
+ padding: 5px;
45
+ border-radius: 5px;
46
+ }
47
+
48
+ </style>
@@ -23,8 +23,9 @@ describe 'starscope executable script' do
23
23
  lines = `#{EXTRACT} -d requires`.lines.to_a
24
24
  _(lines[1].split.first).must_equal 'date'
25
25
  _(lines[2].split.first).must_equal 'foo-bar'
26
- _(lines[3].split.first).must_equal 'react-native'
27
- _(lines[4].split.first).must_equal 'zlib'
26
+ _(lines[3].split.first).must_equal 'marked'
27
+ _(lines[4].split.first).must_equal 'react-native'
28
+ _(lines[5].split.first).must_equal 'zlib'
28
29
  end
29
30
 
30
31
  it 'must correctly query the database' do
data/test/test_helper.rb CHANGED
@@ -9,4 +9,5 @@ GOLANG_SAMPLE = "#{FIXTURES}/sample_golang.go".freeze
9
9
  JAVASCRIPT_EXAMPLE = "#{FIXTURES}/sample_javascript.js".freeze
10
10
  RUBY_SAMPLE = "#{FIXTURES}/sample_ruby.rb".freeze
11
11
  ERB_SAMPLE = "#{FIXTURES}/sample_erb.erb".freeze
12
+ VUE_SAMPLE = "#{FIXTURES}/sample_vue.vue".freeze
12
13
  EMPTY_FILE = "#{FIXTURES}/empty".freeze
@@ -28,15 +28,20 @@ describe Starscope::Lang::Ruby do
28
28
  _(defs).must_include :load
29
29
  _(defs).must_include :update
30
30
  _(defs).must_include :files_from_path
31
+ _(defs).must_include :get_lastfile
31
32
  end
32
33
 
33
34
  it 'must identify constant definitions' do
34
- _(@db[:defs].map { |x| x[:name][-1] }).must_include :PBAR_FORMAT
35
+ _(@db.keys).must_include :defs
36
+ defs = @db[:defs].map { |x| x[:name][-1] }
37
+
38
+ _(defs).must_include :PBAR_FORMAT
39
+ _(defs).must_include :SOME_INVALID_ENCODING
35
40
  end
36
41
 
37
42
  it 'must identify endings' do
38
43
  _(@db.keys).must_include :end
39
- _(@db[:end].count).must_equal 13
44
+ _(@db[:end].count).must_equal 14
40
45
  end
41
46
 
42
47
  it 'must identify function calls' do
@@ -63,4 +68,18 @@ describe Starscope::Lang::Ruby do
63
68
  _(assigns.keys).wont_include :'='
64
69
  _(assigns.keys).wont_include :<
65
70
  end
71
+
72
+ it 'must identify variable and constant reads' do
73
+ _(@db.keys).must_include :reads
74
+ reads = @db[:reads].map { |x| x[:name][-1] }
75
+
76
+ _(reads).must_include :Go
77
+ _(reads).must_include :Ruby
78
+ _(reads).must_include :DB_FORMAT
79
+ _(reads).must_include :UnknownDBFormatError
80
+ _(reads).must_include :path
81
+ _(reads).must_include :entry
82
+ _(reads).must_include :file
83
+ _(reads).must_include :@files
84
+ end
66
85
  end
@@ -0,0 +1,28 @@
1
+ require_relative '../../test_helper'
2
+
3
+ describe Starscope::Lang::Vue do
4
+ before do
5
+ @frags = []
6
+ Starscope::Lang::Vue.extract(VUE_SAMPLE, File.read(VUE_SAMPLE)) do |tbl, name, args|
7
+ _(tbl).must_equal Starscope::DB::FRAGMENT
8
+ _(name).must_equal :Javascript
9
+ @frags << args
10
+ end
11
+ end
12
+
13
+ it 'must match vue files' do
14
+ _(Starscope::Lang::Vue.match_file(VUE_SAMPLE)).must_equal true
15
+ end
16
+
17
+ it 'must not match non-vue files' do
18
+ _(Starscope::Lang::ERB.match_file(GOLANG_SAMPLE)).must_equal false
19
+ _(Starscope::Lang::ERB.match_file(EMPTY_FILE)).must_equal false
20
+ end
21
+
22
+ it 'must identify fragments' do
23
+ _(@frags.length).must_equal(20)
24
+ _(@frags).must_include({ frag: "import marked from 'marked';\n", line_no: 15 })
25
+ _(@frags).must_include({ frag: " markdown() {\n", line_no: 25 })
26
+ _(@frags).must_include({ frag: "}\n", line_no: 34 })
27
+ end
28
+ 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.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Huus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-10 00:00:00.000000000 Z
11
+ date: 2022-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: babel-transpiler
@@ -109,47 +109,47 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.7'
111
111
  - !ruby/object:Gem::Dependency
112
- name: minitest
112
+ name: byebug
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '5.12'
117
+ version: '11.1'
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: '5.12'
124
+ version: '11.1'
125
125
  - !ruby/object:Gem::Dependency
126
- name: mocha
126
+ name: minitest
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '1.3'
131
+ version: '5.12'
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: '1.3'
138
+ version: '5.12'
139
139
  - !ruby/object:Gem::Dependency
140
- name: pry
140
+ name: mocha
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '0.11'
145
+ version: '1.3'
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: '0.11'
152
+ version: '1.3'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: rake
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -236,6 +236,7 @@ files:
236
236
  - lib/starscope/langs/golang.rb
237
237
  - lib/starscope/langs/javascript.rb
238
238
  - lib/starscope/langs/ruby.rb
239
+ - lib/starscope/langs/vue.rb
239
240
  - lib/starscope/matcher.rb
240
241
  - lib/starscope/output.rb
241
242
  - lib/starscope/queryable.rb
@@ -254,6 +255,7 @@ files:
254
255
  - test/fixtures/sample_golang.go
255
256
  - test/fixtures/sample_javascript.js
256
257
  - test/fixtures/sample_ruby.rb
258
+ - test/fixtures/sample_vue.vue
257
259
  - test/functional/starscope_test.rb
258
260
  - test/test_helper.rb
259
261
  - test/unit/db_test.rb
@@ -263,6 +265,7 @@ files:
263
265
  - test/unit/langs/golang_test.rb
264
266
  - test/unit/langs/javascript_test.rb
265
267
  - test/unit/langs/ruby_test.rb
268
+ - test/unit/langs/vue_test.rb
266
269
  - test/unit/output_test.rb
267
270
  - test/unit/queryable_test.rb
268
271
  homepage: https://github.com/eapache/starscope
@@ -285,7 +288,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
285
288
  - !ruby/object:Gem::Version
286
289
  version: '0'
287
290
  requirements: []
288
- rubygems_version: 3.0.9
291
+ rubygems_version: 3.1.2
289
292
  signing_key:
290
293
  specification_version: 4
291
294
  summary: Smart code search and indexing
@@ -303,6 +306,7 @@ test_files:
303
306
  - test/fixtures/sample_golang.go
304
307
  - test/fixtures/sample_javascript.js
305
308
  - test/fixtures/sample_ruby.rb
309
+ - test/fixtures/sample_vue.vue
306
310
  - test/functional/starscope_test.rb
307
311
  - test/test_helper.rb
308
312
  - test/unit/db_test.rb
@@ -312,5 +316,6 @@ test_files:
312
316
  - test/unit/langs/golang_test.rb
313
317
  - test/unit/langs/javascript_test.rb
314
318
  - test/unit/langs/ruby_test.rb
319
+ - test/unit/langs/vue_test.rb
315
320
  - test/unit/output_test.rb
316
321
  - test/unit/queryable_test.rb