ctags.rb 1.0.15 → 1.0.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile +2 -0
- data/Gemfile.lock +25 -0
- data/ctags.rb.gemspec +1 -0
- data/ext/extconf.rb +1 -0
- data/lib/ctags.rb +13 -1
- data/lib/ctags/exuberant.rb +1 -71
- data/lib/ctags/ruby.rb +19 -0
- data/lib/ctags/version.rb +1 -1
- data/test/test_ctags.rb +2 -2
- metadata +17 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MzE3YmY5MGM4ZWFmYWY3OTk3ZTdkODc5OGQ4OGM3YTc1YjE0NzI1Zg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzBiZjNmZjgxZjgxZmY2ZWU4Y2QwZjYzOGI1NzNhOTJhNWEwZTg1OQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YmRmNGQ3Mzk3MmZmNTg3NmE1MDlmY2FhMzQxNzJlYzQ0MTZiZTRmNTJmNmEz
|
10
|
+
YzRiOWIzZmI1MzI5YjUzZmYxY2UwMmMyNjMwN2FiMWYwNWIxMmY1ZTFmZTMz
|
11
|
+
Yzc3NDMwY2FiMTRhZWY4MzNhNWQzNjU2ODFjYWI4NmNhY2ZmOGE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDkyOGZmZWRkOGQ1NjY4NjRjNjg4N2ZhNmNiNGM0OTE4YmUwODU5ZGI1MmRi
|
14
|
+
YTgwMDkyZGYwOTYzZGI0YzhhYWIzMWZjMzNkOGQzNGQ5ZjA5N2Q1OGRkYTU1
|
15
|
+
OGE3NmQzNjZjNjJhMjY1NTczNDNmMDllZTRkMDMzYjFhMGY0N2I=
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ctags.rb (1.0.16)
|
5
|
+
posix-spawn (~> 0.3.6)
|
6
|
+
ripper-tags (~> 0.1.3)
|
7
|
+
yajl-ruby
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
posix-spawn (0.3.8)
|
13
|
+
rake (10.1.1)
|
14
|
+
ripper (1.0.5)
|
15
|
+
ripper-tags (0.1.3)
|
16
|
+
yajl-ruby
|
17
|
+
yajl-ruby (1.2.0)
|
18
|
+
|
19
|
+
PLATFORMS
|
20
|
+
ruby
|
21
|
+
|
22
|
+
DEPENDENCIES
|
23
|
+
ctags.rb!
|
24
|
+
rake
|
25
|
+
ripper
|
data/ctags.rb.gemspec
CHANGED
data/ext/extconf.rb
CHANGED
data/lib/ctags.rb
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
require 'ctags/version'
|
2
2
|
require 'ctags/exuberant'
|
3
|
+
require 'ctags/ruby'
|
3
4
|
|
4
5
|
module Ctags
|
5
|
-
extend
|
6
|
+
extend self
|
7
|
+
|
8
|
+
class Error < StandardError
|
9
|
+
end
|
10
|
+
|
11
|
+
def tags_for_file(file, code=nil)
|
12
|
+
if file =~ /\.rb$/
|
13
|
+
Ruby.tags_for_file(file, code)
|
14
|
+
else
|
15
|
+
Exuberant.tags_for_file(file, code)
|
16
|
+
end
|
17
|
+
end
|
6
18
|
end
|
data/lib/ctags/exuberant.rb
CHANGED
@@ -3,11 +3,9 @@ require 'yajl'
|
|
3
3
|
require 'tempfile'
|
4
4
|
|
5
5
|
module Ctags
|
6
|
-
class Error < StandardError
|
7
|
-
end
|
8
|
-
|
9
6
|
module Exuberant
|
10
7
|
include POSIX::Spawn
|
8
|
+
extend self
|
11
9
|
|
12
10
|
BIN = File.expand_path("../../../ext/dst/bin/ctags", __FILE__)
|
13
11
|
CONFIG = File.expand_path("../../ctags.cnf", __FILE__)
|
@@ -80,78 +78,10 @@ module Ctags
|
|
80
78
|
tags
|
81
79
|
end
|
82
80
|
|
83
|
-
def tags_for_code(filename, code)
|
84
|
-
tags_for_file(filename, code)
|
85
|
-
end
|
86
|
-
|
87
81
|
def tags_for_file(filename, code=nil)
|
88
82
|
cmd = {'command'=>'generate-tags','filename'=>filename}
|
89
83
|
cmd['size'] = code.bytesize if code
|
90
84
|
execute(cmd, code)
|
91
85
|
end
|
92
|
-
|
93
|
-
def tags_for_file_old(filename, code=nil)
|
94
|
-
args = [
|
95
|
-
'--options=NONE',
|
96
|
-
'--fields=+KlnzsStimfa',
|
97
|
-
'--sort=no',
|
98
|
-
'--excmd=pattern',
|
99
|
-
'-o', '-'
|
100
|
-
]
|
101
|
-
|
102
|
-
child =
|
103
|
-
if code
|
104
|
-
# XXX stdin is not seekable
|
105
|
-
# args << "--stdin-filename=#{filename}"
|
106
|
-
# args << {:input => code}
|
107
|
-
|
108
|
-
tempfile = Tempfile.new(['ctags-input', File.extname(filename)])
|
109
|
-
tempfile.write(code)
|
110
|
-
tempfile.close
|
111
|
-
args << tempfile.path
|
112
|
-
|
113
|
-
begin
|
114
|
-
Child.new(BIN, *args)
|
115
|
-
ensure
|
116
|
-
tempfile.unlink
|
117
|
-
end
|
118
|
-
else
|
119
|
-
args << filename
|
120
|
-
Child.new(BIN, *args)
|
121
|
-
end
|
122
|
-
|
123
|
-
if !child.status.success?
|
124
|
-
raise Error, child.err
|
125
|
-
end
|
126
|
-
|
127
|
-
tags = []
|
128
|
-
|
129
|
-
child.out.each_line.map do |line|
|
130
|
-
name, path, rest = line.strip.split("\t", 3)
|
131
|
-
pattern, fields = rest.split("/;\"\t", 2)
|
132
|
-
|
133
|
-
tag = {
|
134
|
-
:name => name,
|
135
|
-
:path => code ? filename : path,
|
136
|
-
:pattern => pattern.sub('/^','').chomp('$').gsub('\\\\','\\')
|
137
|
-
}
|
138
|
-
|
139
|
-
fields.split("\t").each do |field|
|
140
|
-
if field == 'file:'
|
141
|
-
key, value = :scope, 'file'
|
142
|
-
else
|
143
|
-
key, value = field.split(":", 2)
|
144
|
-
end
|
145
|
-
|
146
|
-
tag[key.to_sym] = value
|
147
|
-
end
|
148
|
-
|
149
|
-
tag[:line] = tag[:line].to_i
|
150
|
-
|
151
|
-
tags << tag
|
152
|
-
end
|
153
|
-
|
154
|
-
tags
|
155
|
-
end
|
156
86
|
end
|
157
87
|
end
|
data/lib/ctags/ruby.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'ripper-tags/parser'
|
2
|
+
|
3
|
+
module Ctags
|
4
|
+
module Ruby
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def tags_for_file(file, data=nil)
|
8
|
+
data ||= File.read(file)
|
9
|
+
RipperTags::Parser.extract(data, file)
|
10
|
+
rescue Errno::ENOENT
|
11
|
+
raise Error, $!.message
|
12
|
+
rescue Interrupt
|
13
|
+
raise
|
14
|
+
rescue Object => e
|
15
|
+
STDERR.puts [e, file].inspect
|
16
|
+
[]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/ctags/version.rb
CHANGED
data/test/test_ctags.rb
CHANGED
@@ -13,8 +13,8 @@ class CtagsTest < Test::Unit::TestCase
|
|
13
13
|
assert_equal 'method', tag[:kind]
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
tags = Ctags.
|
16
|
+
def test_tags_for_file_with_code
|
17
|
+
tags = Ctags.tags_for_file('file.rb', File.read(__FILE__))
|
18
18
|
tag = tags.find{ |t| t[:name] == __method__.to_s }
|
19
19
|
|
20
20
|
assert_equal 'file.rb', tag[:path]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ctags.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aman Gupta
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.3.6
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ripper-tags
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.3
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.1.3
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: yajl-ruby
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -47,6 +61,7 @@ extensions:
|
|
47
61
|
extra_rdoc_files: []
|
48
62
|
files:
|
49
63
|
- Gemfile
|
64
|
+
- Gemfile.lock
|
50
65
|
- README.md
|
51
66
|
- Rakefile
|
52
67
|
- bench.rb
|
@@ -485,6 +500,7 @@ files:
|
|
485
500
|
- lib/ctags.cnf
|
486
501
|
- lib/ctags.rb
|
487
502
|
- lib/ctags/exuberant.rb
|
503
|
+
- lib/ctags/ruby.rb
|
488
504
|
- lib/ctags/version.rb
|
489
505
|
- test/test_ctags.rb
|
490
506
|
homepage: http://github.com/tmm1/ctags.rb
|