relax 0.2.0 → 0.2.1
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.
- data/CHANGELOG.md +5 -1
- data/lib/relax/client.rb +2 -0
- data/lib/relax/config.rb +1 -0
- data/lib/relax/resource.rb +2 -2
- data/lib/relax/version.rb +1 -1
- data/spec/relax/client_spec.rb +1 -0
- data/spec/relax/resource_spec.rb +4 -0
- metadata +2 -2
data/CHANGELOG.md
CHANGED
data/lib/relax/client.rb
CHANGED
@@ -3,11 +3,13 @@ require 'faraday'
|
|
3
3
|
module Relax
|
4
4
|
module Client
|
5
5
|
USER_AGENT = "Relax Ruby Gem Client #{Relax::VERSION}"
|
6
|
+
TIMEOUT = 60
|
6
7
|
|
7
8
|
def config
|
8
9
|
@config ||= Config.new.configure do |config|
|
9
10
|
config.adapter = Faraday.default_adapter
|
10
11
|
config.user_agent = USER_AGENT
|
12
|
+
config.timeout = TIMEOUT
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
data/lib/relax/config.rb
CHANGED
data/lib/relax/resource.rb
CHANGED
@@ -14,8 +14,8 @@ module Relax
|
|
14
14
|
|
15
15
|
def connection(options={})
|
16
16
|
options[:url] ||= config.base_uri
|
17
|
-
options[:headers] ||= {}
|
18
|
-
options[:
|
17
|
+
(options[:headers] ||= {})[:user_agent] ||= config.user_agent
|
18
|
+
(options[:request] ||= {})[:timeout] ||= config.timeout
|
19
19
|
|
20
20
|
Faraday.new(options) do |builder|
|
21
21
|
yield(builder) if block_given?
|
data/lib/relax/version.rb
CHANGED
data/spec/relax/client_spec.rb
CHANGED
data/spec/relax/resource_spec.rb
CHANGED
@@ -32,6 +32,10 @@ describe Relax::Resource do
|
|
32
32
|
connection.url_prefix.should == URI.parse(client.config.base_uri)
|
33
33
|
end
|
34
34
|
|
35
|
+
it 'uses the configured timeout' do
|
36
|
+
connection.options[:timeout].should == client.config.timeout
|
37
|
+
end
|
38
|
+
|
35
39
|
it 'accepts an options hash to be passed to Faraday::Connection' do
|
36
40
|
headers = { user_agent: "#{described_class} Test" }
|
37
41
|
connection = subject.send(:connection, headers: headers)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relax
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|