Sha256: c02bef254ed13393575e19f209f646d88464d57843d4b68bcbbcff78a64d6b22

Contents?: true

Size: 853 Bytes

Versions: 11

Compression:

Stored size: 853 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 output_path
      output_path = "doc/fukuzatsu/#{self.file.path_to_file.split('/')[0..-2].join("/")}"
      FileUtils.mkpath(output_path)
      output_path
    end

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

    def export
      begin
        outfile = File.open("#{output_path}/#{filename}", '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

11 entries across 11 versions & 1 rubygems

Version Path
fukuzatsu-0.9.12 lib/fukuzatsu/formatters/base.rb
fukuzatsu-0.9.11 lib/fukuzatsu/formatters/base.rb
fukuzatsu-0.9.10 lib/fukuzatsu/formatters/base.rb
fukuzatsu-0.9.8 lib/fukuzatsu/formatters/base.rb
fukuzatsu-0.9.7 lib/fukuzatsu/formatters/base.rb
fukuzatsu-0.9.6 lib/fukuzatsu/formatters/base.rb
fukuzatsu-0.9.5 lib/fukuzatsu/formatters/base.rb
fukuzatsu-0.9.4 lib/fukuzatsu/formatters/base.rb
fukuzatsu-0.9.3 lib/fukuzatsu/formatters/base.rb
fukuzatsu-0.9.1 lib/fukuzatsu/formatters/base.rb
fukuzatsu-0.9.0 lib/fukuzatsu/formatters/base.rb