relax 0.2.2 → 0.3.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 +7 -0
- data/.github/workflows/build.yml +36 -0
- data/.gitignore +1 -0
- data/.rspec +1 -2
- data/Appraisals +7 -0
- data/CHANGELOG.md +5 -0
- data/gemfiles/faraday_2.0.gemfile +7 -0
- data/gemfiles/faraday_2.7.gemfile +7 -0
- data/lib/relax/version.rb +1 -1
- data/relax.gemspec +15 -13
- data/spec/relax/client_spec.rb +7 -14
- data/spec/relax/config_spec.rb +24 -11
- data/spec/relax/configurable_spec.rb +7 -14
- data/spec/relax/delegator_spec.rb +7 -8
- data/spec/relax/resource_spec.rb +23 -17
- data/spec/spec_helper.rb +0 -1
- metadata +44 -32
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: e9a6f87140b7758340b4a69166c801d0953f84bb0f820f23d3d817e281985d4c
|
|
4
|
+
data.tar.gz: a11fd29fd730571425e4c4160e04a199e94cbab9488babd5485e8012454a694c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 950f73a57eb7f5f7373c862e150a323814d5aba741b9ea4c62aed447f8cd9bb2dea48f8cb0213d8ee74c8e527853514bab77353ae7d16916b53c1c2a9508fcbb
|
|
7
|
+
data.tar.gz: e0e08e5b49c6b926d79e8910762e56cd73f0762b789fc22149c95038d6250bf0fec294205872979af7d71edbcc878ebe3ee999999f569e9adbad40ea490e8f09
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: Build
|
|
2
|
+
on:
|
|
3
|
+
- push
|
|
4
|
+
- pull_request
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
build:
|
|
8
|
+
name: Ruby ${{ matrix.ruby }} / Faraday ${{ matrix.faraday }}
|
|
9
|
+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
|
|
10
|
+
strategy:
|
|
11
|
+
fail-fast: false
|
|
12
|
+
matrix:
|
|
13
|
+
ruby:
|
|
14
|
+
- "2.6"
|
|
15
|
+
- "2.7"
|
|
16
|
+
- "3.0"
|
|
17
|
+
- "3.1"
|
|
18
|
+
faraday:
|
|
19
|
+
- "2.0"
|
|
20
|
+
- "2.7"
|
|
21
|
+
|
|
22
|
+
runs-on: "ubuntu-latest"
|
|
23
|
+
|
|
24
|
+
env:
|
|
25
|
+
BUNDLE_GEMFILE: gemfiles/faraday_${{ matrix.faraday }}.gemfile
|
|
26
|
+
RUBYOPT: "--disable-error_highlight"
|
|
27
|
+
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@v2
|
|
30
|
+
- uses: ruby/setup-ruby@v1
|
|
31
|
+
with:
|
|
32
|
+
ruby-version: ${{ matrix.ruby }}
|
|
33
|
+
- name: Setup project
|
|
34
|
+
run: bundle install
|
|
35
|
+
- name: Run tests
|
|
36
|
+
run: bundle exec rspec
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
--
|
|
2
|
-
--format progress
|
|
1
|
+
--require spec_helper
|
data/Appraisals
ADDED
data/CHANGELOG.md
CHANGED
data/lib/relax/version.rb
CHANGED
data/relax.gemspec
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
require './lib/relax/version'
|
|
2
2
|
|
|
3
|
-
Gem::Specification.new do |
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
Gem::Specification.new do |spec|
|
|
4
|
+
spec.name = 'relax'
|
|
5
|
+
spec.version = Relax::VERSION
|
|
6
|
+
spec.authors = ['Tyler Hunt']
|
|
7
|
+
spec.summary = 'A flexible library for creating web service consumers.'
|
|
8
|
+
spec.homepage = 'http://github.com/tylerhunt/relax'
|
|
9
|
+
spec.license = 'MIT'
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
spec.required_ruby_version = '>= 2.6'
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
spec.add_dependency 'faraday', '~> 2.0'
|
|
14
|
+
spec.add_development_dependency 'rspec', '~> 3.12'
|
|
15
|
+
spec.add_development_dependency 'appraisal', '~> 2.4'
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
spec.files = `git ls-files`.split($\)
|
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
20
|
+
spec.require_paths = ['lib']
|
|
19
21
|
end
|
data/spec/relax/client_spec.rb
CHANGED
|
@@ -1,31 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
describe Relax::Client do
|
|
4
|
-
let(:client) { Class.new { include Relax::Client }.new }
|
|
5
|
-
|
|
6
|
-
subject { client }
|
|
1
|
+
RSpec.describe Relax::Client do
|
|
2
|
+
subject(:client) { Class.new { include Relax::Client }.new }
|
|
7
3
|
|
|
8
4
|
context '#config' do
|
|
9
5
|
it 'returns an instance of Relax::Config' do
|
|
10
|
-
|
|
6
|
+
expect(client.config).to be_a Relax::Config
|
|
11
7
|
end
|
|
12
8
|
|
|
13
9
|
it 'memoizes the configuration' do
|
|
14
|
-
|
|
10
|
+
expect(client.config).to eq client.config
|
|
15
11
|
end
|
|
16
12
|
end
|
|
17
13
|
|
|
18
14
|
context '#configure' do
|
|
19
15
|
it 'yields an instance of the configuration' do
|
|
20
|
-
expect {
|
|
21
|
-
|
|
22
|
-
config.base_uri = 'http://api.example.com/v2'
|
|
23
|
-
end
|
|
24
|
-
}.to change(subject.config, :base_uri).to('http://api.example.com/v2')
|
|
16
|
+
expect { |block| client.configure &block }
|
|
17
|
+
.to yield_with_args(client.config)
|
|
25
18
|
end
|
|
26
19
|
|
|
27
20
|
it 'returns self' do
|
|
28
|
-
|
|
21
|
+
expect(client.configure {}).to eq client
|
|
29
22
|
end
|
|
30
23
|
end
|
|
31
24
|
end
|
data/spec/relax/config_spec.rb
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
describe Relax::Config do
|
|
1
|
+
RSpec.describe Relax::Config do
|
|
4
2
|
{
|
|
5
3
|
USER_AGENT: "Relax Ruby Gem Client #{Relax::VERSION}",
|
|
6
4
|
TIMEOUT: 60
|
|
@@ -8,18 +6,33 @@ describe Relax::Config do
|
|
|
8
6
|
context "::#{constant}" do
|
|
9
7
|
subject { described_class.const_get(constant) }
|
|
10
8
|
|
|
11
|
-
it {
|
|
9
|
+
it { is_expected.to eq value }
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
subject(:config) { described_class.new }
|
|
14
|
+
|
|
15
|
+
context '#adapter' do
|
|
16
|
+
it 'defaults to Faraday’s default adapter' do
|
|
17
|
+
expect(config.adapter).to eq Faraday.default_adapter
|
|
12
18
|
end
|
|
13
19
|
end
|
|
14
20
|
|
|
15
|
-
context '
|
|
16
|
-
|
|
21
|
+
context '#base_uri' do
|
|
22
|
+
it 'defaults to nil' do
|
|
23
|
+
expect(config.base_uri).to be_nil
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
context '#adapter' do
|
|
28
|
+
it 'has a default value' do
|
|
29
|
+
expect(config.timeout).to eq 60
|
|
30
|
+
end
|
|
31
|
+
end
|
|
17
32
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
its(:timeout) { should == 60 }
|
|
22
|
-
its(:user_agent) { should == "Relax Ruby Gem Client #{Relax::VERSION}" }
|
|
33
|
+
context '#adapter' do
|
|
34
|
+
it 'has a default value' do
|
|
35
|
+
expect(config.user_agent).to eq "Relax Ruby Gem Client #{Relax::VERSION}"
|
|
23
36
|
end
|
|
24
37
|
end
|
|
25
38
|
end
|
|
@@ -1,31 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
describe Relax::Configurable do
|
|
4
|
-
let(:configurable) { Class.new { include Relax::Configurable }.new }
|
|
5
|
-
|
|
6
|
-
subject { configurable }
|
|
1
|
+
RSpec.describe Relax::Configurable do
|
|
2
|
+
subject(:configurable) { Class.new { include Relax::Configurable }.new }
|
|
7
3
|
|
|
8
4
|
context '#config' do
|
|
9
5
|
it 'returns an instance of Relax::Config' do
|
|
10
|
-
|
|
6
|
+
expect(configurable.config).to be_a Relax::Config
|
|
11
7
|
end
|
|
12
8
|
|
|
13
9
|
it 'memoizes the configuration' do
|
|
14
|
-
|
|
10
|
+
expect(configurable.config).to eq configurable.config
|
|
15
11
|
end
|
|
16
12
|
end
|
|
17
13
|
|
|
18
14
|
context '#configure' do
|
|
19
15
|
it 'yields an instance of the configuration' do
|
|
20
|
-
expect {
|
|
21
|
-
|
|
22
|
-
config.base_uri = 'http://api.example.com/v2'
|
|
23
|
-
end
|
|
24
|
-
}.to change(subject.config, :base_uri).to('http://api.example.com/v2')
|
|
16
|
+
expect { |block| configurable.configure &block }
|
|
17
|
+
.to yield_with_args(configurable.config)
|
|
25
18
|
end
|
|
26
19
|
|
|
27
20
|
it 'returns self' do
|
|
28
|
-
|
|
21
|
+
expect(configurable.configure {}).to eq configurable
|
|
29
22
|
end
|
|
30
23
|
end
|
|
31
24
|
end
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
describe Relax::Delegator do
|
|
1
|
+
RSpec.describe Relax::Delegator do
|
|
4
2
|
let(:client) { Class.new { include Relax::Client } }
|
|
5
3
|
|
|
6
|
-
subject do
|
|
4
|
+
subject(:delegator) do
|
|
7
5
|
Class.new do
|
|
8
6
|
extend Relax::Delegator[:client]
|
|
9
7
|
|
|
@@ -13,19 +11,20 @@ describe Relax::Delegator do
|
|
|
13
11
|
end
|
|
14
12
|
end
|
|
15
13
|
|
|
16
|
-
before {
|
|
14
|
+
before { delegator.client = client.new }
|
|
17
15
|
|
|
18
16
|
context '.[]' do
|
|
19
17
|
it 'accepts a client method name and returns a module' do
|
|
20
|
-
described_class[:client].
|
|
18
|
+
expect(described_class[:client]).to be_a Module
|
|
21
19
|
end
|
|
22
20
|
end
|
|
23
21
|
|
|
24
22
|
context 'delegation' do
|
|
25
23
|
Relax::Client.instance_methods.each do |method|
|
|
26
24
|
it "delegates .#{method} to the client" do
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
expect(delegator.client).to receive(method)
|
|
26
|
+
|
|
27
|
+
delegator.send method
|
|
29
28
|
end
|
|
30
29
|
end
|
|
31
30
|
end
|
data/spec/relax/resource_spec.rb
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
describe Relax::Resource do
|
|
1
|
+
RSpec.describe Relax::Resource do
|
|
4
2
|
let(:client) do
|
|
5
3
|
Class.new do
|
|
6
4
|
include Relax::Client
|
|
@@ -13,7 +11,7 @@ describe Relax::Resource do
|
|
|
13
11
|
|
|
14
12
|
let(:resource_class) { Class.new { include Relax::Resource } }
|
|
15
13
|
|
|
16
|
-
subject { resource_class.new(client) }
|
|
14
|
+
subject(:resource) { resource_class.new(client) }
|
|
17
15
|
|
|
18
16
|
context '.new' do
|
|
19
17
|
it 'accepts an options hash' do
|
|
@@ -22,42 +20,50 @@ describe Relax::Resource do
|
|
|
22
20
|
end
|
|
23
21
|
|
|
24
22
|
context '#connection' do
|
|
25
|
-
let(:connection) {
|
|
23
|
+
let(:connection) { resource.send(:connection) }
|
|
26
24
|
|
|
27
25
|
it 'returns an instance of Faraday::Connection' do
|
|
28
|
-
connection.
|
|
26
|
+
expect(connection).to be_a Faraday::Connection
|
|
29
27
|
end
|
|
30
28
|
|
|
31
29
|
it 'uses the configured base URI as the URL' do
|
|
32
|
-
connection.url_prefix.
|
|
30
|
+
expect(connection.url_prefix).to eq URI.parse(client.config.base_uri)
|
|
33
31
|
end
|
|
34
32
|
|
|
35
33
|
it 'uses the configured timeout' do
|
|
36
|
-
connection.options[:timeout].
|
|
34
|
+
expect(connection.options[:timeout]).to eq client.config.timeout
|
|
37
35
|
end
|
|
38
36
|
|
|
39
37
|
it 'accepts an options hash to be passed to Faraday::Connection' do
|
|
40
38
|
headers = { user_agent: "#{described_class} Test" }
|
|
41
|
-
connection =
|
|
42
|
-
|
|
39
|
+
connection = resource.send(:connection, headers: headers)
|
|
40
|
+
|
|
41
|
+
expect(connection.headers['User-Agent']).to eq headers[:user_agent]
|
|
43
42
|
end
|
|
44
43
|
|
|
45
44
|
it 'yields a builder to allow the middleware to be customized' do
|
|
46
|
-
|
|
47
|
-
builder.use
|
|
48
|
-
|
|
45
|
+
connection = resource.send(:connection) { |builder|
|
|
46
|
+
builder.use Faraday::Response::Logger
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
expect(connection.builder.handlers).to include Faraday::Response::Logger
|
|
49
50
|
end
|
|
50
51
|
end
|
|
51
52
|
|
|
52
53
|
context 'connection delegation' do
|
|
53
|
-
let(:connection) {
|
|
54
|
+
let(:connection) { double(:connection) }
|
|
54
55
|
|
|
55
|
-
before
|
|
56
|
+
before do
|
|
57
|
+
allow(resource)
|
|
58
|
+
.to receive(:connection)
|
|
59
|
+
.and_return(connection)
|
|
60
|
+
end
|
|
56
61
|
|
|
57
62
|
Faraday::Connection::METHODS.each do |method|
|
|
58
63
|
it "delegates ##{method} to #connection" do
|
|
59
|
-
connection.
|
|
60
|
-
|
|
64
|
+
expect(connection).to receive(method)
|
|
65
|
+
|
|
66
|
+
resource.send method
|
|
61
67
|
end
|
|
62
68
|
end
|
|
63
69
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,57 +1,68 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: relax
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 0.3.0
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- Tyler Hunt
|
|
9
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 2022-11-18 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: faraday
|
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
|
17
|
-
none: false
|
|
18
16
|
requirements:
|
|
19
|
-
- - ~>
|
|
17
|
+
- - "~>"
|
|
20
18
|
- !ruby/object:Gem::Version
|
|
21
|
-
version:
|
|
19
|
+
version: '2.0'
|
|
22
20
|
type: :runtime
|
|
23
21
|
prerelease: false
|
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
-
none: false
|
|
26
23
|
requirements:
|
|
27
|
-
- - ~>
|
|
24
|
+
- - "~>"
|
|
28
25
|
- !ruby/object:Gem::Version
|
|
29
|
-
version:
|
|
26
|
+
version: '2.0'
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
|
31
28
|
name: rspec
|
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
|
33
|
-
none: false
|
|
34
30
|
requirements:
|
|
35
|
-
- - ~>
|
|
31
|
+
- - "~>"
|
|
36
32
|
- !ruby/object:Gem::Version
|
|
37
|
-
version: '
|
|
33
|
+
version: '3.12'
|
|
38
34
|
type: :development
|
|
39
35
|
prerelease: false
|
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
-
none: false
|
|
42
37
|
requirements:
|
|
43
|
-
- - ~>
|
|
38
|
+
- - "~>"
|
|
44
39
|
- !ruby/object:Gem::Version
|
|
45
|
-
version: '
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
version: '3.12'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: appraisal
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '2.4'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '2.4'
|
|
55
|
+
description:
|
|
56
|
+
email:
|
|
48
57
|
executables: []
|
|
49
58
|
extensions: []
|
|
50
59
|
extra_rdoc_files: []
|
|
51
60
|
files:
|
|
52
|
-
- .
|
|
53
|
-
- .
|
|
54
|
-
- .
|
|
61
|
+
- ".github/workflows/build.yml"
|
|
62
|
+
- ".gitignore"
|
|
63
|
+
- ".rspec"
|
|
64
|
+
- ".travis.yml"
|
|
65
|
+
- Appraisals
|
|
55
66
|
- CHANGELOG.md
|
|
56
67
|
- Gemfile
|
|
57
68
|
- LICENSE
|
|
@@ -60,6 +71,8 @@ files:
|
|
|
60
71
|
- examples/delicious.rb
|
|
61
72
|
- examples/flickr.rb
|
|
62
73
|
- examples/vimeo.rb
|
|
74
|
+
- gemfiles/faraday_2.0.gemfile
|
|
75
|
+
- gemfiles/faraday_2.7.gemfile
|
|
63
76
|
- lib/relax.rb
|
|
64
77
|
- lib/relax/client.rb
|
|
65
78
|
- lib/relax/config.rb
|
|
@@ -75,28 +88,27 @@ files:
|
|
|
75
88
|
- spec/relax/resource_spec.rb
|
|
76
89
|
- spec/spec_helper.rb
|
|
77
90
|
homepage: http://github.com/tylerhunt/relax
|
|
78
|
-
licenses:
|
|
79
|
-
|
|
91
|
+
licenses:
|
|
92
|
+
- MIT
|
|
93
|
+
metadata: {}
|
|
94
|
+
post_install_message:
|
|
80
95
|
rdoc_options: []
|
|
81
96
|
require_paths:
|
|
82
97
|
- lib
|
|
83
98
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
|
-
none: false
|
|
85
99
|
requirements:
|
|
86
|
-
- -
|
|
100
|
+
- - ">="
|
|
87
101
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: '
|
|
102
|
+
version: '2.6'
|
|
89
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
|
-
none: false
|
|
91
104
|
requirements:
|
|
92
|
-
- -
|
|
105
|
+
- - ">="
|
|
93
106
|
- !ruby/object:Gem::Version
|
|
94
107
|
version: '0'
|
|
95
108
|
requirements: []
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
specification_version: 3
|
|
109
|
+
rubygems_version: 3.3.7
|
|
110
|
+
signing_key:
|
|
111
|
+
specification_version: 4
|
|
100
112
|
summary: A flexible library for creating web service consumers.
|
|
101
113
|
test_files:
|
|
102
114
|
- spec/relax/client_spec.rb
|