Class: Gemtags::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/gemtags.rb

Instance Method Summary collapse

Instance Method Details

#runObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/gemtags.rb', line 5

def run
  bundler_paths = []
  if File.exist?('Gemfile.lock')
    lockfile_contents = Bundler.read_file('Gemfile.lock')
    lockfile = Bundler::LockfileParser.new(lockfile_contents)
    bundler_paths = lockfile.specs.map do |spec|
      spec.__materialize__
      spec.full_gem_path
    end
  end

  tags_file    = ".gemtags"
  opts         = "--extra=+f -R -f #{tags_file}"
  exclude_dirs = "--exclude=#{File.expand_path('.')}/* --exclude=*.min.js --exclude=.git --exclude=log --exclude=.svn"
  ctag_paths   = "#{bundler_paths.map {|x| x + '/*'}.join(' ')}"
  command      = "ctags #{opts} #{exclude_dirs} #{ctag_paths} 2> /dev/null"

  puts "Processing ctags..."
  system command
  puts "Wrote ctags to '#{tags_file}'"
end