Class: Piggly::Compiler::CoverageReport

Inherits:
Object
  • Object
show all
Includes:
Reporter::HtmlDsl
Defined in:
lib/piggly/compiler/coverage_report.rb

Overview

Produces HTML output to report coverage of tagged nodes in the tree

Constant Summary

Constants included from Reporter::HtmlDsl

Reporter::HtmlDsl::HTML_PATTERN, Reporter::HtmlDsl::HTML_REPLACE

Instance Method Summary collapse

Methods included from Reporter::HtmlDsl

#e, #html, #tag

Constructor Details

#initialize(config) ⇒ CoverageReport

Returns a new instance of CoverageReport.



10
11
12
# File 'lib/piggly/compiler/coverage_report.rb', line 10

def initialize(config)
  @config = config
end

Instance Method Details

#compile(procedure, profile) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/piggly/compiler/coverage_report.rb', line 14

def compile(procedure, profile)
  trace = Compiler::TraceCompiler.new(@config)

  if trace.stale?(procedure)
    raise StaleCacheError,
      "stale cached syntax tree for #{procedure.name}"
  end

  # Get (copies of) the tagged nodes from the compiled tree
  data = trace.compile(procedure)

  return :html  => traverse(data[:tree], profile),
         :lines => 1 .. procedure.source(@config).count("\n") + 1
end