Sha256: b2b8b621190df3495b0fd324faabe9ff13391c4ac3fe1211c6124bf032f340d4

Contents?: true

Size: 748 Bytes

Versions: 5

Compression:

Stored size: 748 Bytes

Contents

module Formatters

  class Csv

    include Formatters::Base

    def self.has_index?
      false
    end

    def self.writes_to_file_system?
      true
    end

    def content
      rows + "\r\n"
    end

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

    def file_extension
      ".csv"
    end

    def path_to_results
      File.join(output_directory, "results#{file_extension}")
    end

    def rows
      file.methods.map do |method|
        "#{file.path_to_file},#{file.class_name},#{method.prefix}#{method.name},#{method.complexity}"
      end.join("\r\n")
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fukuzatsu-1.0.4 lib/fukuzatsu/formatters/csv.rb
fukuzatsu-1.0.3 lib/fukuzatsu/formatters/csv.rb
fukuzatsu-1.0.2 lib/fukuzatsu/formatters/csv.rb
fukuzatsu-1.0.1 lib/fukuzatsu/formatters/csv.rb
fukuzatsu-1.0.0 lib/fukuzatsu/formatters/csv.rb