Class: Coco::HtmlDirectory
- Inherits:
-
Object
- Object
- Coco::HtmlDirectory
- 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
-
#clean ⇒ Object
Public: Delete the directory where the HTML report is stored.
-
#coverage_dir ⇒ Object
Public: Get the name of the directory where the HTML report is stored.
-
#initialize ⇒ HtmlDirectory
constructor
Public: Initialize a new HtmlDirectory object.
-
#list ⇒ Object
Public: I list the html files from the directory where the HTML report is stored.
-
#setup ⇒ Object
Public: Make all directories needed to store the HTML report, then copy media files (css, images, etc.).
Constructor Details
#initialize ⇒ HtmlDirectory
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
#clean ⇒ Object
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_dir ⇒ Object
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 |
#list ⇒ Object
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 |
#setup ⇒ Object
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 |