Formatador XML para SimpleCov

module SimpleCov
module Formatter
class XMLFormatter
RESULT_FILE_NAME
= "coverage.xml"

def format(result)
xml
= "<SimpleCov>n"

xml
<< " <summary percent_covered="#{result.covered_percent.round.to_s}"" ""
xml
<< ""relevant_lines=""#{result.total_lines}"" ""
xml
<< ""lines_covered=""#{result.covered_lines}"" ""
xml
<< ""lines_missed=""#{result.missed_lines}"" />n""
xml
<< "" <files>n""
result
.files.each do |file|
xml
<< "" <file name=""#{shortened_filename file}"" ""
xml
<< ""percent_covered=""#{file.covered_percent.round.to_s}"" ""
xml
<< ""lines=""#{file.lines.count}"" ""
xml
<< ""relevant_lines=""#{file.covered_lines.count + file.missed_lines.count}"" ""
xml
<< ""lines_covered=""#{file.covered_lines.count}"" ""
xml
<< ""lines_missed=""#{file.missed_lines.count}"" />n""
end
xml
<< "" <files>n""
xml
<< ""</SimpleCov>""

result_file_path
= File.join( SimpleCov.coverage_path