hyperclient 1.0.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/.github/dependabot.yml +18 -0
- data/.github/workflows/coverage.yml +24 -0
- data/.github/workflows/danger.yml +22 -0
- data/.github/workflows/lint.yml +16 -0
- data/.github/workflows/test.yml +23 -0
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +37 -31
- data/CHANGELOG.md +8 -0
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +4 -6
- data/README.md +4 -4
- data/RELEASING.md +1 -1
- data/Rakefile +0 -8
- data/features/steps/api_navigation.rb +3 -3
- data/features/steps/default_config.rb +2 -2
- data/features/support/api.rb +22 -11
- data/features/support/env.rb +14 -1
- data/hyperclient.gemspec +4 -4
- data/lib/hyperclient/entry_point.rb +3 -3
- data/lib/hyperclient/resource.rb +1 -3
- data/lib/hyperclient/resource_collection.rb +1 -3
- data/lib/hyperclient/version.rb +1 -1
- data/test/hyperclient/entry_point_test.rb +13 -13
- data/test/hyperclient/resource_test.rb +2 -1
- data/test/hyperclient_test.rb +5 -5
- data/test/test_helper.rb +20 -1
- metadata +18 -32
- data/.travis.yml +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '02694a72cb9a16a0faac55b463c859a470bce22f7976b0b77c19da138cceded8'
|
4
|
+
data.tar.gz: d96697a7e493f29b2a3207850b961664cfa18e0195b526abb16c9c108b2e2bc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45bb98cc9a22fd721c71f32a4e7b2634610279fe66a8466d6f2339efb994853896ed33867baa3e460cd805055b2b2611108d703f7c7788b952ef3693393140fd
|
7
|
+
data.tar.gz: c3c47fee4c97362f31c40a8923eec8c7573be28e215a43bdaac89c44e573cd93cec57291932718dd1bd136689c9f46f1ceff2ace244d613d76871cf9e7529df6
|
data/.DS_Store
ADDED
Binary file
|
@@ -0,0 +1,18 @@
|
|
1
|
+
version: 2
|
2
|
+
updates:
|
3
|
+
- package-ecosystem: bundler
|
4
|
+
directory: "/"
|
5
|
+
schedule:
|
6
|
+
interval: daily
|
7
|
+
time: "04:00"
|
8
|
+
timezone: Europe/Madrid
|
9
|
+
open-pull-requests-limit: 10
|
10
|
+
ignore:
|
11
|
+
- dependency-name: rubocop
|
12
|
+
versions:
|
13
|
+
- 1.10.0
|
14
|
+
- 1.11.0
|
15
|
+
- 1.12.0
|
16
|
+
- 1.12.1
|
17
|
+
- 1.9.0
|
18
|
+
- 1.9.1
|
@@ -0,0 +1,24 @@
|
|
1
|
+
---
|
2
|
+
name: coverage
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
env:
|
6
|
+
COVERAGE: 1
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
build:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v3
|
13
|
+
- name: Install Ruby (2.7)
|
14
|
+
uses: ruby/setup-ruby@v1
|
15
|
+
with:
|
16
|
+
ruby-version: 2.7
|
17
|
+
bundler-cache: true
|
18
|
+
- name: Build and test with RSpec
|
19
|
+
run: |
|
20
|
+
bundle exec rake test
|
21
|
+
- name: Coveralls
|
22
|
+
uses: coverallsapp/github-action@master
|
23
|
+
with:
|
24
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
---
|
2
|
+
name: danger
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
types: [opened, reopened, edited, synchronize]
|
6
|
+
jobs:
|
7
|
+
danger:
|
8
|
+
runs-on: ubuntu-20.04
|
9
|
+
steps:
|
10
|
+
- uses: actions/checkout@v3
|
11
|
+
with:
|
12
|
+
fetch-depth: 0
|
13
|
+
- name: Set up Ruby
|
14
|
+
uses: ruby/setup-ruby@v1
|
15
|
+
with:
|
16
|
+
ruby-version: 2.7
|
17
|
+
bundler-cache: true
|
18
|
+
- name: Run Danger
|
19
|
+
run: |
|
20
|
+
# the personal token is public, this is ok, base64 encode to avoid tripping Github
|
21
|
+
TOKEN=$(echo -n Z2hwX0xNQ3VmanBFeTBvYkZVTWh6NVNqVFFBOEUxU25abzBqRUVuaAo= | base64 --decode)
|
22
|
+
DANGER_GITHUB_API_TOKEN=$TOKEN bundle exec danger --verbose
|
@@ -0,0 +1,16 @@
|
|
1
|
+
name: lint
|
2
|
+
on: [push, pull_request]
|
3
|
+
jobs:
|
4
|
+
rubocop:
|
5
|
+
name: RuboCop
|
6
|
+
runs-on: ubuntu-latest
|
7
|
+
steps:
|
8
|
+
- name: Checkout
|
9
|
+
uses: actions/checkout@v3
|
10
|
+
- name: Set up Ruby
|
11
|
+
uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: '2.7'
|
14
|
+
bundler-cache: true
|
15
|
+
- run: bundle exec rubocop
|
16
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
---
|
2
|
+
name: test
|
3
|
+
on: [push, pull_request]
|
4
|
+
jobs:
|
5
|
+
test:
|
6
|
+
runs-on: ubuntu-latest
|
7
|
+
strategy:
|
8
|
+
fail-fast: false
|
9
|
+
matrix:
|
10
|
+
entry:
|
11
|
+
- { ruby: '3.2' }
|
12
|
+
- { ruby: '2.7' }
|
13
|
+
- { ruby: 'ruby-head', allowed-failure: true }
|
14
|
+
- { ruby: 'jruby-head', allowed-failure: true }
|
15
|
+
name: test (${{ matrix.entry.ruby }})
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v3
|
18
|
+
- uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: ${{ matrix.entry.ruby }}
|
21
|
+
bundler-cache: true
|
22
|
+
- run: bundle exec rake test spinach
|
23
|
+
continue-on-error: ${{ matrix.entry.allowed-failure || false }}
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,21 +1,52 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2024-02-01 15:28:54 UTC using RuboCop version 1.48.1.
|
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
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
10
|
-
#
|
11
|
-
#
|
9
|
+
# Offense count: 1
|
10
|
+
# Configuration parameters: Severity, Include.
|
11
|
+
# Include: **/*.gemspec
|
12
|
+
Gemspec/RequiredRubyVersion:
|
13
|
+
Exclude:
|
14
|
+
- 'hyperclient.gemspec'
|
15
|
+
|
16
|
+
# Offense count: 1
|
17
|
+
# Configuration parameters: AllowComments, AllowEmptyLambdas.
|
18
|
+
Lint/EmptyBlock:
|
19
|
+
Exclude:
|
20
|
+
- 'test/hyperclient/entry_point_test.rb'
|
21
|
+
|
22
|
+
# Offense count: 4
|
23
|
+
Lint/MissingSuper:
|
24
|
+
Exclude:
|
25
|
+
- 'lib/hyperclient/attributes.rb'
|
26
|
+
- 'lib/hyperclient/entry_point.rb'
|
27
|
+
- 'lib/hyperclient/link_collection.rb'
|
28
|
+
- 'lib/hyperclient/resource_collection.rb'
|
29
|
+
|
30
|
+
# Offense count: 1
|
31
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
32
|
+
# Configuration parameters: AllowedMethods.
|
33
|
+
# AllowedMethods: instance_of?, kind_of?, is_a?, eql?, respond_to?, equal?
|
34
|
+
Lint/RedundantSafeNavigation:
|
35
|
+
Exclude:
|
36
|
+
- 'lib/hyperclient/link.rb'
|
37
|
+
|
38
|
+
# Offense count: 3
|
39
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
40
|
+
# Configuration parameters: EnforcedStyle.
|
12
41
|
# SupportedStyles: nested, compact
|
13
42
|
Style/ClassAndModuleChildren:
|
14
43
|
Exclude:
|
15
44
|
- 'features/steps/api_navigation.rb'
|
16
45
|
- 'features/steps/default_config.rb'
|
46
|
+
- 'features/support/env.rb'
|
17
47
|
|
18
|
-
# Offense count:
|
48
|
+
# Offense count: 5
|
49
|
+
# Configuration parameters: AllowedConstants.
|
19
50
|
Style/Documentation:
|
20
51
|
Exclude:
|
21
52
|
- 'spec/**/*'
|
@@ -23,30 +54,5 @@ Style/Documentation:
|
|
23
54
|
- 'features/steps/api_navigation.rb'
|
24
55
|
- 'features/steps/default_config.rb'
|
25
56
|
- 'features/support/api.rb'
|
57
|
+
- 'features/support/env.rb'
|
26
58
|
- 'features/support/fixtures.rb'
|
27
|
-
|
28
|
-
# Offense count: 2
|
29
|
-
Style/DoubleNegation:
|
30
|
-
Exclude:
|
31
|
-
- 'lib/hyperclient/curie.rb'
|
32
|
-
- 'lib/hyperclient/link.rb'
|
33
|
-
|
34
|
-
# Offense count: 3
|
35
|
-
# Cop supports --auto-correct.
|
36
|
-
Style/IfUnlessModifier:
|
37
|
-
Exclude:
|
38
|
-
- 'lib/hyperclient/link_collection.rb'
|
39
|
-
- 'lib/hyperclient/resource.rb'
|
40
|
-
- 'lib/hyperclient/resource_collection.rb'
|
41
|
-
|
42
|
-
# Offense count: 1
|
43
|
-
Style/MethodMissingSuper:
|
44
|
-
Exclude:
|
45
|
-
- 'lib/hyperclient/collection.rb'
|
46
|
-
|
47
|
-
# Offense count: 101
|
48
|
-
# Cop supports --auto-correct.
|
49
|
-
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
50
|
-
# URISchemes: http, https
|
51
|
-
Layout/LineLength:
|
52
|
-
Max: 147
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## Changelog
|
2
2
|
|
3
|
+
### 2.0.0 (2024/02/01)
|
4
|
+
|
5
|
+
* [#268](https://github.com/codegram/hyperclient/pull/268): Replace Travis-CI with GHA - [@dblock](https://github.com/dblock).
|
6
|
+
* [#269](https://github.com/codegram/hyperclient/pull/269): Re-add code coverage - [@dblock](https://github.com/dblock).
|
7
|
+
* [#270](https://github.com/codegram/hyperclient/pull/270): Upgrade Rubocop to 1.45 - [@dblock](https://github.com/dblock).
|
8
|
+
* [#271](https://github.com/codegram/hyperclient/pull/271): Test against Ruby 3.2 - [@dblock](https://github.com/dblock).
|
9
|
+
* [#285](https://github.com/codegram/hyperclient/pull/285): Support Faraday 2.x - [@dblock](https://github.com/dblock).
|
10
|
+
|
3
11
|
### 1.0.1 (2021/01/02)
|
4
12
|
|
5
13
|
* [#193](https://github.com/codegram/hyperclient/pull/193): Auto-paginate collections - [@dblock](https://github.com/dblock).
|
data/CONTRIBUTING.md
CHANGED
@@ -106,7 +106,7 @@ git push origin my-feature-branch -f
|
|
106
106
|
|
107
107
|
#### Check on Your Pull Request
|
108
108
|
|
109
|
-
Go back to your pull request after a few minutes and see whether it passed muster with
|
109
|
+
Go back to your pull request after a few minutes and see whether it passed muster with CI. Everything should look green, otherwise fix issues and amend your commit as described above.
|
110
110
|
|
111
111
|
#### Be Patient
|
112
112
|
|
data/Gemfile
CHANGED
@@ -1,10 +1,5 @@
|
|
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
|
-
|
4
1
|
source 'https://rubygems.org'
|
5
2
|
|
6
|
-
gem 'faraday', ENV['FARADAY_VERSION'] if ENV.key?('FARADAY_VERSION')
|
7
|
-
|
8
3
|
gemspec
|
9
4
|
|
10
5
|
group :development do
|
@@ -18,8 +13,11 @@ end
|
|
18
13
|
|
19
14
|
group :development, :test do
|
20
15
|
gem 'rake'
|
21
|
-
gem 'rubocop', '
|
16
|
+
gem 'rubocop', '~> 1.48.0', require: false
|
17
|
+
gem 'rubocop-minitest', require: false
|
18
|
+
gem 'rubocop-rake', require: false
|
22
19
|
gem 'simplecov', require: false
|
20
|
+
gem 'simplecov-lcov', require: false
|
23
21
|
end
|
24
22
|
|
25
23
|
group :test do
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Hyperclient
|
2
2
|
|
3
3
|
[![Gem Version](http://img.shields.io/gem/v/hyperclient.svg)](http://badge.fury.io/rb/hyperclient)
|
4
|
-
[![Build Status](
|
4
|
+
[![Build Status](https://github.com/codegram/hyperclient/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/codegram/hyperclient/actions/workflows/test.yml)
|
5
5
|
[![Code Climate](https://codeclimate.com/github/codegram/hyperclient.svg)](https://codeclimate.com/github/codegram/hyperclient)
|
6
6
|
[![Coverage Status](https://img.shields.io/coveralls/codegram/hyperclient.svg)](https://coveralls.io/r/codegram/hyperclient?branch=master)
|
7
7
|
|
@@ -25,7 +25,7 @@ Hyperclient is a Hypermedia API client written in Ruby. It fully supports [JSON
|
|
25
25
|
|
26
26
|
# Usage
|
27
27
|
|
28
|
-
The examples in this README use the [Splines Demo API](https://github.com/ruby-grape/grape-with-roar) running [here](https://grape-with-roar.herokuapp.com/api). If you're upgrading from a previous version, please make sure to read [UPGRADING](UPGRADING.md).
|
28
|
+
The examples in this README use the [Splines Demo API](https://github.com/ruby-grape/grape-with-roar) running [here](https://grape-with-roar.herokuapp.com/api). Use version 1.x with Faraday 1.x, and version 2.x with Faraday 2.x. If you're upgrading from a previous version, please make sure to read [UPGRADING](UPGRADING.md).
|
29
29
|
|
30
30
|
## API Client
|
31
31
|
|
@@ -50,7 +50,7 @@ Hyperclient constructs a connection using typical [Faraday](http://github.com/lo
|
|
50
50
|
```ruby
|
51
51
|
api = Hyperclient.new('https://grape-with-roar.herokuapp.com/api') do |client|
|
52
52
|
client.connection do |conn|
|
53
|
-
conn.use Faraday::Request::
|
53
|
+
conn.use Faraday::Request::Instrumentation
|
54
54
|
end
|
55
55
|
end
|
56
56
|
```
|
@@ -60,7 +60,7 @@ You can pass options to the Faraday connection block in the `connection` block:
|
|
60
60
|
```ruby
|
61
61
|
api = Hyperclient.new('https://grape-with-roar.herokuapp.com/api') do |client|
|
62
62
|
client.connection(ssl: { verify: false }) do |conn|
|
63
|
-
conn.use Faraday::Request::
|
63
|
+
conn.use Faraday::Request::Instrumentation
|
64
64
|
end
|
65
65
|
end
|
66
66
|
```
|
data/RELEASING.md
CHANGED
@@ -12,7 +12,7 @@ bundle install
|
|
12
12
|
rake
|
13
13
|
```
|
14
14
|
|
15
|
-
Check that the last build succeeded in
|
15
|
+
Check that the last build succeeded in CI for all supported platforms.
|
16
16
|
|
17
17
|
Increment the version, modify [lib/hyperclient/version.rb](lib/hyperclient/version.rb).
|
18
18
|
|
data/Rakefile
CHANGED
@@ -6,14 +6,6 @@ Bundler.setup :default, :test, :development
|
|
6
6
|
|
7
7
|
Bundler::GemHelper.install_tasks
|
8
8
|
|
9
|
-
if ENV['COVERAGE']
|
10
|
-
require 'simplecov'
|
11
|
-
SimpleCov.start do
|
12
|
-
add_filter '/test/'
|
13
|
-
add_filter '/features/'
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
9
|
require 'rake/testtask'
|
18
10
|
|
19
11
|
Rake::TestTask.new(:test) do |t|
|
@@ -43,13 +43,13 @@ class Spinach::Features::ApiNavigation < Spinach::FeatureSteps
|
|
43
43
|
end
|
44
44
|
|
45
45
|
step 'I should be able to access it\'s title and body' do
|
46
|
-
@post._attributes.title
|
47
|
-
@post._attributes.body
|
46
|
+
assert_kind_of String, @post._attributes.title
|
47
|
+
assert_kind_of String, @post._attributes.body
|
48
48
|
end
|
49
49
|
|
50
50
|
step 'I should also be able to access it\'s embedded comments' do
|
51
51
|
comment = @post._embedded.comments.first
|
52
|
-
comment._attributes.title
|
52
|
+
assert_kind_of String, comment._attributes.title
|
53
53
|
end
|
54
54
|
|
55
55
|
step 'I should be able to navigate to next page' do
|
@@ -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
|
29
|
-
@posts._attributes['total_posts'].to_i
|
28
|
+
assert_equal 4, @posts._attributes.total_posts.to_i
|
29
|
+
assert_equal 4, @posts._attributes['total_posts'].to_i
|
30
30
|
end
|
31
31
|
end
|
data/features/support/api.rb
CHANGED
@@ -7,17 +7,28 @@ module API
|
|
7
7
|
before do
|
8
8
|
WebMock::Config.instance.query_values_notation = :flat_array
|
9
9
|
|
10
|
-
stub_request(:any, /api.example.org*/).to_return(body: root_response,
|
11
|
-
|
12
|
-
stub_request(:get, 'api.example.org
|
13
|
-
|
14
|
-
stub_request(:get, 'api.example.org/
|
15
|
-
|
16
|
-
stub_request(:get, 'api.example.org/posts
|
17
|
-
|
18
|
-
stub_request(:get, 'api.example.org/posts
|
19
|
-
|
20
|
-
stub_request(:get, 'api.example.org/
|
10
|
+
stub_request(:any, /api.example.org*/).to_return(body: root_response,
|
11
|
+
headers: { 'Content-Type' => 'application/hal+json' })
|
12
|
+
stub_request(:get, 'api.example.org').to_return(body: root_response,
|
13
|
+
headers: { 'Content-Type' => 'application/hal+json' })
|
14
|
+
stub_request(:get, 'api.example.org/authors').to_return(body: authors_response,
|
15
|
+
headers: { 'Content-Type' => 'application/hal+json' })
|
16
|
+
stub_request(:get, 'api.example.org/posts').to_return(body: posts_response,
|
17
|
+
headers: { 'Content-Type' => 'application/hal+json' })
|
18
|
+
stub_request(:get, 'api.example.org/posts?page=2').to_return(body: posts_page2_response,
|
19
|
+
headers: { 'Content-Type' => 'application/hal+json' })
|
20
|
+
stub_request(:get, 'api.example.org/posts?page=3').to_return(body: posts_page3_response,
|
21
|
+
headers: { 'Content-Type' => 'application/hal+json' })
|
22
|
+
stub_request(:get, 'api.example.org/posts/1').to_return(body: post1_response,
|
23
|
+
headers: { 'Content-Type' => 'application/hal+json' })
|
24
|
+
stub_request(:get, 'api.example.org/posts/2').to_return(body: post2_response,
|
25
|
+
headers: { 'Content-Type' => 'application/hal+json' })
|
26
|
+
stub_request(:get, 'api.example.org/posts/3').to_return(body: post3_response,
|
27
|
+
headers: { 'Content-Type' => 'application/hal+json' })
|
28
|
+
stub_request(:get, 'api.example.org/page2').to_return(body: page2_response,
|
29
|
+
headers: { 'Content-Type' => 'application/hal+json' })
|
30
|
+
stub_request(:get, 'api.example.org/page3').to_return(body: page3_response,
|
31
|
+
headers: { 'Content-Type' => 'application/hal+json' })
|
21
32
|
end
|
22
33
|
|
23
34
|
def api
|
data/features/support/env.rb
CHANGED
@@ -1,4 +1,17 @@
|
|
1
|
-
require 'minitest
|
1
|
+
require 'minitest'
|
2
2
|
require 'webmock'
|
3
3
|
WebMock.enable!
|
4
4
|
require 'hyperclient'
|
5
|
+
|
6
|
+
Minitest::Spec.new nil if defined?(Minitest::Spec)
|
7
|
+
Spinach.config[:failure_exceptions] << Minitest::Assertion
|
8
|
+
|
9
|
+
class Spinach::FeatureSteps
|
10
|
+
include Minitest::Assertions
|
11
|
+
attr_accessor :assertions
|
12
|
+
|
13
|
+
def initialize(*args)
|
14
|
+
super(*args)
|
15
|
+
self.assertions = 0
|
16
|
+
end
|
17
|
+
end
|
data/hyperclient.gemspec
CHANGED
@@ -8,13 +8,13 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.homepage = 'https://github.com/codegram/hyperclient/'
|
9
9
|
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
10
10
|
gem.files = `git ls-files`.split("\n")
|
11
|
-
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
12
11
|
gem.name = 'hyperclient'
|
13
12
|
gem.require_paths = ['lib']
|
14
13
|
gem.version = Hyperclient::VERSION
|
15
14
|
|
16
15
|
gem.add_dependency 'addressable'
|
17
|
-
gem.add_dependency 'faraday', '>=
|
18
|
-
gem.add_dependency '
|
19
|
-
gem.add_dependency '
|
16
|
+
gem.add_dependency 'faraday', '>= 2'
|
17
|
+
gem.add_dependency 'faraday-follow_redirects'
|
18
|
+
gem.add_dependency 'faraday_hal_middleware', '>= 0.2'
|
19
|
+
gem.metadata['rubygems_mfa_required'] = 'true'
|
20
20
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'faraday/follow_redirects'
|
2
2
|
require 'faraday_hal_middleware'
|
3
3
|
|
4
4
|
module Hyperclient
|
@@ -20,7 +20,7 @@ module Hyperclient
|
|
20
20
|
#
|
21
21
|
# client = Hyperclient::EntryPoint.new('http://my.api.org') do |entry_point|
|
22
22
|
# entry_point.connection do |conn|
|
23
|
-
# conn.use Faraday::Request::
|
23
|
+
# conn.use Faraday::Request::Instrumentation
|
24
24
|
# end
|
25
25
|
# entry_point.headers['Access-Token'] = 'token'
|
26
26
|
# end
|
@@ -138,7 +138,7 @@ module Hyperclient
|
|
138
138
|
def default_faraday_block
|
139
139
|
lambda do |connection, &block|
|
140
140
|
connection.use Faraday::Response::RaiseError
|
141
|
-
connection.use
|
141
|
+
connection.use Faraday::FollowRedirects::Middleware
|
142
142
|
connection.request :hal_json
|
143
143
|
connection.response :hal_json, content_type: /\bjson$/
|
144
144
|
|
data/lib/hyperclient/resource.rb
CHANGED
@@ -111,9 +111,7 @@ module Hyperclient
|
|
111
111
|
elsif !Array.method_defined?(method)
|
112
112
|
%i[_attributes _embedded _links].each do |target|
|
113
113
|
target = send(target)
|
114
|
-
if target.respond_to?(method.to_s)
|
115
|
-
return target.send(method, *args, &block)
|
116
|
-
end
|
114
|
+
return target.send(method, *args, &block) if target.respond_to?(method.to_s)
|
117
115
|
end
|
118
116
|
super
|
119
117
|
end
|
@@ -23,9 +23,7 @@ module Hyperclient
|
|
23
23
|
private
|
24
24
|
|
25
25
|
def build_resource(representation)
|
26
|
-
if representation.is_a?(Array)
|
27
|
-
return representation.map(&method(:build_resource))
|
28
|
-
end
|
26
|
+
return representation.map(&method(:build_resource)) if representation.is_a?(Array)
|
29
27
|
|
30
28
|
Resource.new(representation, @entry_point)
|
31
29
|
end
|
data/lib/hyperclient/version.rb
CHANGED
@@ -26,18 +26,18 @@ module Hyperclient
|
|
26
26
|
|
27
27
|
it 'can insert additional middleware after a connection has been constructed' do
|
28
28
|
_(entry_point.connection).must_be_kind_of Faraday::Connection
|
29
|
-
entry_point.connection.use
|
29
|
+
entry_point.connection.use Faraday::Request::Instrumentation
|
30
30
|
handlers = entry_point.connection.builder.handlers
|
31
|
-
_(handlers).must_include
|
31
|
+
_(handlers).must_include Faraday::Request::Instrumentation
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'creates a Faraday connection with the default block' do
|
35
35
|
handlers = entry_point.connection.builder.handlers
|
36
36
|
|
37
37
|
_(handlers).must_include Faraday::Response::RaiseError
|
38
|
-
_(handlers).must_include
|
39
|
-
_(handlers).must_include
|
40
|
-
_(handlers).must_include
|
38
|
+
_(handlers).must_include Faraday::FollowRedirects::Middleware
|
39
|
+
_(handlers).must_include Faraday::HalJson::Request
|
40
|
+
_(handlers).must_include Faraday::HalJson::Response
|
41
41
|
|
42
42
|
_(entry_point.connection.options.params_encoder).must_equal Faraday::FlatParamsEncoder
|
43
43
|
end
|
@@ -137,9 +137,9 @@ module Hyperclient
|
|
137
137
|
it 'creates a Faraday connection with the default block' do
|
138
138
|
handlers = entry_point.connection.builder.handlers
|
139
139
|
_(handlers).wont_include Faraday::Response::RaiseError
|
140
|
-
_(handlers).wont_include
|
141
|
-
_(handlers).must_include
|
142
|
-
_(handlers).must_include
|
140
|
+
_(handlers).wont_include Faraday::FollowRedirects
|
141
|
+
_(handlers).must_include Faraday::Request::Json
|
142
|
+
_(handlers).must_include Faraday::Response::Json
|
143
143
|
end
|
144
144
|
end
|
145
145
|
end
|
@@ -148,7 +148,7 @@ module Hyperclient
|
|
148
148
|
let(:entry_point) do
|
149
149
|
EntryPoint.new 'http://my.api.org' do |entry_point|
|
150
150
|
entry_point.connection do |conn|
|
151
|
-
conn.use Faraday::Request::
|
151
|
+
conn.use Faraday::Request::Instrumentation
|
152
152
|
end
|
153
153
|
entry_point.headers['Access-Token'] = 'token'
|
154
154
|
end
|
@@ -168,11 +168,11 @@ module Hyperclient
|
|
168
168
|
it 'creates a Faraday connection with the default block plus any additional handlers' do
|
169
169
|
handlers = entry_point.connection.builder.handlers
|
170
170
|
|
171
|
-
_(handlers).must_include Faraday::Request::
|
171
|
+
_(handlers).must_include Faraday::Request::Instrumentation
|
172
172
|
_(handlers).must_include Faraday::Response::RaiseError
|
173
|
-
_(handlers).must_include
|
174
|
-
_(handlers).must_include
|
175
|
-
_(handlers).must_include
|
173
|
+
_(handlers).must_include Faraday::FollowRedirects::Middleware
|
174
|
+
_(handlers).must_include Faraday::HalJson::Request
|
175
|
+
_(handlers).must_include Faraday::HalJson::Response
|
176
176
|
|
177
177
|
_(entry_point.connection.options.params_encoder).must_equal Faraday::FlatParamsEncoder
|
178
178
|
end
|
@@ -60,7 +60,8 @@ module Hyperclient
|
|
60
60
|
|
61
61
|
describe '_links' do
|
62
62
|
it '_expand' do
|
63
|
-
resource = Resource.new({ '_links' => { 'orders' => { 'href' => '/orders/{id}', 'templated' => true } } },
|
63
|
+
resource = Resource.new({ '_links' => { 'orders' => { 'href' => '/orders/{id}', 'templated' => true } } },
|
64
|
+
entry_point)
|
64
65
|
_(resource._links.orders._expand(id: 1)._url).must_equal '/orders/1'
|
65
66
|
_(resource.orders._expand(id: 1)._url).must_equal '/orders/1'
|
66
67
|
_(resource.orders(id: 1)._url).must_equal '/orders/1'
|
data/test/hyperclient_test.rb
CHANGED
@@ -13,7 +13,7 @@ describe Hyperclient do
|
|
13
13
|
let(:client) do
|
14
14
|
Hyperclient.new('http://api.example.org') do |client|
|
15
15
|
client.connection(default: true) do |conn|
|
16
|
-
conn.use Faraday::Request::
|
16
|
+
conn.use Faraday::Request::Instrumentation
|
17
17
|
end
|
18
18
|
client.headers['Access-Token'] = 'token'
|
19
19
|
end
|
@@ -31,11 +31,11 @@ describe Hyperclient do
|
|
31
31
|
|
32
32
|
it 'creates a Faraday connection with the default block plus any additional handlers' do
|
33
33
|
handlers = client.connection.builder.handlers
|
34
|
-
_(handlers).must_include Faraday::Request::
|
34
|
+
_(handlers).must_include Faraday::Request::Instrumentation
|
35
35
|
_(handlers).must_include Faraday::Response::RaiseError
|
36
|
-
_(handlers).must_include
|
37
|
-
_(handlers).must_include
|
38
|
-
_(handlers).must_include
|
36
|
+
_(handlers).must_include Faraday::FollowRedirects::Middleware
|
37
|
+
_(handlers).must_include Faraday::HalJson::Request
|
38
|
+
_(handlers).must_include Faraday::HalJson::Response
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,11 +1,30 @@
|
|
1
1
|
$LOAD_PATH << 'lib'
|
2
2
|
|
3
|
+
if ENV['COVERAGE']
|
4
|
+
require 'simplecov'
|
5
|
+
require 'simplecov-lcov'
|
6
|
+
SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter
|
7
|
+
SimpleCov::Formatter::LcovFormatter.config do |c|
|
8
|
+
c.report_with_single_file = true
|
9
|
+
c.lcov_file_name = 'lcov.info'
|
10
|
+
c.single_report_path = 'coverage/lcov.info'
|
11
|
+
end
|
12
|
+
SimpleCov.start do
|
13
|
+
add_filter '/test/'
|
14
|
+
add_filter '/features/'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
3
18
|
require 'minitest/autorun'
|
4
19
|
require 'minitest/pride'
|
20
|
+
require 'minitest/unit'
|
5
21
|
require 'mocha/minitest'
|
6
22
|
require 'json'
|
7
23
|
|
8
|
-
|
24
|
+
require 'faraday'
|
25
|
+
require 'faraday/request/instrumentation'
|
26
|
+
|
27
|
+
MiniTest::Assertions.class_eval do
|
9
28
|
def stub_request(conn, adapter_class = Faraday::Adapter::Test, &stubs_block)
|
10
29
|
adapter_handler = conn.builder.handlers.find { |h| h.klass < Faraday::Adapter }
|
11
30
|
if adapter_handler
|
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:
|
4
|
+
version: 2.0.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: 2024-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -30,16 +30,16 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '2'
|
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:
|
40
|
+
version: '2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: faraday-follow_redirects
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,19 +53,19 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
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'
|
61
|
+
version: '0.2'
|
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'
|
68
|
+
version: '0.2'
|
69
69
|
description: Hyperclient is a Ruby Hypermedia API client.
|
70
70
|
email:
|
71
71
|
- oriol.gual@gmail.com
|
@@ -73,10 +73,15 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- ".DS_Store"
|
77
|
+
- ".github/dependabot.yml"
|
78
|
+
- ".github/workflows/coverage.yml"
|
79
|
+
- ".github/workflows/danger.yml"
|
80
|
+
- ".github/workflows/lint.yml"
|
81
|
+
- ".github/workflows/test.yml"
|
76
82
|
- ".gitignore"
|
77
83
|
- ".rubocop.yml"
|
78
84
|
- ".rubocop_todo.yml"
|
79
|
-
- ".travis.yml"
|
80
85
|
- ".yardopts"
|
81
86
|
- CHANGELOG.md
|
82
87
|
- CONTRIBUTING.md
|
@@ -122,7 +127,8 @@ files:
|
|
122
127
|
- test/test_helper.rb
|
123
128
|
homepage: https://github.com/codegram/hyperclient/
|
124
129
|
licenses: []
|
125
|
-
metadata:
|
130
|
+
metadata:
|
131
|
+
rubygems_mfa_required: 'true'
|
126
132
|
post_install_message:
|
127
133
|
rdoc_options: []
|
128
134
|
require_paths:
|
@@ -138,28 +144,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
144
|
- !ruby/object:Gem::Version
|
139
145
|
version: '0'
|
140
146
|
requirements: []
|
141
|
-
rubygems_version: 3.1.
|
147
|
+
rubygems_version: 3.1.4
|
142
148
|
signing_key:
|
143
149
|
specification_version: 4
|
144
150
|
summary: ''
|
145
|
-
test_files:
|
146
|
-
- features/api_navigation.feature
|
147
|
-
- features/default_config.feature
|
148
|
-
- features/steps/api_navigation.rb
|
149
|
-
- features/steps/default_config.rb
|
150
|
-
- features/support/api.rb
|
151
|
-
- features/support/env.rb
|
152
|
-
- features/support/fixtures.rb
|
153
|
-
- test/fixtures/collection.json
|
154
|
-
- test/fixtures/element.json
|
155
|
-
- test/fixtures/root.json
|
156
|
-
- test/hyperclient/attributes_test.rb
|
157
|
-
- test/hyperclient/collection_test.rb
|
158
|
-
- test/hyperclient/curie_test.rb
|
159
|
-
- test/hyperclient/entry_point_test.rb
|
160
|
-
- test/hyperclient/link_collection_test.rb
|
161
|
-
- test/hyperclient/link_test.rb
|
162
|
-
- test/hyperclient/resource_collection_test.rb
|
163
|
-
- test/hyperclient/resource_test.rb
|
164
|
-
- test/hyperclient_test.rb
|
165
|
-
- test/test_helper.rb
|
151
|
+
test_files: []
|
data/.travis.yml
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
|
3
|
-
sudo: false
|
4
|
-
|
5
|
-
matrix:
|
6
|
-
include:
|
7
|
-
- rvm: 2.6.6
|
8
|
-
env: FARADAY_VERSION=0.9.0
|
9
|
-
- rvm: 2.6.6
|
10
|
-
env: FARADAY_VERSION=0.17.0
|
11
|
-
- rvm: 2.6.6
|
12
|
-
env: FARADAY_VERSION="~> 1.0"
|
13
|
-
- rvm: 2.6.6
|
14
|
-
script:
|
15
|
-
- bundle exec danger
|
16
|
-
- rvm: 2.3.8
|
17
|
-
- rvm: jruby-9.2.7.0
|
18
|
-
- rvm: jruby-head
|
19
|
-
- rvm: ruby-head
|
20
|
-
allow_failures:
|
21
|
-
- rvm: ruby-head
|
22
|
-
- rvm: jruby-head
|
23
|
-
|
24
|
-
bundler_args: --without development
|