From ab877e3cbbecfea5bd16a3848dd18a81a73dd766 Mon Sep 17 00:00:00 2001 From: Javan Makhmali Date: Sun, 31 Jul 2011 14:16:23 -0400 Subject: [PATCH] improve eval'ing of schedule file to reveal the filename in backtraces --- lib/whenever/job_list.rb | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/whenever/job_list.rb b/lib/whenever/job_list.rb index e5f6c40..0ba6655 100644 --- a/lib/whenever/job_list.rb +++ b/lib/whenever/job_list.rb @@ -3,21 +3,20 @@ module Whenever def initialize(options) @jobs, @env, @set_variables, @pre_set_variables = {}, {}, {}, {} - case options - when String - config = options - when Hash - config = if options[:string] - options[:string] - elsif options[:file] - File.read(options[:file]) - end - pre_set(options[:set]) + if options.is_a? String + options = { :string => options } end + + pre_set(options[:set]) setup = File.read("#{File.expand_path(File.dirname(__FILE__))}/setup.rb") + schedule = if options[:string] + options[:string] + elsif options[:file] + File.read(options[:file]) + end - eval(setup + config) + instance_eval(setup + schedule, options[:file] || '') end def set(variable, value)