class Coco::HtmlIndexFormatter

I format the index.html

Public Class Methods

new(uncovered, result, threshold = 100) click to toggle source

uncovered - An Array list of uncovered files. result - CoverageResult. threshold - Fixnum.

# File lib/coco/formatter/html_index_formatter.rb, line 13
def initialize(uncovered, result, threshold = 100)
  @uncovered = uncovered
  @result = result
  @threshold = threshold
  @summary = Summary.new(result, uncovered)
  @context = nil
  @template = Template.open(File.join(Coco::ROOT, 'template/index.erb'))
  @lines = []
  build_lines_for_context
end

Public Instance Methods

format() click to toggle source
# File lib/coco/formatter/html_index_formatter.rb, line 24
def format
  @context = IndexContext.new(Helpers.index_title, @lines, uncovered_files,
                              @summary, @threshold)
  @template.result(@context.variables)
end

Private Instance Methods

build_lines_for_context() click to toggle source
# File lib/coco/formatter/html_index_formatter.rb, line 32
def build_lines_for_context
  @result.coverable_files.to_a.each do |filename, coverage|
    @lines << IndexLine.build(filename, coverage)
  end
  @lines.sort!
end
uncovered_files() click to toggle source
# File lib/coco/formatter/html_index_formatter.rb, line 39
def uncovered_files
  @uncovered.map { |filename| Helpers.name_for_html(filename) }
end