ragnar 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ *.swp
@@ -14,9 +14,9 @@ module Ragnar
14
14
  # Pass connection options through to AMQP
15
15
  def connect
16
16
  # backwards compatible code
17
- host = @host.nil? ? Ragnar::Config.host : @host
18
- port = @port.nil? ? Ragnar::Config.port : @port
19
- @connection = AMQP.connect({:host => @host, :port => @port})
17
+ @host ||= ::Ragnar::Config.host
18
+ @port ||= ::Ragnar::Config.port
19
+ @connection = ::AMQP.connect({:host => @host, :port => @port})
20
20
  end
21
21
 
22
22
  def connected?
@@ -16,7 +16,7 @@ module Ragnar
16
16
  channel = AMQP::Channel.new(connection)
17
17
  exchange = channel.__send__(@type, @name, @options)
18
18
 
19
- channel.queue(@name).bind(exchange, opts.merge(routing_key: routing_key))
19
+ channel.queue(@name).bind(exchange, opts.merge(:routing_key => routing_key))
20
20
  exchange.publish(message, opts.merge(:routing_key => routing_key))
21
21
  end
22
22
  end
@@ -50,4 +50,4 @@ module Ragnar
50
50
 
51
51
 
52
52
  end
53
- end
53
+ end
@@ -1,3 +1,3 @@
1
1
  module Ragnar
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/ragnar.gemspec CHANGED
@@ -23,4 +23,5 @@ Gem::Specification.new do |s|
23
23
  s.add_dependency 'bunny'
24
24
  s.add_development_dependency 'rspec'
25
25
  s.add_development_dependency 'evented-spec', '~>0.4.1'
26
+ s.add_development_dependency 'pry'
26
27
  end
@@ -5,6 +5,9 @@ describe Ragnar::Connector do
5
5
  include EventedSpec::SpecHelper
6
6
  include EventedSpec::AMQPSpec
7
7
 
8
+ before(:all) { EM.stop_event_loop; sleep(0.3) }
9
+ after(:all) { Thread.new { EM.run }; Thread.pass until EM.reactor_running? }
10
+
8
11
  before(:each) do
9
12
  Ragnar::Connector.connection = nil
10
13
  end
@@ -13,6 +16,7 @@ describe Ragnar::Connector do
13
16
 
14
17
  context 'new configuration methods' do
15
18
  it 'can set host and port and have a connection' do
19
+ AMQP.stub(:connect)
16
20
  AMQP.should_receive(:connect).with({:host => Ragnar::Config.host, :port => Ragnar::Config.port})
17
21
  Ragnar::Connector.connect
18
22
  done
@@ -26,6 +30,7 @@ describe Ragnar::Connector do
26
30
  end
27
31
 
28
32
  it 'can set host and port and have a connection' do
33
+ AMQP.stub(:connect)
29
34
  host = 'test.md.com'
30
35
  port = '5763'
31
36
 
@@ -34,10 +39,32 @@ describe Ragnar::Connector do
34
39
 
35
40
  AMQP.should_receive(:connect).with({host: host, port: port})
36
41
  Ragnar::Connector.connect
42
+ done
43
+ end
44
+ end
45
+
46
+ context 'new configuration methods' do
47
+ it 'can set host and port and have a connection' do
48
+ AMQP.stub(:connect)
49
+ host = 'test2.md.com'
50
+ port = '5763'
51
+
52
+ Ragnar::Connector.host = nil
53
+ Ragnar::Connector.port = nil
54
+
55
+ Ragnar::Config.configure do |c|
56
+ c.host = host
57
+ c.port = port
58
+ end
59
+
60
+ AMQP.should_receive(:connect).with({host: host, port: port})
61
+ Ragnar::Connector.connect
62
+ done
37
63
  end
38
64
  end
39
65
 
40
66
  it 'uses the existing reactor if it already exists' do
67
+ AMQP.stub(:connect)
41
68
  em do
42
69
  EM.should_not_receive(:run)
43
70
  Ragnar::Connector.connect
@@ -50,6 +77,7 @@ describe Ragnar::Connector do
50
77
  describe '.connection' do
51
78
 
52
79
  it 'stores the connection' do
80
+ AMQP.stub(:connect).and_return(double("connection", :connected? => true))
53
81
  Ragnar::Connector.connect
54
82
  delayed(0.3) {
55
83
  Ragnar::Connector.connection.should be_connected
@@ -67,6 +95,7 @@ describe Ragnar::Connector do
67
95
 
68
96
  describe '.connected?' do
69
97
  it 'relays connection state' do
98
+ AMQP.stub(:connect).and_return(double("connection", :connected? => true))
70
99
  Ragnar::Connector.connected?.should be_false
71
100
  Ragnar::Connector.connect
72
101
  delayed(0.3) {
data/spec/spec_helper.rb CHANGED
@@ -6,7 +6,7 @@ require 'eventmachine'
6
6
 
7
7
  unless EM.reactor_running?
8
8
  Thread.new { EventMachine.run }
9
- sleep 0.5
9
+ Thread.pass until EM.reactor_running?
10
10
  end
11
11
 
12
- $: << File.expand_path('../lib', File.dirname(__FILE__))
12
+ $: << File.expand_path('../lib', File.dirname(__FILE__))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ragnar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-17 00:00:00.000000000Z
12
+ date: 2012-04-30 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: amqp
16
- requirement: &2153647520 !ruby/object:Gem::Requirement
16
+ requirement: &2157572600 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.7.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2153647520
24
+ version_requirements: *2157572600
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bunny
27
- requirement: &2153647100 !ruby/object:Gem::Requirement
27
+ requirement: &2157572160 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2153647100
35
+ version_requirements: *2157572160
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &2153646600 !ruby/object:Gem::Requirement
38
+ requirement: &2157571700 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2153646600
46
+ version_requirements: *2157571700
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: evented-spec
49
- requirement: &2153646100 !ruby/object:Gem::Requirement
49
+ requirement: &2157571200 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,7 +54,18 @@ dependencies:
54
54
  version: 0.4.1
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2153646100
57
+ version_requirements: *2157571200
58
+ - !ruby/object:Gem::Dependency
59
+ name: pry
60
+ requirement: &2157570780 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *2157570780
58
69
  description: Provide top-level pub/sub methods with RabbitMQ (AMQP) for interacting
59
70
  with a larger service ecosystem
60
71
  email: