Class: Spoom::Coverage::Page Abstract

Inherits:
Template show all
Defined in:
lib/spoom/coverage/report.rb

Overview

This class is abstract.

Direct Known Subclasses

Report

Constant Summary collapse

TEMPLATE =

: String

"#{Spoom::SPOOM_PATH}/templates/page.erb"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Template

#erb, #get_binding, #html

Constructor Details

#initialize(title:, palette:, template: TEMPLATE) ⇒ Page

: (title: String, palette: D3::ColorPalette, ?template: String) -> void



45
46
47
48
49
# File 'lib/spoom/coverage/report.rb', line 45

def initialize(title:, palette:, template: TEMPLATE)
  super(template: template)
  @title = title
  @palette = palette
end

Instance Attribute Details

#paletteObject (readonly)

: D3::ColorPalette



42
43
44
# File 'lib/spoom/coverage/report.rb', line 42

def palette
  @palette
end

#titleObject (readonly)

: String



39
40
41
# File 'lib/spoom/coverage/report.rb', line 39

def title
  @title
end

Instance Method Details

#body_htmlObject

: -> String



67
68
69
# File 'lib/spoom/coverage/report.rb', line 67

def body_html
  cards.map(&:html).join("\n")
end

#cardsObject

This method is abstract.

: -> Array

Raises:

  • (NotImplementedError)


73
# File 'lib/spoom/coverage/report.rb', line 73

def cards = raise NotImplementedError, "Abstract method called"

: -> String



76
77
78
# File 'lib/spoom/coverage/report.rb', line 76

def footer_html
  "Generated by <a href='https://github.com/Shopify/spoom'>spoom</a> on #{Time.now.utc}."
end

#header_htmlObject

: -> String



62
63
64
# File 'lib/spoom/coverage/report.rb', line 62

def header_html
  "<h1 class='display-3'>#{title}</h1>"
end

#header_scriptObject

: -> String



57
58
59
# File 'lib/spoom/coverage/report.rb', line 57

def header_script
  D3.header_script(palette)
end

#header_styleObject

: -> String



52
53
54
# File 'lib/spoom/coverage/report.rb', line 52

def header_style
  D3.header_style
end