multiple_man 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c09e37ab8dfce2a4417485dde54eb56ffabcf4a2
4
- data.tar.gz: d74f55213b18cfecf1680e598ad73d1514515b14
3
+ metadata.gz: 281afe83885726b5605460d6ca767b02533a46bb
4
+ data.tar.gz: 2c039313e01e5e55085061de80023d835bdfb3d2
5
5
  SHA512:
6
- metadata.gz: d1905e3f95f14aadb247968fafd0ca155214a527368bd08e8ff79063620528a3271bc256bf82480f17b8bdd9c9cc7d69d3251a6739da0804ab1e3723dd41455c
7
- data.tar.gz: cca35db2754128c0068947d0615975de9c3882fb20cc4a5525489d83ecd16e103deeb7ca0bca297d6743c63cd6b698b6ba5da233600ce77a29046b061a6cd74a
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.connect
6
- MultipleMan.logger.info "Connecting to #{MultipleMan.configuration.connection}"
7
- connection = Bunny.new(MultipleMan.configuration.connection)
8
- begin
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
- yield new(connection) if block_given?
12
- ensure
13
- MultipleMan.logger.info "Closing connection"
14
- connection.close
10
+ connection
15
11
  end
16
12
  end
17
13
 
18
- def initialize(connection)
19
- self.connection = connection
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
- @channel ||= connection.create_channel
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 :connection
37
+ attr_accessor :channel
37
38
 
38
39
  end
39
40
  end
@@ -1,3 +1,3 @@
1
1
  module MultipleMan
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
@@ -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.any_instance.stub(:channel).and_return(channel_stub)
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
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-02 00:00:00.000000000 Z
11
+ date: 2014-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler