resque-igo 1.12.5 → 1.12.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,7 +29,12 @@ module Resque
29
29
 
30
30
 
31
31
  def mongo=(server)
32
- if server.is_a? String
32
+ if server.is_a?(String) && server.start_with?('mongodb://')
33
+ raise "Connecting with a mongodb uri requires Mongo driver version 1.1.5 or higher." if Mongo::VERSION < "1.1.5"
34
+ conn = Mongo::Connection.from_uri(server)
35
+ nodes, auths = Mongo::URIParser.parse(server)
36
+ queuedb = auths.first['db_name']
37
+ elsif server.is_a? String
33
38
  opts = server.split(':')
34
39
  host = opts[0]
35
40
  if opts[1] =~ /\//
@@ -41,8 +46,8 @@ module Resque
41
46
  end
42
47
  conn = Mongo::Connection.new host, port
43
48
  elsif server.is_a? Hash
44
- conn = Mongo::Connection.new(options[:server], options[:port], options)
45
- queuedb = options[:queuedb] || 'resque'
49
+ conn = Mongo::Connection.new(server[:server], server[:port], server)
50
+ queuedb = server[:queuedb] || 'resque'
46
51
  elsif server.is_a? Mongo::Connection
47
52
  conn = server
48
53
  end
@@ -134,7 +139,8 @@ module Resque
134
139
  end
135
140
 
136
141
  def to_s
137
- "Resque Client connected to #{mongo.connection.host}:#{mongo.connection.port}/#{mongo.name}"
142
+ connection_info = Mongo::VERSION >= "1.1.3" ? mongo.connection.primary_pool : mongo.connection
143
+ "Resque Client connected to #{connection_info.host}:#{connection_info.port}/#{mongo.name}"
138
144
  end
139
145
 
140
146
  def allows_unique_jobs(klass)
@@ -1,3 +1,3 @@
1
1
  module Resque
2
- Version = VERSION = '1.12.5'
2
+ Version = VERSION = '1.12.6'
3
3
  end
@@ -16,6 +16,13 @@ context "Resque" do
16
16
  Resque.mongo = 'localhost:27017/namespace'
17
17
  assert_equal 'namespace', Resque.mongo.name
18
18
  end
19
+
20
+ test "can connect through a mongodb uri" do
21
+ Resque.mongo.connection.db('authenticated_resque_db').add_user('username', 'password')
22
+ uri = 'mongodb://username:password@localhost:27017/authenticated_resque_db'
23
+ Resque.mongo = uri
24
+ assert_equal 'authenticated_resque_db', Resque.mongo.name
25
+ end
19
26
 
20
27
  test "can put jobs on a queue" do
21
28
  assert Resque::Job.create(:jobs, 'SomeJob', 20, '/tmp')
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-igo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 45
4
+ hash: 43
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 12
9
- - 5
10
- version: 1.12.5
9
+ - 6
10
+ version: 1.12.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nathan D Acuff
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-14 00:00:00 -05:00
18
+ date: 2010-12-22 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency