multiple_man 0.5.8 → 0.5.9
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 +21 -19
- data/lib/multiple_man/version.rb +1 -1
- data/spec/connection_spec.rb +4 -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: 45d1f3a68bbb6908b822a5b57a3c176152851b57
|
4
|
+
data.tar.gz: bf316745d372637203f5a976f14e07c50fe9d213
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: caba00db5b03de4f14b6e473e765bfc1096b5dd1a06f60fd84ec31a3692fafbce3aa3893fc75a97582767f4640787a3fff1b82b36d22d4e58c5cfa02af9044b4
|
7
|
+
data.tar.gz: e6b17cff6eb2fc1b90287969218fbf4b228dd59b499a1ed87787149997c6090dd64782af35d6526dd0bc8e3ac27b90822d83f450a8984507f48c0304f431e8e0
|
@@ -4,30 +4,18 @@ require 'active_support/core_ext/module'
|
|
4
4
|
|
5
5
|
module MultipleMan
|
6
6
|
class Connection
|
7
|
-
@mutex = Mutex.new
|
8
|
-
|
9
|
-
def self.connection
|
10
|
-
@mutex.synchronize do
|
11
|
-
@connection ||= begin
|
12
|
-
connection = Bunny.new(MultipleMan.configuration.connection)
|
13
|
-
MultipleMan.logger.debug "Connecting to #{MultipleMan.configuration.connection}"
|
14
|
-
connection.start
|
15
|
-
connection
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
7
|
def self.connect
|
21
|
-
|
22
|
-
yield
|
8
|
+
connection = new
|
9
|
+
yield connection if block_given?
|
23
10
|
ensure
|
24
|
-
|
11
|
+
connection.close! if connection
|
25
12
|
end
|
26
13
|
|
27
14
|
attr_reader :topic
|
28
15
|
|
29
|
-
def initialize
|
30
|
-
|
16
|
+
def initialize
|
17
|
+
init_connection!
|
18
|
+
init_channel!
|
31
19
|
self.topic = channel.topic(topic_name)
|
32
20
|
end
|
33
21
|
|
@@ -35,11 +23,25 @@ module MultipleMan
|
|
35
23
|
MultipleMan.configuration.topic_name
|
36
24
|
end
|
37
25
|
|
26
|
+
def close!
|
27
|
+
channel.close if channel
|
28
|
+
connection.close if connection
|
29
|
+
end
|
30
|
+
|
38
31
|
delegate :queue, to: :channel
|
39
32
|
|
40
33
|
private
|
41
34
|
|
42
|
-
|
35
|
+
def init_connection!
|
36
|
+
self.connection = Bunny.new(MultipleMan.configuration.connection)
|
37
|
+
connection.start
|
38
|
+
end
|
39
|
+
|
40
|
+
def init_channel!
|
41
|
+
self.channel = connection.create_channel
|
42
|
+
end
|
43
|
+
|
44
|
+
attr_accessor :channel, :connection
|
43
45
|
attr_writer :topic
|
44
46
|
|
45
47
|
end
|
data/lib/multiple_man/version.rb
CHANGED
data/spec/connection_spec.rb
CHANGED
@@ -3,19 +3,21 @@ 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
|
+
let(:mock_channel) { double(Bunny::Channel, topic: nil) }
|
7
7
|
|
8
8
|
describe "connect" do
|
9
9
|
it "should open a connection and a channel" do
|
10
10
|
mock_bunny.should_receive(:start)
|
11
11
|
Bunny.should_receive(:new).and_return(mock_bunny)
|
12
12
|
mock_bunny.should_receive(:create_channel).once.and_return(mock_channel)
|
13
|
+
mock_bunny.should_receive(:close)
|
14
|
+
mock_channel.should_receive(:close)
|
13
15
|
|
14
16
|
described_class.connect { }
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
18
|
-
subject { described_class.new
|
20
|
+
subject { described_class.new }
|
19
21
|
|
20
22
|
its(:topic_name) { should == MultipleMan.configuration.topic_name }
|
21
23
|
|
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.5.
|
4
|
+
version: 0.5.9
|
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-09-
|
11
|
+
date: 2014-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|