Class: FeduxOrgStdlib::Project::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/fedux_org_stdlib/project/report.rb

Overview

Taskjugger report

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(plan:, output_file:, generator: FeduxOrgStdlib::Project::Generators::Taskjuggler.new) ⇒ Report

Create a new report

Parameters:

  • plan (Plan)

    Project plan to be used for report

  • output_file (String)

    The main output file for the report

  • generator (Generator) (defaults to: FeduxOrgStdlib::Project::Generators::Taskjuggler.new)

    A generator to be used to be generator the report



30
31
32
33
34
35
36
37
38
39
# 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

Instance Attribute Details

#directoryObject (readonly)

Returns the value of attribute directory.



14
15
16
# File 'lib/fedux_org_stdlib/project/report.rb', line 14

def directory
  @directory
end

#fileObject (readonly)

Returns the value of attribute file.



14
15
16
# File 'lib/fedux_org_stdlib/project/report.rb', line 14

def file
  @file
end

Instance Method Details

#generateObject

Generate report



42
43
44
45
46
47
48
49
50
# 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

#openObject

Open report in web browser



53
54
55
# File 'lib/fedux_org_stdlib/project/report.rb', line 53

def open
  Launchy.open(output_file)
end