Class: YardJunk::Janitor::HtmlReporter

Inherits:
BaseReporter show all
Defined in:
lib/yard-junk/janitor/html_reporter.rb

Overview

Reporter that just outputs everything in HTML format. Useful for usage with Jenkins. See BaseReporter for details about reporters.

Constant Summary collapse

HEADER =
<<-HTML
  <!DOCTYPE html>
  <html lang="en">
    <header>
      <meta charset='UTF-8' />
      <title>YARD-Junk Report</title>
      <style>
        body, html {
        }
        body {
          font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
          margin: 0;
          padding: 20px;
        }
        h2 {
          font-size: 1.6rem;
        }
        h2 small {
          color: gray;
          font-weight: normal;
        }
        span.path {
          font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
          font-size: 85%;
        }
        .problem { color: red; }
        .notice { color: gray; }
        p.stats {
          padding: 10px;
          font-size: 1.2em;
          border: 1px dotted silver;
        }
      </style>
    </header>
    <body>
      <h1>YARD Validation Report</h1>
HTML
<<-HTML
    </body>
  </html>
HTML
SECTION =
<<-HTML
<h2 class="<%= title == 'Notices' ? 'notice' : 'problem' %>">
  <%= title %>
  <small>(<%= explanation %>)</small>
</h2>
HTML
ROW =
<<-HTML
<li><span class="path"><%= file %>:<%= line %></span>: <%= message %></li>
HTML
STATS =
<<-HTML
<p class="stats">
  <span class="<%= 'problem' unless errors.zero? %>"><%= errors %> failures</span>,
  <span class="<%= 'problem' unless problems.zero? %>"><%= problems %> problems</span>
  (ready in <%= duration %>)
</p>
HTML
Helper =
Class.new(OpenStruct) do
  def the_binding
    binding
  end
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseReporter

#section, #stats

Constructor Details

#initializeHtmlReporter

Returns a new instance of HtmlReporter.



81
82
83
84
# File 'lib/yard-junk/janitor/html_reporter.rb', line 81

def initialize(*)
  super
  @html = HEADER.dup
end

Instance Attribute Details

#htmlObject (readonly)

Returns the value of attribute html.



79
80
81
# File 'lib/yard-junk/janitor/html_reporter.rb', line 79

def html
  @html
end

Instance Method Details

#finalizeObject



86
87
88
89
# File 'lib/yard-junk/janitor/html_reporter.rb', line 86

def finalize
  @html << FOOTER
  @io.puts(@html)
end