simple_stack 0.0.18 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
@@ -46,6 +46,17 @@ module SimpleStack
46
46
  cached_attributes[:guests] ||= SimpleStack::Collection.new self, self, "#{url}/guests", SimpleStack::Guest
47
47
  end
48
48
 
49
+ def import(opts={})
50
+ file = File.open(opts[:from], "rb")
51
+
52
+ response = put_stream("#{url}/guests", file)
53
+ entity_path = response["location"].sub(/^\//, "").sub(/\/$/, "")
54
+ entity_url = "#{connection.url}/#{entity_path}"
55
+ SimpleStack::Guest.new hypervisor, guests, entity_url
56
+ ensure
57
+ file.close rescue nil
58
+ end
59
+
49
60
  def get(url)
50
61
  http_call { HTTParty.get(url, http_options) }
51
62
  end
@@ -83,7 +94,10 @@ module SimpleStack
83
94
 
84
95
  request.body_stream = io
85
96
  request.content_length = io.size
86
- http.request(request)
97
+ response = http.request(request)
98
+
99
+ raise SimpleStack::Exception.factory(JSON.load(response.body)) if response.code >= 400
100
+ response
87
101
  end
88
102
 
89
103
  def delete(url)
@@ -1,3 +1,3 @@
1
1
  module SimpleStack
2
- VERSION = "0.0.18"
2
+ VERSION = "0.0.19"
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.18
4
+ version: 0.0.19
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-07-23 00:00:00.000000000 Z
12
+ date: 2012-07-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2153427280 !ruby/object:Gem::Requirement
16
+ requirement: &2156890840 !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: *2153427280
24
+ version_requirements: *2156890840
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: httparty
27
- requirement: &2153424880 !ruby/object:Gem::Requirement
27
+ requirement: &2156890240 !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: *2153424880
35
+ version_requirements: *2156890240
36
36
  description: A Simple Stack gem
37
37
  email:
38
38
  - thiago.morello@locaweb.com.br