class Gcovinator::IndexReport

Public Class Methods

new(output_dir, file_reports) click to toggle source
# File lib/gcovinator/index_report.rb, line 4
def initialize(output_dir, file_reports)
  @total_lines = 0
  @covered_lines = 0
  @total_branches = 0
  @covered_branches = 0
  run(File.join(output_dir, "index.html"), file_reports)
end

Private Instance Methods

analyze(file_reports) click to toggle source
# File lib/gcovinator/index_report.rb, line 26
def analyze(file_reports)
  file_reports.each do |file_report|
    @total_lines += file_report.total_lines
    @covered_lines += file_report.covered_lines
    @total_branches += file_report.total_branches
    @covered_branches += file_report.covered_branches
  end
end
run(output_file_name, file_reports) click to toggle source
# File lib/gcovinator/index_report.rb, line 14
def run(output_file_name, file_reports)
  analyze(file_reports)
  require "cgi"
  require "erb"
  index_report_template = File.read(File.join(File.dirname(__FILE__), "../../assets/index_report.html.erb"))
  erb = ERB.new(index_report_template, nil, "<>")
  report = erb.result(binding.clone)
  File.open(output_file_name, "w") do |fh|
    fh.write(report)
  end
end