class Coverage::HTMLPrinter::Detail
Attributes
page_title[R]
path[R]
project_name[R]
Public Class Methods
new(path_settings, project_name, path, counts)
click to toggle source
# File lib/coverage/html_printer.rb, line 155 def initialize(path_settings, project_name, path, counts) @path_settings = path_settings @project_name = project_name @path = path @counts = counts @statistics = Coverage::Statistics.new(path, counts) @source = Pathname(path) @page_title = @source.basename @sources = [] @source.each_line.with_index.zip(@counts) do |(line, index), count| @sources << Line.new(index + 1, line, count) end end
Public Instance Methods
code_coverage()
click to toggle source
# File lib/coverage/html_printer.rb, line 203 def code_coverage coverage_bar(@statistics.code_coverage) end
each_line() { |line| ... }
click to toggle source
# File lib/coverage/html_printer.rb, line 179 def each_line @sources.each do |line| yield line end end
html_filename()
click to toggle source
# File lib/coverage/html_printer.rb, line 193 def html_filename dir = @source.sub(Regexp.new(@path_settings.base_directory.to_s), '.').dirname file = @source.basename.sub(/\.rb/, "_rb.html") dir + file end
label()
click to toggle source
# File lib/coverage/html_printer.rb, line 185 def label @label ||= @source.relative_path_from(@path_settings.output_directory).to_s.sub(/\A\.\.\//, '') end
link()
click to toggle source
# File lib/coverage/html_printer.rb, line 189 def link %Q!<a href="#{html_filename}">#{label}</a>! end
print()
click to toggle source
# File lib/coverage/html_printer.rb, line 169 def print erb = ERB.new(File.read(template_path), nil, '-') path = @path_settings.output_directory + html_filename erb.filename = path.to_s FileUtils.mkdir_p(path.dirname) File.open(path, "wb+") do |file| file.puts(erb.result(binding)) end end
total_coverage()
click to toggle source
# File lib/coverage/html_printer.rb, line 199 def total_coverage coverage_bar(@statistics.total_coverage) end
Private Instance Methods
output_directory()
click to toggle source
# File lib/coverage/html_printer.rb, line 212 def output_directory @path_settings.output_directory end
template_path()
click to toggle source
# File lib/coverage/html_printer.rb, line 208 def template_path @path_settings.templates_directory + "detail.html.erb" end