wires 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/wires/channels.rb +11 -21
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed84cacba5f8de403b014bf21dea7f17f715039d
4
- data.tar.gz: 5db5c2bb5684593b81e0faf26dae9317d1c0bb55
3
+ metadata.gz: 0ee0ef4612e829c49c23b2b56726ebfa7b78e0a7
4
+ data.tar.gz: 855a4eee6ae3b7c9906876202c23a1503bc1484e
5
5
  SHA512:
6
- metadata.gz: 18d0e590b738f66685730de3006f978a9faa22124a37e5511e798f909999ceb8b0bd41a72c96a9e18acf8c30a241865dcadbd2a0bca307a5bc7bf301bed57d72
7
- data.tar.gz: e699ce9a9d99f7077f95c06c700e15c0b03ea2795d804da7b10f9f596d7b180cc278d0938660a2a887d9d9a252cc2949afdcbeb2ceab744c248020b85c43240b
6
+ metadata.gz: 980b22d9a6bd54663e18c89f3b57c2fcae6d9973f337b2d08035ae17cb3029a2688ef868864955520fd7db8868340dd8368ecac24c3924417a8946edbc91ea1f
7
+ data.tar.gz: 4ab9d5b9cc254ebc0b9f33d2988b9c08f1f10a960793132b9ed72fca4a3e3a921293a5792eabbe077b274f717a4a65169aa6c2b712342d045942f6bbd80adcbb
@@ -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
- or super(*args, &block)
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, self]
91
+ relevant = [@@channel_star]
92
92
  for c in @@channel_list
93
- for code in Event.from_codestring(self.name).codestrings
94
- relevant << c if case c.name
95
- when Regexp
96
- code =~ c.name
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.2
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-24 00:00:00.000000000 Z
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.