Class: MatrixFormatter::Formatters::HTMLFormatter

Inherits:
MarkdownFormatter show all
Defined in:
lib/matrix_formatter/formatters/html_formatter.rb

Instance Attribute Summary

Attributes inherited from BaseFormatter

#matrix

Instance Method Summary collapse

Methods inherited from MarkdownFormatter

#markdown

Methods inherited from BaseFormatter

#dump_summary, #example_failed, #example_group_started, #example_passed, #example_pending, #example_started, #initialize, #start

Constructor Details

This class inherits a constructor from MatrixFormatter::Formatters::BaseFormatter

Instance Method Details



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/matrix_formatter/formatters/html_formatter.rb', line 38

def footer
  """
  </body>
  <script type=\"text/javascript\">
    var table = document.getElementsByTagName('table')[0];
    var tbody = table.getElementsByTagName('tbody')[0];
    var cells = tbody.getElementsByTagName('td');

    for (var i=0, len=cells.length; i<len; i++){
        if (cells[i].innerText === 'failed'){
            cells[i].className = 'failed';
        }
        else if (cells[i].innerText === 'passed'){
            cells[i].className = 'passed';
        }
        else if (cells[i].innerText === 'pending'){
            cells[i].className = 'pending';
        }
    }
  </script>
  </html>
  """
end

#headerObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/matrix_formatter/formatters/html_formatter.rb', line 12

def header
  """
  <html>
  <head>
  <style type=\"text/css\">
    td {
        padding: 7px 10px;
        vertical-align: top;
        text-align: left;
        border: 1px solid #ddd;
    }
    .passed {
      color: green;
    }
    .failed {
      color: red;
    }
    .pending {
      color: blue;
    }
  </style>
  </head>
  <body>
  """
end

#start_dumpObject



4
5
6
7
8
9
10
# File 'lib/matrix_formatter/formatters/html_formatter.rb', line 4

def start_dump
  renderer = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :tables => true)

  @output.puts header
  @output.puts renderer.render(markdown)
  @output.puts footer
end