lib/fukuzatsu/formatters/csv.rb in fukuzatsu-0.10.1 vs lib/fukuzatsu/formatters/csv.rb in fukuzatsu-1.0.0
- old
+ new
@@ -2,25 +2,41 @@
class Csv
include Formatters::Base
- def header
- columns.join(',')
+ def self.has_index?
+ false
end
- def rows
- file.methods.inject([]) do |a, method|
- a << "#{file.class_name},#{method.prefix}#{method.name},#{method.complexity}"
- a
- end.join("\r\n")
+ def self.writes_to_file_system?
+ true
end
- def footer
+ 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
\ No newline at end of file