Sha256: e431a95de6988bd1ca3c166356c85c794345291b2975eb3ea1b4e828afc47f87

Contents?: true

Size: 862 Bytes

Versions: 7

Compression:

Stored size: 862 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'erb'

module Coco
  
  # I format the index.html
  # @todo document
  class HtmlIndexFormatter < Formatter
    
    def initialize raw_coverages, uncovered
      super(raw_coverages, uncovered)
      @context = nil
      @template = Template.open File.join($COCO_PATH,'template/index.erb')
      @lines = []
      build_lines_for_context
    end
    
    def format
      @context = IndexContext.new Helpers.index_title, @lines, @uncovered
      @template.result(@context.get_binding)
    end
    
    private
    
    def build_lines_for_context
      @raw_coverages.each do |filename, coverage| 
        filename = File.expand_path(filename)
        percentage = CoverageStat.coverage_percent(coverage)
        @lines << [percentage, filename, Helpers.rb2html(filename)]
      end
      @lines.sort!
    end
    
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
coco-0.7.1 lib/coco/formatter/html_index_formatter.rb
coco-0.7 lib/coco/formatter/html_index_formatter.rb
coco-0.6 lib/coco/formatter/html_index_formatter.rb
coco-0.5.1 lib/coco/formatter/html_index_formatter.rb
coco-0.5 lib/coco/formatter/html_index_formatter.rb
coco-0.4.2 lib/coco/formatter/html_index_formatter.rb
coco-0.4.1 lib/coco/formatter/html_index_formatter.rb