Class: SimpleCov::Formatter::CoberturaFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/simplecov-cobertura.rb,
lib/simplecov-cobertura/version.rb

Constant Summary collapse

RESULT_FILE_NAME =
'coverage.xml'
DTD_URL =
'http://cobertura.sourceforge.net/xml/coverage-04.dtd'
VERSION =
'1.4.1'

Instance Method Summary collapse

Instance Method Details

#format(result) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/simplecov-cobertura.rb', line 15

def format(result)
  xml_doc = result_to_xml result
  result_path = File.join(SimpleCov.coverage_path, RESULT_FILE_NAME)

  formatter = REXML::Formatters::Pretty.new
  formatter.compact = true
  string_io = StringIO.new
  formatter.write(xml_doc, string_io)

  xml_str = string_io.string
  File.write(result_path, xml_str)
  puts "Coverage report generated for #{result.command_name} to #{result_path}. #{coverage_output(result)}"
  xml_str
end