Class: Qa::Services::RDFAuthorityParser

Inherits:
Object
  • Object
show all
Defined in:
lib/qa/services/rdf_authority_parser.rb

Overview

Class to parse downloaded content from rdf sources such as Library of Congress and Lexvo to create LocalAuthorityEntries for a named LocalAuthority.

Example calls: RDFAuthorityParser.import_rdf(‘subjects’,) RDFAuthorityParser.import_rdf(‘languages’,,

format: 'rdfxml',
predicate: RDF::URI("http://www.w3.org/2008/05/skos#prefLabel"))

Class Method Summary collapse

Class Method Details

.import_rdf(name, sources, opts = {}) ⇒ Object

import the rdf from the sources and store them as entries for the named LocalAuthority

defaults to :ntripples
defaults to http://www.w3.org/2004/02/skos/core#prefLabel

Parameters:

  • name (String)

    The name of the authority to update

  • sources (Array)

    An array of file names to process

  • opts (Hash) (defaults to: {})

    options for processing

  • [opts] (Hash)

    a customizable set of options



29
30
31
32
33
34
35
36
# File 'lib/qa/services/rdf_authority_parser.rb', line 29

def import_rdf(name, sources, opts = {})
  authority = Qa::LocalAuthority.find_or_create_by(name: name)
  format = opts.fetch(:format, :ntriples)
  predicate = opts.fetch(:predicate, ::RDF::Vocab::SKOS.prefLabel)
  sources.each do |uri|
    import_source(authority, format, predicate, uri)
  end
end