Sha256: 8ad6085a4d896849702ee52441b5085256e013542bb933863c2f39cdba9687cd

Contents?: true

Size: 559 Bytes

Versions: 1

Compression:

Stored size: 559 Bytes

Contents

require 'rest-client'

handler = Class.new do
  def fetch(prefix, identifier)
    client = RestClient::Resource.new(Dor::Config.metadata.catalog.url)
    client["?#{prefix.chomp}=#{identifier.chomp}"].get
  end

  def label(metadata)
    mods = Nokogiri::XML(metadata)
    mods.root.add_namespace_definition('mods','http://www.loc.gov/mods/v3')
    mods.xpath('/mods:mods/mods:titleInfo[1]').xpath('mods:title|mods:nonSort').collect { |n| n.text }.join(' ').strip
  end

  def prefixes
    %w(catkey barcode)
  end
end

Dor::MetadataService.register(handler)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dor-services-5.2.0 lib/dor/services/metadata_handlers/catalog_handler.rb