starscope 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.md CHANGED
@@ -1,10 +1,25 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
- v1.0.1 (trunk)
4
+ v1.0.2 (trunk)
5
5
  --------------------
6
6
 
7
- No changes yet.
7
+ Bug Fixes:
8
+ * Fix an exception when updating the db from line mode.
9
+ * Make sure to mark the db as changed when a source file has been deleted
10
+
11
+ Misc:
12
+ * A few trivial tweaks and optimizations.
13
+ * Store the application version in the db metadata for more fine-grained
14
+ forwards-compatibility.
15
+ * Permit exporting from line mode.
16
+
17
+ v1.0.1 (2014-04-16)
18
+ --------------------
19
+
20
+ Bug Fixes:
21
+ * Stupid forgot-to-change-the-gemspec to actually permit installing on Ruby
22
+ 1.8.7!
8
23
 
9
24
  v1.0.0 (2014-04-16)
10
25
  --------------------
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- starscope (1.0.1)
4
+ starscope (1.0.2)
5
5
  oj (~> 2.7)
6
6
  parser (~> 2.1)
7
7
  ruby-progressbar (~> 1.4)
@@ -14,7 +14,7 @@ GEM
14
14
  method_source (0.8.2)
15
15
  minitest (5.3.3)
16
16
  oj (2.7.3)
17
- parser (2.1.7)
17
+ parser (2.1.8)
18
18
  ast (~> 1.1)
19
19
  slop (~> 3.4, >= 3.4.5)
20
20
  pry (0.9.12.6)
data/bin/starscope CHANGED
@@ -83,7 +83,7 @@ END
83
83
  opts.separator <<END
84
84
  \nEXPORTING
85
85
  At the moment two export formats are supported: 'ctags' and 'cscope'. If
86
- you don't specify a path, the output is written to the files '#{DEFAULT_CTAGS}' (for
86
+ you don't specify a path, the output is written to the file '#{DEFAULT_CTAGS}' (for
87
87
  ctags) or '#{DEFAULT_CSCOPE}' (for cscope) in the current directory.
88
88
  END
89
89
 
@@ -128,6 +128,22 @@ rescue StarScope::DB::NoTableError
128
128
  return false
129
129
  end
130
130
 
131
+ def export(db, param)
132
+ format, path = param.split(',', 2)
133
+ case format
134
+ when 'ctags'
135
+ File.open(path || DEFAULT_CTAGS, 'w') do |file|
136
+ db.export_ctags(file)
137
+ end
138
+ when 'cscope'
139
+ File.open(path || DEFAULT_CSCOPE, 'w') do |file|
140
+ db.export_cscope(file)
141
+ end
142
+ else
143
+ puts "Unrecognized export format"
144
+ end
145
+ end
146
+
131
147
  db = StarScope::DB.new(options[:show_progress], options[:verbose])
132
148
 
133
149
  db_exists = File.exists?(options[:db])
@@ -160,21 +176,7 @@ new_data ||= updated
160
176
 
161
177
  db.save(options[:db]) if options[:write] and (new_data or not db_exists)
162
178
 
163
- if options[:export]
164
- format, path = options[:export].split(',', 2)
165
- case format
166
- when 'ctags'
167
- File.open(path || DEFAULT_CTAGS, 'w') do |file|
168
- db.export_ctags(file)
169
- end
170
- when 'cscope'
171
- File.open(path || DEFAULT_CSCOPE, 'w') do |file|
172
- db.export_cscope(file)
173
- end
174
- else
175
- puts "Unrecognized export format"
176
- end
177
- end
179
+ export(db, options[:export]) if options[:export]
178
180
 
179
181
  if options[:query]
180
182
  table, query = options[:query].split(',', 2)
@@ -196,6 +198,7 @@ def linemode_help
196
198
  Input can be a query of the form 'TABLE QUERY' or a special command starting
197
199
  with a '!'. Recognized special commands are:
198
200
  !dump [TABLE]
201
+ !export FORMAT[,PATH]
199
202
  !summary
200
203
  !update
201
204
 
@@ -214,11 +217,17 @@ if options[:linemode]
214
217
  case cmd[1..-1]
215
218
  when "dump"
216
219
  dump(db, param)
220
+ when "export"
221
+ if param
222
+ export(db, param)
223
+ else
224
+ puts "!export requires an argument"
225
+ end
217
226
  when "summary"
218
227
  print_summary(db)
219
228
  when "update"
220
229
  changed = db.update
221
- db.save(options[:write]) if options[:write] and changed
230
+ db.save(options[:db]) if options[:write] and changed
222
231
  when "help"
223
232
  puts linemode_help
224
233
  when "version"
data/lib/starscope/db.rb CHANGED
@@ -8,13 +8,11 @@ require 'starscope/record'
8
8
 
9
9
  require 'starscope/langs/coffeescript'
10
10
  require 'starscope/langs/go'
11
- require 'starscope/langs/lua'
12
11
  require 'starscope/langs/ruby'
13
12
 
14
13
  LANGS = [
15
14
  StarScope::Lang::CoffeeScript,
16
15
  StarScope::Lang::Go,
17
- StarScope::Lang::Lua,
18
16
  StarScope::Lang::Ruby
19
17
  ]
20
18
 
@@ -27,7 +25,8 @@ class StarScope::DB
27
25
 
28
26
  def initialize(progress, verbose)
29
27
  @output = StarScope::Output.new(progress, verbose)
30
- @meta = {:paths => [], :files => {}, :excludes => []}
28
+ @meta = {:paths => [], :files => {}, :excludes => [],
29
+ :version => StarScope::VERSION}
31
30
  @tables = {}
32
31
  end
33
32
 
@@ -59,6 +58,10 @@ class StarScope::DB
59
58
 
60
59
  def save(file)
61
60
  @output.log("Writing database to `#{file}`...")
61
+
62
+ # regardless of what the old version was, the new version is written by us
63
+ @meta[:version] = StarScope::VERSION
64
+
62
65
  File.open(file, 'w') do |file|
63
66
  Zlib::GzipWriter.wrap(file) do |file|
64
67
  file.puts DB_FORMAT
@@ -105,7 +108,7 @@ class StarScope::DB
105
108
  @output.log("Updating `#{name}`")
106
109
  ret = update_file(name)
107
110
  @output.inc_pbar
108
- changed = true if ret == :update
111
+ changed = true if ret
109
112
  ret == :delete
110
113
  end
111
114
  add_new_files(new_files)
@@ -127,7 +130,12 @@ class StarScope::DB
127
130
  if key == :meta
128
131
  puts "== Metadata Summary =="
129
132
  @meta.each do |k, v|
130
- puts "#{k}: #{v.count}"
133
+ print "#{k}: "
134
+ if [Array, Hash].include? v.class
135
+ puts v.count
136
+ else
137
+ puts v
138
+ end
131
139
  end
132
140
  return
133
141
  end
@@ -135,8 +143,10 @@ class StarScope::DB
135
143
  puts "== Metadata: #{key} =="
136
144
  if @meta[key].is_a? Array
137
145
  @meta[key].sort.each {|x| puts x}
138
- else
146
+ elsif @meta[key].is_a? Hash
139
147
  @meta[key].sort.each {|k,v| puts "#{k}: #{v}"}
148
+ else
149
+ puts @meta[key]
140
150
  end
141
151
  end
142
152
 
@@ -218,7 +228,7 @@ END
218
228
  buf << "\t@\n"
219
229
 
220
230
  header = "cscope 15 #{Dir.pwd} -c "
221
- offset = "%010d\n" % (header.length + 11 + buf.bytes.to_a.length)
231
+ offset = "%010d\n" % (header.length + 11 + buf.bytes.count)
222
232
 
223
233
  file.print(header)
224
234
  file.print(offset)
@@ -1,3 +1,3 @@
1
1
  module StarScope
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
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: 1.0.1
4
+ version: 1.0.2
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-04-16 00:00:00.000000000 Z
12
+ date: 2014-04-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oj
@@ -143,7 +143,6 @@ files:
143
143
  - lib/starscope/db.rb
144
144
  - lib/starscope/langs/coffeescript.rb
145
145
  - lib/starscope/langs/go.rb
146
- - lib/starscope/langs/lua.rb
147
146
  - lib/starscope/langs/ruby.rb
148
147
  - lib/starscope/matcher.rb
149
148
  - lib/starscope/output.rb
@@ -182,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
181
  version: '0'
183
182
  segments:
184
183
  - 0
185
- hash: 297600048847537323
184
+ hash: 2115433325249412524
186
185
  requirements: []
187
186
  rubyforge_project:
188
187
  rubygems_version: 1.8.23
@@ -1,12 +0,0 @@
1
- module StarScope::Lang
2
- module Lua
3
-
4
- def self.match_file(name)
5
- name.end_with?(".lua")
6
- end
7
-
8
- def self.extract(file)
9
- # TODO
10
- end
11
- end
12
- end