class Coco::HtmlDirectory

Public: I prepare the coverage/ directory for html files.

Constants

COVERAGE_DIR

Public Class Methods

new(theme = 'light') click to toggle source

Public: Initialize a new HtmlDirectory object.

theme - The String name of the theme. There is 2 builtin themes :

light & dark. The default one is light.
# File lib/coco/writer/html_directory.rb, line 13
def initialize(theme = 'light')
  @theme = Theme.new(theme)
  img = File.join(Coco::ROOT, 'template/img')
  @img_files = Dir.glob(img + '/*')
end

Public Instance Methods

clean() click to toggle source

Public: Delete the directory where the HTML report is stored.

Returns nothing.

# File lib/coco/writer/html_directory.rb, line 30
def clean
  FileUtils.remove_dir(coverage_dir) if File.exist?(coverage_dir)
end
coverage_dir() click to toggle source

Public: Get the name of the directory where the HTML report is stored.

Returns String.

# File lib/coco/writer/html_directory.rb, line 23
def coverage_dir
  COVERAGE_DIR
end
list() click to toggle source

Public: I list the html files from the directory where the HTML report is stored.

Returns nothing.

# File lib/coco/writer/html_directory.rb, line 49
def list
  files = Dir.glob("#{coverage_dir}/*.html")
  files.map { |file| File.basename(file) }
end
setup() click to toggle source

Public: Make all directories needed to store the HTML report, then copy media files (css, images, etc.).

Returns nothing.

# File lib/coco/writer/html_directory.rb, line 38
def setup
  FileUtils.makedirs([css_dir, image_dir, js_dir])
  FileUtils.cp(@theme.filename, File.join(css_dir, 'coco.css'))
  FileUtils.cp(@img_files, image_dir)
  FileUtils.cp(File.join(Coco::ROOT, 'template/js/coco.js'), js_dir)
end

Private Instance Methods

css_dir() click to toggle source
# File lib/coco/writer/html_directory.rb, line 56
def css_dir
  "#{COVERAGE_DIR}/css"
end
image_dir() click to toggle source
# File lib/coco/writer/html_directory.rb, line 60
def image_dir
  "#{COVERAGE_DIR}/img"
end
js_dir() click to toggle source
# File lib/coco/writer/html_directory.rb, line 64
def js_dir
  "#{COVERAGE_DIR}/js"
end