Class: SimpleCov::Formatter::HTMLFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/simplecov-html.rb,
lib/simplecov-html/version.rb

Constant Summary collapse

VERSION =
"0.13.1"

Instance Method Summary collapse

Constructor Details

#initializeHTMLFormatter

Returns a new instance of HTMLFormatter.



19
20
21
22
23
24
# File 'lib/simplecov-html.rb', line 19

def initialize
  @branchable_result = SimpleCov.branch_coverage?
  @templates = {}
  @inline_assets = !ENV["SIMPLECOV_INLINE_ASSETS"].nil?
  @public_assets_dir = File.join(File.dirname(__FILE__), "../public/")
end

Instance Method Details

#format(result) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/simplecov-html.rb', line 26

def format(result)
  unless @inline_assets
    Dir[File.join(@public_assets_dir, "*")].each do |path|
      FileUtils.cp_r(path, asset_output_path, remove_destination: true)
    end
  end

  File.open(File.join(output_path, "index.html"), "wb") do |file|
    file.puts template("layout").result(binding)
  end
  puts output_message(result)
end