Class: Covered::PartialSummary

Inherits:
Summary
  • Object
show all
Defined in:
lib/covered/summary.rb

Instance Method Summary collapse

Methods inherited from Summary

#each, #initialize, #print_annotations, #print_line, #print_line_header, #terminal

Constructor Details

This class inherits a constructor from Covered::Summary

Instance Method Details

#call(wrapper, output = $stdout, before: 4, after: 4) ⇒ Object



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# 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