ocean-rails 3.7.0 → 3.7.1

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
  SHA1:
3
- metadata.gz: 77809e9f1822672d4c90aeb4a2409d237acab4c0
4
- data.tar.gz: 83438c0ffeb2603067f0f05d8ffb0a29e8926d63
3
+ metadata.gz: ed162b3b5596e3d89355491f248cb6130bc2c740
4
+ data.tar.gz: de749dc4a656157f009b364b123391f7c2785294
5
5
  SHA512:
6
- metadata.gz: f053a42f438109874ac1997c974b9528cada2c4e2bdb1bfe0bfe87ab9279f60eedfe046840704b27724836bf0df9fc559d5a0536f8c068cc490c7b98b29dc773
7
- data.tar.gz: 4494b55bfe4aed431f141b5789eb68debb938b97c1269263096e4f377805529f791c76cabe05983c7b1bc36e24511f25359bfd232e4c9c36393c9410a2649787
6
+ metadata.gz: e504ead775dac6f1a7bf8430fe638ee0aa11c567421c8f4939168b04ffe25551a9b39a5d2ce31d5ed79364550a1f20626b939d833a1e3d8d17306dfa5e92bf1d
7
+ data.tar.gz: 7eb4d41631be3c3f59619e5b6a55caa64778cd6f0fad529ddb06b1b35c00484bd9e59c478600e7c9b5e1e6b0291b269b87817761ae93b111a0f0491254c75488
@@ -13,6 +13,7 @@ class Api
13
13
  # thing.resource_type => 'thing'
14
14
  # thing.status => 200
15
15
  # thing.status_message => "OK"
16
+ # thing.response => #<an Api::Response instance>
16
17
  #
17
18
  # The last raw body can be read:
18
19
  #
@@ -52,7 +53,7 @@ class Api
52
53
  # +thing.get+ does the same, but always returns the RemoteResource. The remote resource
53
54
  # can be examined to see its status.
54
55
  #
55
- # Hyperlinks can be specified to avoid hardcoding API URIs. This is essential. Simply specify
56
+ # Hyperlinks can be specified to avoid hardcoding API URIs. Simply specify
56
57
  # the hyperlink as the first parameter to the instance versions of the HTTP accessors:
57
58
  #
58
59
  # x = Api::RemoteResource.new("http://foo.com/x")
@@ -76,11 +77,15 @@ class Api
76
77
  # x.get
77
78
  # x.get(:self)
78
79
  #
79
- # #post, #post!, #put, #put!, #delete, and #delete! are also available.
80
+ # #post, #post!, #put, #put!, #delete, and #delete! are also available and have the same
81
+ # hyperlink handling capabilities.
80
82
  #
81
83
  # Exceptions:
82
84
  #
83
85
  # GetFailed raised when the GET to obtain the remote resource has failed.
86
+ # PutFailed raised when a PUT on the remote resource has failed.
87
+ # PostFailed raised when a POST to the remote resource has failed.
88
+ # DeleteFailed raised when a DELETE of the remote resource has failed.
84
89
  # UnparseableJson raised when the response body doesn't parse as JSON.
85
90
  # JsonIsNoResource raised when the structure of the parsed JSON body is not a resource.
86
91
  #
@@ -124,7 +129,7 @@ class Api
124
129
 
125
130
  attr_reader :uri, :content_type, :retries, :backoff_time, :backoff_rate, :backoff_max
126
131
  attr_reader :raw, :resource, :resource_type, :status, :headers, :credentials, :x_api_token
127
- attr_reader :status_message
132
+ attr_reader :status_message, :response
128
133
 
129
134
  def initialize(uri, type="application/json",
130
135
  credentials: nil, x_api_token: nil,
@@ -272,7 +277,7 @@ class Api
272
277
  private
273
278
 
274
279
  attr_accessor :present
275
- attr_writer :raw, :resource, :resource_type, :status, :headers, :status_message
280
+ attr_writer :raw, :resource, :resource_type, :status, :headers, :status_message, :response
276
281
 
277
282
 
278
283
  def self._credentials(rr)
@@ -292,6 +297,7 @@ class Api
292
297
  response = Api.request rr.uri, :get, headers: {}, credentials: credentials, x_api_token: token,
293
298
  retries: rr.retries, backoff_time: rr.backoff_time, backoff_rate: rr.backoff_rate,
294
299
  backoff_max: rr.backoff_max
300
+ rr.send :response=, response
295
301
  rr.send :status=, response.status
296
302
  rr.send :status_message=, response.message
297
303
  rr.send :headers=, response.headers
@@ -311,6 +317,7 @@ class Api
311
317
  type, resource = verify_resource body
312
318
  self.resource = resource
313
319
  self.resource_type = type
320
+ self.response = response
314
321
  self.status = response.status
315
322
  self.status_message = response.message
316
323
  self.headers = response.headers
@@ -347,6 +354,7 @@ class Api
347
354
  return if resource_type && type != resource_type
348
355
  self.resource = resource
349
356
  self.resource_type = type
357
+ self.response = response
350
358
  self.status = response.status
351
359
  self.status_message = response.message
352
360
  self.headers = response.headers
@@ -379,6 +387,7 @@ class Api
379
387
  credentials: credentials, x_api_token: token,
380
388
  retries: retries, backoff_time: backoff_time, backoff_rate: backoff_rate,
381
389
  backoff_max: backoff_max
390
+ self.response = response
382
391
  self.status = response.status
383
392
  self.status_message = response.message
384
393
  self.headers = response.headers
data/lib/ocean/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ocean
2
- VERSION = "3.7.0"
2
+ VERSION = "3.7.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocean-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.0
4
+ version: 3.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Bengtson