lib/TaskJuggler.rb in taskjuggler-0.0.7 vs lib/TaskJuggler.rb in taskjuggler-0.0.8
- old
+ new
@@ -12,10 +12,12 @@
require 'drb'
require 'Project'
require 'MessageHandler'
require 'Log'
+# Only needed during profiling.
+#require 'ruby-prof'
# The TaskJuggler class models the object that provides access to the
# fundamental features of the TaskJuggler software. It can read project
# files, schedule them and generate the reports.
class TaskJuggler
@@ -39,10 +41,11 @@
def parse(files, keepParser = false)
Log.enter('parser', 'Parsing files ...')
master = true
@project = nil
+ #RubyProf.start
@parser = ProjectFileParser.new(@messageHandler)
files.each do |file|
begin
@parser.open(file, master)
rescue TjException => msg
@@ -52,27 +55,37 @@
Log.exit('parser')
return false
end
if master
# The first file is considered the master file.
- if (@project = @parser.parse('project')) == false
+ if (@project = @parser.parse(:project)) == false
Log.exit('parser')
return false
end
master = false
else
# All other files.
@parser.setGlobalMacros
- if @parser.parse('properties') == false
+ if @parser.parse(:propertiesFile) == false
Log.exit('parser')
return false
end
end
@project.inputFiles << file
@parser.close
end
+ #profile = RubyProf.stop
+ #printer = RubyProf::GraphHtmlPrinter.new(profile)
+ #File.open("profile.html", "w") do |file|
+ # printer.print(file)
+ #end
+ #printer = RubyProf::CallTreePrinter.new(profile)
+ #File.open("profile.clt", "w") do |file|
+ # printer.print(file)
+ #end
+
# For the report server mode we may need to keep the parser. Otherwise,
# destroy it.
@parser = nil unless keepParser
Log.exit('parser')
@@ -121,16 +134,27 @@
# Generate all specified reports. The project must have be scheduled before
# this method can be called. It returns true if no error occured, false
# otherwise.
def generateReports(outputDir = './')
+ @project.checkReports
outputDir += '/' unless outputDir.empty? || outputDir[-1] == '/'
@project.outputDir = outputDir
Log.enter('reports', 'Generating reports ...')
begin
+ #RubyProf.start
@project.generateReports(@maxCpuCores)
+ #profile = RubyProf.stop
+ #printer = RubyProf::GraphHtmlPrinter.new(profile)
+ #File.open("profile.html", "w") do |file|
+ # printer.print(file)
+ #end
+ #printer = RubyProf::CallTreePrinter.new(profile)
+ #File.open("profile.clt", "w") do |file|
+ # printer.print(file)
+ #end
rescue TjException => msg
if msg.message && !msg.message.empty?
@messageHandler.critical('generate_reports', msg.message)
end
return false
@@ -184,11 +208,11 @@
begin
Log.enter('checkTimeSheet', 'Parsing #{fileName} ...')
# Make sure we don't use data from old time sheets or Journal entries.
@project.timeSheets.clear
@project['journal'] = Journal.new
- return false unless (ts = parseFile(fileName, 'timeSheetFile'))
+ return false unless (ts = parseFile(fileName, :timeSheetFile))
return false unless @project.checkTimeSheets
queryAttrs = { 'project' => @project,
'property' => ts.resource,
'scopeProperty' => nil,
'scenarioIdx' => @project['trackingScenarioIdx'],
@@ -213,10 +237,10 @@
# sheet. If the sheet is syntaxtically correct and matches the loaded
# project, true is returned. Otherwise false.
def checkStatusSheet(fileName)
begin
Log.enter('checkStatusSheet', 'Parsing #{fileName} ...')
- return false unless (ss = parseFile(fileName, 'statusSheetFile'))
+ return false unless (ss = parseFile(fileName, :statusSheetFile))
queryAttrs = { 'project' => @project,
'property' => ss[0],
'scopeProperty' => nil,
'scenarioIdx' => @project['trackingScenarioIdx'],
'timeFormat' => '%Y-%m-%d',