Created
August 21, 2010 15:14
-
-
Save manveru/542434 to your computer and use it in GitHub Desktop.
Little coverage output formatter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'pp' | |
require 'coverage' | |
Coverage.start | |
ARGV.each do |arg| | |
require_relative arg | |
end | |
red, yellow, green = "\e[31m%s\e[0m", "\e[33m%s\e[0m", "\e[32m%s\e[0m" | |
Coverage.result.each do |file, results| | |
puts "", file.center(80, " = "), "" | |
lines = File.readlines(file) | |
lines.zip(results) do |line, result| | |
executed = result || | |
case line | |
when /^\s*end\s*$/; true | |
when /^\s*$/; true | |
when /^\s*#/; true | |
end | |
if result | |
print green % ["%3d | %s" % [result.to_i, line]] | |
elsif executed | |
print yellow % ["%3d | %s" % [result.to_i, line]] | |
else | |
print red % [" | %s" % [line]] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment