Class: Test::Unit::Coverage::DefaultPrinter
- Inherits:
-
Object
- Object
- Test::Unit::Coverage::DefaultPrinter
- Defined in:
- lib/test/unit/coverage.rb
Instance Method Summary collapse
-
#initialize(out = $stdout) ⇒ DefaultPrinter
constructor
A new instance of DefaultPrinter.
- #print(result) ⇒ Object
Constructor Details
#initialize(out = $stdout) ⇒ DefaultPrinter
Returns a new instance of DefaultPrinter.
81 82 83 |
# File 'lib/test/unit/coverage.rb', line 81 def initialize(out=$stdout) @out = out end |
Instance Method Details
#print(result) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/test/unit/coverage.rb', line 85 def print(result) result.each do |path, counts| next if /test-unit/ =~ path source = Pathname(path) @out.puts "### %s ###" % source.basename source.each_line.with_index.zip(counts) do |(line, index), count| line_num = index + 1 @out.puts "%8s:%4s:%s" % [count, line_num, line] end end ensure @out.close unless @out.closed? end |