hal-client 3.2.2 → 3.3.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
  SHA1:
3
- metadata.gz: 1571f90751f4b223e9d6d539ca6d879219d47c97
4
- data.tar.gz: f77f9c7a08dd270b082251f6c9b59740d2d701ae
3
+ metadata.gz: 454803feafd3de62522b145857cf25b91bceea18
4
+ data.tar.gz: 279121c58f7ebc9456d2b8575a342d9069346883
5
5
  SHA512:
6
- metadata.gz: d9538a5d68c53ad009c9dc89c77e27bc0e44e31394cd9b69507420f227e139c0a8a4af5f90df1e92af2ddbdfbb5d85be5f5152189bb30d76ed2c0bf50b7b4665
7
- data.tar.gz: f7d8e1b2ce555e5b51e2a4d2d93bad7e8185cbcba39fcf59dd00cf4a2996bcedc77d8d903c2c9362d7b37d73118f0431c686ca7c174db7e37998b395d45ec19a
6
+ metadata.gz: c4591e0f1bbfc67522893bf2e79781d40ad765030e8cefb9a3bdfddf9d5c1146107ffbdc8dbb401914a0abf3404b0ab75aacc64f35a15996c5b1fc558fb732f9
7
+ data.tar.gz: 1a12ff06dea5247600ddd62b8799b0e00f130b07088aee4de2f5d3507dd48bf9173d72b0b79f2f9ab6f5fdec307f241e7a33647e471791c9dec84a5c5693955c
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://travis-ci.org/pezra/hal-client.png?branch=master)](https://travis-ci.org/pezra/hal-client)
1
+ ![Build Status](https://travis-ci.org/pezra/hal-client.png?branch=master)](https://travis-ci.org/pezra/hal-client)
2
2
  [![Code Climate](https://codeclimate.com/github/pezra/hal-client.png)](https://codeclimate.com/github/pezra/hal-client)
3
3
 
4
4
  # HalClient
@@ -78,7 +78,7 @@ All `HalClient::Representation`s exposed an `#href` attribute which is its ident
78
78
 
79
79
  HalClient provides a high level abstraction for paged collections encoded using [standard `item`, `next` and `prev` link relations](http://tools.ietf.org/html/rfc6573).
80
80
 
81
- articles = HalClient::Collection.new(blog)
81
+ articles = blog.as_enum
82
82
  articles.each do |an_article|
83
83
  # do something with each article representation
84
84
  end
@@ -201,6 +201,10 @@ class HalClient
201
201
  Array(linked) + Array(embedded).map(&:href)
202
202
  end
203
203
 
204
+ def as_enum
205
+ Collection.new(self)
206
+ end
207
+
204
208
  # Returns a short human readable description of this
205
209
  # representation.
206
210
  def to_s
@@ -1,3 +1,3 @@
1
1
  class HalClient
2
- VERSION = "3.2.2"
2
+ VERSION = "3.3.2"
3
3
  end
@@ -215,7 +215,6 @@ HAL
215
215
  specify { expect(subject.to_json).to be_equivalent_json_to raw_repr }
216
216
  specify { expect(subject.to_hal).to be_equivalent_json_to raw_repr }
217
217
 
218
-
219
218
  context "curie links" do
220
219
  let(:raw_repr) { <<-HAL }
221
220
  { "_links": {
@@ -291,6 +290,31 @@ HAL
291
290
  .to raise_error HalClient::InvalidRepresentationError, %r(/_embedded/array-of-atoms) }
292
291
 
293
292
  end
293
+
294
+ specify { expect(repr).to respond_to :as_enum }
295
+
296
+ context "collection" do
297
+ let(:raw_repr) { <<-HAL }
298
+ { "_links": {
299
+ "self": { "href": "http://example.com/foo" }
300
+ }
301
+ ,"_embedded": {
302
+ "item": [
303
+ {"name": "first"}
304
+ ,{"name": "second"}
305
+ ]
306
+ }
307
+ }
308
+ HAL
309
+
310
+ specify { expect(repr.as_enum).to a_kind_of Enumerable }
311
+ specify { expect(repr.as_enum).to have(2).items }
312
+ end
313
+
314
+ context "non-collection" do
315
+ specify { expect{repr.as_enum}.to raise_error }
316
+ end
317
+
294
318
  # Background
295
319
 
296
320
  let(:a_client) { HalClient.new }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hal-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.2
4
+ version: 3.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-21 00:00:00.000000000 Z
11
+ date: 2014-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http