Class: NewspaperWorks::Ingest::ChronAmPublicationInfo
- Inherits:
-
BasePublicationInfo
- Object
- BasePublicationInfo
- NewspaperWorks::Ingest::ChronAmPublicationInfo
- Defined in:
- lib/newspaper_works/ingest/chronam_publication_info.rb
Overview
Publication info from ChronAm as remote authority for metadata
Constant Summary collapse
- XML_NS =
{ dcterms: 'http://purl.org/dc/terms/', frbr: 'http://purl.org/vocab/frbr/core#', owl: 'http://www.w3.org/2002/07/owl#', rda: 'http://rdvocab.info/elements/', rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', rdfs: 'http://www.w3.org/2000/01/rdf-schema#' }.freeze
- BASE_URL =
'https://chroniclingamerica.loc.gov/lccn'.freeze
Instance Attribute Summary collapse
-
#issn ⇒ Object
Returns the value of attribute issn.
-
#language ⇒ Object
Returns the value of attribute language.
-
#place_name ⇒ Object
Returns the value of attribute place_name.
-
#place_of_publication ⇒ Object
Returns the value of attribute place_of_publication.
-
#title ⇒ Object
Returns the value of attribute title.
Attributes inherited from BasePublicationInfo
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(lccn) ⇒ ChronAmPublicationInfo
constructor
A new instance of ChronAmPublicationInfo.
- #inspect ⇒ Object
- #load ⇒ Object
- #load_place ⇒ Object
- #oclcnum ⇒ Object
- #preceded_by ⇒ Object
- #succeeded_by ⇒ Object
- #url ⇒ Object
Methods inherited from BasePublicationInfo
#oclc_prefixed, #place_name_from_title
Constructor Details
#initialize(lccn) ⇒ ChronAmPublicationInfo
Returns a new instance of ChronAmPublicationInfo.
21 22 23 24 25 26 |
# File 'lib/newspaper_works/ingest/chronam_publication_info.rb', line 21 def initialize(lccn) # true until loaded @empty = true super(lccn) @issn = nil # chronam doesn't have this end |
Instance Attribute Details
#issn ⇒ Object
Returns the value of attribute issn.
8 9 10 |
# File 'lib/newspaper_works/ingest/chronam_publication_info.rb', line 8 def issn @issn end |
#language ⇒ Object
Returns the value of attribute language.
8 9 10 |
# File 'lib/newspaper_works/ingest/chronam_publication_info.rb', line 8 def language @language end |
#place_name ⇒ Object
Returns the value of attribute place_name.
8 9 10 |
# File 'lib/newspaper_works/ingest/chronam_publication_info.rb', line 8 def place_name @place_name end |
#place_of_publication ⇒ Object
Returns the value of attribute place_of_publication.
8 9 10 |
# File 'lib/newspaper_works/ingest/chronam_publication_info.rb', line 8 def place_of_publication @place_of_publication end |
#title ⇒ Object
Returns the value of attribute title.
8 9 10 |
# File 'lib/newspaper_works/ingest/chronam_publication_info.rb', line 8 def title @title end |
Instance Method Details
#empty? ⇒ Boolean
28 29 30 |
# File 'lib/newspaper_works/ingest/chronam_publication_info.rb', line 28 def empty? @empty end |
#inspect ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/newspaper_works/ingest/chronam_publication_info.rb', line 32 def inspect format( "<#{self.class}:0x000000000%<oid>x " \ "\tlccn: '#{@lccn}'>", oid: object_id << 1 ) end |
#load ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/newspaper_works/ingest/chronam_publication_info.rb', line 53 def load resp = NewspaperWorks::ResourceFetcher.get url return if resp['status'] == 404 @doc = Nokogiri.XML(resp['body']) @title = normalize_title(find('//dcterms:title').first.text) @language = iso_language_for(find('//dcterms:language').first.text) @empty = false load_place end |
#load_place ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/newspaper_works/ingest/chronam_publication_info.rb', line 40 def load_place place_match = find('//rda:placeOfPublication') return if place_match.nil? @place_name = place_match.first.text @place_of_publication = NewspaperWorks::Ingest.geonames_place_uri( @place_name ) end |
#oclcnum ⇒ Object
63 64 65 66 67 68 |
# File 'lib/newspaper_works/ingest/chronam_publication_info.rb', line 63 def oclcnum key = 'info:oclcnum' selected = sameas_resources.select { |v| v.text.start_with?(key) } return if selected.empty? oclc_prefixed(selected[0].text.split('/')[1]) end |
#preceded_by ⇒ Object
70 71 72 73 74 75 |
# File 'lib/newspaper_works/ingest/chronam_publication_info.rb', line 70 def preceded_by return if empty? found = find('//frbr:successorOf/@rdf:resource').first return if found.nil? (found.text) end |
#succeeded_by ⇒ Object
77 78 79 80 81 82 |
# File 'lib/newspaper_works/ingest/chronam_publication_info.rb', line 77 def succeeded_by return if empty? found = find('//frbr:successor/@rdf:resource').first return if found.nil? (found.text) end |
#url ⇒ Object
49 50 51 |
# File 'lib/newspaper_works/ingest/chronam_publication_info.rb', line 49 def url "#{BASE_URL}/#{@lccn}.rdf" end |