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) def initialize(options)
@jobs, @env, @set_variables, @pre_set_variables = {}, {}, {}, {} @jobs, @env, @set_variables, @pre_set_variables = {}, {}, {}, {}
case options if options.is_a? String
when String options = { :string => options }
config = options end
when Hash
config = if options[:string] pre_set(options[:set])
setup = File.read("#{File.expand_path(File.dirname(__FILE__))}/setup.rb")
schedule = if options[:string]
options[:string] options[:string]
elsif options[:file] elsif options[:file]
File.read(options[:file]) File.read(options[:file])
end end
pre_set(options[:set])
end
setup = File.read("#{File.expand_path(File.dirname(__FILE__))}/setup.rb") instance_eval(setup + schedule, options[:file] || '<eval>')
eval(setup + config)
end end
def set(variable, value) def set(variable, value)