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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f882dd65cecee0e4ce4e18e3fbc646c84681c6c0
4
- data.tar.gz: abb069eea8ddb87763869f388c5ef8f6b6be565e
3
+ metadata.gz: 97e75284e92e6a93f79a820b1d9f4ec3731f1835
4
+ data.tar.gz: 9fad5aa231695dcc376680e3bdfc9b47db1417d6
5
5
  SHA512:
6
- metadata.gz: 817fcf40d93c39cc391ee070ff41ea2f63688d016f6471f49ad84abc8f34f09a2b3f01842731237b722f36387659bcacc192a25fedeb921953e98fbe5332685b
7
- data.tar.gz: e7141b42406626c0acbcd40ab5da4128ab4ea62e7e9586c2100dfa505c57f499d9b3a96cfe25e2757e6f315acd5666936b63b6f9029e9c5f1065d00e7d78e4ae
6
+ metadata.gz: f8220c31e0b1d397e7774082ad2278922ba9b0ce65a4fc8522ce3995ca228a41790d3e670de815ce67fa7cde00e896dc7a157f404cdc50a16b8b7448da3c1f8b
7
+ data.tar.gz: 51204d1464071eb189aefeb28740fc3df575a1146fc8ef69b2f33f13c63afc72bb35cc0abfd5b078a5ee38bf481d0646bccb47f8ca08b20af83f254014df8ba4
data/CHANGELOG CHANGED
@@ -1 +1,2 @@
1
+ v0.2. more basic implementation
1
2
  v0.1. rasmus client
data/Manifest CHANGED
@@ -1,4 +1,4 @@
1
1
  CHANGELOG
2
+ Manifest
2
3
  Rakefile
3
4
  lib/rasmus_client.rb
4
- Manifest
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=nil)
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), 60)
33
+ if raw_response = @redis.brpop(key('resp', uuid), @timeout)
29
34
  JSON.parse raw_response.last
30
35
  else
31
- # timeout
36
+ nil
32
37
  end
33
38
  end
34
-
39
+
35
40
  def key(*strings)
36
- [@namespace, 'rasmus', *strings].compact.join ':'
41
+ [*@namespace, 'rasmus', *strings].compact.map(&:to_s).join ':'
37
42
  end
38
43
  end
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: rasmus_client 0.1 ruby lib
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.1"
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 = "2014-08-30"
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.1'
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: 2014-08-30 00:00:00.000000000 Z
11
+ date: 2015-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis