Class: XunitViewer::Renderer

Inherits:
ERB
  • Object
show all
Defined in:
lib/xunit_viewer.rb

Overview

A renderer for JUnit/Xunit results

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_files, title: nil, brand_logo_url: nil, favicon_url: nil) ⇒ Renderer

Returns a new instance of Renderer.

Parameters:

  • input_files (Mixed)

    Either an array of JUnit/XUnit report filenames, or hash of name => contents

  • title (String) (defaults to: nil)

    the report title

  • brand_logo_url (String) (defaults to: nil)

    the URL to a brand logo

  • favicon_url (String) (defaults to: nil)

    the URL to a favicon



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/xunit_viewer.rb', line 29

def initialize(input_files, title: nil, brand_logo_url: nil, favicon_url: nil)
  @files = input_files.is_a?(Hash) ? input_files : input_files.each_with_object({}) { |f, acc| acc[f] = IO.read(f) }
  @title = title
  @brand_logo_url = brand_logo_url
  @favicon_url = favicon_url

  # this "filename" is from the parent class
  filename = File.expand_path("./report_template.erb", __dir__)
  template = File.read(filename)
  @filename = filename
  super(template)
end

Instance Attribute Details

#brand_logo_urlString

Returns the URL to a brand logo.

Returns:

  • (String)

    the URL to a brand logo



20
21
22
# File 'lib/xunit_viewer.rb', line 20

def brand_logo_url
  @brand_logo_url
end

#favicon_urlString

Returns the URL to a favicon logo.

Returns:

  • (String)

    the URL to a favicon logo



23
24
25
# File 'lib/xunit_viewer.rb', line 23

def favicon_url
  @favicon_url
end

#titleString

Returns the title of the report.

Returns:

  • (String)

    the title of the report



17
18
19
# File 'lib/xunit_viewer.rb', line 17

def title
  @title
end

Instance Method Details

#resultString

Returns the rendered template.

Returns:

  • (String)

    the rendered template



43
44
45
# File 'lib/xunit_viewer.rb', line 43

def result
  super(binding)
end