Method: Traject::MockReader#load_ndjson
- Defined in:
- lib/traject/mock_reader.rb
#load_ndjson(file_io) ⇒ Object
newline delimited json, assuming no internal unescaped newlines in json too!
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/traject/mock_reader.rb', line 38 def load_ndjson(file_io) records = [] this_file_iter = file_io.each_line while true line = this_file_iter.next break if /^\_\_END\_\_/.match line end begin while true json = this_file_iter.next next unless /\S/.match json records << MARC::Record.new_from_hash(JSON.parse(json)) end rescue StopIteration end return records end |