Class: CoverMe::HtmlFormatter

Inherits:
Formatter show all
Defined in:
lib/cover_me/html_formatter.rb

Overview

Generates pretty HTML of the code coverage.

Instance Attribute Summary

Attributes inherited from Formatter

#options

Instance Method Summary collapse

Methods inherited from Formatter

#format, #template

Constructor Details

#initialize(options = {}) ⇒ HtmlFormatter

:nodoc:



4
5
6
7
# File 'lib/cover_me/html_formatter.rb', line 4

def initialize(options = {}) # :nodoc:
  super
  self.options = ({:output_path => CoverMe.config.html_formatter.output_path}.merge(self.options)).to_mash
end

Instance Method Details

#finalizeObject

Generates some .css and .js files to make things look pretty and work well.



24
25
26
27
28
29
30
31
# File 'lib/cover_me/html_formatter.rb', line 24

def finalize
  super
  CoverMe.config.html_formatter.finalizer_files.each do |name, t|
    write_file(name, '') do |file|
      file.write(self.template(t).result(binding))
    end
  end
end

#format_index(index) ⇒ Object

Formats a CoverMe::Index object using the index.html.erb template



17
18
19
20
21
# File 'lib/cover_me/html_formatter.rb', line 17

def format_index(index)
  write_file('index') do |file|
    file.write(self.template('index.html.erb').result(binding))
  end
end

#format_report(report) ⇒ Object

Formats a CoverMe::Report object using the report.html.erb template



10
11
12
13
14
# File 'lib/cover_me/html_formatter.rb', line 10

def format_report(report)
  write_file(report.filename) do |file|
    file.write(self.template('report.html.erb').result(binding))
  end
end