Class: Krikri::Harvesters::MarcXMLHarvester

Inherits:
Object
  • Object
show all
Includes:
Krikri::Harvester
Defined in:
lib/krikri/harvesters/marc_xml_harvester.rb

Overview

A harvester implementation for reading MARC XML documents from a source.

Subclasses of MarcXMLHarvester are expected to implement the following methods:

- #each_collection (yields one or more IO objects containing a MARC XML
- #collection)

Constant Summary

Constants included from Krikri::Harvester

Krikri::Harvester::Registry

Instance Attribute Summary

Attributes included from Krikri::Harvester

#name, #uri

Attributes included from SoftwareAgent

#entity_behavior

Instance Method Summary collapse

Methods included from Krikri::Harvester

#count, expected_opts, #get_record, #initialize, #run

Methods included from SoftwareAgent

#agent_name, #run

Instance Method Details

#content_typeString



39
40
41
# File 'lib/krikri/harvesters/marc_xml_harvester.rb', line 39

def content_type
  'text/xml'
end

#each_collection {|Enumerable<IO>| ... } ⇒ Object

This method is abstract.

Yields:

  • (Enumerable<IO>)

    gives a collection of IO objects representing XML to be parsed into the record.

Raises:

  • (NotImplementedError)


18
19
20
# File 'lib/krikri/harvesters/marc_xml_harvester.rb', line 18

def each_collection
  raise NotImplementedError
end

#record_idsEnumerator::Lazy



32
33
34
# File 'lib/krikri/harvesters/marc_xml_harvester.rb', line 32

def record_ids
  enumerate_records.lazy.map { |rec| rec.identifier }
end

#recordsEnumerator::Lazy



25
26
27
# File 'lib/krikri/harvesters/marc_xml_harvester.rb', line 25

def records
  enumerate_records.lazy.map { |rec| build_record(rec) }
end