harvestdor-indexer 2.3.2 → 2.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4450922f3ca88b01fa640e422b3034573d8ffcd
|
4
|
+
data.tar.gz: 982f4537396650e5df6b180335bd8243dc7d8212
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f82640a960c1274a685c65499f49f8e1b432fb8f95bc2e7a5d45f83bae007c8dba3c92c03c33d4a1311399657f83c012e3c08499c45d1f44bce93c726ee8f528
|
7
|
+
data.tar.gz: 17b1176e6de1ccdaae08b09fb8190615bfc4c7e6768ed5762b25fee7abdc77cdeb4ad41d73125bc6ef1e02bd648f70be071b12dff8e94de4eb07044d1302065b
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# rubocop:disable Metrics/ClassLength
|
2
1
|
require 'active_support/benchmarkable'
|
3
2
|
|
4
3
|
module Harvestdor
|
@@ -99,15 +98,13 @@ module Harvestdor
|
|
99
98
|
# @return [Nokogiri::XML::Document] the public xml for the DOR object
|
100
99
|
def public_xml
|
101
100
|
@public_xml ||= benchmark "public_xml(#{druid})", level: :debug do
|
102
|
-
|
103
|
-
raise "No public xml for #{druid}" unless ng_doc
|
104
|
-
raise "Empty public xml for #{druid}: #{ng_doc.to_xml}" if ng_doc.root.xpath('//text()').empty?
|
105
|
-
ng_doc
|
101
|
+
harvestdor_client.public_xml bare_druid
|
106
102
|
end
|
107
103
|
end
|
108
104
|
|
109
105
|
##
|
110
106
|
# Has the public_xml been previously retrieved?
|
107
|
+
# @deprecated
|
111
108
|
def public_xml?
|
112
109
|
!!@public_xml
|
113
110
|
end
|
@@ -115,6 +112,7 @@ module Harvestdor
|
|
115
112
|
##
|
116
113
|
# Get the public_xml, if retrieved, or the druid. This is used to short-circuit
|
117
114
|
# retrieving metadata out of the public xml.
|
115
|
+
# @deprecated
|
118
116
|
def public_xml_or_druid
|
119
117
|
if public_xml?
|
120
118
|
public_xml
|
@@ -127,40 +125,32 @@ module Harvestdor
|
|
127
125
|
# @return [Nokogiri::XML::Document] the contentMetadata for the DOR object
|
128
126
|
def content_metadata
|
129
127
|
@content_metadata ||= benchmark "content_metadata (#{druid})", level: :debug do
|
130
|
-
harvestdor_client.content_metadata
|
128
|
+
harvestdor_client.content_metadata public_xml
|
131
129
|
end
|
132
|
-
raise "No contentMetadata for \"#{druid}\"" if !@content_metadata || @content_metadata.children.empty?
|
133
|
-
@content_metadata
|
134
130
|
end
|
135
131
|
|
136
132
|
# the identityMetadata for this DOR object, ultimately from the purl public xml
|
137
133
|
# @return [Nokogiri::XML::Document] the identityMetadata for the DOR object
|
138
134
|
def identity_metadata
|
139
135
|
@identity_metadata ||= benchmark "identity_metadata (#{druid})", level: :debug do
|
140
|
-
harvestdor_client.identity_metadata
|
136
|
+
harvestdor_client.identity_metadata public_xml
|
141
137
|
end
|
142
|
-
raise "No identityMetadata for \"#{druid}\"" if !@identity_metadata || @identity_metadata.children.empty?
|
143
|
-
@identity_metadata
|
144
138
|
end
|
145
139
|
|
146
140
|
# the rightsMetadata for this DOR object, ultimately from the purl public xml
|
147
141
|
# @return [Nokogiri::XML::Document] the rightsMetadata for the DOR object
|
148
142
|
def rights_metadata
|
149
143
|
@rights_metadata ||= benchmark "rights_metadata (#{druid})", level: :debug do
|
150
|
-
harvestdor_client.rights_metadata
|
144
|
+
harvestdor_client.rights_metadata public_xml
|
151
145
|
end
|
152
|
-
raise "No rightsMetadata for \"#{druid}\"" if !@rights_metadata || @rights_metadata.children.empty?
|
153
|
-
@rights_metadata
|
154
146
|
end
|
155
147
|
|
156
148
|
# the RDF for this DOR object, ultimately from the purl public xml
|
157
149
|
# @return [Nokogiri::XML::Document] the RDF for the DOR object
|
158
150
|
def rdf
|
159
151
|
@rdf ||= benchmark "rdf (#{druid})", level: :debug do
|
160
|
-
harvestdor_client.rdf
|
152
|
+
harvestdor_client.rdf public_xml
|
161
153
|
end
|
162
|
-
raise "No RDF for \"#{druid}\"" if !@rdf || @rdf.children.empty?
|
163
|
-
@rdf
|
164
154
|
end
|
165
155
|
|
166
156
|
def eql?(other)
|
@@ -19,6 +19,8 @@ describe Harvestdor::Indexer::Resource do
|
|
19
19
|
described_class.new(@indexer, @fake_druid)
|
20
20
|
end
|
21
21
|
|
22
|
+
let(:blank_public_xml) { Nokogiri::XML::Document.new }
|
23
|
+
|
22
24
|
subject { resource }
|
23
25
|
|
24
26
|
describe '#items' do
|
@@ -98,14 +100,6 @@ describe Harvestdor::Indexer::Resource do
|
|
98
100
|
expect(px.root.name).to eq('publicObject')
|
99
101
|
expect(px.root.attributes['id'].text).to eq("druid:#{@fake_druid}")
|
100
102
|
end
|
101
|
-
it 'raises exception if public xml for the druid is empty' do
|
102
|
-
expect(@hdor_client).to receive(:public_xml).with(@fake_druid).and_return(Nokogiri::XML('<publicObject/>'))
|
103
|
-
expect { resource.public_xml }.to raise_error(RuntimeError, Regexp.new("^Empty public xml for #{@fake_druid}: <"))
|
104
|
-
end
|
105
|
-
it 'raises error if there is no public_xml page for the druid' do
|
106
|
-
expect(@hdor_client).to receive(:public_xml).with(@fake_druid).and_return(nil)
|
107
|
-
expect { resource.public_xml }.to raise_error(RuntimeError, "No public xml for #{@fake_druid}")
|
108
|
-
end
|
109
103
|
end
|
110
104
|
context '#content_metadata' do
|
111
105
|
it 'returns a Nokogiri::XML::Document derived from the public xml if a druid is passed' do
|
@@ -117,10 +111,6 @@ describe Harvestdor::Indexer::Resource do
|
|
117
111
|
expect(cm.root.attributes['objectId'].text).to eq(@fake_druid)
|
118
112
|
expect(cm.root.text.strip).to eq('foo')
|
119
113
|
end
|
120
|
-
it 'raises RuntimeError if nil is returned by Harvestdor::Client.contentMetadata for the druid' do
|
121
|
-
expect(@hdor_client).to receive(:content_metadata).with(@fake_druid).and_return(nil)
|
122
|
-
expect { resource.content_metadata }.to raise_error(RuntimeError, "No contentMetadata for \"#{@fake_druid}\"")
|
123
|
-
end
|
124
114
|
end
|
125
115
|
context '#identity_metadata' do
|
126
116
|
it 'returns a Nokogiri::XML::Document derived from the public xml if a druid is passed' do
|
@@ -131,10 +121,6 @@ describe Harvestdor::Indexer::Resource do
|
|
131
121
|
expect(im.root.name).to eq('identityMetadata')
|
132
122
|
expect(im.root.text.strip).to eq("druid:#{@fake_druid}")
|
133
123
|
end
|
134
|
-
it 'raises RuntimeError if nil is returned by Harvestdor::Client.identityMetadata for the druid' do
|
135
|
-
expect(@hdor_client).to receive(:identity_metadata).with(@fake_druid).and_return(nil)
|
136
|
-
expect { resource.identity_metadata }.to raise_error(RuntimeError, "No identityMetadata for \"#{@fake_druid}\"")
|
137
|
-
end
|
138
124
|
end
|
139
125
|
context '#rights_metadata' do
|
140
126
|
it 'returns a Nokogiri::XML::Document derived from the public xml if a druid is passed' do
|
@@ -145,10 +131,6 @@ describe Harvestdor::Indexer::Resource do
|
|
145
131
|
expect(im.root.name).to eq('rightsMetadata')
|
146
132
|
expect(im.root.text.strip).to eq('bar')
|
147
133
|
end
|
148
|
-
it 'raises RuntimeError if nil is returned by Harvestdor::Client.rightsMetadata for the druid' do
|
149
|
-
expect(@hdor_client).to receive(:rights_metadata).with(@fake_druid).and_return(nil)
|
150
|
-
expect { resource.rights_metadata }.to raise_error(RuntimeError, "No rightsMetadata for \"#{@fake_druid}\"")
|
151
|
-
end
|
152
134
|
end
|
153
135
|
context '#rdf' do
|
154
136
|
it 'returns a Nokogiri::XML::Document derived from the public xml if a druid is passed' do
|
@@ -159,10 +141,6 @@ describe Harvestdor::Indexer::Resource do
|
|
159
141
|
expect(im.root.name).to eq('RDF')
|
160
142
|
expect(im.root.text.strip).to eq('relationship!')
|
161
143
|
end
|
162
|
-
it 'raises RuntimeError if nil is returned by Harvestdor::Client.rdf for the druid' do
|
163
|
-
expect(@hdor_client).to receive(:rdf).with(@fake_druid).and_return(nil)
|
164
|
-
expect { resource.rdf }.to raise_error(RuntimeError, "No RDF for \"#{@fake_druid}\"")
|
165
|
-
end
|
166
144
|
end
|
167
145
|
|
168
146
|
describe '#public_xml_or_druid' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: harvestdor-indexer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naomi Dushay
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-07-
|
13
|
+
date: 2016-07-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rsolr
|