nsisam 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/nsisam/client.rb +21 -0
- data/lib/nsisam/fake_server.rb +9 -2
- data/nsisam.gemspec +1 -1
- metadata +16 -16
data/lib/nsisam/client.rb
CHANGED
@@ -20,24 +20,45 @@ module NSISam
|
|
20
20
|
#
|
21
21
|
# @param [String] data the desired data to store
|
22
22
|
# @return [Hash] response with the data key and checksum
|
23
|
+
# * "key" [String] the key to access the stored data
|
24
|
+
# * "checksum" [String] the sha1 checksum of the stored data
|
23
25
|
def store(data)
|
24
26
|
request_data = {:value => data}.to_json
|
25
27
|
request = prepare_request :PUT, request_data
|
26
28
|
execute_request(request)
|
27
29
|
end
|
28
30
|
|
31
|
+
# Delete data at a given SAM key
|
32
|
+
#
|
33
|
+
# @param [Sring] key of the value to delete
|
34
|
+
# @return [Hash] response
|
35
|
+
# * "deleted" [Boolean] true if the key was sucefully deleted
|
29
36
|
def delete(key)
|
30
37
|
request_data = {:key => key}.to_json
|
31
38
|
request = prepare_request :DELETE, request_data
|
32
39
|
execute_request(request)
|
33
40
|
end
|
34
41
|
|
42
|
+
# Recover data stored at a given SAM key
|
43
|
+
#
|
44
|
+
# @param [String] key of the value to acess
|
45
|
+
# @return [Hash] response
|
46
|
+
# * "from_user" [String] the user who stored the value
|
47
|
+
# * "date" [String] the date when the value was stored
|
48
|
+
# * "data" [String, Hash, Array] the data stored at that key
|
35
49
|
def get(key)
|
36
50
|
request_data = {:key => key}.to_json
|
37
51
|
request = prepare_request :GET, request_data
|
38
52
|
execute_request(request)
|
39
53
|
end
|
40
54
|
|
55
|
+
# Update data stored at a given SAM key
|
56
|
+
#
|
57
|
+
# @param [String] key of the data to update
|
58
|
+
# @param [String, Hash, Array] data to be stored at the key
|
59
|
+
# return [Hash] response
|
60
|
+
# * "key" [String] just to value key again
|
61
|
+
# * "checksum" [String] the new sha1 checksum of the key's data
|
41
62
|
def update(key, value)
|
42
63
|
request_data = {:key => key, :value => value}.to_json
|
43
64
|
request = prepare_request :POST, request_data
|
data/lib/nsisam/fake_server.rb
CHANGED
@@ -44,16 +44,23 @@ module NSISam
|
|
44
44
|
end
|
45
45
|
|
46
46
|
class FakeServerManager
|
47
|
-
|
47
|
+
|
48
|
+
# Start the SAM fake server
|
49
|
+
#
|
50
|
+
# @param [Fixnum] port the port where the fake server will listen
|
51
|
+
# * make sure there's not anything else listenning on this port
|
52
|
+
def start_server(port=8888)
|
48
53
|
@thread = Thread.new do
|
49
|
-
Server.run! :port =>
|
54
|
+
Server.run! :port => port
|
50
55
|
end
|
51
56
|
sleep(1)
|
52
57
|
self
|
53
58
|
end
|
54
59
|
|
60
|
+
# Stop the SAM fake server
|
55
61
|
def stop_server
|
56
62
|
@thread.kill
|
63
|
+
self
|
57
64
|
end
|
58
65
|
end
|
59
66
|
end
|
data/nsisam.gemspec
CHANGED
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.2.
|
4
|
+
version: 0.2.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-03-01 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
16
|
-
requirement: &
|
16
|
+
requirement: &17065580 !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: *
|
24
|
+
version_requirements: *17065580
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: sinatra
|
27
|
-
requirement: &
|
27
|
+
requirement: &17064960 !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: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *17064960
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &17064220 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *17064220
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: yard
|
49
|
-
requirement: &
|
49
|
+
requirement: &17063600 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *17063600
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &17063020 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 2.8.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *17063020
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
|
-
requirement: &
|
71
|
+
requirement: &17062340 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 1.0.0
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *17062340
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: jeweler
|
82
|
-
requirement: &
|
82
|
+
requirement: &17061800 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: 1.8.3
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *17061800
|
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
|
@@ -126,7 +126,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
126
|
version: '0'
|
127
127
|
segments:
|
128
128
|
- 0
|
129
|
-
hash: -
|
129
|
+
hash: -2979948941930370823
|
130
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
131
|
none: false
|
132
132
|
requirements:
|