simple_stack 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/simple_stack/connection.rb +3 -1
- data/lib/simple_stack/hypervisor.rb +13 -4
- data/lib/simple_stack/version.rb +1 -1
- metadata +6 -6
@@ -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,
|
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)
|
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)
|
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, :
|
62
|
+
http_call { HTTParty.delete(url, http_options.merge(:body => JSON.dump(body))) }
|
54
63
|
end
|
55
64
|
|
56
65
|
def http_call
|
data/lib/simple_stack/version.rb
CHANGED
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.
|
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-
|
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: &
|
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: *
|
24
|
+
version_requirements: *2157870160
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: httparty
|
27
|
-
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: *
|
35
|
+
version_requirements: *2157869720
|
36
36
|
description: A Simple Stack gem
|
37
37
|
email:
|
38
38
|
- thiago.morello@locaweb.com.br
|