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'.freeze
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(theme = 'light') ⇒ 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(theme = 'light') ⇒ HtmlDirectory
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.
13 14 15 16 17 |
# 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 |
Instance Method Details
#clean ⇒ Object
Public: Delete the directory where the HTML report is stored.
Returns nothing.
30 31 32 |
# File 'lib/coco/writer/html_directory.rb', line 30 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.
23 24 25 |
# File 'lib/coco/writer/html_directory.rb', line 23 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.
49 50 51 52 |
# 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 ⇒ Object
Public: Make all directories needed to store the HTML report, then copy media files (css, images, etc.).
Returns nothing.
38 39 40 41 42 43 |
# 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 |