From 974b5a201621cb5cf01ef3b35a0d7a18e7d34aca Mon Sep 17 00:00:00 2001 From: Javan Makhmali Date: Tue, 26 Oct 2010 09:59:24 -0400 Subject: [PATCH] job type defaults are now in setup.rb --- lib/whenever/job_list.rb | 7 ++----- lib/whenever/{job_types/default.rb => setup.rb} | 5 ++++- 2 files changed, 6 insertions(+), 6 deletions(-) rename lib/whenever/{job_types/default.rb => setup.rb} (74%) diff --git a/lib/whenever/job_list.rb b/lib/whenever/job_list.rb index 44565b2..b04104d 100644 --- a/lib/whenever/job_list.rb +++ b/lib/whenever/job_list.rb @@ -16,12 +16,9 @@ module Whenever pre_set(options[:set]) end - # Load all job type files. - Dir["#{File.expand_path(File.dirname(__FILE__))}/job_types/*.rb"].each do |file| - eval(File.read(file)) - end + setup = File.read("#{File.expand_path(File.dirname(__FILE__))}/setup.rb") - eval(config) + eval(setup + config) end def set(variable, value) diff --git a/lib/whenever/job_types/default.rb b/lib/whenever/setup.rb similarity index 74% rename from lib/whenever/job_types/default.rb rename to lib/whenever/setup.rb index 2b2a4a4..64e6f33 100644 --- a/lib/whenever/job_types/default.rb +++ b/lib/whenever/setup.rb @@ -1,6 +1,9 @@ +# Environemnt defaults to production set :environment, "production" +# Path defaults to the directory `whenever` was run from set :path, Whenever.path +# All jobs are wrapped in this template. # http://blog.scoutapp.com/articles/2010/09/07/rvm-and-cron-in-production set :job_template, "/bin/bash -l -c ':job'" @@ -8,7 +11,7 @@ job_type :command, ":task :output" job_type :rake, "cd :path && RAILS_ENV=:environment rake :task --silent :output" # Create a runner job that's appropriate for the Rails version, -if File.exists?(File.join(Whenever.path, 'script', 'rails')) +if File.exists?(File.join(path, 'script', 'rails')) job_type :runner, "cd :path && script/rails runner -e :environment ':task' :output" else job_type :runner, "cd :path && script/runner -e :environment ':task' :output"