class Covered::PartialSummary
def call(wrapper, output = $stdout, before: 4, after: 4)
def call(wrapper, output = $stdout, before: 4, after: 4) statistics = self.each(wrapper) do |coverage| line_offset = 1 path = wrapper.relative_path(coverage.path) output.puts "", Rainbow(path).bold.underline counts = coverage.counts last_line = nil unless coverage.zero? 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 output.puts ":".rjust(16) end print_annotations(output, coverage, line, line_offset) prefix = "#{line_offset}|".rjust(8) + "#{count}|".rjust(8) if count == nil output.write prefix output.write Rainbow(line).faint elsif count == 0 output.write Rainbow(prefix).background(:darkred) output.write Rainbow(line).red else output.write Rainbow(prefix).background(:darkgreen) output.write Rainbow(line).green end # If there was no newline at end of file, we add one: unless line.end_with? $/ output.puts end last_line = line_offset end line_offset += 1 end end end coverage.print(output) end output.puts statistics.print(output) end