Sha256: 9783046b8e7f4f1bac0969b652c43a08a038a76460b30232b45037b5b9b8d789

Contents?: true

Size: 1002 Bytes

Versions: 3

Compression:

Stored size: 1002 Bytes

Contents

module Formatters

  module Base

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

    def initialize(file)
      self.file = file
    end

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

    def columns
      ["class", "method", "complexity"]
    end

    def root_path
      "doc/fukuzatsu"
    end

    def output_path
      output_path = "#{root_path}/#{self.file.path_to_file.split('/')[0..-2].join("/")}"
      FileUtils.mkpath(output_path)
      output_path
    end

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

    def filename
      self.file.path_to_file.split('/')[-1] + file_extension
    end

    def file_extension
      ""
    end

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

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fukuzatsu-0.9.16 lib/fukuzatsu/formatters/base.rb
fukuzatsu-0.9.15 lib/fukuzatsu/formatters/base.rb
fukuzatsu-0.9.14 lib/fukuzatsu/formatters/base.rb