class Covered::MarkdownSummary

Public Class Methods

new(threshold: 1.0) click to toggle source
# File lib/covered/markdown_summary.rb, line 28
def initialize(threshold: 1.0)
        @threshold = threshold
end

Public Instance Methods

call(wrapper, output = $stdout) click to toggle source

A coverage array gives, for each line, the number of line execution by the interpreter. A nil value means coverage is disabled for this line (lines like else and end).

# File lib/covered/markdown_summary.rb, line 73
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
each(wrapper) { |coverage| ... } click to toggle source
# File lib/covered/markdown_summary.rb, line 32
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
print_annotations(output, coverage, line, line_offset) click to toggle source
print_line(output, line, line_offset, count) click to toggle source
print_line_header(output) click to toggle source