Class: Bulkrax::CsvEntry::CsvWrapper

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
app/models/bulkrax/csv_entry.rb

Overview

The purpose of this class is to reject empty lines. This causes lots of grief in importing. But why not use CSV.read‘s `skip_lines` option? Because for some CSVs, it will never finish reading the file.

There is a spec that demonstrates this approach works.

Instance Method Summary collapse

Constructor Details

#initialize(original) ⇒ CsvWrapper

Returns a new instance of CsvWrapper.



38
39
40
# File 'app/models/bulkrax/csv_entry.rb', line 38

def initialize(original)
  @original = original
end

Instance Method Details

#eachObject



44
45
46
47
48
49
# File 'app/models/bulkrax/csv_entry.rb', line 44

def each
  @original.each do |row|
    next if all_fields_are_empty_for(row: row)
    yield(row)
  end
end