wires-test 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wires/test.rb +18 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3467c6ce43030f93a423b5e8a204092aff7a444
|
4
|
+
data.tar.gz: f018a88b955fdc470142c3b16a4970c07e0d5bc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49278da8615bc376ca929419e38e7f448d9ce5fb55fcd8d2e248e1d013b375607a2cc95fe68d7ece0a86b25231d5ab8dd30f768c2aadf1edd7c6f22f2c8c5ecf
|
7
|
+
data.tar.gz: 284ad78e57dde16b2644703c244cdfd0d41d3eed396de03ad791b9434c4d4b48eb0616127fc5bc16879d8883f6b108ec33e87a5eb0a9ac3ce2f64bc035c5fdff
|
data/lib/wires/test.rb
CHANGED
@@ -22,28 +22,40 @@ module Wires
|
|
22
22
|
Channel.remove_hook(:@before_fire, &@AFFIX_wires_test_fire_hook)
|
23
23
|
end
|
24
24
|
|
25
|
-
def AFFIX_fired?(event, channel,
|
25
|
+
def AFFIX_fired?(event, channel=:__no_channel_was_specified__,
|
26
26
|
clear:false, exclusive:false, plurality:nil,
|
27
27
|
exact_event:false, exact_channel:false,
|
28
28
|
&block)
|
29
|
-
key_chan
|
29
|
+
key_chan =
|
30
|
+
case channel
|
31
|
+
when :__no_channel_was_specified__
|
32
|
+
nil
|
33
|
+
when Channel
|
34
|
+
channel
|
35
|
+
else
|
36
|
+
Channel[channel]
|
37
|
+
end
|
38
|
+
|
30
39
|
key_event = Event.list_from event
|
31
40
|
|
32
41
|
case key_event.count
|
33
42
|
when 0
|
34
|
-
raise ArgumentError,"Can't create an event from input:
|
43
|
+
raise ArgumentError,"Can't create an event from input: "\
|
44
|
+
"#{event.inspect}"
|
35
45
|
when 1
|
36
46
|
key_event = key_event.first
|
37
47
|
else
|
38
|
-
raise ArgumentError,"Can't check for fired? on multiple events:
|
48
|
+
raise ArgumentError,"Can't check for fired? on multiple events: "\
|
49
|
+
"#{key_event.inspect}"
|
39
50
|
end
|
40
51
|
|
41
52
|
results = @AFFIX_wires_events.select { |e,c|
|
42
53
|
c = Channel[c]
|
43
|
-
(exact_event ? (key_event == e) : (key_event =~ e))
|
44
|
-
(exact_channel ? (key_chan == c) : (key_chan =~ c))
|
54
|
+
(exact_event ? (key_event == e) : (key_event =~ e)) && (!key_chan ||
|
55
|
+
(exact_channel ? (key_chan == c) : (key_chan =~ c)))
|
45
56
|
}
|
46
57
|
|
58
|
+
# If passed a block, use it to determine
|
47
59
|
results.select! { |e,c| yield e,c } if block_given?
|
48
60
|
|
49
61
|
clear_AFFIX_fired if clear
|
@@ -52,9 +64,6 @@ module Wires
|
|
52
64
|
return false if exclusive and (@AFFIX_wires_events != results)
|
53
65
|
return false if plurality and (results.size != plurality)
|
54
66
|
|
55
|
-
# # Execute passed block for each match
|
56
|
-
# results.each { |e,c| yield e,c if block_given? }
|
57
|
-
|
58
67
|
true
|
59
68
|
end
|
60
69
|
|