navvy 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +8 -0
- data/LICENSE +20 -0
- data/README.textile +9 -0
- data/Rakefile +50 -0
- data/VERSION +1 -0
- data/lib/job/mongo_mapper.rb +74 -0
- data/lib/navvy.rb +2 -0
- data/lib/navvy/job.rb +16 -0
- data/lib/navvy/job/mongo_mapper.rb +77 -0
- data/lib/navvy/worker.rb +23 -0
- data/navvy.gemspec +76 -0
- data/spec/job/mongo_mapper_spec.rb +111 -0
- data/spec/setup/mongo_mapper.rb +2 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/worker_spec.rb +27 -0
- metadata +133 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Jeff Kreeftmeijer
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
h1. Navvy
|
2
|
+
|
3
|
+
Navvy is a simple background job processor inspired by "delayed_job":http://github.com/tobi/delayed_job, but aiming for database agnosticism.
|
4
|
+
|
5
|
+
??“Navvy is a shorter form of navigator (UK) or navigational engineer (USA) and is particularly applied to describe the manual labourers working on major civil engineering projects. The term was coined in the late 18th century in Britain when numerous canals were being built, which were also sometimes known as "navigations". Canal navvies typically worked with shovels, pickaxes and barrows.”?? - "Wikipedia":http://en.wikipedia.org/wiki/Navvy
|
6
|
+
|
7
|
+
h2. License
|
8
|
+
|
9
|
+
Copyright (c) 2009 Jeff Kreeftmeijer, released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "navvy"
|
8
|
+
gem.summary = %Q{Simple background job processor inspired by delayed_job, but aiming for database agnosticism.}
|
9
|
+
gem.description = %Q{Simple background job processor inspired by delayed_job, but aiming for database agnosticism.}
|
10
|
+
gem.email = "jeff@kreeftmeijer.nl"
|
11
|
+
gem.homepage = "http://github.com/jeffkreeftmeijer/navvy"
|
12
|
+
gem.authors = ["Jeff Kreeftmeijer"]
|
13
|
+
gem.add_dependency "mongo_mapper", ">= 0.6.10"
|
14
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
15
|
+
gem.add_development_dependency "yard", ">= 0.5.2"
|
16
|
+
gem.add_development_dependency "metric_fu", ">= 1.1.6"
|
17
|
+
gem.add_development_dependency "machinist", ">= 1.0.6"
|
18
|
+
gem.add_development_dependency "machinist_mongomapper", ">= 0.9.7"
|
19
|
+
end
|
20
|
+
Jeweler::GemcutterTasks.new
|
21
|
+
rescue LoadError
|
22
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'spec/rake/spectask'
|
26
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
27
|
+
spec.libs << 'lib' << 'spec'
|
28
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
29
|
+
end
|
30
|
+
|
31
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
32
|
+
spec.libs << 'lib' << 'spec'
|
33
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
34
|
+
spec.rcov = true
|
35
|
+
end
|
36
|
+
|
37
|
+
task :spec => :check_dependencies
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
begin
|
42
|
+
require 'yard'
|
43
|
+
YARD::Rake::YardocTask.new
|
44
|
+
rescue LoadError
|
45
|
+
task :yardoc do
|
46
|
+
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
require 'metric_fu'
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'mongo_mapper'
|
3
|
+
|
4
|
+
module Navvy
|
5
|
+
class Job
|
6
|
+
include MongoMapper::Document
|
7
|
+
|
8
|
+
key :object, String
|
9
|
+
key :method, Symbol
|
10
|
+
key :arguments, Array
|
11
|
+
key :exception, String
|
12
|
+
key :run_at, Time
|
13
|
+
key :failed_at, Time
|
14
|
+
|
15
|
+
##
|
16
|
+
# Add a job to the job queue.
|
17
|
+
#
|
18
|
+
# @param [Object] object the object you want to run a method from
|
19
|
+
# @param [Symbol, String] method the name of the method you want to run
|
20
|
+
# @param [*] arguments optional arguments you want to pass to the method
|
21
|
+
#
|
22
|
+
# @return [true, false]
|
23
|
+
|
24
|
+
def self.enqueue(object, method, *args)
|
25
|
+
create(
|
26
|
+
:object => object.name,
|
27
|
+
:method => method.to_sym,
|
28
|
+
:run_at => Time.now,
|
29
|
+
:arguments => args
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
##
|
34
|
+
# Find the next available job in the queue. This will not include failed
|
35
|
+
# jobs (where :failed_at is not nil) and jobs that should run in the future
|
36
|
+
# (where :run_at is greater than the current time).
|
37
|
+
#
|
38
|
+
#
|
39
|
+
# @return [Navvy::Job, nil] the next available job or nil if no jobs
|
40
|
+
# were found
|
41
|
+
|
42
|
+
def self.next
|
43
|
+
first(
|
44
|
+
:failed_at => nil,
|
45
|
+
:run_at => {'$lte', Time.now}
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
##
|
50
|
+
# Run the job. Will delete the Navvy::Job record and return its return
|
51
|
+
# value if it runs successfully. If a job fails, it'll update the
|
52
|
+
# Navvy::Job record to include the exception message it sent back and set
|
53
|
+
# the :failed_at date. Failed jobs don't get deleted.
|
54
|
+
#
|
55
|
+
# @example
|
56
|
+
# job = Navvy::Job.next # finds the next available job in the queue
|
57
|
+
# job.run # runs the job and returns the job's return value
|
58
|
+
#
|
59
|
+
# @return [String] return value of the called method
|
60
|
+
|
61
|
+
def run
|
62
|
+
begin
|
63
|
+
result = object.constantize.send(method)
|
64
|
+
destroy
|
65
|
+
result
|
66
|
+
rescue Exception => exception
|
67
|
+
update_attributes({
|
68
|
+
:exception => exception.message,
|
69
|
+
:failed_at => Time.now
|
70
|
+
})
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/lib/navvy.rb
ADDED
data/lib/navvy/job.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'mongo_mapper'
|
3
|
+
|
4
|
+
module Navvy
|
5
|
+
class Job
|
6
|
+
include MongoMapper::Document
|
7
|
+
|
8
|
+
key :object, String
|
9
|
+
key :method, Symbol
|
10
|
+
key :arguments, Array
|
11
|
+
key :exception, String
|
12
|
+
key :run_at, Time
|
13
|
+
key :failed_at, Time
|
14
|
+
|
15
|
+
##
|
16
|
+
# Add a job to the job queue.
|
17
|
+
#
|
18
|
+
# @param [Object] object the object you want to run a method from
|
19
|
+
# @param [Symbol, String] method the name of the method you want to run
|
20
|
+
# @param [*] arguments optional arguments you want to pass to the method
|
21
|
+
#
|
22
|
+
# @return [true, false]
|
23
|
+
|
24
|
+
def self.enqueue(object, method, *args)
|
25
|
+
create(
|
26
|
+
:object => object.name,
|
27
|
+
:method => method.to_sym,
|
28
|
+
:run_at => Time.now,
|
29
|
+
:arguments => args
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
##
|
34
|
+
# Find the next available jobs in the queue. This will not include failed
|
35
|
+
# jobs (where :failed_at is not nil) and jobs that should run in the future
|
36
|
+
# (where :run_at is greater than the current time).
|
37
|
+
#
|
38
|
+
# @param [Integer] limit the limit of jobs to be fetched. Defaults to
|
39
|
+
# Navvy::Job.limit
|
40
|
+
#
|
41
|
+
# @return [array, nil] the next available jobs in an array or nil if no
|
42
|
+
# jobsn were found.
|
43
|
+
|
44
|
+
def self.next(limit = self.limit)
|
45
|
+
all(
|
46
|
+
:failed_at => nil,
|
47
|
+
:run_at => {'$lte', Time.now},
|
48
|
+
:limit => limit
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
##
|
53
|
+
# Run the job. Will delete the Navvy::Job record and return its return
|
54
|
+
# value if it runs successfully. If a job fails, it'll update the
|
55
|
+
# Navvy::Job record to include the exception message it sent back and set
|
56
|
+
# the :failed_at date. Failed jobs don't get deleted.
|
57
|
+
#
|
58
|
+
# @example
|
59
|
+
# job = Navvy::Job.next # finds the next available job in the queue
|
60
|
+
# job.run # runs the job and returns the job's return value
|
61
|
+
#
|
62
|
+
# @return [String] return value of the called method.
|
63
|
+
|
64
|
+
def run
|
65
|
+
begin
|
66
|
+
result = object.constantize.send(method)
|
67
|
+
destroy
|
68
|
+
result
|
69
|
+
rescue Exception => exception
|
70
|
+
update_attributes({
|
71
|
+
:exception => exception.message,
|
72
|
+
:failed_at => Time.now
|
73
|
+
})
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/lib/navvy/worker.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Navvy
|
2
|
+
class Worker
|
3
|
+
|
4
|
+
##
|
5
|
+
# Start the worker.
|
6
|
+
|
7
|
+
def self.start
|
8
|
+
loop do
|
9
|
+
fetch_and_run_jobs
|
10
|
+
sleep 5
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
##
|
15
|
+
# Fetch jobs an run them.
|
16
|
+
|
17
|
+
def self.fetch_and_run_jobs
|
18
|
+
Job.next.each do |job|
|
19
|
+
job.run
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/navvy.gemspec
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{navvy}
|
8
|
+
s.version = "0.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Jeff Kreeftmeijer"]
|
12
|
+
s.date = %q{2010-01-11}
|
13
|
+
s.description = %q{Simple background job processor inspired by delayed_job, but aiming for database agnosticism.}
|
14
|
+
s.email = %q{jeff@kreeftmeijer.nl}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.textile"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.textile",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/job/mongo_mapper.rb",
|
27
|
+
"lib/navvy.rb",
|
28
|
+
"lib/navvy/job.rb",
|
29
|
+
"lib/navvy/job/mongo_mapper.rb",
|
30
|
+
"lib/navvy/worker.rb",
|
31
|
+
"navvy.gemspec",
|
32
|
+
"spec/job/mongo_mapper_spec.rb",
|
33
|
+
"spec/setup/mongo_mapper.rb",
|
34
|
+
"spec/spec_helper.rb",
|
35
|
+
"spec/worker_spec.rb"
|
36
|
+
]
|
37
|
+
s.homepage = %q{http://github.com/jeffkreeftmeijer/navvy}
|
38
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
39
|
+
s.require_paths = ["lib"]
|
40
|
+
s.rubygems_version = %q{1.3.5}
|
41
|
+
s.summary = %q{Simple background job processor inspired by delayed_job, but aiming for database agnosticism.}
|
42
|
+
s.test_files = [
|
43
|
+
"spec/job/mongo_mapper_spec.rb",
|
44
|
+
"spec/setup/mongo_mapper.rb",
|
45
|
+
"spec/spec_helper.rb",
|
46
|
+
"spec/worker_spec.rb"
|
47
|
+
]
|
48
|
+
|
49
|
+
if s.respond_to? :specification_version then
|
50
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
51
|
+
s.specification_version = 3
|
52
|
+
|
53
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
54
|
+
s.add_runtime_dependency(%q<mongo_mapper>, [">= 0.6.10"])
|
55
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
56
|
+
s.add_development_dependency(%q<yard>, [">= 0.5.2"])
|
57
|
+
s.add_development_dependency(%q<metric_fu>, [">= 1.1.6"])
|
58
|
+
s.add_development_dependency(%q<machinist>, [">= 1.0.6"])
|
59
|
+
s.add_development_dependency(%q<machinist_mongomapper>, [">= 0.9.7"])
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<mongo_mapper>, [">= 0.6.10"])
|
62
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
63
|
+
s.add_dependency(%q<yard>, [">= 0.5.2"])
|
64
|
+
s.add_dependency(%q<metric_fu>, [">= 1.1.6"])
|
65
|
+
s.add_dependency(%q<machinist>, [">= 1.0.6"])
|
66
|
+
s.add_dependency(%q<machinist_mongomapper>, [">= 0.9.7"])
|
67
|
+
end
|
68
|
+
else
|
69
|
+
s.add_dependency(%q<mongo_mapper>, [">= 0.6.10"])
|
70
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
71
|
+
s.add_dependency(%q<yard>, [">= 0.5.2"])
|
72
|
+
s.add_dependency(%q<metric_fu>, [">= 1.1.6"])
|
73
|
+
s.add_dependency(%q<machinist>, [">= 1.0.6"])
|
74
|
+
s.add_dependency(%q<machinist_mongomapper>, [">= 0.9.7"])
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe 'Navvy::Job' do
|
4
|
+
before do
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + '/../setup/mongo_mapper')
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '.enqueue' do
|
9
|
+
before(:each) do
|
10
|
+
Navvy::Job.delete_all
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should enqueue a job' do
|
14
|
+
Navvy::Job.enqueue(Cow, :speak)
|
15
|
+
Navvy::Job.count.should == 1
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should set the object and the method' do
|
19
|
+
Navvy::Job.enqueue(Cow, :speak)
|
20
|
+
job = Navvy::Job.first
|
21
|
+
job.object.should == 'Cow'
|
22
|
+
job.method.should == :speak
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should turn the method into a symbol' do
|
26
|
+
Navvy::Job.enqueue(Cow, 'speak')
|
27
|
+
job = Navvy::Job.first
|
28
|
+
job.method.should == :speak
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should set the arguments' do
|
32
|
+
Navvy::Job.enqueue(Cow, :speak, true, false)
|
33
|
+
job = Navvy::Job.first
|
34
|
+
job.arguments.should == [true, false]
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should set the run_at date' do
|
38
|
+
Navvy::Job.enqueue(Cow, :speak, true, false)
|
39
|
+
job = Navvy::Job.first
|
40
|
+
job.run_at.should be_instance_of Time
|
41
|
+
job.run_at.should <= Time.now
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '.next' do
|
46
|
+
before(:each) do
|
47
|
+
Navvy::Job.delete_all
|
48
|
+
Navvy::Job.create(
|
49
|
+
:object => 'Cow',
|
50
|
+
:method => :break,
|
51
|
+
:failed_at => Time.now
|
52
|
+
)
|
53
|
+
Navvy::Job.create(
|
54
|
+
:object => 'Cow',
|
55
|
+
:method => :tomorrow,
|
56
|
+
:run_at => Time.now + 1.day
|
57
|
+
)
|
58
|
+
12.times do
|
59
|
+
Navvy::Job.enqueue(Cow, :speak)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should find the next 10 available jobs' do
|
64
|
+
jobs = Navvy::Job.next
|
65
|
+
jobs.count.should == 10
|
66
|
+
jobs.each do |job|
|
67
|
+
job.should be_instance_of Navvy::Job
|
68
|
+
job.method.should == :speak
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should find the next 2 available jobs' do
|
73
|
+
Navvy::Job.next(2).count.should == 2
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should find the next 4 available jobs' do
|
77
|
+
Navvy::Job.limit = 4
|
78
|
+
Navvy::Job.next
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe '#run' do
|
83
|
+
describe 'when everything goes well' do
|
84
|
+
before(:each) do
|
85
|
+
Navvy::Job.delete_all
|
86
|
+
Navvy::Job.enqueue(Cow, :speak)
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should run the job and delete it' do
|
90
|
+
jobs = Navvy::Job.next
|
91
|
+
jobs.first.run.should == 'moo'
|
92
|
+
Navvy::Job.count.should == 0
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe 'when a job fails' do
|
97
|
+
before(:each) do
|
98
|
+
Navvy::Job.delete_all
|
99
|
+
Navvy::Job.enqueue(Cow, :broken)
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should store the exception and current time' do
|
103
|
+
jobs = Navvy::Job.next
|
104
|
+
jobs.first.run
|
105
|
+
Navvy::Job.count.should == 1
|
106
|
+
jobs.first.exception.should == 'this method is broken'
|
107
|
+
jobs.first.failed_at.should be_instance_of Time
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'navvy'
|
4
|
+
require 'spec'
|
5
|
+
require 'spec/autorun'
|
6
|
+
|
7
|
+
Spec::Runner.configure do |config|
|
8
|
+
end
|
9
|
+
|
10
|
+
class Cow
|
11
|
+
def self.speak
|
12
|
+
'moo'
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.broken
|
16
|
+
raise 'this method is broken'
|
17
|
+
end
|
18
|
+
end
|
data/spec/worker_spec.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe Navvy::Worker do
|
4
|
+
describe '.fetch_and_run_jobs' do
|
5
|
+
before do
|
6
|
+
@jobs = [
|
7
|
+
Navvy::Job.enqueue(Cow, :speak),
|
8
|
+
Navvy::Job.enqueue(Cow, :speak),
|
9
|
+
Navvy::Job.enqueue(Cow, :speak)
|
10
|
+
]
|
11
|
+
|
12
|
+
Navvy::Job.stub!(:next).and_return(@jobs)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should fetch jobs' do
|
16
|
+
Navvy::Job.should_receive(:next).and_return(@jobs)
|
17
|
+
Navvy::Worker.fetch_and_run_jobs
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should run three jobs' do
|
21
|
+
@jobs.each do |job|
|
22
|
+
job.should_receive(:run)
|
23
|
+
end
|
24
|
+
Navvy::Worker.fetch_and_run_jobs
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: navvy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeff Kreeftmeijer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-01-11 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: mongo_mapper
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.6.10
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.2.9
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: yard
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.5.2
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: metric_fu
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.1.6
|
54
|
+
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: machinist
|
57
|
+
type: :development
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 1.0.6
|
64
|
+
version:
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: machinist_mongomapper
|
67
|
+
type: :development
|
68
|
+
version_requirement:
|
69
|
+
version_requirements: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 0.9.7
|
74
|
+
version:
|
75
|
+
description: Simple background job processor inspired by delayed_job, but aiming for database agnosticism.
|
76
|
+
email: jeff@kreeftmeijer.nl
|
77
|
+
executables: []
|
78
|
+
|
79
|
+
extensions: []
|
80
|
+
|
81
|
+
extra_rdoc_files:
|
82
|
+
- LICENSE
|
83
|
+
- README.textile
|
84
|
+
files:
|
85
|
+
- .document
|
86
|
+
- .gitignore
|
87
|
+
- LICENSE
|
88
|
+
- README.textile
|
89
|
+
- Rakefile
|
90
|
+
- VERSION
|
91
|
+
- lib/job/mongo_mapper.rb
|
92
|
+
- lib/navvy.rb
|
93
|
+
- lib/navvy/job.rb
|
94
|
+
- lib/navvy/job/mongo_mapper.rb
|
95
|
+
- lib/navvy/worker.rb
|
96
|
+
- navvy.gemspec
|
97
|
+
- spec/job/mongo_mapper_spec.rb
|
98
|
+
- spec/setup/mongo_mapper.rb
|
99
|
+
- spec/spec_helper.rb
|
100
|
+
- spec/worker_spec.rb
|
101
|
+
has_rdoc: true
|
102
|
+
homepage: http://github.com/jeffkreeftmeijer/navvy
|
103
|
+
licenses: []
|
104
|
+
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options:
|
107
|
+
- --charset=UTF-8
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: "0"
|
115
|
+
version:
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: "0"
|
121
|
+
version:
|
122
|
+
requirements: []
|
123
|
+
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 1.3.5
|
126
|
+
signing_key:
|
127
|
+
specification_version: 3
|
128
|
+
summary: Simple background job processor inspired by delayed_job, but aiming for database agnosticism.
|
129
|
+
test_files:
|
130
|
+
- spec/job/mongo_mapper_spec.rb
|
131
|
+
- spec/setup/mongo_mapper.rb
|
132
|
+
- spec/spec_helper.rb
|
133
|
+
- spec/worker_spec.rb
|