Class: Topographer::Importer::Helpers::WriteLogToCSV

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/topographer/importer/helpers/write_log_to_csv.rb

Instance Method Summary collapse

Constructor Details

#initializeWriteLogToCSV

Returns a new instance of WriteLogToCSV.



6
7
8
# File 'lib/topographer/importer/helpers/write_log_to_csv.rb', line 6

def initialize

end

Instance Method Details

#write_log_to_csv(log, output_file_path, options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/topographer/importer/helpers/write_log_to_csv.rb', line 10

def write_log_to_csv(log, output_file_path, options = {})
  @log = log
  @write_all = options.fetch(:write_all, true)
  CSV.open(output_file_path, 'wb') do |csv_file|
    csv_file << get_detail_header
    csv_file << get_details
    csv_file << get_log_header if @log.entries?
    @log.all_entries.each do |entry|
      if entry.failure? || @write_all

        csv_file << format_log_entry(entry)
      end
    end
  end
end