Skip to content

Instantly share code, notes, and snippets.

@x0bandeira
Last active March 18, 2016 21:29
Show Gist options
  • Save x0bandeira/29f685201ded6472b0e6 to your computer and use it in GitHub Desktop.
Save x0bandeira/29f685201ded6472b0e6 to your computer and use it in GitHub Desktop.
`ctags` doesn't seem to play well with namespaced ruby class names out of the box. Even trying with `--extra=q`. `ripper-tags` seems to fix it.
#!/usr/bin/env ruby
`/usr/bin/env ctags -R #{ENV["PWD"]}/app`
tags_file = "#{ENV["PWD"]}/tags"
tags = File.read(tags_file)
fixed_tags = tags.split(/\n/).map do |line|
is_rb = line =~ /\.rb/
if is_rb
name = line.gsub(/^.+(?:class|module) ([a-zA-Z0-9:]+).+$/, '\1')
map = line.gsub(/^([a-zA-Z0-9:]+)\t.+$/, '\1')
if name == "" || map != name
line.gsub(/^#{map}/, name)
else
line
end
else
line
end
end.join("\n")
File.open(tags_file, "w") {|f| f.write(fixed_tags) }
#!/usr/bin/env bash
# gem install -u ripper-tags
ripper-tags -R --extra=q --exclude=vendor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment