pipe_rpc 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 133a22837afd6032e1de590b632c2715f4e4913c
4
- data.tar.gz: aa8338e1c9f4d3fad11f5a1ca2b3923c1704b023
3
+ metadata.gz: 38d81befe0835cd840ef1984f9df80e37fd9648c
4
+ data.tar.gz: b131d78842fad4c0df6ad70584583a3f7d7c592e
5
5
  SHA512:
6
- metadata.gz: 924584159e80cf3e6dfec8ccf288ba122985e0f9a29f6e3f8734b74cca608436e0b15f34aeeb409bd53990d5957f2b7688d84687eb06bd02e17ded15a13575d9
7
- data.tar.gz: 997155d89f123a5da38e7190a9e6d1de9d1e46e479c84834c1a810b5f5279da6d757b71b4f49d7612780716e5a84544bcade5c942287837d2482659a4fbad9be
6
+ metadata.gz: 1b97ab5db07bb699cb490bb01c1a0d05c3cbaa7cd9e32b1bff37304ed630d5e8600c64be65004609fe185dfd851602d218aa3ddc157cde351f35f1e14c549b13
7
+ data.tar.gz: eda62283c83632b3ddf4b663f7d9d43934edae49e4ab8fc9296ac3e8ee40c82f24f4c32cb410764445a1b39a8dae262ba0565196984ada4828c33794515e679e
@@ -1,7 +1,8 @@
1
1
  module PipeRpc
2
2
  class Client < BasicInterface
3
3
  def initialize(server_id = :default, hub)
4
- @__rpc_server_id__ = server_id.to_sym
4
+ ::Kernel.raise ClientInitializationError.new("server id #{server_id.inspect} no symbol") unless server_id.is_a? ::Symbol
5
+ @__rpc_server_id__ = server_id
5
6
  @hub = hub
6
7
  end
7
8
 
@@ -24,9 +24,9 @@ module PipeRpc
24
24
  def self.from_transport(object, hub)
25
25
  map(object) do |value|
26
26
  if value.is_a?(String) and value.start_with?('__rpc_client__')
27
- hub.servers[value.sub('__rpc_client__', '')]
27
+ hub.servers[value.sub('__rpc_client__', '').to_sym]
28
28
  elsif value.is_a?(String) and value.start_with?('__rpc_server__')
29
- Client.new(value.sub('__rpc_server__', ''), hub)
29
+ Client.new(value.sub('__rpc_server__', '').to_sym, hub)
30
30
  else
31
31
  value
32
32
  end
@@ -3,6 +3,7 @@ module PipeRpc
3
3
  class ClosedError < Error; end
4
4
  class UnknownError < Error; end
5
5
  class ServerRegistrationError < Error; end
6
+ class ClientInitializationError < Error; end
6
7
 
7
8
  class MessageError < Error; end
8
9
  class MessageParseError < MessageError; end
@@ -6,7 +6,7 @@ module PipeRpc
6
6
  end
7
7
 
8
8
  def [](server)
9
- @clients[server.to_sym] ||= Client.new(server.to_sym, @hub)
9
+ @clients[server] ||= Client.new(server, @hub)
10
10
  end
11
11
  end
12
12
  end
@@ -1,7 +1,7 @@
1
1
  module PipeRpc
2
2
  class Hub::Servers
3
3
  def initialize
4
- @servers = Hash.new{ |hash, key| raise NoServerError.new("no server #{key}") }
4
+ @servers = Hash.new{ |hash, key| raise NoServerError.new("no server #{key.inspect}") }
5
5
  end
6
6
 
7
7
  def add(server)
@@ -11,6 +11,8 @@ module PipeRpc
11
11
  server.first
12
12
  end
13
13
 
14
+ raise ServerRegistrationError.new("server id #{id.inspect} no symbol") unless id.is_a? Symbol
15
+
14
16
  if registered? id
15
17
  raise ServerRegistrationError.new("server id #{id.inspect} already used for another server")
16
18
  else
@@ -18,16 +20,20 @@ module PipeRpc
18
20
  end
19
21
  end
20
22
 
21
- def [](id)
22
- @servers[id.to_sym]
23
+ def registered?(id)
24
+ @servers.has_key?(id)
23
25
  end
24
26
 
25
- def remove(id)
26
- @servers.delete(id.to_sym)
27
+ def registered_ids
28
+ @servers.keys
27
29
  end
28
30
 
29
- def registered?(id)
30
- @servers.has_key?(id)
31
+ def [](id)
32
+ @servers[id]
33
+ end
34
+
35
+ def remove(id)
36
+ @servers.delete(id)
31
37
  end
32
38
  end
33
39
  end
@@ -1,3 +1,3 @@
1
1
  module PipeRpc
2
- VERSION = "2.2.0"
2
+ VERSION = "2.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pipe_rpc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Aue
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-11 00:00:00.000000000 Z
11
+ date: 2016-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack