Object
(abstract) abstract engine class. subclass must include evaluator and converter module.
load file, write cache file, and return engine object. this method create code cache file automatically. cachefile name can be specified with properties[:cachename], or filname + ‘cache’ is used as default.
# File lib/erubis/engine.rb, line 48
48: def self.load_file(filename, properties={})
49: cachename = properties[:cachename] || (filename + '.cache')
50: properties[:filename] = filename
51: if test(ff, cachename) && File.mtime(filename) <= File.mtime(cachename)
52: engine = self.new(nil, properties)
53: engine.src = File.read(cachename)
54: else
55: input = File.open(filename, 'rb') {|f| f.read }
56: engine = self.new(input, properties)
57: File.open(cachename, 'wb') do |f|
58: f.flock(File::LOCK_EX)
59: f.write(engine.src)
60: f.flush()
61: end
62: end
63: engine.src.untaint # ok?
64: return engine
65: end
convert input string and set it to @src
# File lib/erubis/engine.rb, line 37
37: def convert!(input)
38: @src = convert(input)
39: end
helper method to convert and evaluate input text with context object. context may be Binding, Hash, or Object.
# File lib/erubis/engine.rb, line 72
72: def process(input, context=nil, filename=nil)
73: code = convert(input)
74: filename ||= '(erubis)'
75: if context.is_a?(Binding)
76: return eval(code, context, filename)
77: else
78: context = Context.new(context) if context.is_a?(Hash)
79: return context.instance_eval(code, filename)
80: end
81: end
helper method evaluate Proc object with contect object. context may be Binding, Hash, or Object.
# File lib/erubis/engine.rb, line 88
88: def process_proc(proc_obj, context=nil, filename=nil)
89: if context.is_a?(Binding)
90: filename ||= '(erubis)'
91: return eval(proc_obj, context, filename)
92: else
93: context = Context.new(context) if context.is_a?(Hash)
94: return context.instance_eval(&proc_obj)
95: end
96: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.