qu-mongoid 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7140f4126b6506d6e860cb53dc541667e50675d8
4
+ data.tar.gz: ca5e0b3a506f94d0a103842f46a971d18a6f6e2b
5
+ SHA512:
6
+ metadata.gz: 1b718555a14375b1d435d47ee11c1d3d160563fbec7a5e8079525489b394e1fc09aaa08ee7399f3ee92b5faf4994d8f24a5b71d6cb4c7a6c8f3104d9e3e57afd
7
+ data.tar.gz: 417bfd942886d26510d16d01fcd12c73108031c848e139626ae8a8e67e4b2835eb1569e88c982e574870b1f8eac671ba87e570a505d1dd94001b7fa668bc40ba
@@ -1,2 +1,8 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0.0
4
+ - 2.1.2
5
+ - jruby-19mode
6
+ - rbx-2
1
7
  services:
2
8
  - mongodb
data/Gemfile CHANGED
@@ -1,15 +1,8 @@
1
- source :rubygems
1
+ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in qu-mongoid.gemspec
4
4
  gemspec
5
5
 
6
6
  group :test do
7
7
  gem 'SystemTimer', :platform => :mri_18
8
- gem 'ruby-debug', :platform => :mri_18
9
- gem 'ruby-debug', :platform => :jruby
10
- gem 'debugger', :platform => :mri_19
11
- gem 'rake'
12
- gem 'rspec', '~> 2.0'
13
- gem 'guard-rspec'
14
- gem 'guard-bundler'
15
- end
8
+ end
data/README.md CHANGED
@@ -20,6 +20,8 @@ Or install it yourself as:
20
20
 
21
21
  $ gem install qu-mongoid
22
22
 
23
+ Tested in Ruby 1.9.3, 2.0.0, JRuby (1.9 mode), and Rubinius (1.9 mode). Ruby 1.8.7 is not supported because Mongoid 3 only supports Ruby 1.9+.
24
+
23
25
  ## Why not just use the Mongo backend?
24
26
 
25
27
  Starting with version 3, Mongoid uses its own mongoDB driver (Moped) instead of the official 10gen ruby driver (mongo). To avoid loading both drivers, I ported the Mongo backend to Mongoid/Moped.
@@ -1,5 +1,5 @@
1
1
  module Qu
2
2
  module Mongoid
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
@@ -64,8 +64,19 @@ Example:
64
64
  jobs(queue).find.count
65
65
  end
66
66
 
67
+ if defined?(::Moped::BSON::ObjectId)
68
+ def new_id
69
+ ::Moped::BSON::ObjectId.new
70
+ end
71
+ else
72
+ def new_id
73
+ ::BSON::ObjectId.new
74
+ end
75
+ end
76
+ private :new_id
77
+
67
78
  def enqueue(payload)
68
- payload.id = ::Moped::BSON::ObjectId.new
79
+ payload.id = new_id
69
80
  jobs(payload.queue).insert({:_id => payload.id, :klass => payload.klass.to_s, :args => payload.args})
70
81
  self[:queues].where({:name => payload.queue}).upsert({:name => payload.queue})
71
82
  logger.debug { "Enqueued job #{payload}" }
@@ -14,6 +14,9 @@ Gem::Specification.new do |s|
14
14
  s.files = `git ls-files`.split("\n")
15
15
  s.require_paths = ["lib"]
16
16
 
17
- s.add_dependency 'mongoid', '~> 3.0'
17
+ s.add_dependency 'mongoid', '>= 3.0'
18
18
  s.add_dependency 'qu'
19
+
20
+ s.add_development_dependency 'rspec', '~> 2.14'
21
+ s.add_development_dependency 'rake'
19
22
  end
@@ -5,27 +5,27 @@ describe Qu::Backend::Mongoid do
5
5
  it_should_behave_like 'a backend'
6
6
 
7
7
  describe 'connection' do
8
- it 'should use a separate connection in each thread' do
8
+ it 'uses a separate connection in each thread' do
9
9
  backend = subject
10
10
  connection = subject.connection
11
11
  separate_connection = false
12
12
  Thread.new do
13
13
  separate_connection = (backend.connection != connection)
14
14
  end.join
15
- separate_connection.should be_true
15
+ expect(separate_connection).to be true
16
16
  end
17
17
 
18
- it 'should default to the qu database' do
19
- subject.connection.should be_instance_of(Moped::Session)
20
- subject.connection.options[:database].should == 'qu'
18
+ it 'defaults to the qu database' do
19
+ expect(subject.connection).to be_instance_of(Moped::Session)
20
+ expect(subject.connection.options[:database]).to eq('qu')
21
21
  end
22
22
 
23
- it 'should default to the :default session' do
24
- subject.session.should == :default
25
- subject.connection.should == ::Mongoid::Sessions.with_name(subject.session)
23
+ it 'defaults to the :default session' do
24
+ expect(subject.session).to eq(:default)
25
+ expect(subject.connection).to eq(::Mongoid::Sessions.with_name(subject.session))
26
26
  end
27
27
 
28
- it 'should have a configurable session that works with threads' do
28
+ it 'has a configurable session that works with threads' do
29
29
  subject.connection = nil
30
30
 
31
31
  ::Mongoid.sessions[:qu] = {:uri => 'mongodb://127.0.0.1:27017/quspec', :max_retries_on_connection_failure => 4}
@@ -33,29 +33,38 @@ describe Qu::Backend::Mongoid do
33
33
  Qu.configure do |c|
34
34
  c.backend.session = :qu
35
35
  end
36
- subject.connection.should == ::Mongoid::Sessions.with_name(:qu)
36
+ expect(subject.connection).to eq(::Mongoid::Sessions.with_name(:qu))
37
37
 
38
38
  should_have_qu_session_in_new_thread = false
39
39
  Thread.new do
40
40
  should_have_qu_session_in_new_thread = (subject.connection == ::Mongoid::Sessions.with_name(:qu))
41
41
  end.join
42
- should_have_qu_session_in_new_thread.should be_true
42
+ expect(should_have_qu_session_in_new_thread).to be true
43
43
 
44
44
  # Clean up
45
45
  subject.connection=nil
46
46
  ::Mongoid.connect_to('qu')
47
47
  end
48
48
 
49
- it 'should use MONGOHQ_URL from heroku' do
49
+ it 'uses MONGOHQ_URL from heroku' do
50
50
  # Clean up from other tests
51
51
  ::Mongoid.sessions[:default] = nil
52
- subject.connection=nil
52
+ subject.connection = nil
53
53
  ::Mongoid::Sessions.clear
54
54
 
55
55
  ENV['MONGOHQ_URL'] = 'mongodb://127.0.0.1:27017/quspec'
56
- subject.connection.options[:database].should == 'quspec'
57
- subject.connection.cluster.nodes.first.resolved_address.should == "127.0.0.1:27017"
58
- ::Mongoid.sessions[:default][:hosts].should include("127.0.0.1:27017")
56
+ expect(subject.connection.options[:database]).to eq('quspec')
57
+
58
+ node = subject.connection.cluster.nodes.first
59
+ resolved_address = if node.respond_to?(:resolved_address)
60
+ node.resolved_address
61
+ else
62
+ node.address.resolved
63
+ end
64
+
65
+ expect(resolved_address).to eq("127.0.0.1:27017")
66
+
67
+ expect(::Mongoid.sessions[:default][:hosts]).to include("127.0.0.1:27017")
59
68
 
60
69
  # Clean up MONGOHQ stuff
61
70
  ENV.delete('MONGOHQ_URL')
@@ -68,18 +77,18 @@ describe Qu::Backend::Mongoid do
68
77
  let(:worker) { Qu::Worker.new }
69
78
 
70
79
  describe "on mongo >=2" do
71
- it 'should return nil when no jobs exist' do
80
+ it 'returns nil when no jobs exist' do
72
81
  subject.clear
73
- Moped::Session.any_instance.should_receive(:command).and_return(nil)
74
- lambda { subject.reserve(worker, :block => false).should be_nil }.should_not raise_error
82
+ expect_any_instance_of(Moped::Session).to receive(:command).and_return(nil)
83
+ expect { expect(subject.reserve(worker, :block => false)).to be_nil }.not_to raise_error
75
84
  end
76
85
  end
77
86
 
78
87
  describe 'on mongo <2' do
79
- it 'should return nil when no jobs exist' do
88
+ it 'returns nil when no jobs exist' do
80
89
  subject.clear
81
- subject.connection.should_receive(:command).and_raise(Moped::Errors::OperationFailure.new(nil, 'test'))
82
- lambda { subject.reserve(worker, :block => false).should be_nil }.should_not raise_error
90
+ expect(subject.connection).to receive(:command).and_raise(Moped::Errors::OperationFailure.new(nil, 'test'))
91
+ expect { expect(subject.reserve(worker, :block => false)).to be_nil }.not_to raise_error
83
92
  end
84
93
  end
85
94
  end
@@ -5,7 +5,7 @@ require 'qu/backend/spec'
5
5
 
6
6
  RSpec.configure do |config|
7
7
  config.before do
8
- Qu.backend = mock('a backend', :reserve => nil, :failed => nil, :completed => nil,
8
+ Qu.backend = double('a backend', :reserve => nil, :failed => nil, :completed => nil,
9
9
  :register_worker => nil, :unregister_worker => nil)
10
10
  Qu.failure = nil
11
11
  end
metadata CHANGED
@@ -1,50 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qu-mongoid
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.2.1
4
+ version: 0.2.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - David Butler
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-11-29 00:00:00.000000000 Z
11
+ date: 2014-06-25 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: mongoid
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
16
22
  version_requirements: !ruby/object:Gem::Requirement
17
23
  requirements:
18
- - - ~>
24
+ - - ">="
19
25
  - !ruby/object:Gem::Version
20
26
  version: '3.0'
21
- none: false
27
+ - !ruby/object:Gem::Dependency
28
+ name: qu
22
29
  requirement: !ruby/object:Gem::Requirement
23
30
  requirements:
24
- - - ~>
31
+ - - ">="
25
32
  - !ruby/object:Gem::Version
26
- version: '3.0'
27
- none: false
28
- prerelease: false
33
+ version: '0'
29
34
  type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
30
41
  - !ruby/object:Gem::Dependency
31
- name: qu
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.14'
48
+ type: :development
49
+ prerelease: false
32
50
  version_requirements: !ruby/object:Gem::Requirement
33
51
  requirements:
34
- - - ! '>='
52
+ - - "~>"
35
53
  - !ruby/object:Gem::Version
36
- version: !binary |-
37
- MA==
38
- none: false
54
+ version: '2.14'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
39
57
  requirement: !ruby/object:Gem::Requirement
40
58
  requirements:
41
- - - ! '>='
59
+ - - ">="
42
60
  - !ruby/object:Gem::Version
43
- version: !binary |-
44
- MA==
45
- none: false
61
+ version: '0'
62
+ type: :development
46
63
  prerelease: false
47
- type: :runtime
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
48
69
  description: Mongoid backend for the Ruby queuing library Qu
49
70
  email:
50
71
  - dwbutler@ucla.edu
@@ -52,8 +73,8 @@ executables: []
52
73
  extensions: []
53
74
  extra_rdoc_files: []
54
75
  files:
55
- - .gitignore
56
- - .travis.yml
76
+ - ".gitignore"
77
+ - ".travis.yml"
57
78
  - Gemfile
58
79
  - LICENSE
59
80
  - README.md
@@ -66,28 +87,25 @@ files:
66
87
  - spec/spec_helper.rb
67
88
  homepage: http://github.com/dwbutler/qu-mongoid
68
89
  licenses: []
69
- post_install_message:
90
+ metadata: {}
91
+ post_install_message:
70
92
  rdoc_options: []
71
93
  require_paths:
72
94
  - lib
73
95
  required_ruby_version: !ruby/object:Gem::Requirement
74
96
  requirements:
75
- - - ! '>='
97
+ - - ">="
76
98
  - !ruby/object:Gem::Version
77
- version: !binary |-
78
- MA==
79
- none: false
99
+ version: '0'
80
100
  required_rubygems_version: !ruby/object:Gem::Requirement
81
101
  requirements:
82
- - - ! '>='
102
+ - - ">="
83
103
  - !ruby/object:Gem::Version
84
- version: !binary |-
85
- MA==
86
- none: false
104
+ version: '0'
87
105
  requirements: []
88
- rubyforge_project:
89
- rubygems_version: 1.8.24
90
- signing_key:
91
- specification_version: 3
106
+ rubyforge_project:
107
+ rubygems_version: 2.2.2
108
+ signing_key:
109
+ specification_version: 4
92
110
  summary: Mongoid backend for Qu
93
111
  test_files: []