Skip to content

Commit 4b64d39

Browse files
authored
escape-nil-comparisons (#604)
* account for custom work types in #sort_entries * do not export custom work entry types
1 parent e4d7677 commit 4b64d39

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

app/parsers/bulkrax/csv_parser.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,10 @@ def file_set_entry_class
283283
CsvFileSetEntry
284284
end
285285

286+
def valid_entry_types
287+
['Bulkrax::CsvCollectionEntry', 'Bulkrax::CsvFileSetEntry', 'Bulkrax::CsvEntry']
288+
end
289+
286290
# TODO: figure out why using the version of this method that's in the bagit parser
287291
# breaks specs for the "if importer?" line
288292
def total
@@ -325,6 +329,7 @@ def write_files
325329
require 'open-uri'
326330
folder_count = 0
327331
sorted_entries = sort_entries(importerexporter.entries.uniq(&:identifier))
332+
.select { |e| valid_entry_types.include?(e.type) }
328333

329334
sorted_entries[0..limit || total].in_groups_of(records_split_count, false) do |group|
330335
folder_count += 1
@@ -391,12 +396,12 @@ def sort_entries(entries)
391396
# always export models in the same order: work, collection, file set
392397
entries.sort_by do |entry|
393398
case entry.type
394-
when 'Bulkrax::CsvEntry'
395-
'0'
396399
when 'Bulkrax::CsvCollectionEntry'
397400
'1'
398401
when 'Bulkrax::CsvFileSetEntry'
399402
'2'
403+
else
404+
'0'
400405
end
401406
end
402407
end

0 commit comments

Comments
 (0)