Class: Piggly::Reporter::Procedure
- Defined in:
- lib/piggly/reporter/procedure.rb
Constant Summary
Constants included from HtmlDsl
HtmlDsl::HTML_PATTERN, HtmlDsl::HTML_REPLACE
Instance Method Summary collapse
-
#initialize(config, profile) ⇒ Procedure
constructor
A new instance of Procedure.
- #report(procedure) ⇒ Object
Methods inherited from Base
Methods included from HtmlDsl
Constructor Details
#initialize(config, profile) ⇒ Procedure
Returns a new instance of Procedure.
6 7 8 9 |
# File 'lib/piggly/reporter/procedure.rb', line 6 def initialize(config, profile) @config, @profile = config, profile @line_coverage = Compiler::LineCoverage.new(config) end |
Instance Method Details
#report(procedure) ⇒ Object
11 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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/piggly/reporter/procedure.rb', line 11 def report(procedure) io = File.open(report_path(procedure.source_path(@config), ".html"), "w") begin compiler = Compiler::CoverageReport.new(@config) data = compiler.compile(procedure, @profile) # Calculate line coverage for this procedure line_summary = nil begin coverage = @line_coverage.calculate(procedure, @profile) line_summary = @line_coverage.summary(coverage) rescue => e # Skip if can't calculate end html(io) do tag :html, :xmlns => "http://www.w3.org/1999/xhtml" do tag :head do tag :title, "Code Coverage: #{procedure.name}" tag :meta, :charset => "utf-8" tag :link, :rel => "stylesheet", :type => "text/css", :href => "piggly.css" tag :script, "<!-- -->", :type => "text/javascript", :src => "highlight.js" end tag :body do tag :div, :class => "header" do aggregate(procedure.name, @profile.summary(procedure), line_summary) end tag :div, :class => "container" do tag :div, :class => "listing" do tag :table do tag :tr do tag :td, " ", :class => "signature" tag :td, signature(procedure), :class => "signature" end tag :tr do tag :td, data[:lines].to_a.map{|n| %[<a href="#L#{n}" id="L#{n}">#{n}</a>] }.join("\n"), :class => "lines" tag :td, data[:html], :class => "code" end end end toc(@profile[procedure]) end tag :a, "Return to index", :href => "index.html", :class => "return" end end end ensure io.close end end |