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 |
# File 'lib/piggly/reporter/procedure.rb', line 6 def initialize(config, profile) @config, @profile = config, profile end |
Instance Method Details
#report(procedure) ⇒ Object
10 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 |
# File 'lib/piggly/reporter/procedure.rb', line 10 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) html(io) do tag :html, :xmlns => "http://www.w3.org/1999/xhtml" do tag :head do tag :title, "Code Coverage: #{procedure.name}" tag :link, :rel => "stylesheet", :type => "text/css", :href => "piggly.css" tag :script, "<!-- -->", :type => "text/javascript", :src => "highlight.js" end tag :body do aggregate(procedure.name, @profile.summary(procedure)) 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 end end ensure io.close end end |