lapine 0.0.3 → 0.1.0

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: f7e95ed028d5cbadaf4b7fdd8ad5e23999e90abe
4
- data.tar.gz: 94963d6e447234a9f769fb5777e0a2dd123ff474
3
+ metadata.gz: c903d73c15a42efe4c3714fa857ac2445e323710
4
+ data.tar.gz: 8586dd9c5d4d2dc8cc1aa54a4e3c4111b06d8485
5
5
  SHA512:
6
- metadata.gz: 2e69fdf1807c1fd4b22086daf824762c85941b95083c3c05ccbd733a6cf3ed6c73a3ea0da9abac202d1e921d2461752a467ebfab3483dd5c61b5afa8d552149d
7
- data.tar.gz: ed3c4fdd7cf66dbc480c2e6c530bda3e12f852ece1ffedca48f75c7a68ff63105511e25f0d555803e3c8a0d3bf42dc0d543d7252c9bc153717bbf097275497ea
6
+ metadata.gz: 88a0490e40a3107ac07c38cf1e39842af4a31a6886036f24e1c0fbfd1d42641aed7cc4352420fb99522c48ded69930a6ca44c549d57b2ac188e687643a164053
7
+ data.tar.gz: 97bd4d3961e10c83f3bfad031da65061cdb0f3823e52c7c2dcadb19b88bb626788ff20d2069ba2e2377c4a6dd2fef6d3040a0e1324602c0cafbc6e36284c734a
@@ -1,6 +1,6 @@
1
1
  require 'lapine/version'
2
2
  require 'lapine/configuration'
3
- require 'lapine/connection'
3
+ require 'lapine/exchange'
4
4
  require 'lapine/publisher'
5
5
 
6
6
  module Lapine
@@ -26,7 +26,14 @@ module Lapine
26
26
  exchange = config.exchange_properties[name]
27
27
  raise UndefinedExchange unless exchange
28
28
  return config.exchanges[name].exchange if config.exchanges[name]
29
- config.exchanges[name] = Lapine::Connection.new(name, exchange)
29
+ config.exchanges[name] = Lapine::Exchange.new(name, exchange)
30
30
  config.exchanges[name].exchange
31
31
  end
32
+
33
+ def self.close_connections!
34
+ config.exchanges.values.each do |exchange|
35
+ exchange.close!
36
+ config.exchanges.delete exchange.name
37
+ end
38
+ end
32
39
  end
@@ -1,7 +1,7 @@
1
1
  require 'bunny'
2
2
 
3
3
  module Lapine
4
- class Connection
4
+ class Exchange
5
5
  attr_reader :conn, :name, :props, :connection_name, :exchange_type
6
6
 
7
7
  def initialize(name, properties)
@@ -23,5 +23,9 @@ module Lapine
23
23
  channel = conn.create_channel
24
24
  @exchange = Bunny::Exchange.new(channel, exchange_type, name, props)
25
25
  end
26
+
27
+ def close!
28
+ @conn.close
29
+ end
26
30
  end
27
31
  end
@@ -1,3 +1,3 @@
1
1
  module Lapine
2
- VERSION = '0.0.3'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -46,6 +46,27 @@ RSpec.describe Lapine do
46
46
  end
47
47
  end
48
48
 
49
+ describe '.close_connections!' do
50
+ let(:connection1) { double('blah connection', close!: true, name: 'blah') }
51
+ let(:connection2) { double('blargh connection', close!: true, name: 'blargh') }
52
+
53
+ before do
54
+ config.exchanges['blah'] = connection1
55
+ config.exchanges['blargh'] = connection2
56
+ end
57
+
58
+ it 'calls close on each connection' do
59
+ Lapine.close_connections!
60
+ expect(connection1).to have_received(:close!)
61
+ expect(connection2).to have_received(:close!)
62
+ end
63
+
64
+ it 'clears the exchanges' do
65
+ Lapine.close_connections!
66
+ expect(Lapine.config.exchanges).to be_empty
67
+ end
68
+ end
69
+
49
70
  describe '.find_exchange' do
50
71
  before do
51
72
  allow(Bunny).to receive(:new).and_return(connection)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lapine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Saxby
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-10 00:00:00.000000000 Z
12
+ date: 2014-11-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bunny
@@ -112,7 +112,7 @@ files:
112
112
  - lapine.gemspec
113
113
  - lib/lapine.rb
114
114
  - lib/lapine/configuration.rb
115
- - lib/lapine/connection.rb
115
+ - lib/lapine/exchange.rb
116
116
  - lib/lapine/publisher.rb
117
117
  - lib/lapine/version.rb
118
118
  - spec/lib/lapine/publisher_spec.rb