bunny_hair 0.0.9 → 0.0.10

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: c14e6ea05db60ca10bdfe42bfb32c779598a1966
4
- data.tar.gz: 80ba433d1b1619d9774aaf5606dfea4a3e731e9a
3
+ metadata.gz: ced6ed2775249cf471c4631cbef03dc63af935cf
4
+ data.tar.gz: 3e122327d23d09db6fdbce87a5079fb9e9156314
5
5
  SHA512:
6
- metadata.gz: 9963a9760f1506d294eb44774b9fc92b72791b8e229bb48d0a79b45d97e18ed9b3b1fdeb06b877799a7a03d7e11d60ac498fc3c8833d51a4ef9249b938f09e31
7
- data.tar.gz: d8d449cb1abb2f319eab3a13d3d722e0eaf6721e11cd656446d0ec591b6f4f971647023c99074aceeac9df61902ec6700cab7fb84dd3f17113dbf319df69b779
6
+ metadata.gz: 830a6d65c89377eb3b52d3b6f14c3922769d5b3864545407285678964794ca36ae4f4efe5b55838604d013529ec2221fc38d2169bc344d1767343243f9e75b64
7
+ data.tar.gz: a8488bad9d736e14f715734887e65d7e5fcddd6ca564655871e843708d4e332e2c6e4a1c0fa7feff3c931ae43034e746386ad6175933193169b0fa8620320f98
@@ -1,29 +1,49 @@
1
1
  module BunnyHair
2
2
  class Channel
3
- attr_reader :connection
3
+ attr_reader :connection, :test_queues, :test_exchanges
4
4
 
5
5
  def initialize(connection=BunnyHair.new)
6
6
  @connection = connection
7
+ @test_queues = []
8
+ @test_exchanges = []
7
9
  end
8
10
 
9
11
  def queue(name, options={})
10
- Queue.new(name, options)
12
+ if queue = @test_queues.select {|q| q.name == name }[0]
13
+ return queue
14
+ end
15
+
16
+ Queue.new(name, options).tap do |queue|
17
+ @test_queues << queue
18
+ end
11
19
  end
12
20
 
13
21
  def topic(name, options={})
14
- Exchange.new(connection, :topic, name, options)
22
+ exchange_factory(name, :topic, options)
15
23
  end
16
24
 
17
25
  def fanout(name, options={})
18
- Exchange.new(connection, :fanout, name, options)
26
+ exchange_factory(name, :fanout, options)
19
27
  end
20
28
 
21
29
  def direct(name, options={})
22
- Exchange.new(connection, :direct, name, options)
30
+ exchange_factory(name, :direct, options)
23
31
  end
24
32
 
25
33
  def ack(*args)
26
34
  end
27
35
  alias acknowledge ack
36
+
37
+ private
38
+
39
+ def exchange_factory(name, type, options={})
40
+ if exchange = @test_exchanges.select {|e| e.name == name }[0]
41
+ return exchange
42
+ end
43
+
44
+ Exchange.new(connection, type, name, options).tap do |ex|
45
+ @test_exchanges << ex
46
+ end
47
+ end
28
48
  end
29
49
  end
@@ -15,11 +15,15 @@ module BunnyHair
15
15
  end
16
16
 
17
17
  def create_channel
18
- Channel.new
18
+ Channel.new(self)
19
19
  end
20
20
 
21
21
  def default_channel
22
- @channel ||= Channel.new
22
+ @channel ||= Channel.new(self)
23
+ end
24
+
25
+ def reset_all!
26
+ @channel = nil
23
27
  end
24
28
  end
25
29
  end
@@ -1,3 +1,3 @@
1
1
  module BunnyHair
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
@@ -26,6 +26,17 @@ describe BunnyHair::Channel do
26
26
  queue = channel.queue('queue', options)
27
27
  expect(queue.options).to eq(options)
28
28
  end
29
+
30
+ it 'adds the queue to the array' do
31
+ queue = channel.queue('test.queue')
32
+ expect(channel.test_queues.size).to be(1)
33
+ expect(channel.test_queues).to include(queue)
34
+ end
35
+
36
+ it 'returns the same queue when you use the same name twice' do
37
+ queue = channel.queue('test.queue')
38
+ expect(channel.queue('test.queue')).to be(queue)
39
+ end
29
40
  end
30
41
 
31
42
  describe '#topic' do
@@ -35,6 +46,11 @@ describe BunnyHair::Channel do
35
46
  expect(exchange.type).to be(:topic)
36
47
  expect(exchange).to be_durable
37
48
  end
49
+
50
+ it 'returns the same exchange object' do
51
+ exchange = channel.topic('my.topic.exchange', durable: true)
52
+ expect(channel.topic('my.topic.exchange')).to be(exchange)
53
+ end
38
54
  end
39
55
 
40
56
  describe '#fanout' do
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bunny_hair
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Ross
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-16 00:00:00.000000000 Z
11
+ date: 2014-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: guard-rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: 3.0.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: 3.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pry
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.9.12.2
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.9.12.2
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: 2.14.1
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: 2.14.1
83
83
  description: A simple replacement for Bunny
@@ -87,8 +87,8 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - ".gitignore"
91
- - ".rspec"
90
+ - .gitignore
91
+ - .rspec
92
92
  - Gemfile
93
93
  - Guardfile
94
94
  - LICENSE.txt
@@ -119,12 +119,12 @@ require_paths:
119
119
  - lib
120
120
  required_ruby_version: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  requirements:
127
- - - ">="
127
+ - - '>='
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
130
  requirements: []