wires 0.1.2 → 0.1.3
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/wires/channels.rb +11 -21
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ee0ef4612e829c49c23b2b56726ebfa7b78e0a7
|
4
|
+
data.tar.gz: 855a4eee6ae3b7c9906876202c23a1503bc1484e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 980b22d9a6bd54663e18c89f3b57c2fcae6d9973f337b2d08035ae17cb3029a2688ef868864955520fd7db8868340dd8368ecac24c3924417a8946edbc91ea1f
|
7
|
+
data.tar.gz: 4ab9d5b9cc254ebc0b9f33d2988b9c08f1f10a960793132b9ed72fca4a3e3a921293a5792eabbe077b274f717a4a65169aa6c2b712342d045942f6bbd80adcbb
|
data/lib/wires/channels.rb
CHANGED
@@ -22,7 +22,6 @@ class Channel
|
|
22
22
|
def initialize(name)
|
23
23
|
@name = name
|
24
24
|
@target_list = Set.new
|
25
|
-
@@channel_list << self
|
26
25
|
nil end
|
27
26
|
|
28
27
|
# Ensure that there is only one instance of Channel per name
|
@@ -30,9 +29,11 @@ class Channel
|
|
30
29
|
@@new_lock = Mutex.new
|
31
30
|
def self.new(*args, &block)
|
32
31
|
@@new_lock.synchronize do
|
33
|
-
(@@channel_list.select {|x|
|
34
|
-
(x.name==args[0] and x.name.class==args[0].class)} [0])
|
35
|
-
|
32
|
+
if not (inst = (@@channel_list.select {|x| \
|
33
|
+
(x.name==args[0] and x.name.class==args[0].class)} [0]))
|
34
|
+
@@channel_list << (inst = super(*args, &block))
|
35
|
+
end
|
36
|
+
inst
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
@@ -62,8 +63,7 @@ class Channel
|
|
62
63
|
_event, *args = _event
|
63
64
|
|
64
65
|
# Create event object from event as an object, class, or symbol/string
|
65
|
-
event =
|
66
|
-
case _event
|
66
|
+
event = case _event
|
67
67
|
when Event
|
68
68
|
_event
|
69
69
|
when Class
|
@@ -88,22 +88,12 @@ class Channel
|
|
88
88
|
"Cannot fire on Regexp channel: #{self.name}."\
|
89
89
|
" Regexp channels can only used in event handlers." end
|
90
90
|
|
91
|
-
relevant = [@@channel_star
|
91
|
+
relevant = [@@channel_star]
|
92
92
|
for c in @@channel_list
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
when Event
|
98
|
-
code == c.name.class
|
99
|
-
when Class
|
100
|
-
c.name <= Event ?
|
101
|
-
code == c.name :
|
102
|
-
code == c.name.to_s
|
103
|
-
else
|
104
|
-
code == c.name.to_s
|
105
|
-
end
|
106
|
-
end
|
93
|
+
relevant << c if \
|
94
|
+
(c.name.is_a?(Regexp) ?
|
95
|
+
self.name =~ c.name :
|
96
|
+
self.name.to_s == c.name.to_s)
|
107
97
|
end
|
108
98
|
return relevant.uniq
|
109
99
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wires
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe McIlvain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: An asynchronous (threaded) event routing framework in Ruby. Patch your
|
14
14
|
objects together with wires. Inspired by the python 'circuits' framework.
|