relax 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,10 @@
1
1
  # Changelog
2
2
 
3
- ## 0.2.0Unreleased
3
+ ## 0.2.1May 30, 2012
4
+
5
+ * Add a timeout configuration option and use it on the resource connection
6
+
7
+ ## 0.2.0 – May 23, 2012
4
8
 
5
9
  * Rewrote from scratch to be a smaller, simpler library
6
10
 
@@ -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
 
@@ -2,6 +2,7 @@ module Relax
2
2
  class Config
3
3
  attr :adapter, true
4
4
  attr :base_uri, true
5
+ attr :timeout, true
5
6
  attr :user_agent, true
6
7
 
7
8
  def configure
@@ -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[:headers][:user_agent] ||= config.user_agent
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?
@@ -1,3 +1,3 @@
1
1
  module Relax
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
@@ -19,6 +19,7 @@ describe Relax::Client do
19
19
 
20
20
  its(:adapter) { should == Faraday.default_adapter }
21
21
  its(:base_uri) { should be_nil }
22
+ its(:timeout) { should == 60 }
22
23
  its(:user_agent) { should == "Relax Ruby Gem Client #{Relax::VERSION}" }
23
24
  end
24
25
  end
@@ -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.0
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-23 00:00:00.000000000 Z
12
+ date: 2012-05-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday