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



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

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

Instance Attribute Details

#htmlObject (readonly)

Returns the value of attribute html.



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

def html
  @html
end

Instance Method Details

#finalizeObject



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

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