class FeduxOrgStdlib::Project::Report

Taskjugger report

Attributes

directory[R]
file[R]
generator[R]
output_directory[R]
output_file[R]
plan[R]

Public Class Methods

new( plan:, output_file:, generator: FeduxOrgStdlib::Project::Generators::Taskjuggler.new ) click to toggle source

Create a new report

@param [Plan] plan

Project plan to be used for report

@param [String] output_file

The main output file for the report

@param [Generator] generator

A generator to be used to be generator the report
# File lib/fedux_org_stdlib/project/report.rb, line 30
def initialize(
  plan:,
  output_file:,
  generator: FeduxOrgStdlib::Project::Generators::Taskjuggler.new
)
  @plan             = plan
  @output_directory = File.dirname(output_file)
  @output_file      = output_file
  @generator        = generator
end

Public Instance Methods

generate() click to toggle source

Generate report

# File lib/fedux_org_stdlib/project/report.rb, line 42
def generate
  prepare_environment

  if output_file_does_not_exist? || plan_is_newer_than_output_file?
    generator.generate_report(output_directory, plan)
  else
    FeduxOrgStdlib::Project.logger.warn "No need to re-generate report. The plan file \"#{plan}\" is NOT newer than output \"#{@output_file}\"."
  end
end
open() click to toggle source

Open report in web browser

# File lib/fedux_org_stdlib/project/report.rb, line 53
def open
  Launchy.open(output_file)
end

Private Instance Methods

output_file_does_not_exist?() click to toggle source
# File lib/fedux_org_stdlib/project/report.rb, line 63
def output_file_does_not_exist?
  !File.exist? output_file
end
plan_is_newer_than_output_file?() click to toggle source
# File lib/fedux_org_stdlib/project/report.rb, line 67
def plan_is_newer_than_output_file?
  plan.needs_to_be_compiled? output_file
end
prepare_environment() click to toggle source
# File lib/fedux_org_stdlib/project/report.rb, line 59
def prepare_environment
  FileUtils.mkdir_p output_directory
end