starscope 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,6 +1,8 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
+ - 1.8.7
5
+ - 1.9.2
4
6
  - 1.9.3
5
7
  - 2.0.0
6
8
  - 2.1.0
data/CHANGELOG.md CHANGED
@@ -1,7 +1,14 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
- v0.1.9 (trunk)
4
+ v0.1.10 (trunk)
5
+ -------------------
6
+
7
+ Improvements:
8
+ * Import new ruby parser version and make necessary changes so that StarScope
9
+ now runs on older Ruby versions (1.9.2 and 1.8.7)
10
+
11
+ v0.1.9 (2014-02-22)
5
12
  -------------------
6
13
 
7
14
  Bug Fixes:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- starscope (0.1.9)
4
+ starscope (0.1.10)
5
5
  oj (~> 2.5)
6
6
  parser (~> 2.1)
7
7
  ruby-progressbar (~> 1.4)
@@ -11,25 +11,16 @@ GEM
11
11
  specs:
12
12
  ast (1.1.0)
13
13
  coderay (1.1.0)
14
- columnize (0.3.6)
15
- debugger (1.6.5)
16
- columnize (>= 0.3.1)
17
- debugger-linecache (~> 1.2.0)
18
- debugger-ruby_core_source (~> 1.3.1)
19
- debugger-linecache (1.2.0)
20
- debugger-ruby_core_source (1.3.1)
21
14
  method_source (0.8.2)
15
+ minitest (5.2.3)
22
16
  oj (2.5.5)
23
- parser (2.1.4)
17
+ parser (2.1.5)
24
18
  ast (~> 1.1)
25
19
  slop (~> 3.4, >= 3.4.5)
26
20
  pry (0.9.12.6)
27
21
  coderay (~> 1.0)
28
22
  method_source (~> 0.8)
29
23
  slop (~> 3.4)
30
- pry-debugger (0.2.2)
31
- debugger (~> 1.3)
32
- pry (~> 0.9.10)
33
24
  rake (10.1.1)
34
25
  ruby-progressbar (1.4.1)
35
26
  slop (3.4.7)
@@ -39,7 +30,7 @@ PLATFORMS
39
30
 
40
31
  DEPENDENCIES
41
32
  bundler (~> 1.5)
33
+ minitest
42
34
  pry
43
- pry-debugger
44
35
  rake
45
36
  starscope!
data/README.md CHANGED
@@ -13,7 +13,7 @@ StarScope is a similar tool for [Ruby](https://www.ruby-lang.org/) and
13
13
  support for other languages at some point within the same framework (thus the
14
14
  name StarScope, ie \*scope).
15
15
 
16
- Install it as a gem (requires at least Ruby 1.9.3):
16
+ Install it as a gem:
17
17
  ```
18
18
  $ gem install starscope
19
19
  ```
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
3
 
4
4
  Rake::TestTask.new do |t|
@@ -6,5 +6,5 @@ Rake::TestTask.new do |t|
6
6
  t.test_files = FileList['test/lib/test_*.rb']
7
7
  end
8
8
 
9
- desc "Run tests"
9
+ desc 'Run tests'
10
10
  task :default => :test
data/lib/starscope/db.rb CHANGED
@@ -33,7 +33,7 @@ class StarScope::DB
33
33
  if format == DB_FORMAT
34
34
  @paths = Oj.load(file.gets)
35
35
  @files = Oj.load(file.gets)
36
- @tables = Oj.load(file.gets, symbol_keys: true)
36
+ @tables = Oj.load(file.gets, :symbol_keys => true)
37
37
  elsif format <= 2
38
38
  # Old format (pre-json), so read the directories segment then rebuild
39
39
  len = file.gets.to_i
@@ -66,7 +66,7 @@ class StarScope::DB
66
66
  files = paths.map {|p| self.class.files_from_path(p)}.flatten
67
67
  return if files.empty?
68
68
  if @progress
69
- pbar = ProgressBar.create(title: "Building", total: files.length, format: PBAR_FORMAT, length: 80)
69
+ pbar = ProgressBar.create(:title => "Building", :total => files.length, :format => PBAR_FORMAT, :length => 80)
70
70
  end
71
71
  files.each do |f|
72
72
  add_file(f)
@@ -77,7 +77,7 @@ class StarScope::DB
77
77
  def update
78
78
  new_files = (@paths.map {|p| self.class.files_from_path(p)}.flatten) - @files.keys
79
79
  if @progress
80
- pbar = ProgressBar.create(title: "Updating", total: new_files.length + @files.length, format: PBAR_FORMAT, length: 80)
80
+ pbar = ProgressBar.create(:title => "Updating", :total => new_files.length + @files.length, :format => PBAR_FORMAT, :length => 80)
81
81
  end
82
82
  changed = @files.keys.map do |f|
83
83
  changed = update_file(f)
@@ -236,7 +236,7 @@ END
236
236
  if entry[:line_no]
237
237
  tmpdb[entry[:file]] ||= {}
238
238
  tmpdb[entry[:file]][entry[:line_no]] ||= []
239
- tmpdb[entry[:file]][entry[:line_no]] << {tbl: tbl, key: key, entry: entry}
239
+ tmpdb[entry[:file]][entry[:line_no]] << {:tbl => tbl, :key => key, :entry => entry}
240
240
  end
241
241
  end
242
242
  end
@@ -1,7 +1,7 @@
1
1
  module StarScope::Lang
2
2
  module Go
3
3
  FUNC_CALL = /([\w\.]*?\w)\(/
4
- END_OF_BLOCK = /^\s*}\s*$/
4
+ END_OF_BLOCK = /^\s*\}\s*$/
5
5
  END_OF_GROUP = /^\s*\)\s*$/
6
6
  BUILTIN_FUNCS = ['new', 'make', 'len', 'close', 'copy', 'delete',
7
7
  'int', 'int8', 'int16', 'int32', 'int64',
@@ -51,7 +51,7 @@ module StarScope::Lang
51
51
  when :struct
52
52
  case line
53
53
  when END_OF_BLOCK
54
- yield :end, "}", line_no: line_no, scope: scope, type: :class
54
+ yield :end, "}", :line_no => line_no, :scope => scope, :type => :class
55
55
  stack.pop
56
56
  scope.pop
57
57
  when /(.+)\s+\w+/
@@ -60,11 +60,11 @@ module StarScope::Lang
60
60
  when :interface
61
61
  case line
62
62
  when END_OF_BLOCK
63
- yield :end, "}", line_no: line_no, scope: scope, type: :class
63
+ yield :end, "}", :line_no => line_no, :scope => scope, :type => :class
64
64
  stack.pop
65
65
  scope.pop
66
66
  when /(\w+)\(.*\)\s+/
67
- yield :defs, $1, line_no: line_no, scope: scope
67
+ yield :defs, $1, :line_no => line_no, :scope => scope
68
68
  end
69
69
  when :def
70
70
  case line
@@ -81,55 +81,55 @@ module StarScope::Lang
81
81
  stack.pop
82
82
  when /"(.+)"/
83
83
  name = $1.split('/')
84
- yield :imports, name[-1], line_no: line_no, scope: name[0...-1]
84
+ yield :imports, name[-1], :line_no => line_no, :scope => name[0...-1]
85
85
  end
86
86
  else
87
- if stack[-1] == :func and /^}/ =~ line
88
- yield :end, "}", line_no: line_no, type: :func
87
+ if stack[-1] == :func and /^\}/ =~ line
88
+ yield :end, "}", :line_no => line_no, :type => :func
89
89
  stack.pop
90
90
  end
91
91
  case line
92
92
  when /^func\s+(\w+)\(/
93
- yield :defs, $1, line_no: line_no, scope: scope, type: :func
93
+ yield :defs, $1, :line_no => line_no, :scope => scope, :type => :func
94
94
  stack.push(:func)
95
95
  when /^func\s+\(\w+\s+\*?(\w+)\)\s*(\w+)\(/
96
- yield :defs, $2, line_no: line_no, scope: scope + [$1], type: :func
96
+ yield :defs, $2, :line_no => line_no, :scope => scope + [$1], :type => :func
97
97
  stack.push(:func)
98
98
  when /^package\s+(\w+)/
99
- yield :defs, $1, line_no: line_no, scope: scope, type: :package
99
+ yield :defs, $1, :line_no => line_no, :scope => scope, :type => :package
100
100
  scope.push($1)
101
- when /^type\s+(\w+)\s+struct\s*{/
102
- yield :defs, $1, line_no: line_no, scope: scope, type: :class
101
+ when /^type\s+(\w+)\s+struct\s*\{/
102
+ yield :defs, $1, :line_no => line_no, :scope => scope, :type => :class
103
103
  scope.push($1)
104
104
  stack.push(:struct)
105
- when /^type\s+(\w+)\s+interface\s*{/
106
- yield :defs, $1, line_no: line_no, scope: scope, type: :class
105
+ when /^type\s+(\w+)\s+interface\s*\{/
106
+ yield :defs, $1, :line_no => line_no, :scope => scope, :type => :class
107
107
  scope.push($1)
108
108
  stack.push(:interface)
109
109
  when /^type\s+(\w+)/
110
- yield :defs, $1, line_no: line_no, scope: scope, type: :type
110
+ yield :defs, $1, :line_no => line_no, :scope => scope, :type => :type
111
111
  when /^import\s+"(.+)"/
112
112
  name = $1.split('/')
113
- yield :imports, name[-1], line_no: line_no, scope: name[0...-1]
113
+ yield :imports, name[-1], :line_no => line_no, :scope => name[0...-1]
114
114
  when /^import\s+\(/
115
115
  stack.push(:import)
116
116
  when /^var\s+\(/
117
117
  stack.push(:def)
118
118
  when /^var\s+(\w+)\s+\w+/
119
- yield :defs, $1, line_no: line_no, scope: scope
119
+ yield :defs, $1, :line_no => line_no, :scope => scope
120
120
  when /^const\s+\(/
121
121
  stack.push(:def)
122
122
  when /^const\s+(\w+)\s+\w+/
123
- yield :defs, $1, line_no: line_no, scope: scope
123
+ yield :defs, $1, :line_no => line_no, :scope => scope
124
124
  when /^\s+(.*?) :?=[^=]/
125
125
  $1.split(' ').each do |var|
126
126
  next if CONTROL_KEYS.include?(var)
127
127
  name = var.delete(',').split('.')
128
128
  next if name[0] == "_" # assigning to _ is a discard in golang
129
129
  if name.length == 1
130
- yield :assigns, name[0], line_no: line_no, scope: scope
130
+ yield :assigns, name[0], :line_no => line_no, :scope => scope
131
131
  else
132
- yield :assigns, name[1], line_no: line_no, scope: name[0..-1]
132
+ yield :assigns, name[1], :line_no => line_no, :scope => name[0..-1]
133
133
  end
134
134
  end
135
135
  parse_call(line, line_no, scope, &block)
@@ -151,19 +151,19 @@ module StarScope::Lang
151
151
  if name.length == 1
152
152
  next if name[0] == 'func'
153
153
  if BUILTIN_FUNCS.include?(name[0])
154
- yield :calls, name[0], line_no: line_no
154
+ yield :calls, name[0], :line_no => line_no
155
155
  else
156
- yield :calls, name[0], line_no: line_no, scope: scope
156
+ yield :calls, name[0], :line_no => line_no, :scope => scope
157
157
  end
158
158
  else
159
- yield :calls, name[-1], line_no: line_no, scope: name[0...-1]
159
+ yield :calls, name[-1], :line_no => line_no, :scope => name[0...-1]
160
160
  end
161
161
  end
162
162
  end
163
163
 
164
164
  def self.parse_def(line, line_no, scope)
165
165
  line.split.each do |var|
166
- yield :defs, var.delete(','), line_no: line_no, scope: scope
166
+ yield :defs, var.delete(','), :line_no => line_no, :scope => scope
167
167
  break if not var.end_with?(',')
168
168
  end
169
169
  end
@@ -53,38 +53,38 @@ module StarScope::Lang
53
53
  when :send
54
54
  fqn = scoped_name(node)
55
55
  yield :calls, fqn.last,
56
- line_no: node.location.expression.line,
57
- scope: fqn[0...-1]
56
+ :line_no => node.location.expression.line,
57
+ :scope => fqn[0...-1]
58
58
  if node.children[0].nil? and node.children[1] == :require and node.children[2].type == :str
59
59
  fqn = node.children[2].children[0].split("/")
60
60
  yield :requires, fqn.last,
61
- line_no: node.location.expression.line,
62
- scope: fqn[0...-1]
61
+ :line_no => node.location.expression.line,
62
+ :scope => fqn[0...-1]
63
63
  end
64
64
  when :def
65
65
  yield :defs, node.children[0],
66
- line_no: node.location.expression.line,
67
- scope: @scope, type: :func
68
- yield :end, :end, line_no: node.location.end.line, type: :func
66
+ :line_no => node.location.expression.line,
67
+ :scope => @scope, :type => :func
68
+ yield :end, :end, :line_no => node.location.end.line, :type => :func
69
69
  when :defs
70
70
  yield :defs, node.children[1],
71
- line_no: node.location.expression.line,
72
- scope: @scope, type: :func
73
- yield :end, :end, line_no: node.location.end.line, type: :func
71
+ :line_no => node.location.expression.line,
72
+ :scope => @scope, :type => :func
73
+ yield :end, :end, :line_no => node.location.end.line, :type => :func
74
74
  when :module, :class
75
75
  fqn = @scope + scoped_name(node.children[0])
76
- yield :defs, fqn.last, line_no: node.location.expression.line,
77
- scope: fqn[0...-1], type: node.type
78
- yield :end, :end, line_no: node.location.end.line, type: node.type
76
+ yield :defs, fqn.last, :line_no => node.location.expression.line,
77
+ :scope => fqn[0...-1], :type => node.type
78
+ yield :end, :end, :line_no => node.location.end.line, :type => node.type
79
79
  when :casgn
80
80
  fqn = scoped_name(node)
81
81
  yield :assigns, fqn.last,
82
- line_no: node.location.expression.line,
83
- scope: fqn[0...-1]
82
+ :line_no => node.location.expression.line,
83
+ :scope => fqn[0...-1]
84
84
  when :lvasgn, :ivasgn, :cvasgn, :gvasgn
85
85
  yield :assigns, node.children[0],
86
- line_no: node.location.expression.line,
87
- scope: @scope
86
+ :line_no => node.location.expression.line,
87
+ :scope => @scope
88
88
  end
89
89
  end
90
90
 
@@ -1,3 +1,3 @@
1
1
  module StarScope
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  end
data/starscope.gemspec CHANGED
@@ -21,5 +21,5 @@ Gem::Specification.new do |gem|
21
21
  gem.add_development_dependency 'bundler', '~> 1.5'
22
22
  gem.add_development_dependency 'rake'
23
23
  gem.add_development_dependency 'pry'
24
- gem.add_development_dependency 'pry-debugger'
24
+ gem.add_development_dependency 'minitest'
25
25
  end
@@ -26,7 +26,7 @@ class StarScope::DB
26
26
  if format == DB_FORMAT
27
27
  @paths = Oj.load(file.gets)
28
28
  @files = Oj.load(file.gets)
29
- @tables = Oj.load(file.gets, symbol_keys: true)
29
+ @tables = Oj.load(file.gets, :symbol_keys => true)
30
30
  elsif format <= 2
31
31
  # Old format (pre-json), so read the directories segment then rebuild
32
32
  len = file.gets.to_i
@@ -59,7 +59,7 @@ class StarScope::DB
59
59
  files = paths.map {|p| self.class.files_from_path(p)}.flatten
60
60
  return if files.empty?
61
61
  if @progress
62
- pbar = ProgressBar.create(title: "Building", total: files.length, format: PBAR_FORMAT, length: 80)
62
+ pbar = ProgressBar.create(:title => "Building", :total => files.length, :format => PBAR_FORMAT, :length => 80)
63
63
  end
64
64
  files.each do |f|
65
65
  add_file(f)
@@ -70,7 +70,7 @@ class StarScope::DB
70
70
  def update
71
71
  new_files = (@paths.map {|p| self.class.files_from_path(p)}.flatten) - @files.keys
72
72
  if @progress
73
- pbar = ProgressBar.create(title: "Updating", total: new_files.length + @files.length, format: PBAR_FORMAT, length: 80)
73
+ pbar = ProgressBar.create(:title => "Updating", :total => new_files.length + @files.length, :format => PBAR_FORMAT, :length => 80)
74
74
  end
75
75
  changed = @files.keys.map do |f|
76
76
  changed = update_file(f)
@@ -114,7 +114,7 @@ class StarScope::DB
114
114
  if entry[:line_no]
115
115
  tmpdb[entry[:file]] ||= {}
116
116
  tmpdb[entry[:file]][entry[:line_no]] ||= []
117
- tmpdb[entry[:file]][entry[:line_no]] << {tbl: tbl, key: key, entry: entry}
117
+ tmpdb[entry[:file]][entry[:line_no]] << {:tbl => tbl, :key => key, :entry => entry}
118
118
  end
119
119
  end
120
120
  end
data/test/lib/test_db.rb CHANGED
@@ -1,4 +1,4 @@
1
- require_relative '../test_helper'
1
+ require File.expand_path('../../test_helper', __FILE__)
2
2
 
3
3
  describe StarScope::DB do
4
4
 
@@ -1,6 +1,6 @@
1
- require_relative '../test_helper'
1
+ require File.expand_path('../../test_helper', __FILE__)
2
2
 
3
- class TestGolang < MiniTest::Unit::TestCase
3
+ class TestGolang < Minitest::Test
4
4
  def setup
5
5
  @db = {}
6
6
  StarScope::Lang::Go.extract(GOLANG_SAMPLE) do |tbl, key, args|
@@ -1,6 +1,6 @@
1
- require_relative '../test_helper'
1
+ require File.expand_path('../../test_helper', __FILE__)
2
2
 
3
- class TestRuby < MiniTest::Unit::TestCase
3
+ class TestRuby < Minitest::Test
4
4
  def setup
5
5
  @db = {}
6
6
  StarScope::Lang::Ruby.extract(RUBY_SAMPLE) do |tbl, key, args|
@@ -1,4 +1,4 @@
1
- require_relative '../test_helper'
1
+ require File.expand_path('../../test_helper', __FILE__)
2
2
 
3
3
  describe StarScope do
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: starscope
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-23 00:00:00.000000000 Z
12
+ date: 2014-02-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oj
@@ -108,7 +108,7 @@ dependencies:
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  - !ruby/object:Gem::Dependency
111
- name: pry-debugger
111
+ name: minitest
112
112
  requirement: !ruby/object:Gem::Requirement
113
113
  none: false
114
114
  requirements:
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
176
  version: '0'
177
177
  segments:
178
178
  - 0
179
- hash: 3638836367076446031
179
+ hash: 818285020742325812
180
180
  requirements: []
181
181
  rubyforge_project:
182
182
  rubygems_version: 1.8.23