nsicloudooo 0.2.8 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.8
1
+ 0.2.9
@@ -136,16 +136,21 @@ module NSICloudooo
136
136
  end
137
137
 
138
138
  def execute_request(request)
139
- response = Net::HTTP.start @url, @port do |http|
140
- http.request(request)
141
- end
142
- raise NSICloudooo::Errors::Client::KeyNotFoundError if response.code == "404"
143
- raise NSICloudooo::Errors::Client::MalformedRequestError if response.code == "400"
144
- raise NSICloudooo::Errors::Client::AuthenticationError if response.code == "401"
145
- if response.code == "500" and response.body.include?("SAM")
146
- raise NSICloudooo::Errors::Client::SAMConnectionError
139
+ begin
140
+ response = Net::HTTP.start @url, @port do |http|
141
+ http.request(request)
142
+ end
143
+ rescue Errno::ECONNREFUSED => e
144
+ raise NSICloudooo::Errors::Client::ConnectionRefusedError
145
+ else
146
+ raise NSICloudooo::Errors::Client::KeyNotFoundError if response.code == "404"
147
+ raise NSICloudooo::Errors::Client::MalformedRequestError if response.code == "400"
148
+ raise NSICloudooo::Errors::Client::AuthenticationError if response.code == "401"
149
+ if response.code == "500" and response.body.include?("SAM")
150
+ raise NSICloudooo::Errors::Client::SAMConnectionError
151
+ end
152
+ JSON.parse(response.body)
147
153
  end
148
- JSON.parse(response.body)
149
154
  end
150
155
  end
151
156
  end
@@ -15,6 +15,9 @@ module NSICloudooo
15
15
 
16
16
  class SAMConnectionError < RuntimeError
17
17
  end
18
+
19
+ class ConnectionRefusedError < RuntimeError
20
+ end
18
21
  end
19
22
  end
20
23
  end
data/nsicloudooo.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "nsicloudooo"
8
- s.version = "0.2.8"
8
+ s.version = "0.2.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Douglas Camata"]
12
- s.date = "2012-04-17"
12
+ s.date = "2012-04-28"
13
13
  s.description = "A simple gem to access a nsi.cloudooo node"
14
14
  s.email = "d.camata@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -14,6 +14,14 @@ describe NSICloudooo do
14
14
  @fake_cloudooo.stop_server
15
15
  end
16
16
 
17
+ context "cannot connect to the server" do
18
+ it "throws error if couldn't connec to the server" do
19
+ nsicloudooo = NSICloudooo::Client.new 'http://test:test@localhost:4000'
20
+ expect { nsicloudooo.granulate(:file => 'document', :filename => "teste.odt") }.to \
21
+ raise_error(NSICloudooo::Errors::Client::ConnectionRefusedError)
22
+ end
23
+ end
24
+
17
25
  context "simple granulation" do
18
26
  it "can send a document to be granulated by a cloudooo node" do
19
27
  response = @nsicloudooo.granulate(:file => 'document', :filename => 'test.odt')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nsicloudooo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.9
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-04-17 00:00:00.000000000 Z
12
+ date: 2012-04-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
@@ -144,7 +144,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
144
  version: '0'
145
145
  segments:
146
146
  - 0
147
- hash: 146615512699019041
147
+ hash: 1769661169347116718
148
148
  required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements: