Class: ERBLint::Reporters::JunitReporter

Inherits:
ERBLint::Reporter show all
Defined in:
lib/erb_lint/reporters/junit_reporter.rb

Constant Summary collapse

ESCAPE_MAP =
{
  '"' => """,
  "'" => "'",
  "<" => "&lt;",
  ">" => "&gt;",
  "&" => "&amp;",
}.freeze
PROPERTIES =
[
  ["erb_lint_version", ERBLint::VERSION],
  ["ruby_engine", RUBY_ENGINE],
  ["ruby_version", RUBY_VERSION],
  ["ruby_patchlevel", RUBY_PATCHLEVEL.to_s],
  ["ruby_platform", RUBY_PLATFORM],
].freeze

Instance Method Summary collapse

Methods inherited from ERBLint::Reporter

available_format?, available_formats, create_reporter, #initialize

Constructor Details

This class inherits a constructor from ERBLint::Reporter

Instance Method Details

#previewObject



22
# File 'lib/erb_lint/reporters/junit_reporter.rb', line 22

def preview; end

#showObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/erb_lint/reporters/junit_reporter.rb', line 24

def show
  puts %(<?xml version="1.0" encoding="UTF-8"?>)
  puts %(<testsuite name="erblint" tests="#{@stats.processed_files.size}" failures="#{@stats.found}">)

  puts %(  <properties>)
  PROPERTIES.each do |key, value|
    puts %(    <property name="#{xml_escape(key)}" value="#{xml_escape(value)}"/>)
  end
  puts %(  </properties>)

  processed_files.each do |filename, offenses|
    filename_escaped = xml_escape(filename)
    if offenses.empty?
      puts %(  <testcase name="#{filename_escaped}" file="#{filename_escaped}"/>)
    else
      offenses.each do |offense|
        type = offense.simple_name
        message = "#{type}: #{offense.message}"
        body = "#{message} at #{filename}:#{offense.line_number}:#{offense.column}"

        puts %(  <testcase name="#{filename_escaped}" file="#{filename_escaped}" lineno="#{offense.line_number}">)
        puts %(    <failure message="#{xml_escape(message)}" type="#{xml_escape(type)}">)
        puts %(      #{xml_escape(body)})
        puts %(    </failure>)
        puts %(  </testcase>)
      end
    end
  end

  puts %(</testsuite>)
end