Class: SimpleCov::Formatter::CoberturaFormatter
- Inherits:
-
Object
- Object
- SimpleCov::Formatter::CoberturaFormatter
- 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 =
'2.1.0'
Instance Method Summary collapse
- #format(result) ⇒ Object
-
#initialize(result_file_name: RESULT_FILE_NAME) ⇒ CoberturaFormatter
constructor
A new instance of CoberturaFormatter.
Constructor Details
#initialize(result_file_name: RESULT_FILE_NAME) ⇒ CoberturaFormatter
Returns a new instance of CoberturaFormatter.
15 16 17 |
# File 'lib/simplecov-cobertura.rb', line 15 def initialize(result_file_name: RESULT_FILE_NAME) @result_file_name = result_file_name end |
Instance Method Details
#format(result) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/simplecov-cobertura.rb', line 19 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 |