improve eval'ing of schedule file to reveal the filename in backtraces
This commit is contained in:
parent
8bb0f04131
commit
ab877e3cbb
@ -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
|
|
||||||
when Hash
|
|
||||||
config = if options[:string]
|
|
||||||
options[:string]
|
|
||||||
elsif options[:file]
|
|
||||||
File.read(options[:file])
|
|
||||||
end
|
|
||||||
pre_set(options[:set])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
pre_set(options[:set])
|
||||||
|
|
||||||
setup = File.read("#{File.expand_path(File.dirname(__FILE__))}/setup.rb")
|
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] || '<eval>')
|
||||||
end
|
end
|
||||||
|
|
||||||
def set(variable, value)
|
def set(variable, value)
|
||||||
|
Loading…
Reference in New Issue
Block a user