nsisam 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,9 +1,9 @@
1
1
  = nsisam
2
2
 
3
- Description goes here.
3
+ Just a simple and lightweight package to access a SAM node using Ruby.
4
4
 
5
5
  == Contributing to nsisam
6
-
6
+
7
7
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
8
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
9
  * Fork the project.
data/Rakefile CHANGED
@@ -30,11 +30,7 @@ require 'rspec/core'
30
30
  require 'rspec/core/rake_task'
31
31
  RSpec::Core::RakeTask.new(:spec) do |spec|
32
32
  spec.pattern = FileList['spec/**/*_spec.rb']
33
- end
34
-
35
- RSpec::Core::RakeTask.new(:rcov) do |spec|
36
- spec.pattern = 'spec/**/*_spec.rb'
37
- spec.rcov = true
33
+ spec.rspec_opts = "--color --format nested"
38
34
  end
39
35
 
40
36
  task :default => :spec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/lib/client.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  require "json"
2
2
  require "net/http"
3
+ require "errors"
3
4
 
4
5
  module Client
6
+
5
7
  class Client
6
8
 
7
9
  def initialize(url)
@@ -49,8 +51,8 @@ module Client
49
51
  response = Net::HTTP.start @url, @port do |http|
50
52
  http.request(request)
51
53
  end
54
+ raise NSISam::Errors::Client::KeyNotFoundError if response.code == "404"
52
55
  JSON.parse(response.body)
53
56
  end
54
-
55
57
  end
56
58
  end
data/lib/errors.rb ADDED
@@ -0,0 +1,8 @@
1
+ module NSISam
2
+ module Errors
3
+ module Client
4
+ class KeyNotFoundError < RuntimeError
5
+ end
6
+ end
7
+ end
8
+ end
data/nsisam.gemspec ADDED
@@ -0,0 +1,70 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "nsisam"
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Douglas Camata"]
12
+ s.date = "2012-02-12"
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
+ s.email = "d.camata@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "lib/client.rb",
28
+ "lib/errors.rb",
29
+ "lib/nsisam.rb",
30
+ "nsisam.gemspec",
31
+ "spec/nsisam_spec.rb",
32
+ "spec/spec_helper.rb"
33
+ ]
34
+ s.homepage = "http://github.com/nsi-iff/nsisam-ruby"
35
+ s.licenses = ["MIT"]
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = "1.8.15"
38
+ s.summary = "A simple gem to access a SAM service."
39
+
40
+ if s.respond_to? :specification_version then
41
+ s.specification_version = 3
42
+
43
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
+ s.add_runtime_dependency(%q<json>, [">= 0"])
45
+ s.add_development_dependency(%q<rake>, [">= 0"])
46
+ s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
47
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
48
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
49
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
50
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
51
+ else
52
+ s.add_dependency(%q<json>, [">= 0"])
53
+ s.add_dependency(%q<rake>, [">= 0"])
54
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
55
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
56
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
57
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
58
+ s.add_dependency(%q<simplecov>, [">= 0"])
59
+ end
60
+ else
61
+ s.add_dependency(%q<json>, [">= 0"])
62
+ s.add_dependency(%q<rake>, [">= 0"])
63
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
64
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
65
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
66
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
67
+ s.add_dependency(%q<simplecov>, [">= 0"])
68
+ end
69
+ end
70
+
data/spec/nsisam_spec.rb CHANGED
@@ -11,36 +11,56 @@ describe NSISam do
11
11
  @keys.each { |key| @nsisam.delete(key) }
12
12
  end
13
13
 
14
- it "can store a value in SAM" do
15
- response = @nsisam.store("something")
16
- response.should_not be_nil
17
- response.should have_key("key")
18
- response.should have_key("checksum")
14
+ context "storing" do
15
+ it "can store a value in SAM" do
16
+ response = @nsisam.store("something")
17
+ response.should_not be_nil
18
+ response.should have_key("key")
19
+ response.should have_key("checksum")
19
20
 
20
- @keys.push(response["key"])
21
+ @keys.push(response["key"])
22
+ end
21
23
  end
22
24
 
23
- it "can delete a stored value" do
24
- key = @nsisam.store("delete this")["key"]
25
- response = @nsisam.delete(key)
26
- response["deleted"].should be_true
25
+ context "deleting" do
26
+ it "can delete a stored value" do
27
+ key = @nsisam.store("delete this")["key"]
28
+ response = @nsisam.delete(key)
29
+ response["deleted"].should be_true
30
+ end
31
+
32
+ it "raises error when key not found" do
33
+ expect { @nsisam.delete("i dont exist") }.to raise_error(NSISam::Errors::Client::KeyNotFoundError)
34
+ end
27
35
  end
28
36
 
29
- it "can retrieve a stored value" do
30
- key = @nsisam.store("retrieve this")["key"]
31
- response = @nsisam.get(key)
32
- response["data"].should == "retrieve this"
37
+ context "retrieving" do
38
+ it "can retrieve a stored value" do
39
+ key = @nsisam.store("retrieve this")["key"]
40
+ response = @nsisam.get(key)
41
+ response["data"].should == "retrieve this"
42
+
43
+ @keys.push(key)
44
+ end
33
45
 
34
- @keys.push(key)
46
+ it "raises error when key not found" do
47
+ expect { @nsisam.get("non existing key") }.to raise_error(NSISam::Errors::Client::KeyNotFoundError)
48
+ end
35
49
  end
36
50
 
37
- it "can update values in keys already stored" do
38
- key = @nsisam.store("update this")["key"]
39
- response = @nsisam.update(key, "updated")
40
- response["key"].should == key
41
- response.should have_key("checksum")
51
+ context "updating" do
52
+ it "can update values in keys already stored" do
53
+ key = @nsisam.store("update this")["key"]
54
+ response = @nsisam.update(key, "updated")
55
+ response["key"].should == key
56
+ response.should have_key("checksum")
57
+
58
+ @keys.push(key)
59
+ end
42
60
 
43
- @keys.push(key)
61
+ it "raises error when key not found" do
62
+ expect { @nsisam.update("ruby is fast", "foo") }.to raise_error(NSISam::Errors::Client::KeyNotFoundError)
63
+ end
44
64
  end
45
65
 
46
66
  end
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.1.0
4
+ version: 0.1.1
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-02-09 00:00:00.000000000 Z
12
+ date: 2012-02-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &70359173552000 !ruby/object:Gem::Requirement
16
+ requirement: &70252524589480 !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: :runtime
23
23
  prerelease: false
24
- version_requirements: *70359173552000
24
+ version_requirements: *70252524589480
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70359173566740 !ruby/object:Gem::Requirement
27
+ requirement: &70252524588120 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70359173566740
35
+ version_requirements: *70252524588120
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70359173565780 !ruby/object:Gem::Requirement
38
+ requirement: &70252524584740 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.8.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70359173565780
46
+ version_requirements: *70252524584740
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rdoc
49
- requirement: &70359173564980 !ruby/object:Gem::Requirement
49
+ requirement: &70252524533140 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '3.12'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70359173564980
57
+ version_requirements: *70252524533140
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
- requirement: &70359173564040 !ruby/object:Gem::Requirement
60
+ requirement: &70252524530400 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.0.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70359173564040
68
+ version_requirements: *70252524530400
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: jeweler
71
- requirement: &70359173584480 !ruby/object:Gem::Requirement
71
+ requirement: &70252524529100 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.8.3
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70359173584480
79
+ version_requirements: *70252524529100
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: simplecov
82
- requirement: &70359173577380 !ruby/object:Gem::Requirement
82
+ requirement: &70252524528200 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70359173577380
90
+ version_requirements: *70252524528200
91
91
  description: ! "A simple gem to access a SAM node. For more info about SAM\n visit
92
92
  www.github.com/nsi-iff/sam_buildout."
93
93
  email: d.camata@gmail.com
@@ -105,7 +105,9 @@ files:
105
105
  - Rakefile
106
106
  - VERSION
107
107
  - lib/client.rb
108
+ - lib/errors.rb
108
109
  - lib/nsisam.rb
110
+ - nsisam.gemspec
109
111
  - spec/nsisam_spec.rb
110
112
  - spec/spec_helper.rb
111
113
  homepage: http://github.com/nsi-iff/nsisam-ruby
@@ -123,7 +125,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
123
125
  version: '0'
124
126
  segments:
125
127
  - 0
126
- hash: -2847547609533104459
128
+ hash: 4537102661431384406
127
129
  required_rubygems_version: !ruby/object:Gem::Requirement
128
130
  none: false
129
131
  requirements: