Class: NdrImport::Avro::Table

Inherits:
Table
  • Object
show all
Defined in:
lib/ndr_import/avro/table.rb

Overview

Syntatic sugar to ensure ‘header_lines` and `footer_lines` are 1 and 0 respectively. All other Table logic is inherited from `NdrImport::Table`

Instance Attribute Summary

Attributes inherited from Table

#notifier

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Table

#all_valid_options, #encode_with, #header_valid?, #initialize, #match, #process_line, #transform, #transform_line

Constructor Details

This class inherits a constructor from NdrImport::Table

Class Method Details

.all_valid_optionsObject



20
21
22
# File 'lib/ndr_import/avro/table.rb', line 20

def self.all_valid_options
  super - %w[delimiter header_lines footer_lines]
end

.from_schema(safe_path) ⇒ Object

Scaffold an ‘NdrImport::Avro::Table` instance from avro schema file

Raises:

  • (SecurityError)


9
10
11
12
13
14
15
16
17
18
# File 'lib/ndr_import/avro/table.rb', line 9

def self.from_schema(safe_path)
  raise SecurityError, "#{safe_path} is not a SafePath" unless safe_path.is_a? SafePath

  table_columns = columns_from(::Avro::Schema.parse(::File.open(safe_path)))
  file_name     = SafeFile.basename(safe_path).sub(/\.avsc\z/, '.avro')

  new(filename_pattern: "/#{file_name}\\z/",
      klass: 'ExampleKlass',
      columns: table_columns)
end

Instance Method Details



28
29
30
# File 'lib/ndr_import/avro/table.rb', line 28

def footer_lines
  0
end

#header_linesObject



24
25
26
# File 'lib/ndr_import/avro/table.rb', line 24

def header_lines
  1
end