multiple_man 0.2.4 → 0.2.5
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/connection.rb +15 -14
- data/lib/multiple_man/version.rb +1 -1
- data/spec/connection_spec.rb +4 -2
- data/spec/model_publisher_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 281afe83885726b5605460d6ca767b02533a46bb
|
4
|
+
data.tar.gz: 2c039313e01e5e55085061de80023d835bdfb3d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4a0c73c560386a2d8c54b22487f21855946824e58673c171ef8653e03fe4ced85de3b7fc758d6c7e298cc7c8412dcf1f76810ca0448b43aba7aaeceed26ef3c
|
7
|
+
data.tar.gz: 7f66da89814c25bbec40ae3be723071bdd1b56899f9cccecb1672680f92eaab0816398ddf6123fa90d730dbdc146b77c575cba185e3be9cb4b856e9ce458d9af
|
@@ -2,25 +2,26 @@ require 'bunny'
|
|
2
2
|
|
3
3
|
module MultipleMan
|
4
4
|
class Connection
|
5
|
-
def self.
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
MultipleMan.logger.info "Starting connection"
|
5
|
+
def self.connection
|
6
|
+
@connection ||= begin
|
7
|
+
connection = Bunny.new(MultipleMan.configuration.connection)
|
8
|
+
MultipleMan.logger.info "Connecting to #{MultipleMan.configuration.connection}"
|
10
9
|
connection.start
|
11
|
-
|
12
|
-
ensure
|
13
|
-
MultipleMan.logger.info "Closing connection"
|
14
|
-
connection.close
|
10
|
+
connection
|
15
11
|
end
|
16
12
|
end
|
17
13
|
|
18
|
-
def
|
19
|
-
|
14
|
+
def self.connect
|
15
|
+
channel = connection.create_channel
|
16
|
+
begin
|
17
|
+
yield new(channel) if block_given?
|
18
|
+
ensure
|
19
|
+
channel.close
|
20
|
+
end
|
20
21
|
end
|
21
22
|
|
22
|
-
def channel
|
23
|
-
|
23
|
+
def initialize(channel)
|
24
|
+
self.channel = channel
|
24
25
|
end
|
25
26
|
|
26
27
|
def topic
|
@@ -33,7 +34,7 @@ module MultipleMan
|
|
33
34
|
|
34
35
|
private
|
35
36
|
|
36
|
-
attr_accessor :
|
37
|
+
attr_accessor :channel
|
37
38
|
|
38
39
|
end
|
39
40
|
end
|
data/lib/multiple_man/version.rb
CHANGED
data/spec/connection_spec.rb
CHANGED
@@ -3,13 +3,15 @@ require 'spec_helper'
|
|
3
3
|
describe MultipleMan::Connection do
|
4
4
|
|
5
5
|
let(:mock_bunny) { double(Bunny) }
|
6
|
+
let(:mock_channel) { double(Bunny::Channel) }
|
6
7
|
|
7
8
|
describe "connect" do
|
8
9
|
it "should open and close the connection" do
|
9
10
|
mock_bunny.should_receive(:start)
|
10
|
-
mock_bunny.should_receive(:close)
|
11
11
|
Bunny.should_receive(:new).and_return(mock_bunny)
|
12
|
-
|
12
|
+
mock_bunny.should_receive(:create_channel).and_return(mock_channel)
|
13
|
+
mock_channel.should_receive(:close)
|
14
|
+
|
13
15
|
described_class.connect
|
14
16
|
end
|
15
17
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe MultipleMan::ModelPublisher do
|
4
|
-
let(:channel_stub) { double(Bunny::Channel, topic: topic_stub)}
|
4
|
+
let(:channel_stub) { double(Bunny::Channel, topic: topic_stub, close: nil)}
|
5
5
|
let(:topic_stub) { double(Bunny::Exchange, publish: nil) }
|
6
6
|
|
7
7
|
before {
|
@@ -9,7 +9,7 @@ describe MultipleMan::ModelPublisher do
|
|
9
9
|
config.topic_name = "app"
|
10
10
|
end
|
11
11
|
|
12
|
-
MultipleMan::Connection.
|
12
|
+
MultipleMan::Connection.stub(:connection).and_return(double(Bunny, create_channel: channel_stub))
|
13
13
|
}
|
14
14
|
|
15
15
|
class MockObject
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multiple_man
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Brunner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|