ripper-tags 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/bin/ripper-tags CHANGED
@@ -14,6 +14,12 @@ if ARGV.delete('--vim')
14
14
  vim = true
15
15
  all_tags = []
16
16
  end
17
+ if ARGV.delete('--emacs')
18
+ emacs = true
19
+ end
20
+ if ARGV.delete('--debug-full')
21
+ debug_full = true
22
+ end
17
23
 
18
24
  ARGV.each do |file|
19
25
  begin
@@ -21,14 +27,29 @@ ARGV.each do |file|
21
27
  sexp = TagRipper.new(data, file).parse
22
28
  v = TagRipper::Visitor.new(sexp, file, data)
23
29
 
24
- if debug
30
+ if debug_full
31
+ pp Ripper.sexp(data)
32
+
33
+ elsif debug
25
34
  pp sexp
35
+
26
36
  elsif json
27
37
  v.tags.each do |tag|
28
38
  puts Yajl.dump(tag)
29
39
  end
40
+
41
+ elsif emacs
42
+ section = []
43
+ v.tags.each do |tag|
44
+ section << "#{tag[:pattern]}\x7F#{tag[:name]}\x01#{tag[:line]},0"
45
+ end
46
+ section = section.join("\n")
47
+
48
+ print "\x0C\n#{file},#{section.bytesize}\n#{section}\n"
49
+
30
50
  elsif vim
31
51
  all_tags += v.tags
52
+
32
53
  else
33
54
  v.tags.each do |tag|
34
55
  kind = case tag[:kind]
@@ -36,6 +57,7 @@ ARGV.each do |file|
36
57
  when /^const/ then 'const'
37
58
  else tag[:kind]
38
59
  end
60
+
39
61
  if kind == 'class' && tag[:inherits]
40
62
  suffix = " < #{tag[:inherits]}"
41
63
  else
data/lib/tag_ripper.rb CHANGED
@@ -55,6 +55,7 @@ class TagRipper < Ripper
55
55
  a.flatten!(1)
56
56
  [[a && a[0], b[0]].join('::'), b[1]]
57
57
  end
58
+ alias on_const_path_field on_const_path_ref
58
59
 
59
60
  def on_binary(*args)
60
61
  end
@@ -96,7 +97,10 @@ class TagRipper < Ripper
96
97
  def on_method_add_block(method, body)
97
98
  return unless method and body
98
99
  if method[2] == 'class_eval'
99
- [:class_eval, [method[1], method[3]], body.last]
100
+ [:class_eval, [
101
+ method[1].is_a?(Array) ? method[1][0] : method[1],
102
+ method[3]
103
+ ], body.last]
100
104
  end
101
105
  end
102
106
 
data/ripper-tags.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'ripper-tags'
3
- s.version = '0.1.0'
3
+ s.version = '0.1.1'
4
4
 
5
5
  s.summary = 'ctags generator for ruby code'
6
6
  s.description = 'fast, accurate ctags generator for ruby source code using Ripper'
@@ -34,6 +34,11 @@ class TagRipperTest < Test::Unit::TestCase
34
34
  def self.cmethod4
35
35
  end
36
36
  end
37
+ M::C::Const3 = true
38
+ M.class_eval do
39
+ def imethod5
40
+ end
41
+ end
37
42
  EOC
38
43
 
39
44
  assert_equal %w[
@@ -52,6 +57,8 @@ class TagRipperTest < Test::Unit::TestCase
52
57
  M::C.cmethod_alias
53
58
  M::C#imethod3
54
59
  M::C.cmethod4
60
+ M::C::Const3
61
+ M#imethod5
55
62
  ], tags.map{ |t| t[:full_name] }
56
63
  end
57
64
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ripper-tags
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Aman Gupta
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-01-01 00:00:00 Z
18
+ date: 2013-01-03 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: yajl-ruby