Method: Krikri::Harvesters::OAIHarvester#records

Defined in:
lib/krikri/harvesters/oai_harvester.rb

#records(opts = {}) ⇒ Object

Sends ListRecords requests lazily.

The following will only send requests to the endpoint until it has 1000 records:

records.take(1000)

See Also:

  • #expected_opts


91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/krikri/harvesters/oai_harvester.rb', line 91

def records(opts = {})
  opts = @opts.merge(opts)
  request_with_sets(opts) do |set_opts|
    client.list_records(set_opts).full.lazy.flat_map do |rec|
      begin
        @record_class.build(mint_id(get_identifier(rec)),
                            record_xml(rec))
      rescue => e
        Krikri::Logger.log(:error, e.message)
        next
      end
    end
  end
end