dor-workflow-client 3.12.0 → 3.13.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5cbb16ceddf569a9b82c822b1b885ebba29b592cd012ae340cb76882c61cc3d8
4
- data.tar.gz: 4f1a7c2f940898abb328618ba1a8e09628fcf5a232e146b5546811a2bd3c223f
3
+ metadata.gz: ea39b8e90466517fda9d9c0c8a7d1e6bfe2fe09d38566e51db76031e2768eae0
4
+ data.tar.gz: d75001c1f99852c3cd0410ea5cb018abf713162c04fcc81cc43c58817bcae34a
5
5
  SHA512:
6
- metadata.gz: 228c451516708789a413be980b76fe25cb1efa7cf12865763291350ff86b2bdb63adfae2390ad02c3ef5fe33a213e68213a5a8dfb35a99531bded86fe396e21b
7
- data.tar.gz: 42646cbdf62345f5128f7cc7c3391f245a387d6255734ddd498c71f38d82e6f6ec6ddbd2d3ad33c553abc09a9fee6525276343f7e6802cda1ed156aa8d55f643
6
+ metadata.gz: 6e414f5936d21fed90a4690ada9cf3df8c6130734c043a9b0e4c178c8fbe17f5320547dc83c0982e17ee11fb660054b644f8d57cf873128ca91fd05aabe31dc7
7
+ data.tar.gz: cc096fad25055d2f31fb3344d9af42fddeeb36aa90a12795a620c6b6a14dbd1946fd3996902a6092ecb352bc49bd10f6ef51eab2fd585faf4e039796c6e8fdae
data/Gemfile CHANGED
@@ -9,5 +9,4 @@ gem 'activesupport', ENV['RAILS_VERSION'] if ENV['RAILS_VERSION']
9
9
 
10
10
  group :development, :test do
11
11
  gem 'byebug'
12
- gem 'simplecov'
13
12
  end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dor
4
+ class MissingWorkflowException < WorkflowException
5
+ end
6
+ end
@@ -18,13 +18,21 @@ module Dor
18
18
  # @param [String] payload body for (e.g. put) request
19
19
  # @param [Hash] opts addtional headers options
20
20
  # @return [Object] response from method
21
+ # @raise [Dor::WorkflowException,Dor::MissingWorkflowException] if there are Faraday exceptions
21
22
  def request(uri_string, meth = 'get', payload = '', opts = {})
22
23
  response = send_workflow_resource_request(uri_string, meth, payload, opts)
23
24
  response.body
24
25
  rescue Faraday::Error => e
26
+ # `status` is set to `nil` if:
27
+ # * `e` does not respond to `:response`
28
+ # * `e` responds to `:response` and:
29
+ # * `e.response` is `nil`
30
+ # * `e.response` is a hash missing the `:status` key
31
+ # else it is set to the value of `e.response[:status]`
32
+ status = e.try(:response)&.fetch(:status, nil)
25
33
  msg = "Failed to retrieve resource: #{meth} #{base_url}/#{uri_string}"
26
- msg += " (HTTP status #{e.response[:status]})" if e.respond_to?(:response) && e.response
27
- raise Dor::WorkflowException, msg
34
+ msg += " (HTTP status #{status})" unless status.nil?
35
+ raise (status == 404 ? Dor::MissingWorkflowException : Dor::WorkflowException), msg
28
36
  end
29
37
 
30
38
  private
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Workflow
5
5
  class Client
6
- VERSION = '3.12.0'
6
+ VERSION = '3.13.0'
7
7
  end
8
8
  end
9
9
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dor
4
- class WorkflowException < ::RuntimeError
4
+ class WorkflowException < RuntimeError
5
5
  end
6
6
  end
@@ -329,9 +329,17 @@ RSpec.describe Dor::Workflow::Client do
329
329
  end
330
330
  end
331
331
 
332
- context 'when it fails for any reason' do
332
+ context 'when the status is not found' do
333
333
  let(:status) { 404 }
334
334
 
335
+ it 'throws the missing workflow exception' do
336
+ expect { subject }.to raise_error Dor::MissingWorkflowException
337
+ end
338
+ end
339
+
340
+ context 'when it fails with status other than 404' do
341
+ let(:status) { 422 }
342
+
335
343
  it 'throws an exception' do
336
344
  expect { subject }.to raise_error Dor::WorkflowException
337
345
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dor-workflow-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.12.0
4
+ version: 3.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Willy Mene
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-12-10 00:00:00.000000000 Z
12
+ date: 2019-12-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -209,6 +209,7 @@ files:
209
209
  - README.md
210
210
  - Rakefile
211
211
  - dor-workflow-client.gemspec
212
+ - lib/dor/missing_workflow_exception.rb
212
213
  - lib/dor/workflow/client.rb
213
214
  - lib/dor/workflow/client/connection_factory.rb
214
215
  - lib/dor/workflow/client/lifecycle_routes.rb
@@ -251,7 +252,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
251
252
  - !ruby/object:Gem::Version
252
253
  version: '0'
253
254
  requirements: []
254
- rubygems_version: 3.0.3
255
+ rubyforge_project:
256
+ rubygems_version: 2.7.8
255
257
  signing_key:
256
258
  specification_version: 4
257
259
  summary: Provides convenience methods to work with the DOR Workflow Service