Class: Rcov::HTMLCoverage

Inherits:
Formatter show all
Includes:
XX::XHTML, XX::XMLish
Defined in:
lib/rcov/report.rb

Overview

:nodoc:

Direct Known Subclasses

HTMLProfiling

Defined Under Namespace

Classes: SummaryFileInfo

Constant Summary collapse

JAVASCRIPT_PROLOG =
<<-EOS

// \<![CDATA[
  function toggleCode( id ) {
if ( document.getElementById )
  elem = document.getElementById( id );
else if ( document.all )
  elem = eval( "document.all." + id );
else
  return false;

elemStyle = elem.style;

if ( elemStyle.display != "block" ) {
  elemStyle.display = "block"
} else {
  elemStyle.display = "none"
}

return true;
  }

  // Make cross-references hidden by default
  document.writeln( "\<style type=\\"text/css\\">span.cross-ref { display: none }</style>" )
  // ]]>
EOS
CSS_PROLOG =
<<-EOS
span.cross-ref-title {
    font-size: 140%;
}
span.cross-ref a {
  text-decoration: none;
}
span.cross-ref {
    background-color:#f3f7fa;
    border: 1px dashed #333;
    margin: 1em;
    padding: 0.5em;
    overflow: hidden;
}
a.crossref-toggle {
  text-decoration: none;
}
span.marked0 {
  background-color: rgb(185, 210, 200);
  display: block;
}
span.marked1 {
  background-color: rgb(190, 215, 205);
  display: block;
}
span.inferred0 {
  background-color: rgb(255, 255, 240);
  display: block;
}
span.inferred1 {
  background-color: rgb(255, 255, 240);
  display: block;
}
span.uncovered0 {
  background-color: rgb(225, 110, 110);
  display: block;
}
span.uncovered1 {
  background-color: rgb(235, 120, 120);
  display: block;
}
span.overview {
  border-bottom: 8px solid black;
}
div.overview {
  border-bottom: 8px solid black;
}
body {
    font-family: verdana, arial, helvetica;
}

div.footer {
    font-size: 68%;
    margin-top: 1.5em;
}

h1, h2, h3, h4, h5, h6 {
    margin-bottom: 0.5em;
}

h5 {
    margin-top: 0.5em;
}

.hidden {
    display: none;
}

div.separator {
    height: 10px;
}
/* Commented out for better readability, esp. on IE */
/*
table tr td, table tr th {
    font-size: 68%;
}

td.value table tr td {
    font-size: 11px;
}
*/

table.percent_graph {
    height: 12px;
    border: #808080 1px solid;
    empty-cells: show;
}

table.percent_graph td.covered {
    height: 10px;
    background: #00f000;
}

table.percent_graph td.uncovered {
    height: 10px;
    background: #e00000;
}

table.percent_graph td.NA {
    height: 10px;
    background: #eaeaea;
}

table.report {
    border-collapse: collapse;
    width: 100%;
}

table.report td.heading {
    background: #dcecff;
    border: #d0d0d0 1px solid;
    font-weight: bold;
    text-align: center;
}

table.report td.heading:hover {
    background: #c0ffc0;
}

table.report td.text {
    border: #d0d0d0 1px solid;
}

table.report td.value,
table.report td.lines_total,
table.report td.lines_code {
    text-align: right;
    border: #d0d0d0 1px solid;
}
table.report tr.light {
    background-color: rgb(240, 240, 245);
}
table.report tr.dark {
    background-color: rgb(230, 230, 235);
}
EOS
DEFAULT_OPTS =
{:color => false, :fsr => 30, :destdir => "coverage",
 :callsites => false, :cross_references => false,
 :validator_links => true, :charset => nil
}

Constants included from XX::Markup

XX::Markup::XX_MARKUP_RECURSIVE_INCLUSION_PROC

Instance Method Summary collapse

Methods included from XX::XMLish

#xmlish_

Methods included from XX::Markup

included

Methods included from XX::Markup::ClassMethods

#xx_ancestors, #xx_config, #xx_config_for, #xx_configure, #xx_define_tag_method, #xx_define_tmp_method, #xx_remove_tag_method, #xx_tag_method_name

Methods included from XX::Markup::InstanceMethods

#_, #method_missing, #xx_ancestors, #xx_any_, #xx_cdata_, #xx_class, #xx_config, #xx_config_for, #xx_configure, #xx_define_tag_method, #xx_define_tmp_method, #xx_doc, #xx_markup_, #xx_parse_attributes, #xx_parse_yaml_attributes, #xx_remove_tag_method, #xx_tag_method_name, #xx_text_, #xx_which, #xx_with_doc_in_effect

Methods included from XX::XHTML

#xhtml_

Methods inherited from Formatter

#add_file, #code_coverage, #each_file_pair_sorted, #mangle_filename, #normalize_filename, #num_code_lines, #num_lines, #sorted_file_pairs, #total_coverage

Constructor Details

#initialize(opts = {}) ⇒ HTMLCoverage

Returns a new instance of HTMLCoverage.



704
705
706
707
708
709
710
711
712
713
714
715
# File 'lib/rcov/report.rb', line 704

def initialize(opts = {})
  options = DEFAULT_OPTS.clone.update(opts)
  super(options)
  @dest = options[:destdir]
  @color = options[:color]
  @fsr = options[:fsr]
  @do_callsites = options[:callsites]
  @do_cross_references = options[:cross_references]
  @span_class_index = 0
  @show_validator_links = options[:validator_links]
  @charset = options[:charset]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class XX::Markup::InstanceMethods

Instance Method Details

#executeObject



717
718
719
720
721
722
723
724
725
# File 'lib/rcov/report.rb', line 717

def execute
  return if @files.empty?
  FileUtils.mkdir_p @dest
  create_index(File.join(@dest, "index.html"))

  each_file_pair_sorted do |filename, fileinfo|
    create_file(File.join(@dest, mangle_filename(filename)), fileinfo)
  end
end