class Gared::Aleph
Public Class Methods
new(host, port, database, syntax = 'USMARC')
click to toggle source
# File lib/gared/aleph.rb, line 21 def initialize(host, port, database, syntax = 'USMARC') @options = {host: host, port: port, database: database, syntax: syntax} end
Public Instance Methods
query_person(person)
click to toggle source
# File lib/gared/aleph.rb, line 27 def query_person(person) end
query_persons(q)
click to toggle source
# File lib/gared/aleph.rb, line 24 def query_persons(q) end
query_publication(publication)
click to toggle source
# File lib/gared/aleph.rb, line 33 def query_publication(publication) end
query_publications(q)
click to toggle source
# File lib/gared/aleph.rb, line 30 def query_publications(q) end
query_publications_by_person(person, ctx = nil)
click to toggle source
# File lib/gared/aleph.rb, line 36 def query_publications_by_person(person, ctx = nil) ZOOM::Connection.open(@options[:host], @options[:port]) do |conn| conn.database_name = @options[:database] # 'aleph.nli.org.il',9991 conn.preferred_record_syntax = @options[:syntax] rset = conn.search("@attr 1=1003 @attr 2=3 @attr 4=1 \"#{person}\"") rr = rset.records return nil if rr.nil? or rr.empty? ret = [] rr.each do |r| xml = Nokogiri::Slop(r.xml) xml.remove_namespaces! # keeps biting me :) # these scrapes are based on the National Library of Israel usage. No attempt to make it generic. :) p = Publication.new(ctx) begin p.author_line = xml.xpath('//datafield[@tag=\'100\']/subfield[@code=\'a\']')[0].text # puts "author: #{p.author_line}" # DEBUG rescue nil end begin p.title = xml.xpath('//datafield[@tag=\'245\']/subfield[@code=\'a\']')[0].text # puts "title: #{p.title}" # DEBUG rescue nil end begin p.notes = xml.xpath('//datafield[@tag=\'500\']/subfield[@code=\'a\']').collect{|note| note.text}.join("\n") rescue nil end begin h = Holding.new h.source_id = xml.xpath('//datafield[@tag=\'090\']/subfield[@code=\'a\']')[0].text h.source_name = @options[:database] p.add_holding(h) ret << p rescue nil # ignore records with no holdings; they may be archival files or other non-publications end # end return ret end end