Sha256: d6937277919afa3cc54df2ba63deeb2bb9a065b58d917c08d829d60095937231

Contents?: true

Size: 782 Bytes

Versions: 2

Compression:

Stored size: 782 Bytes

Contents

# -*- encoding: utf-8 -*-

module Coco

  # Public: I populate the coverage/ directory with files, if any.
  class HtmlFilesWriter

    # Public: Initialize a new HtmlFilesWriter.
    #
    # html_files - Hash, key is filename, value is html content.
    def initialize(html_files)
      @html_files = html_files
      @html_dir = HtmlDirectory.new
    end

    # Public: Write HTML files in the right place.
    #
    # Returns nothing.
    def write
      @html_dir.clean
      if @html_files.size > 0
        @html_dir.setup
        write_each_file
      end
    end

    private

    def write_each_file
      @html_files.each do |filename, html|
        FileWriter.write File.join(
          @html_dir.coverage_dir, Helpers.rb2html(filename)), html
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
coco-0.12.0 lib/coco/writer/html_files_writer.rb
coco-0.11.0 lib/coco/writer/html_files_writer.rb