65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/jkr/utils.rb', line 65
def self.define_routine_utils(result_dir, plan, params)
_plan = plan
begin
line = __LINE__; src = <<EOS
def result_file_name(basename)
File.join(#{result_dir.inspect}, basename)
end
def rname(basename)
result_file_name(basename)
end
def result_file(basename, mode = "a+")
path = result_file_name(basename)
File.open(path, mode)
end
def common_file_name(basename)
File.join(File.dirname(#{result_dir.inspect}), basename)
end
def cname(basename)
result_file_name(basename)
end
def touch_result_file(basename, options = {})
path = result_file_name(basename)
FileUtils.touch(path, options)
path
end
def with_result_file(basename, mode = "a+")
file = result_file(basename, mode)
err = nil
begin
yield(file)
rescue Exception => e
err = e
end
file.close
raise err if err
file.path
end
EOS
if _plan.routine
_plan.routine.binding.eval(src, __FILE__, line)
end
end while _plan = _plan.base_plan
end
|