Skip to content

Commit

Permalink
DRY-up rake task definitions.
Browse files Browse the repository at this point in the history
Signed-off-by: Tobias Lütke <[email protected]>
  • Loading branch information
Dean Strelau authored and Tobias Lütke committed Dec 29, 2008
1 parent c08971b commit 825ebcf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion delayed_job.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Gem::Specification.new do |s|
lib/delayed/worker.rb
lib/delayed_job.rb
tasks/jobs.rake
tasks/merbtasks.rb
tasks/tasks.rb
]
s.test_files = %w[
spec/database.rb
Expand Down
2 changes: 1 addition & 1 deletion lib/delayed_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
Object.send(:include, Delayed::MessageSending)

if defined?(Merb::Plugins)
Merb::Plugins.add_rakefiles File.dirname(__FILE__) / '..' / 'tasks' / 'merbtasks'
Merb::Plugins.add_rakefiles File.dirname(__FILE__) / '..' / 'tasks' / 'tasks'
end
12 changes: 1 addition & 11 deletions tasks/jobs.rake
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
namespace :jobs do
desc "Clear the delayed_job queue."
task :clear => :environment do
Delayed::Job.delete_all
end

desc "Start a delayed_job worker."
task :work => :environment do
Delayed::Worker.new(:min_priority => ENV['MIN_PRIORITY'], :max_priority => ENV['MAX_PRIORITY']).start
end
end
load 'tasks'
8 changes: 6 additions & 2 deletions tasks/merbtasks.rb → tasks/tasks.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Re-definitions are appended to existing tasks
task :environment
task :merb_env

namespace :jobs do
desc "Clear the delayed_job queue."
task :clear => :merb_env do
task :clear => [:merb_env, :environment] do
Delayed::Job.delete_all
end

desc "Start a delayed_job worker."
task :work => :merb_env do
task :work => [:merb_env, :environment] do
Delayed::Worker.new(:min_priority => ENV['MIN_PRIORITY'], :max_priority => ENV['MAX_PRIORITY']).start
end
end

2 comments on commit 825ebcf

@taylorbarstow
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes an error in my project when running “rake”. I think the “load ‘tasks’” line in tasks/jobs.rake is confusing rake, as it tries to load RAILS_ROOT/lib/tasks, which is a directory.

Here is the full error (replacing preceding path parts with “RAILS_ROOT”):


rake aborted!
Is a directory - RAILS_ROOT/lib/tasks
RAILS_ROOT/lib/tasks
RAILS_ROOT/vendor/rails/activesupport/lib/active_support/dependencies.rb:142:in `load_without_new_constant_marking'
RAILS_ROOT/vendor/rails/activesupport/lib/active_support/dependencies.rb:142:in `load'
RAILS_ROOT/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
RAILS_ROOT/vendor/rails/activesupport/lib/active_support/dependencies.rb:142:in `load'
RAILS_ROOT/vendor/plugins/delayed_job/tasks/jobs.rake:1
RAILS_ROOT/vendor/rails/activesupport/lib/active_support/dependencies.rb:142:in `load_without_new_constant_marking'
RAILS_ROOT/vendor/rails/activesupport/lib/active_support/dependencies.rb:142:in `load'
RAILS_ROOT/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
RAILS_ROOT/vendor/rails/activesupport/lib/active_support/dependencies.rb:142:in `load'
RAILS_ROOT/vendor/rails/railties/lib/tasks/rails.rb:7
RAILS_ROOT/vendor/rails/railties/lib/tasks/rails.rb:7:in `each'
RAILS_ROOT/vendor/rails/railties/lib/tasks/rails.rb:7
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
RAILS_ROOT/rakefile:10
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2349:in `load'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2349:in `raw_load_rakefile'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1985:in `load_rakefile'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standard_exception_handling'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1984:in `load_rakefile'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1969:in `run'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standard_exception_handling'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:in `run'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/bin/rake:31
/usr/local/bin/rake:19:in `load'
/usr/local/bin/rake:19

@dstrelau
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silly mistake on my part. I’ve pushed the fix to my fork

Please sign in to comment.