circulate 0.1.0 → 0.1.1
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/circulate/matchers.rb +15 -0
- data/lib/circulate/publisher.rb +20 -0
- data/lib/circulate/subscriber.rb +17 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b123bfadf59479e615d89fa0b5d5f9cb5ee38ac6
|
4
|
+
data.tar.gz: 5590dc896ee144f9224d2c5eb3aaf2e8f1e6bd9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff1b9c83f2e92c488ee426aef3ea5b8463b48203810784948e73fc55c628c4a5cd2f9c75c8c91005c103a6a4d2f6990efb5a20c85510c4251bb0ce50b108641c
|
7
|
+
data.tar.gz: 66f6664faa856fcb4afce30d961b9cf2eb1a3de37588f9064a174218399283b8df3e4ddb0b443a6dd4f8dc7b7762ee413aae561735805f50296d426b3f0b8c4a
|
@@ -0,0 +1,15 @@
|
|
1
|
+
RSpec::Matchers.define :publish do |method_name|
|
2
|
+
match do |receiver|
|
3
|
+
ActiveSupport::Notifications.should_receive :instrument
|
4
|
+
receiver.send method_name
|
5
|
+
true
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
RSpec::Matchers.define :subscribe_to do |method_name|
|
10
|
+
match do |receiver|
|
11
|
+
receiver.should_receive method_name
|
12
|
+
ActiveSupport::Notifications.instrument method_name.to_s
|
13
|
+
true
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Circulate
|
2
|
+
module Publisher
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
def publish(*method_names)
|
7
|
+
mod = Module.new do
|
8
|
+
method_names.each do |name|
|
9
|
+
define_method name do |*args|
|
10
|
+
ActiveSupport::Notifications.instrument(name.to_s, self) { super *args }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
prepend mod
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Circulate
|
2
|
+
module Subscriber
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
def subscribe(*publication_names)
|
7
|
+
publication_names.each do |name|
|
8
|
+
ActiveSupport::Notifications.subscribe(name.to_s) do |*args|
|
9
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
10
|
+
self.send name, event.payload
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: circulate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Stump
|
@@ -86,7 +86,10 @@ executables: []
|
|
86
86
|
extensions: []
|
87
87
|
extra_rdoc_files: []
|
88
88
|
files:
|
89
|
-
- lib/circulate.rb
|
89
|
+
- ./lib/circulate/matchers.rb
|
90
|
+
- ./lib/circulate/publisher.rb
|
91
|
+
- ./lib/circulate/subscriber.rb
|
92
|
+
- ./lib/circulate.rb
|
90
93
|
homepage: http://rubygems.org/gems/circulate
|
91
94
|
licenses:
|
92
95
|
- MIT
|
@@ -112,4 +115,3 @@ signing_key:
|
|
112
115
|
specification_version: 4
|
113
116
|
summary: Pubsub DSL for ActiveSupport::Notifications
|
114
117
|
test_files: []
|
115
|
-
has_rdoc:
|