yeller 0.2.0 → 0.3.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/README.md +3 -0
- data/lib/yeller/key.rb +1 -1
- data/lib/yeller/subscriber_collection.rb +7 -10
- data/lib/yeller/version.rb +1 -1
- 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: 91d37bc468ab59a7850bc568712d5d85b7e6dc4e
|
4
|
+
data.tar.gz: e1233eee0b0e8d31ad267277b4a7ccd087e2fd31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1352bc2a30381fdd58340411f66fbbf9192ac40a2524e45ac99e8bc5fa4af8811c474eae0177e4c19fdab061f1fa90f7ff504b7f1445dedbdff2d10f3c13500b
|
7
|
+
data.tar.gz: 3957d510fa14a2889fb33fcc5a832cf288c5f9c2e5ff78282187401248c76e722634b70f843447963f3510633553c82bb26b71cf500516f36ae5aac5b5bce41e
|
data/README.md
CHANGED
@@ -54,6 +54,9 @@ class MyListenerClass
|
|
54
54
|
# or, if you have just the one key
|
55
55
|
subscribe with: :react, to: "key"
|
56
56
|
|
57
|
+
# you can also subscribe to an arbitrary regexp key
|
58
|
+
subscribe with: :react, to: "key.*"
|
59
|
+
|
57
60
|
def self.react( message )
|
58
61
|
puts "received #{message}"
|
59
62
|
end
|
data/lib/yeller/key.rb
CHANGED
@@ -1,26 +1,23 @@
|
|
1
1
|
module Yeller
|
2
2
|
class SubscriberCollection
|
3
3
|
def initialize( )
|
4
|
-
@subscribers =
|
4
|
+
@subscribers = []
|
5
5
|
end
|
6
6
|
|
7
7
|
def add( subscriber )
|
8
|
-
|
9
|
-
|
10
|
-
@subscribers[key] ||= []
|
11
|
-
|
12
|
-
@subscribers[key] << subscriber
|
8
|
+
@subscribers << subscriber
|
13
9
|
end
|
14
10
|
|
15
11
|
def remove( subscriber )
|
16
|
-
|
17
|
-
@subscribers[key] = @subscribers[key].delete_if do |sub|
|
12
|
+
@subscribers = @subscribers.delete_if do |sub|
|
18
13
|
sub == subscriber
|
19
|
-
end
|
14
|
+
end
|
20
15
|
end
|
21
16
|
|
22
17
|
def find( key )
|
23
|
-
@subscribers
|
18
|
+
@subscribers.select do |subscriber|
|
19
|
+
key.to_s.match(Regexp.new(subscriber.key.to_s)).present?
|
20
|
+
end
|
24
21
|
end
|
25
22
|
end
|
26
23
|
end
|
data/lib/yeller/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yeller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|