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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7b860f3537f1110bf32aa9ace742b8f2d0651ea
4
- data.tar.gz: 03cd81f5720b7223df677a225a1ccd95c21892be
3
+ metadata.gz: 4cdfa3e51489f936968807873748a378d7b9f3e0
4
+ data.tar.gz: e6eff61eaea30c0bf12f45c8b493895c499de159
5
5
  SHA512:
6
- metadata.gz: 9fd8f4562f017be6be225faea4cc2ee96bc2606322cbdf3c21193892a5974e24323a5da05bc6ad9e11ef0c1e1eff83cd08eccea6ed0b6b1d109961d73e4e488d
7
- data.tar.gz: 0c886d543a4216146680e025d4920370519925c87acf6ffd3ab734a0db032b79f2ac7508d0d14e35ad662762ab3e9a238c014f78608475f28ae512659d40365d
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).with_indifferent_access)
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
@@ -34,7 +34,7 @@ module MultipleMan
34
34
  end
35
35
 
36
36
  def queue_name
37
- "#{MultipleMan.configuration.app_name}.#{klass.name}"
37
+ "#{MultipleMan.configuration.topic_name}.#{MultipleMan.configuration.app_name}.#{klass.name}"
38
38
  end
39
39
 
40
40
  private
@@ -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
@@ -1,3 +1,3 @@
1
1
  module MultipleMan
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -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
@@ -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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiple_man
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Brunner