harvestdor 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -6
- data/harvestdor.gemspec +1 -0
- data/lib/harvestdor/purl_xml.rb +17 -4
- data/lib/harvestdor/version.rb +1 -1
- data/lib/harvestdor.rb +1 -1
- data/spec/purl_xml_spec.rb +6 -6
- metadata +17 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 512b556fbe2a3547829f7ea157be1e984d302294
|
4
|
+
data.tar.gz: b6512cb57d70adea02eef25519ff0d3265253305
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27c95f0765aa2c5a44729b5620e59fc942e490096da2d64a066e4bf3ab4babfa9c52d508b8736fcf15d268e3c917a0269ed42cdf189f4add3f933bc17617564e
|
7
|
+
data.tar.gz: 7094c91f20e889b729f1c507629fae1875e8f6125a4562bd1163accadd7fe42ceb2162aadc3a055fd3af3f08708bdc9efd6772f9d8b4a9b0c647019357746dff
|
data/.travis.yml
CHANGED
data/harvestdor.gemspec
CHANGED
data/lib/harvestdor/purl_xml.rb
CHANGED
@@ -13,8 +13,8 @@ module Harvestdor
|
|
13
13
|
# @return [Nokogiri::XML::Document] the MODS for the fedora object
|
14
14
|
def self.mods druid, purl_url = Harvestdor::PURL_DEFAULT
|
15
15
|
begin
|
16
|
-
Nokogiri::XML(
|
17
|
-
rescue
|
16
|
+
Nokogiri::XML(http_client.get("#{purl_url}/#{druid}.mods").body,nil,'UTF-8')
|
17
|
+
rescue Faraday::Error::ClientError
|
18
18
|
raise Harvestdor::Errors::MissingMods.new(druid)
|
19
19
|
end
|
20
20
|
end
|
@@ -26,10 +26,10 @@ module Harvestdor
|
|
26
26
|
def self.public_xml druid, purl_url = Harvestdor::PURL_DEFAULT
|
27
27
|
return druid if druid.instance_of?(Nokogiri::XML::Document)
|
28
28
|
begin
|
29
|
-
ng_doc = Nokogiri::XML(
|
29
|
+
ng_doc = Nokogiri::XML(http_client.get("#{purl_url}/#{druid}.xml").body)
|
30
30
|
raise Harvestdor::Errors::MissingPublicXml.new(druid) if !ng_doc || ng_doc.children.empty?
|
31
31
|
ng_doc
|
32
|
-
rescue
|
32
|
+
rescue Faraday::Error::ClientError
|
33
33
|
raise Harvestdor::Errors::MissingPurlPage.new(druid)
|
34
34
|
end
|
35
35
|
end
|
@@ -137,5 +137,18 @@ module Harvestdor
|
|
137
137
|
end
|
138
138
|
pub_xml_ng_doc
|
139
139
|
end
|
140
|
+
|
141
|
+
def self.http_client
|
142
|
+
@http_client ||= Faraday.new do |conn|
|
143
|
+
conn.adapter Faraday.default_adapter
|
144
|
+
conn.use Faraday::Response::RaiseError
|
145
|
+
conn.request :retry, max: 5,
|
146
|
+
interval: 0.05,
|
147
|
+
interval_randomness: 0.5,
|
148
|
+
backoff_factor: 2,
|
149
|
+
exceptions: ['Errno::ECONNRESET', 'Errno::ETIMEDOUT', 'Timeout::Error', 'Faraday::Error::TimeoutError', 'Faraday::Error::ConnectionFailed']
|
150
|
+
end
|
151
|
+
end
|
152
|
+
private_class_method :http_client
|
140
153
|
|
141
154
|
end # module Harvestdor
|
data/lib/harvestdor/version.rb
CHANGED
data/lib/harvestdor.rb
CHANGED
data/spec/purl_xml_spec.rb
CHANGED
@@ -40,7 +40,7 @@ describe Harvestdor::Client do
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
it "raises Harvestdor::Errors::MissingPublicXML if purl page returns nil document" do
|
43
|
-
|
43
|
+
expect(Harvestdor.send(:http_client)).to receive(:get).and_return(double(body: nil))
|
44
44
|
expect { Harvestdor.public_xml(@fake_druid, @purl) }.to raise_error(Harvestdor::Errors::MissingPublicXml)
|
45
45
|
end
|
46
46
|
end
|
@@ -89,7 +89,7 @@ describe Harvestdor::Client do
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
it "returns a Nokogiri::XML::Document from passed Nokogiri::XML::Document and does no fetch" do
|
92
|
-
|
92
|
+
expect(Harvestdor.send(:http_client)).not_to receive(:get)
|
93
93
|
im = Harvestdor.identity_metadata(@ng_pub_xml)
|
94
94
|
expect(im).to be_kind_of(Nokogiri::XML::Document)
|
95
95
|
expect(im.root.name).to eql('identityMetadata')
|
@@ -110,7 +110,7 @@ describe Harvestdor::Client do
|
|
110
110
|
end
|
111
111
|
end
|
112
112
|
it "returns a Nokogiri::XML::Document from passed Nokogiri::XML::Document and does no fetch" do
|
113
|
-
|
113
|
+
expect(Harvestdor.send(:http_client)).not_to receive(:get)
|
114
114
|
rm = Harvestdor.rights_metadata(@ng_pub_xml)
|
115
115
|
expect(rm).to be_kind_of(Nokogiri::XML::Document)
|
116
116
|
expect(rm.root.name).to eql('rightsMetadata')
|
@@ -131,7 +131,7 @@ describe Harvestdor::Client do
|
|
131
131
|
end
|
132
132
|
end
|
133
133
|
it "returns a Nokogiri::XML::Document from passed Nokogiri::XML::Document and does no fetch" do
|
134
|
-
|
134
|
+
expect(Harvestdor.send(:http_client)).not_to receive(:get)
|
135
135
|
rdf = Harvestdor.rdf(@ng_pub_xml)
|
136
136
|
expect(rdf).to be_kind_of(Nokogiri::XML::Document)
|
137
137
|
expect(rdf.root.name).to eql('RDF')
|
@@ -153,7 +153,7 @@ describe Harvestdor::Client do
|
|
153
153
|
end
|
154
154
|
end
|
155
155
|
it "returns a Nokogiri::XML::Document from passed Nokogiri::XML::Document and does no fetch" do
|
156
|
-
|
156
|
+
expect(Harvestdor.send(:http_client)).not_to receive(:get)
|
157
157
|
dc = Harvestdor.dc(@ng_pub_xml)
|
158
158
|
expect(dc).to be_kind_of(Nokogiri::XML::Document)
|
159
159
|
expect(dc.root.name).to eql('dc')
|
@@ -199,7 +199,7 @@ describe Harvestdor::Client do
|
|
199
199
|
@client.mods(@druid)
|
200
200
|
end
|
201
201
|
it "methods for parts of public_xml should work with Nokogiri::XML::Document arg (and not fetch)" do
|
202
|
-
|
202
|
+
expect(Harvestdor.send(:http_client)).not_to receive(:get)
|
203
203
|
expect(@client.content_metadata(@ng_pub_xml)).to be_kind_of(Nokogiri::XML::Document)
|
204
204
|
expect(@client.identity_metadata(@ng_pub_xml)).to be_kind_of(Nokogiri::XML::Document)
|
205
205
|
expect(@client.rights_metadata(@ng_pub_xml)).to be_kind_of(Nokogiri::XML::Document)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: harvestdor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naomi Dushay
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: confstruct
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: faraday
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -219,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
219
233
|
version: '0'
|
220
234
|
requirements: []
|
221
235
|
rubyforge_project:
|
222
|
-
rubygems_version: 2.
|
236
|
+
rubygems_version: 2.5.1
|
223
237
|
signing_key:
|
224
238
|
specification_version: 4
|
225
239
|
summary: Harvest DOR object metadata
|
@@ -236,4 +250,3 @@ test_files:
|
|
236
250
|
- spec/harvestdor_client_spec.rb
|
237
251
|
- spec/purl_xml_spec.rb
|
238
252
|
- spec/spec_helper.rb
|
239
|
-
has_rdoc:
|