Class: Coco::HtmlDirectory

Inherits:
Object
  • Object
show all
Defined in:
lib/coco/writer/html_directory.rb

Overview

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

Constant Summary collapse

COVERAGE_DIR =
'coverage'

Instance Method Summary collapse

Constructor Details

#initializeHtmlDirectory

Public: Initialize a new HtmlDirectory object.


10
11
12
13
14
15
# File 'lib/coco/writer/html_directory.rb', line 10

def initialize
  css = File.join(Coco::ROOT, 'template/css')
  @css_files = Dir.glob(css + '/*')
  img = File.join(Coco::ROOT, 'template/img')
  @img_files = Dir.glob(img + '/*')
end

Instance Method Details

#cleanObject

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

Returns nothing.


28
29
30
# File 'lib/coco/writer/html_directory.rb', line 28

def clean
  FileUtils.remove_dir(coverage_dir) if File.exist?(coverage_dir)
end

#coverage_dirObject

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

Returns String.


21
22
23
# File 'lib/coco/writer/html_directory.rb', line 21

def coverage_dir
  COVERAGE_DIR
end

#listObject

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

Returns nothing.


47
48
49
50
# File 'lib/coco/writer/html_directory.rb', line 47

def list
  files = Dir.glob("#{coverage_dir}/*.html")
  files.map {|file| File.basename(file) }
end

#setupObject

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

Returns nothing.


36
37
38
39
40
41
# File 'lib/coco/writer/html_directory.rb', line 36

def setup
  FileUtils.makedirs(css_dir)
  FileUtils.makedirs(image_dir)
  FileUtils.cp(@css_files, css_dir)
  FileUtils.cp(@img_files, image_dir)
end