Class: Pal::Handler::GenericCSVHandlerImpl

Inherits:
Base
  • Object
show all
Includes:
Log
Defined in:
lib/pal/handler/base.rb

Overview

Generic has first row column headers, then data rows.

Direct Known Subclasses

AwsCurHandlerImpl

Instance Method Summary collapse

Methods included from Log

#log_debug, #log_error, #log_info, #log_warn

Methods inherited from Base

#initialize, #process_runbook, #retrieve_column_definitions, #should_include?

Methods included from Configuration

#config, #register_config

Constructor Details

This class inherits a constructor from Pal::Handler::Base

Instance Method Details

#_csv_processor(source_file_loc) ⇒ Pal::Operation::CSVProcessor

Parameters:

  • source_file_loc (String)

Returns:



121
122
123
# File 'lib/pal/handler/base.rb', line 121

def _csv_processor(source_file_loc)
  Operation::CSVProcessor.retrieve_default_processor(source_file_loc)
end

#_parse_file(ctx, csv_processor, &_block) ⇒ Hash


Each impl needs to return a hash of candidate columns and values eg. { col_name: col_value, col_name_2: col_value_2 }

Parameters:

Returns:

  • (Hash)


105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/pal/handler/base.rb', line 105

def _parse_file(ctx, csv_processor, &_block)
  log_info("Starting to process file, using #{csv_processor.class} processor for #{_type} CUR file.")
  ctx.current_file_row_count = 0

  csv_processor.parse(ctx, header: :none) do |row|
    if ctx.current_file_row_count == 1
      ctx.extract_column_headers(row)
      next
    end

    yield row
  end
end

#_typeString

Returns:

  • (String)


126
127
128
# File 'lib/pal/handler/base.rb', line 126

def _type
  "generic"
end