hyperclient 0.8.6 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +6 -29
- data/CHANGELOG.md +6 -0
- data/Dangerfile +1 -1
- data/Gemfile +7 -6
- data/LICENSE +1 -1
- data/README.md +18 -35
- data/Rakefile +1 -8
- data/UPGRADING.md +16 -0
- data/features/steps/api_navigation.rb +1 -1
- data/features/support/api.rb +1 -1
- data/hyperclient.gemspec +1 -2
- data/lib/hyperclient/collection.rb +1 -1
- data/lib/hyperclient/entry_point.rb +2 -4
- data/lib/hyperclient/link.rb +1 -10
- data/lib/hyperclient/resource.rb +2 -2
- data/lib/hyperclient/version.rb +1 -1
- data/test/hyperclient/collection_test.rb +1 -1
- data/test/hyperclient/entry_point_test.rb +2 -8
- data/test/hyperclient/link_test.rb +4 -200
- data/test/hyperclient/resource_test.rb +1 -1
- data/test/test_helper.rb +0 -4
- metadata +25 -18
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: f96f4a987e6b56ca1668ea89fb5d93affb0360f6200b164ad45593dcaa2de8d3
|
|
4
|
+
data.tar.gz: 1aded500fd45aa1e80817df0807ebae6d67814d79313d7b30b2552f2abe08695
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a4c468104b767ac408e5e3763b4620e719b0ce8671e721d5537ce0751b88752b8aa6fdf5abdd335107994ff60d5740b77c88e7d1c1ad5ac317491ad6bbb7f5db
|
|
7
|
+
data.tar.gz: 739ad270184b0d15c574eeb1e7f835ac069f613fe1e90af671c49df5594964a0f7030878fc635331b4e452004a443b3390714bbb80a60fe6a4e1b67987e1ed61
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on
|
|
3
|
+
# on 2018-01-05 16:54:58 -0500 using RuboCop version 0.50.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
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
# Offense count: 1
|
|
10
10
|
# Configuration parameters: CountComments.
|
|
11
11
|
Metrics/ClassLength:
|
|
12
|
-
Max:
|
|
12
|
+
Max: 103
|
|
13
13
|
|
|
14
|
-
# Offense count:
|
|
15
|
-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
|
|
14
|
+
# Offense count: 94
|
|
15
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
|
16
16
|
# URISchemes: http, https
|
|
17
17
|
Metrics/LineLength:
|
|
18
18
|
Max: 142
|
|
19
19
|
|
|
20
|
-
# Offense count:
|
|
20
|
+
# Offense count: 3
|
|
21
21
|
# Configuration parameters: CountComments.
|
|
22
22
|
Metrics/MethodLength:
|
|
23
23
|
Max: 25
|
|
@@ -25,12 +25,7 @@ Metrics/MethodLength:
|
|
|
25
25
|
# Offense count: 3
|
|
26
26
|
# Configuration parameters: CountComments.
|
|
27
27
|
Metrics/ModuleLength:
|
|
28
|
-
Max:
|
|
29
|
-
|
|
30
|
-
# Offense count: 1
|
|
31
|
-
Style/AsciiComments:
|
|
32
|
-
Exclude:
|
|
33
|
-
- 'lib/hyperclient/collection.rb'
|
|
28
|
+
Max: 265
|
|
34
29
|
|
|
35
30
|
# Offense count: 2
|
|
36
31
|
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
@@ -56,25 +51,7 @@ Style/DoubleNegation:
|
|
|
56
51
|
- 'lib/hyperclient/curie.rb'
|
|
57
52
|
- 'lib/hyperclient/link.rb'
|
|
58
53
|
|
|
59
|
-
# Offense count: 5
|
|
60
|
-
# Cop supports --auto-correct.
|
|
61
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
62
|
-
# SupportedStyles: line_count_dependent, lambda, literal
|
|
63
|
-
Style/Lambda:
|
|
64
|
-
Exclude:
|
|
65
|
-
- 'test/hyperclient/entry_point_test.rb'
|
|
66
|
-
- 'test/hyperclient/link_test.rb'
|
|
67
|
-
- 'test/hyperclient/resource_test.rb'
|
|
68
|
-
|
|
69
54
|
# Offense count: 1
|
|
70
55
|
Style/MethodMissing:
|
|
71
56
|
Exclude:
|
|
72
57
|
- 'lib/hyperclient/collection.rb'
|
|
73
|
-
|
|
74
|
-
# Offense count: 1
|
|
75
|
-
# Cop supports --auto-correct.
|
|
76
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
|
|
77
|
-
# SupportedStyles: slashes, percent_r, mixed
|
|
78
|
-
Style/RegexpLiteral:
|
|
79
|
-
Exclude:
|
|
80
|
-
- 'features/support/api.rb'
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
### 0.9.0 (January 10, 2018)
|
|
2
|
+
|
|
3
|
+
* [#133](https://github.com/codegram/hyperclient/pull/133): Removed futuroscope - [@dblock](https://github.com/dblock).
|
|
4
|
+
* [#131](https://github.com/codegram/hyperclient/pull/131): Upgrade to Rubocop 0.50.0, fix Bundler's insecure git source warning - [@nebolsin](https://github.com/nebolsin).
|
|
5
|
+
* [#132](https://github.com/codegram/hyperclient/pull/132): Swapped yard dependency for danger-toc - [@dblock](https://github.com/dblock).
|
|
6
|
+
|
|
1
7
|
### 0.8.6 (August 27, 2017)
|
|
2
8
|
|
|
3
9
|
* [#122](https://github.com/codegram/hyperclient/pull/122): Improve error message when server returns invalid data - [@ivoanjo](https://github.com/ivoanjo).
|
data/Dangerfile
CHANGED
data/Gemfile
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
# NOTE: this is temporary until Bundler 2.0 changes how github: references work.
|
|
2
|
+
git_source(:github) { |repo| "https://github.com/#{repo['/'] ? repo : "#{repo}/#{repo}"}.git" }
|
|
3
|
+
|
|
1
4
|
source 'https://rubygems.org'
|
|
2
5
|
|
|
3
6
|
gemspec
|
|
@@ -12,20 +15,18 @@ group :development do
|
|
|
12
15
|
end
|
|
13
16
|
|
|
14
17
|
group :development, :test do
|
|
15
|
-
gem 'yard', '~> 0.8'
|
|
16
|
-
gem 'yard-tomdoc'
|
|
17
18
|
gem 'rake'
|
|
19
|
+
gem 'rubocop', '~> 0.50.0', require: false
|
|
18
20
|
gem 'simplecov', require: false
|
|
19
|
-
gem 'rubocop', '~> 0.42.0', require: false
|
|
20
21
|
end
|
|
21
22
|
|
|
22
23
|
group :test do
|
|
23
|
-
gem 'futuroscope', github: 'codegram/futuroscope'
|
|
24
24
|
gem 'danger-changelog', '~> 0.1'
|
|
25
|
+
gem 'danger-toc', '~> 0.1'
|
|
25
26
|
gem 'minitest'
|
|
26
|
-
gem 'turn'
|
|
27
|
-
gem 'webmock'
|
|
28
27
|
gem 'mocha'
|
|
29
28
|
gem 'rack-test'
|
|
30
29
|
gem 'spinach'
|
|
30
|
+
gem 'turn'
|
|
31
|
+
gem 'webmock'
|
|
31
32
|
end
|
data/LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -8,23 +8,21 @@
|
|
|
8
8
|
|
|
9
9
|
Hyperclient is a Hypermedia API client written in Ruby. It fully supports [JSON HAL](http://stateless.co/hal_specification.html).
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<sub><sup>ToC created with [gh-md-toc](https://github.com/ekalinin/github-markdown-toc)</sup></sub>
|
|
11
|
+
# Table of Contents
|
|
12
|
+
|
|
13
|
+
- [Usage](#usage)
|
|
14
|
+
- [API Client](#api-client)
|
|
15
|
+
- [Resources and Attributes](#resources-and-attributes)
|
|
16
|
+
- [Links and Embedded Resources](#links-and-embedded-resources)
|
|
17
|
+
- [Templated Links](#templated-links)
|
|
18
|
+
- [Curies](#curies)
|
|
19
|
+
- [Attributes](#attributes)
|
|
20
|
+
- [HTTP](#http)
|
|
21
|
+
- [Testing Using Hyperclient](#testing-using-hyperclient)
|
|
22
|
+
- [Reference](#reference)
|
|
23
|
+
- [Hyperclient Users](#hyperclient-users)
|
|
24
|
+
- [Contributing](#contributing)
|
|
25
|
+
- [License](#license)
|
|
28
26
|
|
|
29
27
|
# Usage
|
|
30
28
|
|
|
@@ -205,23 +203,6 @@ spline._delete
|
|
|
205
203
|
|
|
206
204
|
HTTP methods always return a new instance of Resource.
|
|
207
205
|
|
|
208
|
-
## Asynchronous requests
|
|
209
|
-
|
|
210
|
-
By default, Hyperclient requests are performed asynchronously in a background thread pool via the [Futuroscope](https://github.com/codegram/futuroscope) gem. You can control the size of this pool by setting the `min_workers` and `max_workers` settings:
|
|
211
|
-
|
|
212
|
-
```ruby
|
|
213
|
-
Futuroscope.default_pool.min_workers = 10
|
|
214
|
-
Futuroscope.default_pool.max_workers = 20
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
If you want to disable this behavior and have all requests performed synchronously, you can use the client `options` to disable this behavior:
|
|
218
|
-
|
|
219
|
-
```ruby
|
|
220
|
-
api = Hyperclient.new('https://grape-with-roar.herokuapp.com/api') do |client|
|
|
221
|
-
client.options[:async] = false
|
|
222
|
-
end
|
|
223
|
-
```
|
|
224
|
-
|
|
225
206
|
# Testing Using Hyperclient
|
|
226
207
|
|
|
227
208
|
You can combine RSpec, Faraday::Adapter::Rack and Hyperclient to test your HAL API without having to ever examine the raw JSON response.
|
|
@@ -265,4 +246,6 @@ Hyperclient is work of [many people](https://github.com/codegram/hyperclient/gra
|
|
|
265
246
|
|
|
266
247
|
# License
|
|
267
248
|
|
|
268
|
-
MIT License, see [LICENSE](LICENSE) for details.
|
|
249
|
+
MIT License, see [LICENSE](LICENSE) for details.
|
|
250
|
+
|
|
251
|
+
Copyright (c) 2012-2018 Oriol Gual, [Codegram Technologies](http://codegram.com) and Contributors
|
data/Rakefile
CHANGED
|
@@ -13,13 +13,6 @@ if ENV['COVERAGE']
|
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
require 'yard'
|
|
17
|
-
YARD::Config.load_plugin('yard-tomdoc')
|
|
18
|
-
YARD::Rake::YardocTask.new do |t|
|
|
19
|
-
t.files = ['lib/**/*.rb']
|
|
20
|
-
t.options = %w(-r README.md)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
16
|
require 'rake/testtask'
|
|
24
17
|
|
|
25
18
|
Rake::TestTask.new(:test) do |t|
|
|
@@ -38,4 +31,4 @@ end
|
|
|
38
31
|
require 'rubocop/rake_task'
|
|
39
32
|
RuboCop::RakeTask.new(:rubocop)
|
|
40
33
|
|
|
41
|
-
task default: [
|
|
34
|
+
task default: %i[test spinach rubocop]
|
data/UPGRADING.md
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
Upgrading Hyperclient
|
|
2
2
|
=====================
|
|
3
3
|
|
|
4
|
+
### Upgrading to >= 0.9.0
|
|
5
|
+
|
|
6
|
+
Previous versions of Hyperclient performed asynchronous requests using [futuroscope](https://github.com/codegram/futuroscope) by default, which could be disabled by providing the `:async` option to each Hyperclient instance. This has been removed and you can remove any such code.
|
|
7
|
+
|
|
8
|
+
```ruby
|
|
9
|
+
api = Hyperclient.new('https://grape-with-roar.herokuapp.com/api') do |client|
|
|
10
|
+
client.options[:async] = false
|
|
11
|
+
end
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The default new behavior is synchronous. We recommend [concurrent-ruby](https://github.com/ruby-concurrency/concurrent-ruby) for your asynchronous needs.
|
|
15
|
+
|
|
16
|
+
Include [futuroscope](https://github.com/codegram/futuroscope) in your `Gemfile` and wrap Hyperclient requests into `Futuroscope::Future.new` blocks to get the old behavior.
|
|
17
|
+
|
|
18
|
+
See [#133](https://github.com/codegram/hyperclient/pull/133) and [#123](https://github.com/codegram/hyperclient/issues/123) for more information.
|
|
19
|
+
|
|
4
20
|
### Upgrading to >= 0.8.0
|
|
5
21
|
|
|
6
22
|
### Changes in curies
|
|
@@ -18,7 +18,7 @@ class Spinach::Features::ApiNavigation < Spinach::FeatureSteps
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
step 'I search for posts by tag with a templated link' do
|
|
21
|
-
api._links.tagged._expand(tags: %w
|
|
21
|
+
api._links.tagged._expand(tags: %w[foo bar])._resource
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
step 'the API should receive the request for posts by tag with all the params' do
|
data/features/support/api.rb
CHANGED
|
@@ -7,7 +7,7 @@ module API
|
|
|
7
7
|
before do
|
|
8
8
|
WebMock::Config.instance.query_values_notation = :flat_array
|
|
9
9
|
|
|
10
|
-
stub_request(:any,
|
|
10
|
+
stub_request(:any, /api.example.org*/).to_return(body: root_response, headers: { 'Content-Type' => 'application/hal+json' })
|
|
11
11
|
stub_request(:get, 'api.example.org/posts').to_return(body: posts_response, headers: { 'Content-Type' => 'application/hal+json' })
|
|
12
12
|
stub_request(:get, 'api.example.org/posts/1').to_return(body: post_response, headers: { 'Content-Type' => 'application/hal+json' })
|
|
13
13
|
stub_request(:get, 'api.example.org/page2').to_return(body: page2_response, headers: { 'Content-Type' => 'application/hal+json' })
|
data/hyperclient.gemspec
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
require File.expand_path('../lib/hyperclient/version', __FILE__)
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |gem|
|
|
@@ -15,7 +15,6 @@ Gem::Specification.new do |gem|
|
|
|
15
15
|
gem.version = Hyperclient::VERSION
|
|
16
16
|
|
|
17
17
|
gem.add_dependency 'faraday', '>= 0.9.0'
|
|
18
|
-
gem.add_dependency 'futuroscope'
|
|
19
18
|
gem.add_dependency 'faraday_middleware'
|
|
20
19
|
gem.add_dependency 'faraday_hal_middleware'
|
|
21
20
|
gem.add_dependency 'uri_template'
|
|
@@ -35,7 +35,7 @@ module Hyperclient
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
# Public: Returns a value from the collection for the given key.
|
|
38
|
-
# If the key can
|
|
38
|
+
# If the key can't be found, there are several options:
|
|
39
39
|
# With no other arguments, it will raise an KeyError exception;
|
|
40
40
|
# if default is given, then that will be returned;
|
|
41
41
|
#
|
|
@@ -38,7 +38,7 @@ module Hyperclient
|
|
|
38
38
|
def initialize(url, &_block)
|
|
39
39
|
@link = { 'href' => url }
|
|
40
40
|
@entry_point = self
|
|
41
|
-
@options = {
|
|
41
|
+
@options = {}
|
|
42
42
|
@connection = nil
|
|
43
43
|
@resource = nil
|
|
44
44
|
@key = nil
|
|
@@ -118,9 +118,7 @@ module Hyperclient
|
|
|
118
118
|
|
|
119
119
|
# Public: Read/Set options.
|
|
120
120
|
#
|
|
121
|
-
# value - A Hash containing the client options.
|
|
122
|
-
# to disable the default behavior of performing requests asynchronously
|
|
123
|
-
# using futures.
|
|
121
|
+
# value - A Hash containing the client options.
|
|
124
122
|
attr_accessor :options
|
|
125
123
|
|
|
126
124
|
private
|
data/lib/hyperclient/link.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
require 'uri_template'
|
|
2
|
-
require 'futuroscope'
|
|
3
2
|
|
|
4
3
|
module Hyperclient
|
|
5
4
|
# Internal: The Link is used to let a Resource interact with the API.
|
|
@@ -168,15 +167,7 @@ module Hyperclient
|
|
|
168
167
|
|
|
169
168
|
def http_method(method, body = nil)
|
|
170
169
|
@resource = begin
|
|
171
|
-
response =
|
|
172
|
-
if @entry_point.options[:async]
|
|
173
|
-
Futuroscope::Future.new do
|
|
174
|
-
@entry_point.connection.run_request(method, _url, body, nil)
|
|
175
|
-
end
|
|
176
|
-
else
|
|
177
|
-
@entry_point.connection.run_request(method, _url, body, nil)
|
|
178
|
-
end
|
|
179
|
-
|
|
170
|
+
response = @entry_point.connection.run_request(method, _url, body, nil)
|
|
180
171
|
Resource.new(response.body, @entry_point, response)
|
|
181
172
|
end
|
|
182
173
|
end
|
data/lib/hyperclient/resource.rb
CHANGED
|
@@ -109,7 +109,7 @@ module Hyperclient
|
|
|
109
109
|
if args.any? && args.first.is_a?(Hash)
|
|
110
110
|
_links.send(method, [], &block)._expand(*args)
|
|
111
111
|
elsif !Array.method_defined?(method)
|
|
112
|
-
[
|
|
112
|
+
%i[_attributes _embedded _links].each do |target|
|
|
113
113
|
target = send(target)
|
|
114
114
|
return target.send(method, *args, &block) if target.respond_to?(method.to_s)
|
|
115
115
|
end
|
|
@@ -120,7 +120,7 @@ module Hyperclient
|
|
|
120
120
|
# Internal: Accessory method to allow the resource respond to
|
|
121
121
|
# methods that will hit method_missing.
|
|
122
122
|
def respond_to_missing?(method, include_private = false)
|
|
123
|
-
[
|
|
123
|
+
%i[_attributes _embedded _links].each do |target|
|
|
124
124
|
return true if send(target).respond_to?(method, include_private)
|
|
125
125
|
end
|
|
126
126
|
false
|
data/lib/hyperclient/version.rb
CHANGED
|
@@ -45,12 +45,12 @@ module Hyperclient
|
|
|
45
45
|
|
|
46
46
|
it 'raises a ConnectionAlreadyInitializedError if attempting to modify headers' do
|
|
47
47
|
entry_point.connection.must_be_kind_of Faraday::Connection
|
|
48
|
-
|
|
48
|
+
-> { entry_point.headers = {} }.must_raise ConnectionAlreadyInitializedError
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
it 'raises a ConnectionAlreadyInitializedError if attempting to modify the faraday block' do
|
|
52
52
|
entry_point.connection.must_be_kind_of Faraday::Connection
|
|
53
|
-
|
|
53
|
+
-> { entry_point.connection {} }.must_raise ConnectionAlreadyInitializedError
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
|
|
@@ -59,12 +59,6 @@ module Hyperclient
|
|
|
59
59
|
entry_point._url.must_equal 'http://my.api.org'
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
|
-
|
|
63
|
-
describe 'options' do
|
|
64
|
-
it 'enables the async option by default' do
|
|
65
|
-
entry_point.options[:async].must_equal true
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
62
|
end
|
|
69
63
|
|
|
70
64
|
describe 'faraday_options' do
|
|
@@ -7,7 +7,7 @@ module Hyperclient
|
|
|
7
7
|
EntryPoint.new('http://api.example.org/')
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
%w
|
|
10
|
+
%w[type deprecation name profile title hreflang].each do |prop|
|
|
11
11
|
describe prop do
|
|
12
12
|
it 'returns the property value' do
|
|
13
13
|
link = Link.new('key', { prop => 'value' }, entry_point)
|
|
@@ -39,7 +39,7 @@ module Hyperclient
|
|
|
39
39
|
it 'returns a list of required variables' do
|
|
40
40
|
link = Link.new('key', { 'href' => '/orders{?id,owner}', 'templated' => true }, entry_point)
|
|
41
41
|
|
|
42
|
-
link._variables.must_equal %w
|
|
42
|
+
link._variables.must_equal %w[id owner]
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
it 'returns an empty array for untemplated links' do
|
|
@@ -161,35 +161,7 @@ module Hyperclient
|
|
|
161
161
|
stub.get('http://api.example.org/productions/1') { [400, {}, nil] }
|
|
162
162
|
end
|
|
163
163
|
|
|
164
|
-
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
it 'executes requests asynchronously using futuroscope' do
|
|
168
|
-
link = Link.new('key', { 'href' => '/productions/1' }, entry_point)
|
|
169
|
-
|
|
170
|
-
stub_request(entry_point.connection) do |stub|
|
|
171
|
-
stub.get('http://api.example.org/productions/1') { [200, {}, nil] }
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
Futuroscope::Future.expects(:new).returns(stub(body: nil))
|
|
175
|
-
|
|
176
|
-
link._get
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
describe 'when entry_point.options is set to { async: false }' do
|
|
180
|
-
it 'executes requests synchronously without futuroscope' do
|
|
181
|
-
entry_point.options = { async: false }
|
|
182
|
-
|
|
183
|
-
link = Link.new('key', { 'href' => '/productions/1' }, entry_point)
|
|
184
|
-
|
|
185
|
-
stub_request(entry_point.connection) do |stub|
|
|
186
|
-
stub.get('http://api.example.org/productions/1') { [200, {}, nil] }
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
Futuroscope::Future.expects(:new).never
|
|
190
|
-
|
|
191
|
-
link._get
|
|
192
|
-
end
|
|
164
|
+
-> { link._get }.must_raise Faraday::ClientError
|
|
193
165
|
end
|
|
194
166
|
end
|
|
195
167
|
|
|
@@ -203,34 +175,6 @@ module Hyperclient
|
|
|
203
175
|
|
|
204
176
|
link._options.must_be_kind_of Resource
|
|
205
177
|
end
|
|
206
|
-
|
|
207
|
-
it 'executes requests asynchronously using futuroscope' do
|
|
208
|
-
link = Link.new('key', { 'href' => '/productions/1' }, entry_point)
|
|
209
|
-
|
|
210
|
-
stub_request(entry_point.connection) do |stub|
|
|
211
|
-
stub.options('http://api.example.org/productions/1') { [200, {}, nil] }
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
Futuroscope::Future.expects(:new).returns(stub(body: nil))
|
|
215
|
-
|
|
216
|
-
link._options
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
describe 'when entry_point.options is set to { async: false }' do
|
|
220
|
-
it 'executes requests synchronously without futuroscope' do
|
|
221
|
-
entry_point.options = { async: false }
|
|
222
|
-
|
|
223
|
-
link = Link.new('key', { 'href' => '/productions/1' }, entry_point)
|
|
224
|
-
|
|
225
|
-
stub_request(entry_point.connection) do |stub|
|
|
226
|
-
stub.options('http://api.example.org/productions/1') { [200, {}, nil] }
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
Futuroscope::Future.expects(:new).never
|
|
230
|
-
|
|
231
|
-
link._options
|
|
232
|
-
end
|
|
233
|
-
end
|
|
234
178
|
end
|
|
235
179
|
|
|
236
180
|
describe '_head' do
|
|
@@ -243,34 +187,6 @@ module Hyperclient
|
|
|
243
187
|
|
|
244
188
|
link._head.must_be_kind_of Resource
|
|
245
189
|
end
|
|
246
|
-
|
|
247
|
-
it 'executes requests asynchronously using futuroscope' do
|
|
248
|
-
link = Link.new('key', { 'href' => '/productions/1' }, entry_point)
|
|
249
|
-
|
|
250
|
-
stub_request(entry_point.connection) do |stub|
|
|
251
|
-
stub.head('http://api.example.org/productions/1') { [200, {}, nil] }
|
|
252
|
-
end
|
|
253
|
-
|
|
254
|
-
Futuroscope::Future.expects(:new).returns(stub(body: nil))
|
|
255
|
-
|
|
256
|
-
link._head
|
|
257
|
-
end
|
|
258
|
-
|
|
259
|
-
describe 'when entry_point.options is set to { async: false }' do
|
|
260
|
-
it 'executes requests synchronously without futuroscope' do
|
|
261
|
-
entry_point.options = { async: false }
|
|
262
|
-
|
|
263
|
-
link = Link.new('key', { 'href' => '/productions/1' }, entry_point)
|
|
264
|
-
|
|
265
|
-
stub_request(entry_point.connection) do |stub|
|
|
266
|
-
stub.head('http://api.example.org/productions/1') { [200, {}, nil] }
|
|
267
|
-
end
|
|
268
|
-
|
|
269
|
-
Futuroscope::Future.expects(:new).never
|
|
270
|
-
|
|
271
|
-
link._head
|
|
272
|
-
end
|
|
273
|
-
end
|
|
274
190
|
end
|
|
275
191
|
|
|
276
192
|
describe '_delete' do
|
|
@@ -283,34 +199,6 @@ module Hyperclient
|
|
|
283
199
|
|
|
284
200
|
link._delete.must_be_kind_of Resource
|
|
285
201
|
end
|
|
286
|
-
|
|
287
|
-
it 'executes requests asynchronously using futuroscope' do
|
|
288
|
-
link = Link.new('key', { 'href' => '/productions/1' }, entry_point)
|
|
289
|
-
|
|
290
|
-
stub_request(entry_point.connection) do |stub|
|
|
291
|
-
stub.delete('http://api.example.org/productions/1') { [200, {}, nil] }
|
|
292
|
-
end
|
|
293
|
-
|
|
294
|
-
Futuroscope::Future.expects(:new).returns(stub(body: nil))
|
|
295
|
-
|
|
296
|
-
link._delete
|
|
297
|
-
end
|
|
298
|
-
|
|
299
|
-
describe 'when entry_point.options is set to { async: false }' do
|
|
300
|
-
it 'executes requests synchronously without futuroscope' do
|
|
301
|
-
entry_point.options = { async: false }
|
|
302
|
-
|
|
303
|
-
link = Link.new('key', { 'href' => '/productions/1' }, entry_point)
|
|
304
|
-
|
|
305
|
-
stub_request(entry_point.connection) do |stub|
|
|
306
|
-
stub.delete('http://api.example.org/productions/1') { [200, {}, nil] }
|
|
307
|
-
end
|
|
308
|
-
|
|
309
|
-
Futuroscope::Future.expects(:new).never
|
|
310
|
-
|
|
311
|
-
link._delete
|
|
312
|
-
end
|
|
313
|
-
end
|
|
314
202
|
end
|
|
315
203
|
|
|
316
204
|
describe '_post' do
|
|
@@ -331,34 +219,6 @@ module Hyperclient
|
|
|
331
219
|
|
|
332
220
|
link._post.must_be_kind_of Resource
|
|
333
221
|
end
|
|
334
|
-
|
|
335
|
-
it 'executes requests asynchronously using futuroscope' do
|
|
336
|
-
link = Link.new('key', { 'href' => '/productions/1' }, entry_point)
|
|
337
|
-
|
|
338
|
-
stub_request(entry_point.connection) do |stub|
|
|
339
|
-
stub.post('http://api.example.org/productions/1') { [200, {}, nil] }
|
|
340
|
-
end
|
|
341
|
-
|
|
342
|
-
Futuroscope::Future.expects(:new).returns(stub(body: nil))
|
|
343
|
-
|
|
344
|
-
link._post
|
|
345
|
-
end
|
|
346
|
-
|
|
347
|
-
describe 'when entry_point.options is set to { async: false }' do
|
|
348
|
-
it 'executes requests synchronously without futuroscope' do
|
|
349
|
-
entry_point.options = { async: false }
|
|
350
|
-
|
|
351
|
-
link = Link.new('key', { 'href' => '/productions/1' }, entry_point)
|
|
352
|
-
|
|
353
|
-
stub_request(entry_point.connection) do |stub|
|
|
354
|
-
stub.post('http://api.example.org/productions/1') { [200, {}, nil] }
|
|
355
|
-
end
|
|
356
|
-
|
|
357
|
-
Futuroscope::Future.expects(:new).never
|
|
358
|
-
|
|
359
|
-
link._post
|
|
360
|
-
end
|
|
361
|
-
end
|
|
362
222
|
end
|
|
363
223
|
|
|
364
224
|
describe '_put' do
|
|
@@ -379,34 +239,6 @@ module Hyperclient
|
|
|
379
239
|
|
|
380
240
|
link._put.must_be_kind_of Resource
|
|
381
241
|
end
|
|
382
|
-
|
|
383
|
-
it 'executes requests asynchronously using futuroscope' do
|
|
384
|
-
link = Link.new('key', { 'href' => '/productions/1' }, entry_point)
|
|
385
|
-
|
|
386
|
-
stub_request(entry_point.connection) do |stub|
|
|
387
|
-
stub.put('http://api.example.org/productions/1') { [200, {}, nil] }
|
|
388
|
-
end
|
|
389
|
-
|
|
390
|
-
Futuroscope::Future.expects(:new).returns(stub(body: nil))
|
|
391
|
-
|
|
392
|
-
link._put
|
|
393
|
-
end
|
|
394
|
-
|
|
395
|
-
describe 'when entry_point.options is set to { async: false }' do
|
|
396
|
-
it 'executes requests synchronously without futuroscope' do
|
|
397
|
-
entry_point.options = { async: false }
|
|
398
|
-
|
|
399
|
-
link = Link.new('key', { 'href' => '/productions/1' }, entry_point)
|
|
400
|
-
|
|
401
|
-
stub_request(entry_point.connection) do |stub|
|
|
402
|
-
stub.put('http://api.example.org/productions/1') { [200, {}, nil] }
|
|
403
|
-
end
|
|
404
|
-
|
|
405
|
-
Futuroscope::Future.expects(:new).never
|
|
406
|
-
|
|
407
|
-
link._put
|
|
408
|
-
end
|
|
409
|
-
end
|
|
410
242
|
end
|
|
411
243
|
|
|
412
244
|
describe '_patch' do
|
|
@@ -427,34 +259,6 @@ module Hyperclient
|
|
|
427
259
|
|
|
428
260
|
link._patch.must_be_kind_of Resource
|
|
429
261
|
end
|
|
430
|
-
|
|
431
|
-
it 'executes requests asynchronously using futuroscope' do
|
|
432
|
-
link = Link.new('key', { 'href' => '/productions/1' }, entry_point)
|
|
433
|
-
|
|
434
|
-
stub_request(entry_point.connection) do |stub|
|
|
435
|
-
stub.patch('http://api.example.org/productions/1') { [200, {}, nil] }
|
|
436
|
-
end
|
|
437
|
-
|
|
438
|
-
Futuroscope::Future.expects(:new).returns(stub(body: nil))
|
|
439
|
-
|
|
440
|
-
link._patch
|
|
441
|
-
end
|
|
442
|
-
|
|
443
|
-
describe 'when entry_point.options is set to { async: false }' do
|
|
444
|
-
it 'executes requests synchronously without futuroscope' do
|
|
445
|
-
entry_point.options = { async: false }
|
|
446
|
-
|
|
447
|
-
link = Link.new('key', { 'href' => '/productions/1' }, entry_point)
|
|
448
|
-
|
|
449
|
-
stub_request(entry_point.connection) do |stub|
|
|
450
|
-
stub.patch('http://api.example.org/productions/1') { [200, {}, nil] }
|
|
451
|
-
end
|
|
452
|
-
|
|
453
|
-
Futuroscope::Future.expects(:new).never
|
|
454
|
-
|
|
455
|
-
link._patch
|
|
456
|
-
end
|
|
457
|
-
end
|
|
458
262
|
end
|
|
459
263
|
|
|
460
264
|
describe 'inspect' do
|
|
@@ -531,7 +335,7 @@ module Hyperclient
|
|
|
531
335
|
end
|
|
532
336
|
|
|
533
337
|
it 'raises an error when the method does not exist in the resource' do
|
|
534
|
-
|
|
338
|
+
-> { link.this_method_does_not_exist }.must_raise NoMethodError
|
|
535
339
|
end
|
|
536
340
|
|
|
537
341
|
it 'responds to missing methods' do
|
|
@@ -100,7 +100,7 @@ module Hyperclient
|
|
|
100
100
|
resource._attributes.expects('respond_to?').with('foo').returns(false)
|
|
101
101
|
resource._links.expects('respond_to?').with('foo').returns(false)
|
|
102
102
|
resource._embedded.expects('respond_to?').with('foo').returns(false)
|
|
103
|
-
|
|
103
|
+
-> { resource.foo }.must_raise NoMethodError
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
it 'delegates []' do
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hyperclient
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.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: 2018-01-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -24,20 +24,6 @@ dependencies:
|
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: 0.9.0
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: futuroscope
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - ">="
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '0'
|
|
34
|
-
type: :runtime
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - ">="
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '0'
|
|
41
27
|
- !ruby/object:Gem::Dependency
|
|
42
28
|
name: faraday_middleware
|
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -183,8 +169,29 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
183
169
|
version: '0'
|
|
184
170
|
requirements: []
|
|
185
171
|
rubyforge_project:
|
|
186
|
-
rubygems_version: 2.
|
|
172
|
+
rubygems_version: 2.7.3
|
|
187
173
|
signing_key:
|
|
188
174
|
specification_version: 4
|
|
189
175
|
summary: ''
|
|
190
|
-
test_files:
|
|
176
|
+
test_files:
|
|
177
|
+
- features/api_navigation.feature
|
|
178
|
+
- features/default_config.feature
|
|
179
|
+
- features/steps/api_navigation.rb
|
|
180
|
+
- features/steps/default_config.rb
|
|
181
|
+
- features/support/api.rb
|
|
182
|
+
- features/support/env.rb
|
|
183
|
+
- features/support/fixtures.rb
|
|
184
|
+
- test/faraday/connection_test.rb
|
|
185
|
+
- test/fixtures/collection.json
|
|
186
|
+
- test/fixtures/element.json
|
|
187
|
+
- test/fixtures/root.json
|
|
188
|
+
- test/hyperclient/attributes_test.rb
|
|
189
|
+
- test/hyperclient/collection_test.rb
|
|
190
|
+
- test/hyperclient/curie_test.rb
|
|
191
|
+
- test/hyperclient/entry_point_test.rb
|
|
192
|
+
- test/hyperclient/link_collection_test.rb
|
|
193
|
+
- test/hyperclient/link_test.rb
|
|
194
|
+
- test/hyperclient/resource_collection_test.rb
|
|
195
|
+
- test/hyperclient/resource_test.rb
|
|
196
|
+
- test/hyperclient_test.rb
|
|
197
|
+
- test/test_helper.rb
|