lib/simplecov-markdown.rb in simplecov-markdown-0.1.1 vs lib/simplecov-markdown.rb in simplecov-markdown-0.1.2

- old
+ new

@@ -2,10 +2,11 @@ class SimpleCov::Formatter::MarkdownFormatter def format(result) report_writer = ReportWriter.new(SimpleCov::Formatter::MarkdownFormatter.output_path) report_writer.write_header "Code Coverage Report" + report_writer.write_description(result) report_writer.write_result(result) report_writer.destroy! end def self.output_path File.join(SimpleCov.coverage_path, 'report.md') @@ -19,17 +20,30 @@ @table_writer = TableWriter.new(report) end def write_header(title) @report.puts title - @report.puts "=" * 20 + "\n\n" + @report.puts "=" * 20 + @report.puts "\n" end + def write_description(result) + @report.puts "Project name: " + SimpleCov.project_name + @report.puts "Created at: " + result.created_at.to_s + @report.puts "\n" + end + def write_result(result) @table_writer.write_header result.files.each do |file| - @table_writer.write_record(file.filename, file.covered_percent.to_s + "%") + @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 def destroy! @@ -41,11 +55,11 @@ class TableWriter attr_reader :report, :columns_headers, :columns_header_aligns def initialize(report) @report = report - @columns_headers = ["File", "Coverage"] - @columns_header_aligns = [:left, :right] + @columns_headers = ["File", "Coverage", "Covered", "Missed", "Total"] + @columns_header_aligns = [:left, :right, :right, :right, :right] end def write_header write_values @columns_headers headers = @columns_header_aligns.map do |align|