Sha256: 80a11e39c048b00264d8cbee2a59fce3b60f159f6d1fe1d5a1de9ef68ee1dfc3

Contents?: true

Size: 1016 Bytes

Versions: 1

Compression:

Stored size: 1016 Bytes

Contents

module Fukuzatsu

  module Formatters

    class HtmlIndex

      include Formatters::Base

      attr_reader :summaries

      def initialize(summaries)
        @summaries = summaries
      end

      def content
        Haml::Engine.new(output_template).render(
          Object.new, {
            summaries: summaries,
            date: Time.now.strftime("%Y/%m/%d"),
            time: Time.now.strftime("%l:%M %P")
          }
        )
      end

      def export
        begin
          File.open(path_to_results, 'w') {|outfile| outfile.write(content)}
        rescue Exception => e
          puts "Unable to write output: #{e} #{e.backtrace}"
        end
      end

      def filename
        "index.htm"
      end

      def file_extension
        ".htm"
      end

      def output_path
        FileUtils.mkpath(self.output_directory)
        self.output_directory
      end

      def output_template
        File.read(File.dirname(__FILE__) + "/templates/index.html.haml")
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fukuzatsu-2.1.1 lib/fukuzatsu/formatters/html_index.rb