Parent

Rcov::Formatters::HtmlErbTemplate

Attributes

local_variables[RW]

Public Class Methods

new(template_file, locals={}) click to toggle source
    # File lib/rcov/formatters/html_erb_template.rb, line 6
 6:       def initialize(template_file, locals={})
 7:         require "erb"
 8: 
 9:         template_path = File.expand_path("#{File.dirname(__FILE__)}/../templates/#{template_file}")
10:         @template = ERB.new(File.read(template_path))
11:         @local_variables = locals
12:         @path_relativizer = Hash.new{|h,base|
13:           h[base] = Pathname.new(base).cleanpath.to_s.gsub(%{^\w:[/\\]}, "").gsub(/\./, "_").gsub(/[\\\/]/, "-") + ".html"
14:         }
15:       end

Public Instance Methods

code_coverage_html(code_coverage_percentage, is_total=false) click to toggle source
    # File lib/rcov/formatters/html_erb_template.rb, line 26
26:       def code_coverage_html(code_coverage_percentage, is_total=false)
27:         %{<div class="percent_graph_legend"><tt class='#{ is_total ? 'coverage_total' : ''}'>#{ "%3.2f" % code_coverage_percentage }%</tt></div>
28:           <div class="percent_graph">
29:             <div class="covered" style="width:#{ code_coverage_percentage.round }px"></div>
30:             <div class="uncovered" style="width:#{ 100 - code_coverage_percentage.round }px"></div>
31:           </div>}
32:       end
coverage_threshold_classes(percentage) click to toggle source
    # File lib/rcov/formatters/html_erb_template.rb, line 21
21:       def coverage_threshold_classes(percentage)
22:         return 110 if percentage == 100
23:         return (1..10).find_all{|i| i * 10 > percentage}.map{|i| i.to_i * 10} * " " 
24:       end
file_filter_classes(file_path) click to toggle source
    # File lib/rcov/formatters/html_erb_template.rb, line 34
34:       def file_filter_classes(file_path)
35:         file_path.split('/')[0..2] * " "
36:       end
get_binding() click to toggle source
    # File lib/rcov/formatters/html_erb_template.rb, line 57
57:       def get_binding
58:         binding 
59:       end
line_css(line_number) click to toggle source
    # File lib/rcov/formatters/html_erb_template.rb, line 42
42:       def line_css(line_number)
43:         case fileinfo.coverage[line_number]
44:         when true
45:           "marked"
46:         when :inferred
47:           "inferred"
48:         else
49:           "uncovered"
50:         end
51:       end
method_missing(key, *args) click to toggle source
    # File lib/rcov/formatters/html_erb_template.rb, line 53
53:       def method_missing(key, *args)
54:         local_variables.has_key?(key) ? local_variables[key] : super
55:       end
relative_filename(path) click to toggle source
    # File lib/rcov/formatters/html_erb_template.rb, line 38
38:       def relative_filename(path)
39:         @path_relativizer[path]
40:       end
render() click to toggle source
    # File lib/rcov/formatters/html_erb_template.rb, line 17
17:       def render
18:         @template.result(get_binding)
19:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.