class BigSister::CsvReporter
Public Class Methods
new(schema, i)
click to toggle source
Calls superclass method
BigSister::Reporter::new
# File lib/bigsister/reporters/csv_reporter.rb, line 6 def initialize(schema, i) super(schema, i) if !schema.key?("path") raise BigSister::InvalidConfiguration.new("CSV Reporter path is required.") else @outfile_path = schema.fetch("path") end end
Public Instance Methods
csv()
click to toggle source
# File lib/bigsister/reporters/csv_reporter.rb, line 15 def csv if summary? summary else detail end end
render()
click to toggle source
# File lib/bigsister/reporters/csv_reporter.rb, line 23 def render File.open(@outfile_path, "w") { |file| file.write(csv) } end
Protected Instance Methods
detail()
click to toggle source
Calls superclass method
BigSister::Reporter#detail
# File lib/bigsister/reporters/csv_reporter.rb, line 35 def detail rows = super.map { |row| row.to_csv(row_sep: nil) } ([headers] + rows).join("\n") end
headers()
click to toggle source
# File lib/bigsister/reporters/csv_reporter.rb, line 31 def headers @columns.map { |column| column["title"] }.to_csv(row_sep: nil) end
summary()
click to toggle source
Calls superclass method
BigSister::Reporter#summary
# File lib/bigsister/reporters/csv_reporter.rb, line 40 def summary [headers, super.to_csv(row_sep: nil)].join("\n") end