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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/wires/test.rb +18 -9
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f0991c03a9d93a361970b27477d58a18656a54dc
4
- data.tar.gz: 6992614716f21cb4d501e994c10391f08158282a
3
+ metadata.gz: c3467c6ce43030f93a423b5e8a204092aff7a444
4
+ data.tar.gz: f018a88b955fdc470142c3b16a4970c07e0d5bc5
5
5
  SHA512:
6
- metadata.gz: 0043870480143307e8469fb414866dd10ffe0f5706422c4a692b7323f7609fbf564d31489db0b040e7fff670371ffbe2bcea4543afff01e6d2e7c5f286c6339c
7
- data.tar.gz: 952ff5f296535e411b7bf65f6b8025329b8f1426103faf50d268ace723716fac1508ed2124d83968dec4f9751fa955fbf45baf88af7e9a230f3d0d404aadbf4f
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 = channel.is_a?(Channel) ? channel : Channel[channel]
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: #{input.inspect}"
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: #{key_event.inspect}"
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)) and
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wires-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe McIlvain