Project

ctags.rb

0.0
No commit activity in last 3 years
No release in over 3 years
ctags.rb exposes exuberant-ctags to Ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

ctags.rb

simple ruby wrapper for universal-ctags and ripper-tags

usage

>> pp Ctags.tags_for_file('/usr/lib/ruby/1.8/timeout.rb')
[
 {:path=> "/usr/lib/ruby/1.8/timeout.rb", :kind=>"module", :language=>"Ruby", :pattern=>"module Timeout", :name=>"Timeout", :line=>30},
 {:path=> "/usr/lib/ruby/1.8/timeout.rb", :kind=>"class", :class=>"Timeout", :language=>"Ruby", :pattern=>"class Error < Interrupt", :name=>"Error", :line=>35},
 {:path=> "/usr/lib/ruby/1.8/timeout.rb", :kind=>"method", :class=>"Timeout", :language=>"Ruby", :pattern=>"def timeout(sec, klass = nil)", :name=>"timeout", :line=>52},
]

architecture

This ctags.rb gem includes the sources of my fork of universal-ctags. The source is compiled into a ctags binary when the gem is installed, and the binary is invoked as an external program by this gem to generate code tags.

The changes in my fork include universal-ctags/ctags#1071, which adds an interactive mode. In this mode, a single long-running instance of ctags can be used to generate tags for various inputs by sending it json commands over a pipe. Code can also be streamed into ctags over stdin, for cases where it is fetched over a network and not readily available on disk. This parent-child setup was chosen for several reasons:

  • the ctags codebase was written as a unix command line utility, which makes it very hard to link directly and use as a library (error handling generally causes an exit(1) and leaves global variables in a dirty state)
  • the language parsers in ctags could contain security vulnerabilities, so running them in a separate process provides for better sandboxing opportunities
  • on some platforms (like win32), process bootup cost is very expensive. using a single long-running ctags invocation eliminates this overhead.

license

ctags.rb is licensed under the MIT license.

universal-ctags is licensed under the GPLv2 license.