class Covered::PartialSummary

Public Instance Methods

call(wrapper, output = $stdout, before: 4, after: 4) click to toggle source
# File lib/covered/summary.rb, line 162
def call(wrapper, output = $stdout, before: 4, after: 4)
        terminal = self.terminal(output)
        
        statistics = self.each(wrapper) do |coverage|
                line_offset = 1
                
                path = wrapper.relative_path(coverage.path)
                terminal.puts ""
                terminal.puts path, style: :path
                
                counts = coverage.counts
                last_line = nil
                
                unless coverage.zero?
                        print_line_header(terminal)
                        
                        coverage.read do |file|
                                file.each_line do |line|
                                        range = Range.new([line_offset - before, 0].max, line_offset+after)
                                        
                                        if counts[range]&.include?(0)
                                                count = counts[line_offset]
                                                
                                                if last_line and last_line != line_offset-1
                                                        terminal.puts ":".rjust(16)
                                                end
                                                
                                                print_annotations(terminal, coverage, line, line_offset)
                                                print_line(terminal, line, line_offset, count)
                                                
                                                last_line = line_offset
                                        end
                                        
                                        line_offset += 1
                                end
                        end
                end
                
                coverage.print(output)
        end
        
        terminal.puts
        statistics.print(output)
end