csdn-tire 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,6 +21,10 @@ module Tire
21
21
  reset_variables.each { |v| instance_variable_set(v.to_sym, nil) }
22
22
  end
23
23
 
24
+ def self.timeout_sec(value=nil)
25
+ @timeout_sec = value || @timeout_sec || 10
26
+ end
27
+
24
28
  end
25
29
 
26
30
  end
@@ -1,9 +1,11 @@
1
1
  # -*- encoding : utf-8 -*-
2
+ require 'timeout'
2
3
  module Tire
3
4
 
4
5
  module HTTP
5
6
 
6
7
  module Client
8
+ class RequestTimeout < Timeout::Error ; end
7
9
 
8
10
  class RestClient
9
11
  ConnectionExceptions = [::RestClient::ServerBrokeConnection, ::RestClient::RequestTimeout]
@@ -51,7 +53,9 @@ module Tire
51
53
  private
52
54
 
53
55
  def self.perform(response)
54
- Response.new response.body, response.code, response.headers
56
+ timeout(Configuration.timeout_sec, RequestTimeout) do
57
+ Response.new response.body, response.code, response.headers
58
+ end
55
59
  end
56
60
 
57
61
  end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Tire
3
- VERSION = "0.7.1"
3
+ VERSION = "0.7.2"
4
4
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csdn-tire
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 1
10
- version: 0.7.1
9
+ - 2
10
+ version: 0.7.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Hooopo
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-06-21 00:00:00 +08:00
18
+ date: 2012-06-27 00:00:00 +08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency