class Covered::MarkdownSummary
def call(wrapper, output = $stdout)
def call(wrapper, output = $stdout) output.puts '# Coverage Report' output.puts ordered = [] buffer = StringIO.new statistics = self.each(wrapper) do |coverage| ordered << coverage unless coverage.complete? end statistics.print(output) if ordered.any? output.puts "", "\#\# Least Coverage:", "" ordered.sort_by!(&:missing_count).reverse! ordered.first(5).each do |coverage| path = wrapper.relative_path(coverage.path) output.puts "- `#{path}`: #{coverage.missing_count} lines not executed!" end end output.print(buffer.string) end
def each(wrapper)
def each(wrapper) statistics = Statistics.new wrapper.each do |coverage| statistics << coverage if @threshold.nil? or coverage.ratio < @threshold yield coverage end end return statistics end
def initialize(threshold: 1.0)
def initialize(threshold: 1.0) @threshold = threshold end
def print_annotations(output, coverage, line, line_offset)
def print_annotations(output, coverage, line, line_offset) if annotations = coverage.annotations[line_offset] prefix = "#{line_offset}|".rjust(8) + "*|".rjust(8) output.write prefix output.write line.match(/^\s+/) output.puts "\# #{annotations.join(", ")}" end end
def print_line(output, line, line_offset, count)
def print_line(output, line, line_offset, count) prefix = "#{line_offset}|".rjust(8) + "#{count}|".rjust(8) output.write prefix output.write line # If there was no newline at end of file, we add one: unless line.end_with?($/) output.puts end end
def print_line_header(output)
def print_line_header(output) output.puts "Line|".rjust(8) + "Hits|".rjust(8) end