simplepubsub 0.2.1 → 0.3.0
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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +2 -1
- data/lib/simplepubsub.rb +32 -3
- metadata +17 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e873ef3c736b8c38420941d316c1ba142c02364f
|
4
|
+
data.tar.gz: f308de51ac99f1f91dd1aea5358f2542f848d3e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35f2a14a27d74a66876e88c8fc0fc20eda8da253ffa2c6500797e22aa7c932339f5ac8658b6e6127eb42cef4e1f3c2c78ede0b142986e5f23f4e41c5cdc16fbf
|
7
|
+
data.tar.gz: 2b0a29b582cc29b2cc8b89610c58c97aeb6b21a55f876d0470fd0318da0c2c7df34ea348804fb1f4c027b1b3e754d583c8004aa8674b13ab363686395f929a71
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
�4v�Ufr���|A �Ē��7���3�D���`t�U�艱���G�x=��HC˰���s@�dFha�y��x�ֵ�x[�H��$���ʈH��_��!�7�b��R&xHPN�,3b?���32��TɎ��m��S�Zf�d�8,q`x��_��
|
2
|
+
p�;e�e�g����{7���z���Ш2���Y�L�
|
data/lib/simplepubsub.rb
CHANGED
@@ -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.
|
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
|
-
|
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.
|
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-
|
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
|