nsisam 0.3.3 → 0.3.4
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.
- data/VERSION +1 -1
- data/lib/nsisam/client.rb +12 -7
- data/lib/nsisam/errors.rb +3 -0
- data/nsisam.gemspec +2 -2
- data/spec/nsisam_spec.rb +7 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.4
|
data/lib/nsisam/client.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "json"
|
2
2
|
require "net/http"
|
3
|
-
require "digest
|
3
|
+
require "digest"
|
4
4
|
require File.dirname(__FILE__) + '/errors'
|
5
5
|
|
6
6
|
module NSISam
|
@@ -104,13 +104,18 @@ module NSISam
|
|
104
104
|
end
|
105
105
|
|
106
106
|
def execute_request(request)
|
107
|
-
|
108
|
-
http
|
107
|
+
begin
|
108
|
+
response = Net::HTTP.start @url, @port do |http|
|
109
|
+
http.request(request)
|
110
|
+
end
|
111
|
+
rescue Errno::ECONNREFUSED => e
|
112
|
+
raise NSISam::Errors::Client::ConnectionRefusedError
|
113
|
+
else
|
114
|
+
raise NSISam::Errors::Client::KeyNotFoundError if response.code == "404"
|
115
|
+
raise NSISam::Errors::Client::MalformedRequestError if response.code == "400"
|
116
|
+
raise NSISam::Errors::Client::AuthenticationError if response.code == "401"
|
117
|
+
JSON.parse(response.body)
|
109
118
|
end
|
110
|
-
raise NSISam::Errors::Client::KeyNotFoundError if response.code == "404"
|
111
|
-
raise NSISam::Errors::Client::MalformedRequestError if response.code == "400"
|
112
|
-
raise NSISam::Errors::Client::AuthenticationError if response.code == "401"
|
113
|
-
JSON.parse(response.body)
|
114
119
|
end
|
115
120
|
|
116
121
|
def verify_checksum(data, expected_checksum)
|
data/lib/nsisam/errors.rb
CHANGED
data/nsisam.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "nsisam"
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.4"
|
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-
|
12
|
+
s.date = "2012-04-28"
|
13
13
|
s.description = "A simple gem to access a SAM node. For more info about SAM\n visit www.github.com/nsi-iff/sam_buildout."
|
14
14
|
s.email = "d.camata@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
data/spec/nsisam_spec.rb
CHANGED
@@ -12,6 +12,13 @@ describe NSISam do
|
|
12
12
|
@fake_sam.stop_server
|
13
13
|
end
|
14
14
|
|
15
|
+
context "cannot connect to server" do
|
16
|
+
it "throws error if couldn't connect to the server" do
|
17
|
+
sam = NSISam::Client.new 'http://test:test@localhost:4000'
|
18
|
+
expect { sam.store('anything') }.to raise_error(NSISam::Errors::Client::ConnectionRefusedError)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
15
22
|
context "storing" do
|
16
23
|
it "can store a value in SAM" do
|
17
24
|
response = @nsisam.store("something")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nsisam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
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-
|
12
|
+
date: 2012-04-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -161,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
161
161
|
version: '0'
|
162
162
|
segments:
|
163
163
|
- 0
|
164
|
-
hash: -
|
164
|
+
hash: -1576657204801045917
|
165
165
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
166
|
none: false
|
167
167
|
requirements:
|