class SimpleCov::Formatter::MarkdownFormatter::ReportWriter

Attributes

report[R]

Public Class Methods

new(report_path) click to toggle source
# File lib/simplecov-markdown.rb, line 18
def initialize(report_path)
  @report = File.open(report_path, 'w')
  @table_writer = TableWriter.new(report)
end

Public Instance Methods

destroy!() click to toggle source
# File lib/simplecov-markdown.rb, line 49
def destroy!
  @report.close
  @report = nil
end
write_description(result) click to toggle source
# File lib/simplecov-markdown.rb, line 29
def write_description(result)
  @report.puts "Project name: " + SimpleCov.project_name
  @report.puts "Created at: " + result.created_at.to_s
  @report.puts "\n"
end
write_header(title) click to toggle source
# File lib/simplecov-markdown.rb, line 23
def write_header(title)
  @report.puts title
  @report.puts "=" * 20
  @report.puts "\n"
end
write_result(result) click to toggle source
# File lib/simplecov-markdown.rb, line 35
def write_result(result)
  @table_writer.write_header
  result.files.each do |file|
    @table_writer.write_record(
      file.filename,
      file.covered_percent.round(2).to_s + "%",
      file.covered_lines.size,
      file.missed_lines.size,
      file.lines_of_code
    )
  end
  @table_writer.destroy!
end