ezid-client 1.9.3 → 1.10.0
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 +4 -4
- data/.dockerignore +9 -0
- data/.github/workflows/ruby.yml +1 -1
- data/Dockerfile +13 -0
- data/README.md +17 -8
- data/VERSION +1 -1
- data/lib/ezid/error.rb +2 -0
- data/lib/ezid/requests/request.rb +25 -5
- data/lib/ezid/responses/response.rb +0 -2
- data/spec/unit/client_spec.rb +3 -12
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0238bbb49530de30773410dba606a4db95117b344d452bbab62e986e06a29df8'
|
4
|
+
data.tar.gz: 8d846a6821058d66a956635d8b1863a345f086b1586716aa0fb38e71518ca90f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d37ad9714ab1403568642178f805b6b73e3c0c93df42e3202a262e35db3ad32522caa9aa4b53cc69924dc5732a798b606634b1d6a6c8cf8f25b40d28813fb9c
|
7
|
+
data.tar.gz: 536501b2cf78dbd6c276a8c010257df7ef1ad442786f4297d32c92191de17f92f165ca6ad9ae95fef606147f6791453ffbf3aa6fb584eb0e33bb647ab486339d
|
data/.dockerignore
ADDED
data/.github/workflows/ruby.yml
CHANGED
data/Dockerfile
ADDED
data/README.md
CHANGED
@@ -128,20 +128,20 @@ See http://ezid.cdlib.org/doc/apidoc.html#parameters. Repeated values should be
|
|
128
128
|
```
|
129
129
|
>> batch_download = Ezid::BatchDownload.new(:csv)
|
130
130
|
=> #<Ezid::BatchDownload format=:csv>
|
131
|
-
|
131
|
+
|
132
132
|
>> batch_download.column = ["_id", "_target"]
|
133
133
|
=> ["_id", "_target"]
|
134
|
-
|
134
|
+
|
135
135
|
>> batch_download.createdAfter = Date.today.to_time
|
136
136
|
=> 2016-02-24 00:00:00 -0500
|
137
|
-
|
137
|
+
|
138
138
|
>> batch_download
|
139
139
|
=> #<Ezid::BatchDownload column=["_id", "_target"] createdAfter=1456290000 format=:csv>
|
140
|
-
|
140
|
+
|
141
141
|
>> batch_download.url
|
142
142
|
I, [2016-02-24T18:03:40.828005 #1084] INFO -- : EZID BatchDownload -- success: http://ezid.cdlib.org/download/4a63401e17.csv.gz
|
143
143
|
=> "http://ezid.cdlib.org/download/4a63401e17.csv.gz"
|
144
|
-
|
144
|
+
|
145
145
|
>> batch_download.file
|
146
146
|
=> /current/working/directory/4a63401e17.csv.gz
|
147
147
|
```
|
@@ -155,13 +155,13 @@ I, [2016-02-24T18:03:40.828005 #1084] INFO -- : EZID BatchDownload -- success:
|
|
155
155
|
```
|
156
156
|
>> require 'ezid/batch'
|
157
157
|
=> true
|
158
|
-
|
158
|
+
|
159
159
|
>> batch = Ezid::Batch.new(:anvl, "spec/fixtures/anvl_batch.txt")
|
160
160
|
=> #<Ezid::Batch:0x007f87a8900308 @format=:anvl, @batch_file="spec/fixtures/anvl_batch.txt">
|
161
|
-
|
161
|
+
|
162
162
|
>> id = batch.first
|
163
163
|
=> #<Ezid::Identifier id=ark:/99999/fk4086hs23>
|
164
|
-
|
164
|
+
|
165
165
|
>> id.target
|
166
166
|
=> "http://example.com"
|
167
167
|
|
@@ -318,6 +318,15 @@ See http://ezid.cdlib.org/doc/apidoc.html#testing-the-api.
|
|
318
318
|
|
319
319
|
In order to run the integration tests successfully, you must supply the password for the test account "apitest" (contact EZID). To run the test suite without the integration tests, use the `rake ci` task.
|
320
320
|
|
321
|
+
## Dockerfile
|
322
|
+
|
323
|
+
A basic Dockerfile is provided based on Docker official Ruby image tags.
|
324
|
+
|
325
|
+
An example building an image with the latest Ruby and running the unit tests:
|
326
|
+
|
327
|
+
$ docker build -t ezid-client .
|
328
|
+
$ docker run --rm -it ezid-client bundle exec rspec ./spec/unit/
|
329
|
+
|
321
330
|
## Contributing
|
322
331
|
|
323
332
|
1. Fork it ( https://github.com/[my-github-username]/ezid-client/fork )
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.10.0
|
data/lib/ezid/error.rb
CHANGED
@@ -22,6 +22,10 @@ module Ezid
|
|
22
22
|
POST = Net::HTTP::Post
|
23
23
|
DELETE = Net::HTTP::Delete
|
24
24
|
|
25
|
+
RETRIABLE_SERVER_ERRORS = %w[500 502 503 504].freeze
|
26
|
+
|
27
|
+
RETRIES = ENV.fetch('EZID_REQUEST_RETRIES', '2').to_i
|
28
|
+
|
25
29
|
class << self
|
26
30
|
attr_accessor :http_method, :path, :response_class
|
27
31
|
|
@@ -37,7 +41,7 @@ module Ezid
|
|
37
41
|
end
|
38
42
|
|
39
43
|
attr_reader :client
|
40
|
-
def_delegators :client, :connection, :user, :password, :session
|
44
|
+
def_delegators :client, :connection, :user, :password, :session, :logger, :config
|
41
45
|
|
42
46
|
# @param client [Ezid::Client] the client
|
43
47
|
def initialize(client, *args)
|
@@ -50,12 +54,24 @@ module Ezid
|
|
50
54
|
# @return [Ezid::Response] the response
|
51
55
|
def execute
|
52
56
|
retries = 0
|
57
|
+
|
53
58
|
begin
|
54
|
-
|
55
|
-
|
56
|
-
if
|
57
|
-
|
59
|
+
http_response = get_response_for_request
|
60
|
+
|
61
|
+
if RETRIABLE_SERVER_ERRORS.include? http_response.code
|
62
|
+
raise ServerError, "#{http_response.code} #{http_response.msg}"
|
63
|
+
end
|
64
|
+
|
65
|
+
response_class.new(http_response)
|
66
|
+
|
67
|
+
rescue ServerError, UnexpectedResponseError => e
|
68
|
+
if retries < RETRIES
|
69
|
+
logger.error "EZID error: #{e}"
|
70
|
+
|
58
71
|
retries += 1
|
72
|
+
logger.info "Retry (#{retries} of #{RETRIES}) of #{short_name} #{path} in #{config.retry_interval} seconds ..."
|
73
|
+
sleep config.retry_interval
|
74
|
+
|
59
75
|
retry
|
60
76
|
else
|
61
77
|
raise
|
@@ -85,6 +101,10 @@ module Ezid
|
|
85
101
|
# @return [String] the query string
|
86
102
|
def query; end
|
87
103
|
|
104
|
+
def short_name
|
105
|
+
self.class.short_name
|
106
|
+
end
|
107
|
+
|
88
108
|
def authentication_required?
|
89
109
|
true
|
90
110
|
end
|
data/spec/unit/client_spec.rb
CHANGED
@@ -179,16 +179,6 @@ EOS
|
|
179
179
|
allow(GetIdentifierMetadataRequest).to receive(:execute).with(subject, "invalid") { stub_response }
|
180
180
|
end
|
181
181
|
|
182
|
-
describe "HTTP error response" do
|
183
|
-
before do
|
184
|
-
allow(http_response).to receive(:value).and_raise(Net::HTTPServerException.new('Barf!', double))
|
185
|
-
end
|
186
|
-
|
187
|
-
it "raises an exception" do
|
188
|
-
expect { subject.get_identifier_metadata("invalid") }.to raise_error(Net::HTTPServerException)
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
182
|
describe "EZID API error response" do
|
193
183
|
let(:body) { "error: bad request - no such identifier" }
|
194
184
|
|
@@ -220,11 +210,12 @@ EOS
|
|
220
210
|
|
221
211
|
describe "retrying on certain errors" do
|
222
212
|
before do
|
213
|
+
allow(subject.config).to receive(:retry_interval) { 1 }
|
223
214
|
allow(GetIdentifierMetadataResponse).to receive(:new).and_raise(exception)
|
224
215
|
end
|
225
216
|
|
226
|
-
describe "
|
227
|
-
let(:exception) {
|
217
|
+
describe "retriable server error" do
|
218
|
+
let(:exception) { ServerError.new('502 Bad Gateway') }
|
228
219
|
|
229
220
|
it "retries twice" do
|
230
221
|
begin
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ezid-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Chandek-Stark
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -121,9 +121,11 @@ executables: []
|
|
121
121
|
extensions: []
|
122
122
|
extra_rdoc_files: []
|
123
123
|
files:
|
124
|
+
- ".dockerignore"
|
124
125
|
- ".github/workflows/ruby.yml"
|
125
126
|
- ".gitignore"
|
126
127
|
- ".rspec"
|
128
|
+
- Dockerfile
|
127
129
|
- Gemfile
|
128
130
|
- LICENSE.txt
|
129
131
|
- README.md
|
@@ -185,7 +187,7 @@ homepage: https://github.com/duke-libraries/ezid-client
|
|
185
187
|
licenses:
|
186
188
|
- BSD-3-Clause
|
187
189
|
metadata: {}
|
188
|
-
post_install_message:
|
190
|
+
post_install_message:
|
189
191
|
rdoc_options: []
|
190
192
|
require_paths:
|
191
193
|
- lib
|
@@ -200,8 +202,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
202
|
- !ruby/object:Gem::Version
|
201
203
|
version: '0'
|
202
204
|
requirements: []
|
203
|
-
rubygems_version: 3.
|
204
|
-
signing_key:
|
205
|
+
rubygems_version: 3.5.6
|
206
|
+
signing_key:
|
205
207
|
specification_version: 4
|
206
208
|
summary: Ruby client for EZID API Version 2
|
207
209
|
test_files:
|