rasmus_client 0.1 → 0.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG +1 -0
- data/Manifest +1 -1
- data/lib/rasmus_client.rb +15 -10
- data/rasmus_client.gemspec +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97e75284e92e6a93f79a820b1d9f4ec3731f1835
|
4
|
+
data.tar.gz: 9fad5aa231695dcc376680e3bdfc9b47db1417d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8220c31e0b1d397e7774082ad2278922ba9b0ce65a4fc8522ce3995ca228a41790d3e670de815ce67fa7cde00e896dc7a157f404cdc50a16b8b7448da3c1f8b
|
7
|
+
data.tar.gz: 51204d1464071eb189aefeb28740fc3df575a1146fc8ef69b2f33f13c63afc72bb35cc0abfd5b078a5ee38bf481d0646bccb47f8ca08b20af83f254014df8ba4
|
data/CHANGELOG
CHANGED
data/Manifest
CHANGED
data/lib/rasmus_client.rb
CHANGED
@@ -3,36 +3,41 @@ require 'securerandom'
|
|
3
3
|
require 'json'
|
4
4
|
|
5
5
|
class RasmusClient
|
6
|
-
attr_accessor :redis
|
6
|
+
attr_accessor :redis, :timeout
|
7
7
|
|
8
|
-
def initialize(redis, namespace
|
8
|
+
def initialize(redis, *namespace)
|
9
9
|
@redis = redis
|
10
10
|
@namespace = namespace
|
11
|
+
@timeout = 60
|
11
12
|
end
|
12
|
-
|
13
|
+
|
13
14
|
def read(path)
|
15
|
+
request(command: 'read', path: path)
|
14
16
|
end
|
15
|
-
|
17
|
+
|
16
18
|
def write(path, mode, data)
|
19
|
+
request(command: 'write', path: path, input: data, mode: mode)
|
17
20
|
end
|
18
|
-
|
21
|
+
|
19
22
|
def list(path)
|
23
|
+
request(command: 'list', path: path)
|
20
24
|
end
|
21
25
|
|
22
26
|
def execute(cmd, input, *params)
|
27
|
+
request(command: 'execute', path: cmd, input: input, params: params)
|
23
28
|
end
|
24
|
-
|
29
|
+
|
25
30
|
def request(args={})
|
26
31
|
uuid = SecureRandom.uuid
|
27
32
|
@redis.lpush(key('req'), args.merge(uuid: uuid).to_json)
|
28
|
-
if raw_response = @redis.brpop(key('resp', uuid),
|
33
|
+
if raw_response = @redis.brpop(key('resp', uuid), @timeout)
|
29
34
|
JSON.parse raw_response.last
|
30
35
|
else
|
31
|
-
|
36
|
+
nil
|
32
37
|
end
|
33
38
|
end
|
34
|
-
|
39
|
+
|
35
40
|
def key(*strings)
|
36
|
-
[
|
41
|
+
[*@namespace, 'rasmus', *strings].compact.map(&:to_s).join ':'
|
37
42
|
end
|
38
43
|
end
|
data/rasmus_client.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: rasmus_client 0.
|
2
|
+
# stub: rasmus_client 0.2 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "rasmus_client"
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.2"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib"]
|
10
10
|
s.authors = ["Andrew Snow "]
|
11
|
-
s.date = "
|
11
|
+
s.date = "2015-01-10"
|
12
12
|
s.description = "Ruby client for Rasmus server"
|
13
13
|
s.email = "andrew@modulus.org"
|
14
14
|
s.extra_rdoc_files = ["CHANGELOG", "lib/rasmus_client.rb"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rasmus_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 'Andrew Snow '
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|