simple_stack 0.0.9 → 0.0.10

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.
@@ -1,11 +1,13 @@
1
1
  module SimpleStack
2
2
  class Connection
3
- attr_accessor :url, :graceful_degradation, :cache_enabled
3
+ attr_accessor :url, :graceful_degradation, :cache_enabled, :timeout, :read_timeout
4
4
 
5
5
  def initialize(options = {})
6
6
  self.url = options[:url].to_s.sub(/\/$/, "")
7
7
  self.graceful_degradation = options[:graceful_degradation]
8
8
  self.cache_enabled = options[:cache_enabled]
9
+ self.timeout = options[:timeout] || 60
10
+ self.read_timeout = options[:read_timeout] || timeout
9
11
  end
10
12
 
11
13
  def connect_to(type, options)
@@ -25,6 +25,15 @@ module SimpleStack
25
25
  }
26
26
  end
27
27
 
28
+ def http_options
29
+ {
30
+ :timeout => connection.timeout,
31
+ :read_timeout => connection.read_timeout,
32
+ :no_follow => true,
33
+ :headers => headers
34
+ }
35
+ end
36
+
28
37
  def token
29
38
  Base64.encode64("#{username}:#{password}").split("\n").join("")
30
39
  end
@@ -38,19 +47,19 @@ module SimpleStack
38
47
  end
39
48
 
40
49
  def get(url)
41
- http_call { HTTParty.get(url, :headers => headers, :no_follow => true) }
50
+ http_call { HTTParty.get(url, http_options) }
42
51
  end
43
52
 
44
53
  def post(url, body)
45
- http_call { HTTParty.post(url, :body => JSON.dump(body), :headers => headers, :no_follow => true) }
54
+ http_call { HTTParty.post(url, http_options.merge(:body => JSON.dump(body))) }
46
55
  end
47
56
 
48
57
  def put(url, body)
49
- http_call { HTTParty.put(url, :body => JSON.dump(body), :headers => headers, :no_follow => true) }
58
+ http_call { HTTParty.put(url, http_options.merge(:body => JSON.dump(body))) }
50
59
  end
51
60
 
52
61
  def delete(url)
53
- http_call { HTTParty.delete(url, :headers => headers, :no_follow => true) }
62
+ http_call { HTTParty.delete(url, http_options.merge(:body => JSON.dump(body))) }
54
63
  end
55
64
 
56
65
  def http_call
@@ -1,3 +1,3 @@
1
1
  module SimpleStack
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_stack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-26 00:00:00.000000000 Z
12
+ date: 2012-07-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2153243460 !ruby/object:Gem::Requirement
16
+ requirement: &2157870160 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2153243460
24
+ version_requirements: *2157870160
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: httparty
27
- requirement: &2152952420 !ruby/object:Gem::Requirement
27
+ requirement: &2157869720 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2152952420
35
+ version_requirements: *2157869720
36
36
  description: A Simple Stack gem
37
37
  email:
38
38
  - thiago.morello@locaweb.com.br