hyperclient 0.7.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -1
- data/CHANGELOG.md +4 -0
- data/README.md +2 -1
- data/UPGRADING.md +44 -0
- data/lib/hyperclient/link_collection.rb +4 -6
- data/lib/hyperclient/version.rb +1 -1
- data/test/fixtures/element.json +2 -2
- data/test/hyperclient/curie_test.rb +6 -1
- data/test/hyperclient/link_collection_test.rb +4 -0
- metadata +36 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c97a980b3d83d85d0f1d2ec0273ce6e01ecb5d7c
|
4
|
+
data.tar.gz: b73b424bd3bc23698d2d1dc6f1c04c1f8b43ba33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81931fcf7209cc55227b6578b7588c86a94883d02b53cdf0cfe3b09e798e331e7bbe415aaa5b3c162e08a361ea115765b3e9d02c66f13324780a17c79d4a7213
|
7
|
+
data.tar.gz: c7a746bcbe812cd16828915c7457e3474e6848ada0b2f3f58a8f21702fa412f5845951f258758a9af149a8718a2020c649021efe0db214321206f9bec8083dda
|
data/.travis.yml
CHANGED
@@ -3,7 +3,8 @@ rvm:
|
|
3
3
|
- 2.0.0
|
4
4
|
- 2.1
|
5
5
|
- 2.2
|
6
|
-
-
|
6
|
+
- 2.3.0
|
7
|
+
- rbx-2
|
7
8
|
- jruby-19mode
|
8
9
|
- ruby-head
|
9
10
|
- jruby-head
|
@@ -12,3 +13,7 @@ matrix:
|
|
12
13
|
allow_failures:
|
13
14
|
- rvm: ruby-head
|
14
15
|
- rvm: jruby-head
|
16
|
+
- rvm: rbx-2
|
17
|
+
|
18
|
+
before_install:
|
19
|
+
- gem install bundler
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
### 0.8.0 (March 15, 2015)
|
2
|
+
|
3
|
+
* [#97](https://github.com/codegram/hyperclient/issues/97): Fix: curies are no longer used as link shorteners - [@joshco](https://github.com/joshco), [@dblock](https://github.com/dblock).
|
4
|
+
|
1
5
|
### 0.7.2 (August 23, 2015)
|
2
6
|
|
3
7
|
* [#95](https://github.com/codegram/hyperclient/issues/95): Fix: re-add eager delegation for `resource.x._embeddded.x` - [@dblock](https://github.com/dblock).
|
data/README.md
CHANGED
@@ -127,10 +127,11 @@ The client is responsible for supplying all the necessary parameters. Templated
|
|
127
127
|
|
128
128
|
### Curies
|
129
129
|
|
130
|
-
Curies are
|
130
|
+
Curies are a suggested means by which to link documentation of a given resource. For example, the demo API contains very long links to images that use an "images" curie.
|
131
131
|
|
132
132
|
```ruby
|
133
133
|
puts spline['image:thumbnail'] # => https://grape-with-roar.herokuapp.com/api/splines/uuid/images/thumbnail.jpg
|
134
|
+
puts spline.links._curies['image'].expand('thumbnail') # => /docs/images/thumbnail
|
134
135
|
```
|
135
136
|
|
136
137
|
### Attributes
|
data/UPGRADING.md
CHANGED
@@ -1,6 +1,50 @@
|
|
1
1
|
Upgrading Hyperclient
|
2
2
|
=====================
|
3
3
|
|
4
|
+
### Upgrading to >= 0.8.0
|
5
|
+
|
6
|
+
### Changes in curies
|
7
|
+
|
8
|
+
Previous versions of Hyperclient misinterpreted the HAL RFC and used curies as if they were designed to enable compact URIs. Curies in HAL are provided for documentation purposes.
|
9
|
+
|
10
|
+
Since version 0.8.0 they are no longer expanded. Consider the following example.
|
11
|
+
|
12
|
+
```json
|
13
|
+
{
|
14
|
+
"_links": {
|
15
|
+
"self": { "href": "/orders" },
|
16
|
+
"curies": [{
|
17
|
+
"name": "acme",
|
18
|
+
"href": "http://docs.acme.com/relations/{rel}",
|
19
|
+
"templated": true
|
20
|
+
}],
|
21
|
+
"acme:widgets": { "href": "/widgets" }
|
22
|
+
}
|
23
|
+
}
|
24
|
+
```
|
25
|
+
|
26
|
+
```rb
|
27
|
+
client = Hyperclient.new('http://example.org/api')
|
28
|
+
|
29
|
+
client._links["acme:widgets"]
|
30
|
+
|
31
|
+
# before
|
32
|
+
# => "http://docs.acme.com/relations/widgets"
|
33
|
+
|
34
|
+
# after
|
35
|
+
# => "http://example.org/api/widgets"
|
36
|
+
```
|
37
|
+
|
38
|
+
In addition, you can now access and expand the curie.
|
39
|
+
|
40
|
+
```rb
|
41
|
+
curie = client._links._curies["acme"]
|
42
|
+
curie.expand('widgets')
|
43
|
+
# => "http://docs.acme.com/relations/widgets"
|
44
|
+
```
|
45
|
+
|
46
|
+
See [#97](https://github.com/codegram/hyperclient/issues/97) for more information.
|
47
|
+
|
4
48
|
### Upgrading to >= 0.7.0
|
5
49
|
|
6
50
|
#### Changes in default headers
|
@@ -11,6 +11,8 @@ module Hyperclient
|
|
11
11
|
# resource.links.author
|
12
12
|
#
|
13
13
|
class LinkCollection < Collection
|
14
|
+
attr_reader :_curies
|
15
|
+
|
14
16
|
# Public: Initializes a LinkCollection.
|
15
17
|
#
|
16
18
|
# collection - The Hash with the links.
|
@@ -19,13 +21,13 @@ module Hyperclient
|
|
19
21
|
def initialize(collection, curies, entry_point)
|
20
22
|
fail "Invalid response for LinkCollection. The response was: #{collection.inspect}" if collection && !collection.respond_to?(:collect)
|
21
23
|
|
22
|
-
@
|
24
|
+
@_curies = (curies || {}).reduce({}) do |hash, curie_hash|
|
23
25
|
curie = build_curie(curie_hash, entry_point)
|
24
26
|
hash.update(curie.name => curie)
|
25
27
|
end
|
26
28
|
|
27
29
|
@collection = (collection || {}).reduce({}) do |hash, (name, link)|
|
28
|
-
hash.update(name => build_link(name, link, @
|
30
|
+
hash.update(name => build_link(name, link, @_curies, entry_point))
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
@@ -46,10 +48,6 @@ module Hyperclient
|
|
46
48
|
link_or_links.map do |link|
|
47
49
|
build_link(name, link, curies, entry_point)
|
48
50
|
end
|
49
|
-
elsif (curie_parts = /(?<ns>[^:]+):(?<short_name>.+)/.match(name))
|
50
|
-
curie = curies[curie_parts[:ns]]
|
51
|
-
link_or_links['href'] = curie.expand(link_or_links['href']) if curie
|
52
|
-
Link.new(name, link_or_links, entry_point)
|
53
51
|
else
|
54
52
|
Link.new(name, link_or_links, entry_point)
|
55
53
|
end
|
data/lib/hyperclient/version.rb
CHANGED
data/test/fixtures/element.json
CHANGED
@@ -18,13 +18,13 @@
|
|
18
18
|
"curies" : [
|
19
19
|
{
|
20
20
|
"name": "image",
|
21
|
-
"href": "/images/{rel}",
|
21
|
+
"href": "/docs/images/{rel}",
|
22
22
|
"templated": true
|
23
23
|
}
|
24
24
|
],
|
25
25
|
"null_link": null,
|
26
26
|
"image:thumbnail": {
|
27
|
-
"href": "thumbnails/{version}.jpg",
|
27
|
+
"href": "/images/thumbnails/{version}.jpg",
|
28
28
|
"templated": true
|
29
29
|
}
|
30
30
|
},
|
@@ -23,12 +23,17 @@ module Hyperclient
|
|
23
23
|
end
|
24
24
|
|
25
25
|
let(:curie) do
|
26
|
-
Curie.new({ 'name' => 'image', 'href' => '/images/{
|
26
|
+
Curie.new({ 'name' => 'image', 'href' => '/images/{rel}', 'templated' => true }, entry_point)
|
27
27
|
end
|
28
28
|
describe '_name' do
|
29
29
|
it 'returns curie name' do
|
30
30
|
curie.name.must_equal 'image'
|
31
31
|
end
|
32
32
|
end
|
33
|
+
describe 'expand' do
|
34
|
+
it 'expands link' do
|
35
|
+
curie.expand('thumbnail').must_equal '/images/thumbnail'
|
36
|
+
end
|
37
|
+
end
|
33
38
|
end
|
34
39
|
end
|
@@ -46,9 +46,13 @@ module Hyperclient
|
|
46
46
|
|
47
47
|
describe 'curied link collection' do
|
48
48
|
let(:curied_link) { links['image:thumbnail'] }
|
49
|
+
let(:curie) { links._curies['image'] }
|
49
50
|
it 'must expand' do
|
50
51
|
curied_link._expand(version: 'small')._url.must_equal '/images/thumbnails/small.jpg'
|
51
52
|
end
|
53
|
+
it 'exposes curie' do
|
54
|
+
curie.expand('thumbnail').must_equal '/docs/images/thumbnail'
|
55
|
+
end
|
52
56
|
end
|
53
57
|
|
54
58
|
describe 'array of links' do
|
metadata
CHANGED
@@ -1,195 +1,195 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyperclient
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oriol Gual
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: futuroscope
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: faraday_middleware
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: faraday_hal_middleware
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: uri_template
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: net-http-digest_auth
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: faraday-digestauth
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '>='
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: minitest
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - '>='
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - '>='
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: turn
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - '>='
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - '>='
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: webmock
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- -
|
143
|
+
- - '>='
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- -
|
150
|
+
- - '>='
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: mocha
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- -
|
157
|
+
- - '>='
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: '0'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- -
|
164
|
+
- - '>='
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: rack-test
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
|
-
- -
|
171
|
+
- - '>='
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: '0'
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- -
|
178
|
+
- - '>='
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: spinach
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
|
-
- -
|
185
|
+
- - '>='
|
186
186
|
- !ruby/object:Gem::Version
|
187
187
|
version: '0'
|
188
188
|
type: :development
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
|
-
- -
|
192
|
+
- - '>='
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
195
|
description: HyperClient is a Ruby Hypermedia API client.
|
@@ -199,11 +199,11 @@ executables: []
|
|
199
199
|
extensions: []
|
200
200
|
extra_rdoc_files: []
|
201
201
|
files:
|
202
|
-
-
|
203
|
-
-
|
204
|
-
-
|
205
|
-
-
|
206
|
-
-
|
202
|
+
- .gitignore
|
203
|
+
- .rubocop.yml
|
204
|
+
- .rubocop_todo.yml
|
205
|
+
- .travis.yml
|
206
|
+
- .yardopts
|
207
207
|
- CHANGELOG.md
|
208
208
|
- CONTRIBUTING.md
|
209
209
|
- Gemfile
|
@@ -256,17 +256,17 @@ require_paths:
|
|
256
256
|
- lib
|
257
257
|
required_ruby_version: !ruby/object:Gem::Requirement
|
258
258
|
requirements:
|
259
|
-
- -
|
259
|
+
- - '>='
|
260
260
|
- !ruby/object:Gem::Version
|
261
261
|
version: '0'
|
262
262
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
263
263
|
requirements:
|
264
|
-
- -
|
264
|
+
- - '>='
|
265
265
|
- !ruby/object:Gem::Version
|
266
266
|
version: '0'
|
267
267
|
requirements: []
|
268
268
|
rubyforge_project:
|
269
|
-
rubygems_version: 2.
|
269
|
+
rubygems_version: 2.4.5
|
270
270
|
signing_key:
|
271
271
|
specification_version: 4
|
272
272
|
summary: ''
|