class Teapot::Loader
Loads the teapot.rb script and can reload it if it was changed.
Attributes
script[R]
Public Class Methods
new(context, package, path = TEAPOT_FILE)
click to toggle source
# File lib/teapot/loader.rb, line 145 def initialize(context, package, path = TEAPOT_FILE) @context = context @package = package @path = path @mtime = nil @script, @mtime = load! end
Public Instance Methods
changed?()
click to toggle source
# File lib/teapot/loader.rb, line 161 def changed? File.mtime(teapot_path) > @mtime end
reload()
click to toggle source
# File lib/teapot/loader.rb, line 165 def reload self.class.new(@context, @package, @path) end
teapot_path()
click to toggle source
# File lib/teapot/loader.rb, line 157 def teapot_path @package.path + @path end
Private Instance Methods
load!(path = teapot_path)
click to toggle source
Load a teapot.rb file relative to the root of the @package.
# File lib/teapot/loader.rb, line 172 def load!(path = teapot_path) raise MissingTeapotError.new(path) unless File.exist?(path) script = Script.new(@context, @package) mtime = File.mtime(path) script.instance_eval(path.read, path.to_s) if script.version == nil raise IncompatibleTeapotError.new(@package, "<unspecified>") end return script, mtime end