Permalink
Browse files

initial version

  • Loading branch information...
ivalkeen committed Oct 2, 2011
1 parent a2b271c commit bbe4e31e38b35e750ae3b471486a2ef3630947ac
Showing with 132 additions and 0 deletions.
  1. +4 −0 Gemfile
  2. +9 −0 LICENSE
  3. +37 −0 README.md
  4. +1 −0 Rakefile
  5. +26 −0 guard-ctags-bundler.gemspec
  6. +43 −0 lib/guard/ctags-bundler.rb
  7. +5 −0 lib/guard/ctags-bundler/templates/Guardfile
  8. +7 −0 lib/guard/ctags-bundler/version.rb
View
@@ -0,0 +1,4 @@
+source "http://rubygems.org"
+
+# Specify your gem's dependencies in guard-ctags-bundler.gemspec
+gemspec
View
@@ -0,0 +1,9 @@
+The MIT License (MIT)
+
+Copyright (c) 2011 Ivan Tkalin
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -0,0 +1,37 @@
+Guard-CTags-Bundler
+=====
+
+Guard-CTags-Bundler generates [ctags](http://ctags.sourceforge.net) for your project and for gems in your bundle. For project tags file `tags` is generated, for gems tags file `gems.tags` is generated.
+
+When you run `bundle install` in your project, `gems.tags` file is automatically is generated or updated. When you save one of you project files, `tags` file is automatically generated or updated.
+
+## Install
+
+Make sure you have [Guard](http://github.com/guard/guard) installed.
+
+Install the gem:
+
+ $ gem install guard-ctags-bundler
+
+Add it to your `Gemfile` (inside development group):
+
+ gem 'guard-ctags-bundler'
+
+And then add a basic setup to your `Guardfile`:
+
+ $ guard init ctags-bundler
+
+
+## CTags
+
+[Ctags](http://ctags.sourceforge.net) generates an index (or tag) file of language objects found in source files that allows these items to be quickly and easily located by a text editor or other utility. A tag signifies a language object for which an index entry is available (or, alternatively, the index entry created for that object).
+
+In ubuntu you can install ctags by running
+
+ $ sudo apt-get install exuberant-ctags
+
+## Vim
+
+Vim supports ctags by default. All you need to do is add your `gems.tags` file to the Vim's tag stack.
+
+ set tags+=gems.tags
View
@@ -0,0 +1 @@
+require "bundler/gem_tasks"
@@ -0,0 +1,26 @@
+# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+require "guard/ctags-bundler/version"
+
+Gem::Specification.new do |s|
+ s.name = "guard-ctags-bundler"
+ s.version = Guard::Ctags::Bundler::VERSION
+ s.authors = ["Ivan Tkalin"]
+ s.email = ["itkalin@gmail.com"]
+ s.homepage = "https://github.com/ivalkeen/guard-ctags-bundler"
+ s.summary = %q{Guard gem for generating ctags for project files and gems from project's bundle.}
+ s.description = %q{Guard::CtagsBundler uses ctags utility and generates 2 files: tags -- with tags generated from project's source tree and gems.tags -- with tags generated from rubygems from project's bundle.}
+
+ s.rubyforge_project = "guard-ctags-bundler"
+
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
+
+ # specify any dependencies here; for example:
+ s.add_dependency 'guard', '>= 0.4.0'
+
+ # s.add_development_dependency "rspec"
+ # s.add_runtime_dependency "rest-client"
+end
View
@@ -0,0 +1,43 @@
+require "guard/ctags-bundler/version"
+require 'guard'
+require 'guard/guard'
+require 'rubygems'
+
+module Guard
+ class CtagsBundler < Guard
+ BUNDLER = "__bundler__"
+
+ def initialize(watchers = [], options = {})
+ super(watchers, options)
+ end
+
+ def start
+ UI.info 'Guard::CtagsBundler is running!'
+ end
+
+ def run_on_change(paths)
+ if paths == [BUNDLER]
+ UI.info "regenerating bundler tags..."
+ generate_bundler_tags
+ else
+ UI.info "regenerating project tags..."
+ generate_project_tags(paths)
+ end
+ end
+
+ private
+
+ def generate_project_tags(paths)
+ Thread.new do
+ system("find #{paths.join(' ')} -type f -name \\*.rb | ctags -f tags -L -")
+ end
+ end
+
+ def generate_bundler_tags
+ Thread.new do
+ paths = `ruby -e "require('bundler'); puts(Bundler.load.specs.map(&:full_gem_path).join(' '))"`
+ system("find #{paths.strip} -type f -name \\*.rb | ctags -f gems.tags -L -")
+ end
+ end
+ end
+end
@@ -0,0 +1,5 @@
+guard 'ctags-bundler' do
+ watch(/^(app|lib|spec\/support)\/.*\.rb$/) { ["app", "lib", "spec/support"] }
+ watch(/^Gemfile.lock$/) { ::Guard::CtagsBundler::BUNDLER }
+end
+
@@ -0,0 +1,7 @@
+module Guard
+ module Ctags
+ module Bundler
+ VERSION = "0.0.1"
+ end
+ end
+end

0 comments on commit bbe4e31

Please sign in to comment.