Sha256: c14ba95181eeb3dcfa82ecdbab8321abfbe27f2d646d42f60e75536bc38077a7

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

module Snuffle

  module Formatters

    module Base

      def self.included(klass)
        klass.send(:attr_accessor, :summary)
        klass.send(:attr_accessor, :source)
      end

      def initialize(summary, source="")
        self.summary = summary
        self.source = source
      end

      def content
        [header, rows, footer].flatten.join("\r\n")
      end

      def columns
        ["filename", "host class", "candidate object attributes", "source line numbers"]
      end

      def root_path
        "doc/snuffle"
      end

      def output_path
        return @output_path if @output_path
        path = root_path
        path << "/" + summary.path_to_results if summary
        FileUtils.mkpath(path)
        @output_path = root_path
      end

      def path_to_results
        "#{output_path}/#{filename}"
      end

      def filename
        base = "#{summary.filename}"
        base + file_extension
      end

      def file_extension
        ""
      end

      def export
        outfile = File.open("#{path_to_results}", 'w')
        outfile.write(content)
        outfile.close
        path_to_results
      end

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
snuffle-0.12.1 lib/snuffle/formatters/base.rb