sub_pub 0.0.9 → 0.0.10
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.
- data/Gemfile.lock +1 -1
- data/lib/sub_pub/active_record_subscriber.rb +8 -0
- data/lib/sub_pub/subscriber.rb +6 -4
- data/lib/sub_pub/version.rb +1 -1
- data/lib/sub_pub_matchers.rb +2 -2
- data/pkg/sub_pub-0.0.9.gem +0 -0
- data/spec/unit/active_record_matchers_spec.rb +15 -0
- data/spec/unit/matchers_spec.rb +9 -0
- data/spec/unit/subscriber_spec.rb +6 -0
- metadata +14 -3
data/Gemfile.lock
CHANGED
data/lib/sub_pub/subscriber.rb
CHANGED
@@ -3,15 +3,13 @@ module SubPub
|
|
3
3
|
attr_reader :options
|
4
4
|
alias :payload :options
|
5
5
|
|
6
|
-
def initialize(options)
|
6
|
+
def initialize(options={})
|
7
7
|
@options = options
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.subscribe_to(topic_name)
|
11
|
-
klass = self
|
12
|
-
|
13
11
|
@subscription = SubPub.subscribe(topic_name) do |topic, options|
|
14
|
-
publish(
|
12
|
+
publish(new(options))
|
15
13
|
end
|
16
14
|
end
|
17
15
|
|
@@ -31,6 +29,10 @@ module SubPub
|
|
31
29
|
topic
|
32
30
|
end
|
33
31
|
|
32
|
+
def topic_name
|
33
|
+
self.class.topic_name
|
34
|
+
end
|
35
|
+
|
34
36
|
def on_publish
|
35
37
|
raise "Please define an on_publish method for #{self.class.name}"
|
36
38
|
end
|
data/lib/sub_pub/version.rb
CHANGED
data/lib/sub_pub_matchers.rb
CHANGED
@@ -28,7 +28,7 @@ module SubPub
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def matches?(subject)
|
31
|
-
|
31
|
+
subject.model_name.should == @expected.name
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -38,7 +38,7 @@ module SubPub
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def matches?(subject)
|
41
|
-
|
41
|
+
subject.callback_name.should == @expected
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
Binary file
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "active record matchers" do
|
4
|
+
class FakeUser
|
5
|
+
end
|
6
|
+
|
7
|
+
class FoozBarz < SubPub::ActiveRecord::Subscriber
|
8
|
+
subscribe_to(FakeUser, 'after_create')
|
9
|
+
end
|
10
|
+
|
11
|
+
describe FoozBarz do
|
12
|
+
it { should subscribe_to_model(FakeUser) }
|
13
|
+
it { should subscribe_to_callback('after_create') }
|
14
|
+
end
|
15
|
+
end
|
@@ -14,4 +14,10 @@ describe SubPub::Subscriber do
|
|
14
14
|
|
15
15
|
it { should subscribe_to_topic('foo_bar_topic') }
|
16
16
|
end
|
17
|
+
|
18
|
+
describe "#topic_name" do
|
19
|
+
it "returns the name of the topic sent to subscribe_to" do
|
20
|
+
Bazero.new.topic_name.should == 'foo_bar_topic'
|
21
|
+
end
|
22
|
+
end
|
17
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sub_pub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-04 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: In process publish/subscribe for Ruby
|
15
15
|
email:
|
@@ -41,9 +41,12 @@ files:
|
|
41
41
|
- pkg/sub_pub-0.0.6.gem
|
42
42
|
- pkg/sub_pub-0.0.7.gem
|
43
43
|
- pkg/sub_pub-0.0.8.gem
|
44
|
+
- pkg/sub_pub-0.0.9.gem
|
44
45
|
- spec/integration/sub_pub_spec.rb
|
45
46
|
- spec/spec_helper.rb
|
47
|
+
- spec/unit/active_record_matchers_spec.rb
|
46
48
|
- spec/unit/active_record_subscriber_spec.rb
|
49
|
+
- spec/unit/matchers_spec.rb
|
47
50
|
- spec/unit/register_spec.rb
|
48
51
|
- spec/unit/subscriber_spec.rb
|
49
52
|
- sub_pub.gemspec
|
@@ -59,15 +62,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
59
62
|
- - ! '>='
|
60
63
|
- !ruby/object:Gem::Version
|
61
64
|
version: '0'
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
hash: -3975189905250384298
|
62
68
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
69
|
none: false
|
64
70
|
requirements:
|
65
71
|
- - ! '>='
|
66
72
|
- !ruby/object:Gem::Version
|
67
73
|
version: '0'
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
hash: -3975189905250384298
|
68
77
|
requirements: []
|
69
78
|
rubyforge_project:
|
70
|
-
rubygems_version: 1.8.
|
79
|
+
rubygems_version: 1.8.24
|
71
80
|
signing_key:
|
72
81
|
specification_version: 3
|
73
82
|
summary: SubPub is a thin wrapper around ActiveSupport::Notifications, which provides
|
@@ -75,6 +84,8 @@ summary: SubPub is a thin wrapper around ActiveSupport::Notifications, which pro
|
|
75
84
|
test_files:
|
76
85
|
- spec/integration/sub_pub_spec.rb
|
77
86
|
- spec/spec_helper.rb
|
87
|
+
- spec/unit/active_record_matchers_spec.rb
|
78
88
|
- spec/unit/active_record_subscriber_spec.rb
|
89
|
+
- spec/unit/matchers_spec.rb
|
79
90
|
- spec/unit/register_spec.rb
|
80
91
|
- spec/unit/subscriber_spec.rb
|