multiple_man 0.2.1 → 0.2.3
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/multiple_man/listener.rb +3 -2
- data/lib/multiple_man/model_subscriber.rb +1 -1
- data/lib/multiple_man/routing_key.rb +6 -1
- data/lib/multiple_man/version.rb +1 -1
- data/spec/listener_spec.rb +1 -1
- data/spec/model_publisher_spec.rb +1 -1
- data/spec/model_subscriber_spec.rb +2 -2
- data/spec/routing_key_spec.rb +10 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cdfa3e51489f936968807873748a378d7b9f3e0
|
4
|
+
data.tar.gz: e6eff61eaea30c0bf12f45c8b493895c499de159
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26117bc284c1aca81ffb25b0a77f931de766b3ff7edd210b33fd8b0a3fd9ba98a52838403446325e1741ce76d306ebdaf3e999ef66d6c966e95c093c74b23dfb
|
7
|
+
data.tar.gz: 6878932e97e1598b335adec5c889fa041b344d817fe05a82670065feb59c1895f70cae506d9baa9f0ce0d878e312bc0a70bf1da395a8ea642a9e6c973f82aa83
|
@@ -32,11 +32,12 @@ module MultipleMan
|
|
32
32
|
MultipleMan.logger.info "Processing message for #{delivery_info.routing_key}."
|
33
33
|
begin
|
34
34
|
operation = delivery_info.routing_key.split(".").last
|
35
|
-
subscription.send(operation, JSON.parse(payload)
|
35
|
+
subscription.send(operation, JSON.parse(payload))
|
36
36
|
rescue Exception => ex
|
37
37
|
MultipleMan.logger.error " Error - #{ex.message}"
|
38
|
+
else
|
39
|
+
MultipleMan.logger.info " Successfully processed!"
|
38
40
|
end
|
39
|
-
MultipleMan.logger.info " Successfully processed!"
|
40
41
|
end
|
41
42
|
|
42
43
|
def queue
|
@@ -8,7 +8,7 @@ module MultipleMan
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def to_s
|
11
|
-
"#{klass.name}.#{operation}"
|
11
|
+
"#{topic_name}.#{klass.name}.#{operation}"
|
12
12
|
end
|
13
13
|
|
14
14
|
attr_reader :operation
|
@@ -23,5 +23,10 @@ module MultipleMan
|
|
23
23
|
@klass = (value.is_a?(Class) ? value : value.class)
|
24
24
|
end
|
25
25
|
|
26
|
+
private
|
27
|
+
def topic_name
|
28
|
+
MultipleMan.configuration.topic_name
|
29
|
+
end
|
30
|
+
|
26
31
|
end
|
27
32
|
end
|
data/lib/multiple_man/version.rb
CHANGED
data/spec/listener_spec.rb
CHANGED
@@ -41,6 +41,6 @@ describe MultipleMan::Listener do
|
|
41
41
|
subscriber = double(MultipleMan::ModelSubscriber, klass: MockClass1, routing_key: "MockClass1.#")
|
42
42
|
listener = MultipleMan::Listener.new(subscriber)
|
43
43
|
subscriber.should_receive(:create).with({"a" => 1, "b" => 2})
|
44
|
-
listener.process_message(OpenStruct.new(routing_key: "MockClass1.create"), '{"a":1,"b":2}')
|
44
|
+
listener.process_message(OpenStruct.new(routing_key: "app.MockClass1.create"), '{"a":1,"b":2}')
|
45
45
|
end
|
46
46
|
end
|
@@ -35,7 +35,7 @@ describe MultipleMan::ModelPublisher do
|
|
35
35
|
end
|
36
36
|
it "should send the jsonified version of the model to the correct routing key" do
|
37
37
|
MultipleMan::AttributeExtractor.any_instance.should_receive(:to_json).and_return('{"id":10,"data":{"foo": "bar"}}')
|
38
|
-
topic_stub.should_receive(:publish).with('{"id":10,"data":{"foo": "bar"}}', routing_key: "MockObject.create")
|
38
|
+
topic_stub.should_receive(:publish).with('{"id":10,"data":{"foo": "bar"}}', routing_key: "app.MockObject.create")
|
39
39
|
described_class.new(:create, fields: [:foo]).after_commit(MockObject.new)
|
40
40
|
end
|
41
41
|
end
|
@@ -34,13 +34,13 @@ describe MultipleMan::ModelSubscriber do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
specify "routing_key should be the model name and a wildcard" do
|
37
|
-
MultipleMan::ModelSubscriber.new(MockClass).routing_key.should == "MockClass.#"
|
37
|
+
MultipleMan::ModelSubscriber.new(MockClass).routing_key.should == "app.MockClass.#"
|
38
38
|
end
|
39
39
|
|
40
40
|
specify "queue name should be the app name + class" do
|
41
41
|
MultipleMan.configure do |config|
|
42
42
|
config.app_name = "test"
|
43
43
|
end
|
44
|
-
MultipleMan::ModelSubscriber.new(MockClass).queue_name.should == "test.MockClass"
|
44
|
+
MultipleMan::ModelSubscriber.new(MockClass).queue_name.should == "app.test.MockClass"
|
45
45
|
end
|
46
46
|
end
|
data/spec/routing_key_spec.rb
CHANGED
@@ -4,27 +4,33 @@ describe MultipleMan::RoutingKey do
|
|
4
4
|
class MockObject
|
5
5
|
end
|
6
6
|
|
7
|
+
before do
|
8
|
+
MultipleMan.configure do |config|
|
9
|
+
config.topic_name = "app"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
7
13
|
describe "to_s" do
|
8
14
|
subject { described_class.new(MockObject.new, operation).to_s }
|
9
15
|
|
10
16
|
context "creating" do
|
11
17
|
let(:operation) { :create }
|
12
|
-
it { should == "MockObject.create" }
|
18
|
+
it { should == "app.MockObject.create" }
|
13
19
|
end
|
14
20
|
|
15
21
|
context "updating" do
|
16
22
|
let(:operation) { :update }
|
17
|
-
it { should == "MockObject.update" }
|
23
|
+
it { should == "app.MockObject.update" }
|
18
24
|
end
|
19
25
|
|
20
26
|
context "destroying" do
|
21
27
|
let(:operation) { :destroy }
|
22
|
-
it { should == "MockObject.destroy" }
|
28
|
+
it { should == "app.MockObject.destroy" }
|
23
29
|
end
|
24
30
|
|
25
31
|
context "not specified" do
|
26
32
|
subject { described_class.new(MockObject.new).to_s }
|
27
|
-
it { should == "MockObject.#" }
|
33
|
+
it { should == "app.MockObject.#" }
|
28
34
|
end
|
29
35
|
end
|
30
36
|
|