simplepubsub 0.2.1 → 0.3.0

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: ab32f9c65b4215927e54757ecd94f42a00c8badb
4
- data.tar.gz: 3940577be197a3fc6ca44dccb4e8dc5a6df1932d
3
+ metadata.gz: e873ef3c736b8c38420941d316c1ba142c02364f
4
+ data.tar.gz: f308de51ac99f1f91dd1aea5358f2542f848d3e1
5
5
  SHA512:
6
- metadata.gz: 8780a95d7ea3a1558d8a137122e4e29284de409414f2d3475beec98c0ffef0e129f7387975f42839fe9db58af41b7319a55b564200f494f8728b2b9b6efbbfb6
7
- data.tar.gz: 0aba7520c5f13d82b706c60fa94aad3c1d4e0b29bbf18fa29868ba93dee31bc4cfc4e6844ee6616de83b61e96125dade93ebff78d86e5046e40993a2cf3403a1
6
+ metadata.gz: 35f2a14a27d74a66876e88c8fc0fc20eda8da253ffa2c6500797e22aa7c932339f5ac8658b6e6127eb42cef4e1f3c2c78ede0b142986e5f23f4e41c5cdc16fbf
7
+ data.tar.gz: 2b0a29b582cc29b2cc8b89610c58c97aeb6b21a55f876d0470fd0318da0c2c7df34ea348804fb1f4c027b1b3e754d583c8004aa8674b13ab363686395f929a71
Binary file
data.tar.gz.sig CHANGED
@@ -1 +1,2 @@
1
- �3��aMr��}���]8�/B9d�_�4|_�^����n���+��k�lP2S{� j�@��lRx��+ ÿyOص�Υ�4��t�Zl�_R����\ n���1����ͼ��Cy��&�v�^Q�Ɣ ��<%��M�y�JF��7N�9�<�"7��л p6j��\0���L����N�+А9'CQ����Č��� �|�]�<)��e>U)���Tg���#����/��MQQ����
1
+ �4vUfr���|A �Ē��7���3D���`t�U�艱���Gx=��HC˰���s@�dFha�y��x �ֵ�x[H��$� ��ʈH��_��!�7�b��R&xHPN�,3b?���32��TɎ��m��S�Zfd8,q`x��_��
2
+ p�;e�e�g����{7���z���Ш2���Y�L�
@@ -4,9 +4,10 @@
4
4
 
5
5
  require 'open-uri'
6
6
  require 'drb'
7
+ require 'dws-registry'
7
8
 
8
9
 
9
- USER_AGENT = 'SimplePubSub client 0.2'
10
+ USER_AGENT = 'SimplePubSub client 0.3'
10
11
 
11
12
  module SimplePubSub
12
13
 
@@ -56,15 +57,40 @@ module SimplePubSub
56
57
 
57
58
  attr_reader :subscribers, :bridges
58
59
 
59
- def initialize(hostname)
60
+ def initialize(hostname, raw_reg='simplepubsub.xml')
61
+
62
+
63
+ h = {DWSRegistry: ->{raw_reg}, String: ->{DWSRegistry.new raw_reg}}
64
+
65
+ @reg = h[raw_reg.class.to_s.to_sym].call
66
+
67
+ # try to read the subscribers
68
+ topics = @reg.get_key 'hkey_apps/simplepubsub/subscription_topics'
69
+
70
+ @subscribers = {'#' => []}
71
+
72
+ if topics then
73
+ topics.elements.each do |topic_element|
74
+ topic = topic_element.name
75
+ @subscribers[topic] ||= []
76
+ @subscribers[topic] = topic_element.elements[0].elements.map(&:value)
77
+ end
78
+ end
79
+
60
80
  @hostname = hostname
61
- @subscribers = {'#' => []}
81
+
62
82
  @bridges = {'#' => []}
63
83
  end
64
84
 
65
85
  def subscribe(topic, uri)
66
86
  @subscribers[topic] ||= []
67
87
  @subscribers[topic] << uri
88
+
89
+ # e.g. 'hkey_apps/simplepubsub/subscription_topics/magic/subscribers/niko',
90
+ # 'druby://niko:353524'
91
+ key = "hkey_apps/simplepubsub/subscription_topics/%s/subscribers/%s" % \
92
+ [topic, uri[/[^\/]+$/].sub(':','')]
93
+ @reg.set_key key, uri
68
94
  end
69
95
 
70
96
  def deliver(topic, msg)
@@ -90,6 +116,9 @@ module SimplePubSub
90
116
  echo.message topic, msg
91
117
  rescue DRb::DRbConnError => e
92
118
  @subscribers[topic].delete uri
119
+ key = "hkey_apps/simplepubsub/subscription_topics/%s/subscribers/%s" % \
120
+ [topic, uri[/[^\/]+$/].sub(':','')]
121
+ @reg.delete_key key
93
122
  end
94
123
 
95
124
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplepubsub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,8 +31,22 @@ cert_chain:
31
31
  i0PBE6fLwlIMk8jNNUcX3J1csSMgLNTwE8CwrlSZE8sueHj0pQzICM7lF0gGREO6
32
32
  hQHD0LljU3MusQ==
33
33
  -----END CERTIFICATE-----
34
- date: 2013-06-21 00:00:00.000000000 Z
35
- dependencies: []
34
+ date: 2013-06-26 00:00:00.000000000 Z
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: dws-registry
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
36
50
  description:
37
51
  email:
38
52
  executables: []
metadata.gz.sig CHANGED
Binary file