hyperclient 0.7.1 → 0.7.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: c935e08d5410e72969d8b83c213ef56d7ae5236e
4
- data.tar.gz: a250cb39f383c471f637cec668ce683c0310e808
3
+ metadata.gz: 35a0a5739c9ec4a3ba6bc86bba399d2c6ad5a2e2
4
+ data.tar.gz: 9ed0041d6c5800b897a94b075655729cfb4e0018
5
5
  SHA512:
6
- metadata.gz: 10c73a4a2d78e9947a69719e831d1dccd467fecf6006a21fba2561cd23e74e5c7b8604398dc75477a76a5327cf0dfc31e018424cf41c81067bb057854dbd5960
7
- data.tar.gz: c4eba8f9223ccc8ffa166dc731e32ac842d8230f4e9ee507b9f175503ee935a235e5820d823a24378239080de2d8c74bfb2ee29a25949a841d44d78d5a4ff747
6
+ metadata.gz: d0ca28cf98b945f26e1f43f39a0bb455bddb9d8312727394fdd75a3a87a81fd2c7bb459d628eec976df99508ad48401ba8f7c82c8892deba68bbd7892803dade
7
+ data.tar.gz: ad8de8de9a44cfa88b96ed1339a99cc6d574ea26e970e6aad4ff69f8bb3bb0ed45faf2fe10ab9bb23dfefd2177a151f0d8f47770af901f7981b4bd6e4d70784d
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2015-08-15 16:01:39 -0400 using RuboCop version 0.33.0.
3
+ # on 2015-08-23 09:45:44 -0400 using RuboCop version 0.33.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
@@ -11,20 +11,20 @@
11
11
  Metrics/ClassLength:
12
12
  Max: 103
13
13
 
14
- # Offense count: 80
14
+ # Offense count: 85
15
15
  # Configuration parameters: AllowURI, URISchemes.
16
16
  Metrics/LineLength:
17
17
  Max: 142
18
18
 
19
- # Offense count: 3
19
+ # Offense count: 4
20
20
  # Configuration parameters: CountComments.
21
21
  Metrics/MethodLength:
22
- Max: 14
22
+ Max: 25
23
23
 
24
24
  # Offense count: 3
25
25
  # Configuration parameters: CountComments.
26
26
  Metrics/ModuleLength:
27
- Max: 238
27
+ Max: 258
28
28
 
29
29
  # Offense count: 1
30
30
  Style/AsciiComments:
data/.travis.yml CHANGED
@@ -1,5 +1,14 @@
1
1
  rvm:
2
2
  - 1.9.3
3
3
  - 2.0.0
4
- - 2.1.2
4
+ - 2.1
5
+ - 2.2
6
+ - rbx-2.2.10
7
+ - jruby-19mode
8
+ - ruby-head
9
+ - jruby-head
5
10
 
11
+ matrix:
12
+ allow_failures:
13
+ - rvm: ruby-head
14
+ - rvm: jruby-head
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 0.7.2 (August 23, 2015)
2
+
3
+ * [#95](https://github.com/codegram/hyperclient/issues/95): Fix: re-add eager delegation for `resource.x._embeddded.x` - [@dblock](https://github.com/dblock).
4
+
1
5
  ### 0.7.1 (August 15, 2015)
2
6
 
3
7
  * [#89](https://github.com/codegram/hyperclient/issues/89): Added `Hyperclient::Resource#fetch` - [@alabeduarte](https://github.com/alabeduarte).
data/Gemfile CHANGED
@@ -9,7 +9,6 @@ gem 'guard-minitest'
9
9
  gem 'guard-spinach'
10
10
  gem 'pry'
11
11
 
12
- gem 'redcarpet'
13
12
  gem 'yard', '~> 0.8'
14
13
  gem 'yard-tomdoc'
15
14
  gem 'simplecov', require: false
@@ -26,3 +26,7 @@ Feature: API navigation
26
26
  When I connect to the API
27
27
  Then I should be able to navigate to next page
28
28
  Then I should be able to navigate to next page without links
29
+
30
+ Scenario: Counts
31
+ When I connect to the API
32
+ Then I should be able to count embedded items
@@ -38,4 +38,10 @@ class Spinach::Features::ApiNavigation < Spinach::FeatureSteps
38
38
  step 'I should be able to navigate to next page without links' do
39
39
  assert_equal '/posts_of_page2', api.next.posts._url
40
40
  end
41
+
42
+ step 'I should be able to count embedded items' do
43
+ assert_equal 2, api._links.posts._resource._embedded.posts.count
44
+ assert_equal 2, api.posts._embedded.posts.count
45
+ assert_equal 2, api.posts.count
46
+ end
41
47
  end
@@ -25,7 +25,7 @@ class Spinach::Features::DefaultConfig < Spinach::FeatureSteps
25
25
  end
26
26
 
27
27
  step 'it should have been parsed as JSON' do
28
- @posts._attributes.total_posts.to_i.must_equal 9
29
- @posts._attributes['total_posts'].to_i.must_equal 9
28
+ @posts._attributes.total_posts.to_i.must_equal 2
29
+ @posts._attributes['total_posts'].to_i.must_equal 2
30
30
  end
31
31
  end
@@ -20,7 +20,25 @@ module Spinach
20
20
  "self": { "href": "/posts" },
21
21
  "last_post": {"href": "/posts/1"}
22
22
  },
23
- "total_posts": "9"
23
+ "total_posts": "2",
24
+ "_embedded": {
25
+ "posts": [
26
+ {
27
+ "title": "My first blog post",
28
+ "body": "Lorem ipsum dolor sit amet",
29
+ "_links": {
30
+ "self": { "href": "/posts/1" }
31
+ }
32
+ },
33
+ {
34
+ "title": "My second blog post",
35
+ "body": "Lorem ipsum dolor sit amet",
36
+ "_links": {
37
+ "self": { "href": "/posts/2" }
38
+ }
39
+ }
40
+ ]
41
+ }
24
42
  }'
25
43
  end
26
44
 
data/hyperclient.gemspec CHANGED
@@ -14,18 +14,18 @@ Gem::Specification.new do |gem|
14
14
  gem.require_paths = ['lib']
15
15
  gem.version = Hyperclient::VERSION
16
16
 
17
- gem.add_dependency 'faraday', '~> 0.8'
18
- gem.add_dependency 'futuroscope', '>= 0.0.10'
19
- gem.add_dependency 'faraday_middleware', '~> 0.9'
20
- gem.add_dependency 'faraday_hal_middleware', '~> 0.0.1'
21
- gem.add_dependency 'uri_template', '~> 0.5'
22
- gem.add_dependency 'net-http-digest_auth', '~> 1.2'
23
- gem.add_dependency 'faraday-digestauth', '~> 0.2'
17
+ gem.add_dependency 'faraday'
18
+ gem.add_dependency 'futuroscope'
19
+ gem.add_dependency 'faraday_middleware'
20
+ gem.add_dependency 'faraday_hal_middleware'
21
+ gem.add_dependency 'uri_template'
22
+ gem.add_dependency 'net-http-digest_auth'
23
+ gem.add_dependency 'faraday-digestauth'
24
24
 
25
- gem.add_development_dependency 'minitest', '~> 3.4.0'
26
- gem.add_development_dependency 'turn', '~> 0.9'
27
- gem.add_development_dependency 'webmock', '~> 1.8'
28
- gem.add_development_dependency 'mocha', '~> 0.13'
29
- gem.add_development_dependency 'rack-test', '~> 0.6'
25
+ gem.add_development_dependency 'minitest'
26
+ gem.add_development_dependency 'turn'
27
+ gem.add_development_dependency 'webmock'
28
+ gem.add_development_dependency 'mocha'
29
+ gem.add_development_dependency 'rack-test'
30
30
  gem.add_development_dependency 'spinach'
31
31
  end
@@ -154,7 +154,7 @@ module Hyperclient
154
154
 
155
155
  # Internal: avoid delegating to resource
156
156
  #
157
- # #to_ary is called for implicit array coersion (such as parallel assignment
157
+ # #to_ary is called for implicit array coercion (such as parallel assignment
158
158
  # or Array#flatten). Returning nil tells Ruby that this record is not Array-like.
159
159
  def to_ary
160
160
  nil
@@ -84,7 +84,7 @@ module Hyperclient
84
84
  def method_missing(method, *args, &block)
85
85
  if args.any? && args.first.is_a?(Hash)
86
86
  _links.send(method, [], &block)._expand(*args)
87
- else
87
+ elsif !Enumerable.method_defined?(method)
88
88
  [:_attributes, :_embedded, :_links].each do |target|
89
89
  target = send(target)
90
90
  return target.send(method, *args, &block) if target.respond_to?(method.to_s)
@@ -1,3 +1,3 @@
1
1
  module Hyperclient
2
- VERSION = '0.7.1'
2
+ VERSION = '0.7.2'
3
3
  end
@@ -75,6 +75,21 @@ module Hyperclient
75
75
  link._expand._url.must_equal '/orders'
76
76
  link._url.must_equal '/orders'
77
77
  end
78
+
79
+ it 'does not expand unknown variables' do
80
+ link = Link.new('key', { 'href' => '/orders{?id}', 'templated' => true }, entry_point)
81
+ link._expand(unknown: '1')._url.must_equal '/orders'
82
+ end
83
+
84
+ it 'only expands known variables' do
85
+ link = Link.new('key', { 'href' => '/orders{?id}', 'templated' => true }, entry_point)
86
+ link._expand(unknown: '1', id: '2')._url.must_equal '/orders?id=2'
87
+ end
88
+
89
+ it 'only expands templated links' do
90
+ link = Link.new('key', { 'href' => '/orders{?id}', 'templated' => false }, entry_point)
91
+ link._expand(id: '1')._url.must_equal '/orders{?id}'
92
+ end
78
93
  end
79
94
  end
80
95
 
@@ -91,6 +106,18 @@ module Hyperclient
91
106
  link._url.must_equal '/orders?id=1'
92
107
  end
93
108
 
109
+ it 'does not expand an uri template with unknown variables' do
110
+ link = Link.new('key', { 'href' => '/orders{?id}', 'templated' => true }, entry_point, unknown: 1)
111
+
112
+ link._url.must_equal '/orders'
113
+ end
114
+
115
+ it 'only expands known variables in a uri template' do
116
+ link = Link.new('key', { 'href' => '/orders{?id}', 'templated' => true }, entry_point, unknown: 1, id: 2)
117
+
118
+ link._url.must_equal '/orders?id=2'
119
+ end
120
+
94
121
  it 'returns the link when no uri template' do
95
122
  link = Link.new('key', { 'href' => '/orders' }, entry_point)
96
123
  link._url.must_equal '/orders'
metadata CHANGED
@@ -1,183 +1,183 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyperclient
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oriol Gual
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-15 00:00:00.000000000 Z
11
+ date: 2015-08-23 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
- version: '0.8'
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
- version: '0.8'
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
- version: 0.0.10
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
- version: 0.0.10
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
- version: '0.9'
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
- version: '0.9'
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
- version: 0.0.1
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
- version: 0.0.1
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
- version: '0.5'
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
- version: '0.5'
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
- version: '1.2'
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
- version: '1.2'
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
- version: '0.2'
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
- version: '0.2'
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
- version: 3.4.0
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
- version: 3.4.0
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
- version: '0.9'
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
- version: '0.9'
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
- version: '1.8'
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
- version: '1.8'
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
- version: '0.13'
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
- version: '0.13'
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
- version: '0.6'
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
- version: '0.6'
180
+ version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: spinach
183
183
  requirement: !ruby/object:Gem::Requirement