ezid-client 1.9.4 → 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 +1 -0
 - data/.github/workflows/ruby.yml +1 -1
 - data/Dockerfile +4 -4
 - 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 +6 -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
    CHANGED
    
    
    
        data/.github/workflows/ruby.yml
    CHANGED
    
    
    
        data/Dockerfile
    CHANGED
    
    | 
         @@ -4,10 +4,10 @@ FROM ruby:${ruby_version} 
     | 
|
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            SHELL ["/bin/bash", "-c"]
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
            RUN gem install bundler -v '~>2.0'
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
7 
     | 
    
         
             
            WORKDIR /app
         
     | 
| 
       10 
8 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
            COPY .  
     | 
| 
      
 9 
     | 
    
         
            +
            COPY VERSION Gemfile ezid-client.gemspec ./
         
     | 
| 
       12 
10 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
            RUN bundle install
         
     | 
| 
      
 11 
     | 
    
         
            +
            RUN gem install bundler -v '~>2.0' && bundle install
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            COPY . .
         
     | 
    
        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
         
     | 
| 
         @@ -187,7 +187,7 @@ homepage: https://github.com/duke-libraries/ezid-client 
     | 
|
| 
       187 
187 
     | 
    
         
             
            licenses:
         
     | 
| 
       188 
188 
     | 
    
         
             
            - BSD-3-Clause
         
     | 
| 
       189 
189 
     | 
    
         
             
            metadata: {}
         
     | 
| 
       190 
     | 
    
         
            -
            post_install_message: 
     | 
| 
      
 190 
     | 
    
         
            +
            post_install_message:
         
     | 
| 
       191 
191 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       192 
192 
     | 
    
         
             
            require_paths:
         
     | 
| 
       193 
193 
     | 
    
         
             
            - lib
         
     | 
| 
         @@ -202,8 +202,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       202 
202 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       203 
203 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       204 
204 
     | 
    
         
             
            requirements: []
         
     | 
| 
       205 
     | 
    
         
            -
            rubygems_version: 3. 
     | 
| 
       206 
     | 
    
         
            -
            signing_key: 
     | 
| 
      
 205 
     | 
    
         
            +
            rubygems_version: 3.5.6
         
     | 
| 
      
 206 
     | 
    
         
            +
            signing_key:
         
     | 
| 
       207 
207 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       208 
208 
     | 
    
         
             
            summary: Ruby client for EZID API Version 2
         
     | 
| 
       209 
209 
     | 
    
         
             
            test_files:
         
     |