brightbox-warren 0.8.9 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +1 -0
- data/lib/warren.rb +2 -2
- data/lib/warren/adapters/dummy_adapter.rb +3 -3
- data/lib/warren/queue.rb +11 -0
- data/spec/warren/queue_spec.rb +22 -0
- data/warren.gemspec +3 -3
- metadata +2 -2
data/CHANGELOG
CHANGED
data/lib/warren.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require "yaml"
|
2
|
-
|
2
|
+
require "logger"
|
3
3
|
#
|
4
4
|
# Library for pushing messages onto RabbitMQ queues,
|
5
5
|
# and receiving them at the other end.
|
@@ -15,7 +15,7 @@ end
|
|
15
15
|
|
16
16
|
WARREN_ENV = ENV['WARREN_ENV'] || ((defined?(RAILS_ENV) ? RAILS_ENV : "development")) unless defined?(WARREN_ENV)
|
17
17
|
WARREN_ROOT = (defined?(RAILS_ROOT) ? RAILS_ROOT : File.dirname($0)) unless defined?(WARREN_ROOT)
|
18
|
-
WARREN_LIB_ROOT = File.expand_path(File.dirname(__FILE__))
|
18
|
+
WARREN_LIB_ROOT = File.expand_path(File.dirname(__FILE__)) unless defined? WARREN_LIB_ROOT
|
19
19
|
|
20
20
|
# Require everything in the lib folder
|
21
21
|
Dir["#{WARREN_LIB_ROOT}/warren/*.rb"].each do |file|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require "rubygems"
|
2
2
|
|
3
3
|
class DummyAdapter < Warren::Queue
|
4
|
+
|
4
5
|
def self.publish queue_name, payload, &blk
|
5
|
-
|
6
|
+
logger.info "publishing #{payload.inspect} to #{queue_name}"
|
6
7
|
end
|
7
8
|
|
8
9
|
def self.subscribe queue_name, &block
|
9
|
-
|
10
|
+
logger.info "subscribing to #{queue_name}"
|
10
11
|
end
|
11
12
|
end
|
12
|
-
|
data/lib/warren/queue.rb
CHANGED
@@ -2,6 +2,7 @@ module Warren
|
|
2
2
|
class Queue
|
3
3
|
@@connection = nil
|
4
4
|
@@adapter = nil
|
5
|
+
@@logger = nil
|
5
6
|
|
6
7
|
#
|
7
8
|
# Raised if no connection has been defined yet.
|
@@ -75,5 +76,15 @@ module Warren
|
|
75
76
|
self.adapter.subscribe(*args, &blk)
|
76
77
|
end
|
77
78
|
|
79
|
+
def self.logger
|
80
|
+
unless @@logger
|
81
|
+
@@logger = Logger.new(nil)
|
82
|
+
end
|
83
|
+
@@logger
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.logger=(l)
|
87
|
+
@@logger = l
|
88
|
+
end
|
78
89
|
end
|
79
90
|
end
|
data/spec/warren/queue_spec.rb
CHANGED
@@ -88,4 +88,26 @@ describe Warren::Queue do
|
|
88
88
|
Warren::Queue.subscribe("foo", "bar", block).should == "subscribe"
|
89
89
|
end
|
90
90
|
end
|
91
|
+
|
92
|
+
describe "logger" do
|
93
|
+
|
94
|
+
before(:each) do
|
95
|
+
Warren::Queue.logger = nil
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should have a default logger" do
|
99
|
+
Warren::Queue.logger.should_not be_nil
|
100
|
+
Warren::Queue.logger.should be_a_kind_of(Logger)
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should allow you to set a custom logger" do
|
104
|
+
log = mock(Logger)
|
105
|
+
|
106
|
+
Warren::Queue.logger = log
|
107
|
+
|
108
|
+
Warren::Queue.logger.should_not be_nil
|
109
|
+
Warren::Queue.logger.should == log
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
91
113
|
end
|
data/warren.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{warren}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.9.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Caius Durling, David Smalley"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-09-10}
|
10
10
|
s.description = %q{Library for pushing messages onto and off RabbitMQ queues}
|
11
11
|
s.email = %q{support@brightbox.co.uk}
|
12
12
|
s.extra_rdoc_files = ["CHANGELOG", "lib/warren/adapters/amqp_adapter.rb", "lib/warren/adapters/bunny_adapter.rb", "lib/warren/adapters/dummy_adapter.rb", "lib/warren/adapters/test_adapter.rb", "lib/warren/connection.rb", "lib/warren/filters/shared_secret.rb", "lib/warren/filters/yaml.rb", "lib/warren/message_filter.rb", "lib/warren/queue.rb", "lib/warren.rb", "LICENSE", "tasks/rdoc.rake", "tasks/rspec.rake"]
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Warren", "--main", "readme.rdoc"]
|
16
16
|
s.require_paths = ["lib"]
|
17
17
|
s.rubyforge_project = %q{warren}
|
18
|
-
s.rubygems_version = %q{1.3.
|
18
|
+
s.rubygems_version = %q{1.3.5}
|
19
19
|
s.summary = %q{Library for pushing messages onto and off RabbitMQ queues}
|
20
20
|
|
21
21
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brightbox-warren
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Caius Durling, David Smalley
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-10 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|