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.



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

def initialize(original)
  @original = original
end

Instance Method Details

#eachObject



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

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