Class: TaskJuggler::TagFile

Inherits:
ReportBase show all
Defined in:
lib/taskjuggler/reports/TagFile.rb

Overview

This class specializes ReportBase to generate tag files used by editors such as vim.

Defined Under Namespace

Classes: TagFileEntry

Instance Method Summary collapse

Methods inherited from ReportBase

#a, #filterAccountList, #filterResourceList, #filterTaskList

Constructor Details

#initialize(report) ⇒ TagFile

Returns a new instance of TagFile.



54
55
56
# File 'lib/taskjuggler/reports/TagFile.rb', line 54

def initialize(report)
  super
end

Instance Method Details

#generateIntermediateFormatObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/taskjuggler/reports/TagFile.rb', line 58

def generateIntermediateFormat
  super

  @tags = []

  # Add the resources.
  @resourceList = PropertyList.new(@project.resources)
  @resourceList.setSorting(a('sortResources'))
  @resourceList = filterResourceList(@resourceList, nil, a('hideResource'),
                                     a('rollupResource'), a('openNodes'))
  @resourceList.each do |resource|
    next unless resource.sourceFileInfo
    @tags << TagFileEntry.new(resource.fullId,
                              resource.sourceFileInfo.fileName,
                              resource.sourceFileInfo.lineNo, 'r')
  end

  # Add the tasks.
  @taskList = PropertyList.new(@project.tasks)
  @taskList.setSorting(a('sortTasks'))
  @taskList = filterTaskList(@taskList, nil, a('hideTask'), a('rollupTask'),
                             a('openNodes'))
  @taskList.each do |task|
    next unless task.sourceFileInfo
    @tags << TagFileEntry.new(task.fullId,
                              task.sourceFileInfo.fileName,
                              task.sourceFileInfo.lineNo, 't')
  end

  # Add the reports.
  @project.reports.each do |report|
    next unless report.sourceFileInfo
    @tags << TagFileEntry.new(report.fullId,
                              report.sourceFileInfo.fileName,
                              report.sourceFileInfo.lineNo, 'p')
  end
end

#to_ctagsObject

Returns a String that contains the content of the ctags file. See vimdoc.sourceforge.net/htmldoc/tagsrch.html for the spec.



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/taskjuggler/reports/TagFile.rb', line 98

def to_ctags
  # The ctags header. Not used if this is really needed.
  s = <<"EOT"
!_TAG_FILE_FORMAT	2	/extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED	1	/0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR	#{AppConfig.authors.join(';')}	//
!_TAG_PROGRAM_NAME	#{AppConfig.softwareName}	//
!_TAG_PROGRAM_URL	#{AppConfig.contact}	/official site/
!_TAG_PROGRAM_VERSION	#{AppConfig.version}	//
EOT

  # Turn the list of Tags into ctags lines.
  @tags.sort.each do |tag|
    s << tag.to_ctags
  end

  s
end