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

Returns the content type for the records generated by this harvester.

Returns:

  • (String)

    the content type for the records generated by this harvester



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

Returns an enumerator of the 001 control fields from the records targeted by this harvester.

Returns:

  • (Enumerator::Lazy)

    an enumerator of the 001 control fields from the records targeted by this harvester.



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

Returns an enumerator of the records targeted by this harvester.

Returns:

  • (Enumerator::Lazy)

    an enumerator of the records targeted by this harvester.



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

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