preservation-client 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87f6d28de114c911290ae02d86e45dc39728ffd2ca63e76c7868f40a44656b01
4
- data.tar.gz: 623f1c5881b8cb1cc402376bd934494708c0ee5d388ee3e6e7d78a366d6ebdee
3
+ metadata.gz: 40602017c072b2c6acf9ac778a53171a10102477e0783f42c18006b6783d3cc2
4
+ data.tar.gz: 8069794031fff97a91cfb4a8e43dab2f4112f01659d9157aa2347c1cbf06d70e
5
5
  SHA512:
6
- metadata.gz: 6a8a7c2f696815790e7fc8142049867f5a5a138cde7e22d966ddef7ba4f12b5314b25266d9093757008e81eab5943221c234b4ce3618791fa20a7d93aa5d63f9
7
- data.tar.gz: a9e1d7b4b08b208882b900c83509a5f4f79699f2aec5509ae206ff1659b032ed5bd43a63a130ceccfab11ac68c02092a913d184802ab63c1e073f38ff939691f
6
+ metadata.gz: a3caae88635c58bc4ff0fdee436cad522c3442855dbc9cde2ccdda6570a9ac310f27645e6171438cc29b102c69bcb9b94d5d75e06cec443b333d3cf885c5795e
7
+ data.tar.gz: 459b15285b9231257d0c28da3ba22a8f40942aed7f334f8aa8dc1aa83a6bfafd3137eb214a799cdd71fac4c6760df45987b1c1b45d7b5910de227cba407b1df9
data/.rubocop.yml CHANGED
@@ -18,7 +18,7 @@ Metrics/LineLength:
18
18
  - 'spec/**/*'
19
19
 
20
20
  Metrics/MethodLength:
21
- Max: 15
21
+ Max: 25
22
22
 
23
23
  Style/Documentation:
24
24
  Exclude:
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2019-09-24 11:53:40 -0700 using RuboCop version 0.74.0.
3
+ # on 2019-09-25 11:19:34 -0700 using RuboCop version 0.74.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -8,4 +8,4 @@
8
8
 
9
9
  # Offense count: 2
10
10
  Metrics/AbcSize:
11
- Max: 26
11
+ Max: 31
@@ -28,7 +28,7 @@ module Preservation
28
28
  status_info = status_msg.blank? ? status_code : "#{status_msg} (#{status_code})"
29
29
  object_id_info = " for #{object_id}" if object_id.present?
30
30
 
31
- "Preservation::Client.#{client_method_name}#{object_id_info} got #{status_info} from Preservation Catalog at #{req_url}: #{body}"
31
+ "Preservation::Client.#{client_method_name}#{object_id_info} got #{status_info} from Preservation at #{req_url}: #{body}"
32
32
  end
33
33
  end
34
34
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Preservation
4
4
  class Client
5
- VERSION = '0.2.1'
5
+ VERSION = '0.2.2'
6
6
  end
7
7
  end
@@ -15,21 +15,27 @@ module Preservation
15
15
 
16
16
  # @param path [String] path to be appended to connection url (no leading slash)
17
17
  def get_json(path, object_id, caller_method_name)
18
+ req_url = api_version.present? ? "#{api_version}/#{path}" : path
18
19
  resp = connection.get do |req|
19
- req.url api_version.present? ? "#{api_version}/#{path}" : path
20
+ req.url req_url
20
21
  req.headers['Content-Type'] = 'application/json'
21
22
  req.headers['Accept'] = 'application/json'
22
23
  end
23
24
  return JSON.parse(resp.body).with_indifferent_access if resp.success?
24
25
 
25
- errmsg = ResponseErrorFormatter
26
- .format(response: resp, object_id: object_id, client_method_name: caller_method_name)
27
- raise Preservation::Client::UnexpectedResponseError, errmsg
26
+ if resp.status == 404
27
+ errmsg = "#{object_id} not found in Preservation at #{connection.url_prefix}#{req_url}"
28
+ raise Preservation::Client::NotFoundError, errmsg
29
+ else
30
+ errmsg = ResponseErrorFormatter
31
+ .format(response: resp, object_id: object_id, client_method_name: caller_method_name)
32
+ raise Preservation::Client::UnexpectedResponseError, errmsg
33
+ end
28
34
  rescue Faraday::ResourceNotFound => e
29
- errmsg = "HTTP GET to #{connection.url_prefix}#{path} failed with #{e.class}: #{e.message}"
35
+ errmsg = "HTTP GET to #{connection.url_prefix}#{req_url} failed with #{e.class}: #{e.message}"
30
36
  raise Preservation::Client::NotFoundError, errmsg
31
37
  rescue Faraday::ParsingError, Faraday::RetriableResponse => e
32
- errmsg = "HTTP GET to #{connection.url_prefix}#{path} failed with #{e.class}: #{e.message}"
38
+ errmsg = "HTTP GET to #{connection.url_prefix}#{req_url} failed with #{e.class}: #{e.message}"
33
39
  raise Preservation::Client::UnexpectedResponseError, errmsg
34
40
  end
35
41
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: preservation-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naomi Dushay
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-24 00:00:00.000000000 Z
11
+ date: 2019-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport