circulate 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2fc212899a5fba0159d395a5c6eac6449bb31f6c
4
- data.tar.gz: fba8ad6afb555eed497ad9da7ddbc6468dd00b9f
3
+ metadata.gz: b123bfadf59479e615d89fa0b5d5f9cb5ee38ac6
4
+ data.tar.gz: 5590dc896ee144f9224d2c5eb3aaf2e8f1e6bd9e
5
5
  SHA512:
6
- metadata.gz: faf5c55bb359e8e6b4553424ddd374b12047a7bf1c048da59d350f33077122f22dcbc1470b0ea6bcaba0234d0a3a2836a83a3661e3d8c82c124dd48a569a908b
7
- data.tar.gz: 8065be84b0ca9868bdd0ca56b688aba6e994a0be6360e60f953e24570593b2f4f40089296c392d00db7fee613b98b55a0092aade4a4d5e2f07d7467e91580ec1
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.0
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: