Class: CSV2Avro
- Inherits:
-
Object
- Object
- CSV2Avro
- Defined in:
- lib/csv2avro.rb,
lib/csv2avro/schema.rb,
lib/csv2avro/version.rb,
lib/csv2avro/converter.rb,
lib/csv2avro/avro_writer.rb,
lib/csv2avro/datum_writer.rb,
lib/csv2avro/schema_validator.rb
Defined Under Namespace
Classes: AvroWriter, Converter, DatumWriter, Schema, SchemaValidationError, SchemaValidator
Constant Summary collapse
- VERSION =
"1.3.1"
Instance Attribute Summary collapse
-
#bad_rows_path ⇒ Object
readonly
Returns the value of attribute bad_rows_path.
-
#input_path ⇒ Object
readonly
Returns the value of attribute input_path.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#schema_path ⇒ Object
readonly
Returns the value of attribute schema_path.
-
#stdout_option ⇒ Object
readonly
Returns the value of attribute stdout_option.
Class Method Summary collapse
Instance Method Summary collapse
- #convert ⇒ Object
-
#initialize(options) ⇒ CSV2Avro
constructor
A new instance of CSV2Avro.
- #logger ⇒ Object
Constructor Details
#initialize(options) ⇒ CSV2Avro
Returns a new instance of CSV2Avro.
17 18 19 20 21 22 23 24 |
# File 'lib/csv2avro.rb', line 17 def initialize() @input_path = ARGV.first @schema_path = .delete(:schema) @bad_rows_path = .delete(:bad_rows) @stdout_option = !input_path || .delete(:stdout) @options = end |
Instance Attribute Details
#bad_rows_path ⇒ Object (readonly)
Returns the value of attribute bad_rows_path.
7 8 9 |
# File 'lib/csv2avro.rb', line 7 def bad_rows_path @bad_rows_path end |
#input_path ⇒ Object (readonly)
Returns the value of attribute input_path.
7 8 9 |
# File 'lib/csv2avro.rb', line 7 def input_path @input_path end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/csv2avro.rb', line 7 def @options end |
#schema_path ⇒ Object (readonly)
Returns the value of attribute schema_path.
7 8 9 |
# File 'lib/csv2avro.rb', line 7 def schema_path @schema_path end |
#stdout_option ⇒ Object (readonly)
Returns the value of attribute stdout_option.
7 8 9 |
# File 'lib/csv2avro.rb', line 7 def stdout_option @stdout_option end |
Class Method Details
.logger ⇒ Object
9 10 11 |
# File 'lib/csv2avro.rb', line 9 def self.logger @logger ||= Logr::Logger.new('csv2avro') end |
Instance Method Details
#convert ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/csv2avro.rb', line 26 def convert logger.event('started_converting', filename: input_filename) .monitored("Started converting #{input_filename}", "Started converting #{input_filename}") .info("Started converting #{input_filename}") lines = Converter.new(reader, writer, bad_rows_writer, input_filename, , schema: schema).convert logger.event('finished_converting', filename: input_filename) .metric('lines_processed', lines) .monitored("Finished converting #{input_filename}", "Finished converting #{input_filename}, processed #{lines} lines in total.") .info("Finished converting #{input_filename}") ensure writer.close if writer bad_rows_writer.close end |
#logger ⇒ Object
13 14 15 |
# File 'lib/csv2avro.rb', line 13 def logger self.class.logger end |