improve eval'ing of schedule file to reveal the filename in backtraces

This commit is contained in:
Javan Makhmali 2011-07-31 14:16:23 -04:00
parent 8bb0f04131
commit ab877e3cbb

View File

@ -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
setup = File.read("#{File.expand_path(File.dirname(__FILE__))}/setup.rb")
pre_set(options[:set])
eval(setup + config)
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
instance_eval(setup + schedule, options[:file] || '<eval>')
end
def set(variable, value)