Sha256: 2777129bfce738063bc2dba2d1b6f1a083eccbb1a658f91ecbad40ffd82f1593

Contents?: true

Size: 1.05 KB

Versions: 7

Compression:

Stored size: 1.05 KB

Contents

module Fukuzatsu

  module Formatters

    class HtmlIndex

      include Formatters::Base

      attr_reader :summaries

      def initialize(summaries, base_output_path)
        @summaries = summaries
        @base_output_path = base_output_path
      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

7 entries across 7 versions & 1 rubygems

Version Path
fukuzatsu-2.3.2 lib/fukuzatsu/formatters/html_index.rb
fukuzatsu-2.3.1 lib/fukuzatsu/formatters/html_index.rb
fukuzatsu-2.3.0 lib/fukuzatsu/formatters/html_index.rb
fukuzatsu-2.2.4 lib/fukuzatsu/formatters/html_index.rb
fukuzatsu-2.2.3 lib/fukuzatsu/formatters/html_index.rb
fukuzatsu-2.2.2 lib/fukuzatsu/formatters/html_index.rb
fukuzatsu-2.2.1 lib/fukuzatsu/formatters/html_index.rb