tiny_bus 3.4.2 → 3.6.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
- data/lib/tiny_bus.rb +8 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f68f0f35a09503b6ecd6fa7d914e5886b078ee18001bd79de12aaa06c54c9d11
|
4
|
+
data.tar.gz: d8768af58ad92f7b0c38994833c095546f5d32ee63a709218633d2803a427d16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9ec3f27c4da06841ecd727b15f0120f42efbce9848019a78e9d030921a4642734fd0d8d18c1fac92859c26fb7113d2be7ac409d3b2b6e998891ee1bdbbffaa7
|
7
|
+
data.tar.gz: e6e5bfaf301ab9ff091788612b27f16a5ab02463234302ee567cf1845d14dc3d55328a978e79ba91abe2d94101ba46268ce57899e7b7a6e9ae66551d09b9c517
|
data/lib/tiny_bus.rb
CHANGED
@@ -83,14 +83,18 @@ class TinyBus
|
|
83
83
|
@subs[topic] << subber
|
84
84
|
@stats[topic] ||= 0
|
85
85
|
|
86
|
-
msg({ @topic_key => 'sub', 'to_topic' => topic, 'subber' => subber
|
86
|
+
msg({ @topic_key => 'sub', 'to_topic' => topic, 'subber' => _to_subber_id(subber) }, 'TINYBUS-SUB')
|
87
87
|
end
|
88
88
|
|
89
89
|
# removes a subscriber from a topic
|
90
90
|
def unsub(topic, subber)
|
91
91
|
@subs[topic]&.delete(subber)
|
92
92
|
|
93
|
-
msg({ @topic_key => 'unsub', 'from_topic' => topic, 'subber' => subber
|
93
|
+
msg({ @topic_key => 'unsub', 'from_topic' => topic, 'subber' => _to_subber_id(subber) }, 'TINYBUS-UNSUB')
|
94
|
+
end
|
95
|
+
|
96
|
+
def _to_subber_id(subber)
|
97
|
+
"#{subber.class.name}@#{subber.object_id}"
|
94
98
|
end
|
95
99
|
|
96
100
|
# takes an incoming message and distributes it to subscribers
|
@@ -133,6 +137,8 @@ class TinyBus
|
|
133
137
|
def to_s
|
134
138
|
<<~DEBUG
|
135
139
|
TinyBus stats: #{@subs.keys.length > 0 ? "\n " + @stats.keys.sort.map{|t| "#{t.rjust(12)}: #{@stats[t]}" }.join("\n ") : '<NONE>'}
|
140
|
+
Topics & Subscribers:
|
141
|
+
#{@subs.map{|topic, subbers| "#{topic}\n #{subbers.map(&:to_s).join("\n ")}" }.join("\n ") }
|
136
142
|
DEBUG
|
137
143
|
end
|
138
144
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tiny_bus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Lunt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tiny_log
|