Method: Textbringer::Commands#get_tags

Defined in:
lib/textbringer/commands/ctags.rb

#get_tagsObject



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/textbringer/commands/ctags.rb', line 73

def get_tags
  path = File.expand_path("tags")
  mtime = File.mtime(path)
  if CTAGS[:path] != path || CTAGS[:tags_mtime] != mtime
    CTAGS[:path] = path
    tags = Hash.new { |h, k| h[k] = [] }
    File.read(path).scan(/^(.*?)\t(.*?)\t(.*?)(?:;".*)?$/) do
      |name, file, addr|
      n = tags[name].count { |f,| f == file } + 1
      tags[name].push([file, addr, n])
    end
    CTAGS[:tags] = tags
    CTAGS[:tags_mtime] = mtime
    message("Loaded #{path}")
  end
  CTAGS[:tags]
end