Class: Teapot::Loader
- Inherits:
-
Object
- Object
- Teapot::Loader
- Defined in:
- lib/teapot/loader.rb
Overview
Loads the teapot.rb script and can reload it if it was changed.
Instance Attribute Summary collapse
-
#script ⇒ Object
readonly
Returns the value of attribute script.
Instance Method Summary collapse
-
#changed? ⇒ Boolean
Whether the teapot file has been modified since it was loaded.
-
#initialize(context, package, path = TEAPOT_FILE) ⇒ Loader
constructor
Initialize a new loader.
-
#reload ⇒ Object
Reload the loader with fresh data.
-
#teapot_path ⇒ Object
The absolute path to the teapot.rb file for this package.
Constructor Details
#initialize(context, package, path = TEAPOT_FILE) ⇒ Loader
Initialize a new loader.
151 152 153 154 155 156 157 158 159 |
# File 'lib/teapot/loader.rb', line 151 def initialize(context, package, path = TEAPOT_FILE) @context = context @package = package @path = path @mtime = nil @script, @mtime = load! end |
Instance Attribute Details
#script ⇒ Object (readonly)
Returns the value of attribute script.
161 162 163 |
# File 'lib/teapot/loader.rb', line 161 def script @script end |
Instance Method Details
#changed? ⇒ Boolean
Whether the teapot file has been modified since it was loaded.
171 172 173 |
# File 'lib/teapot/loader.rb', line 171 def changed? File.mtime(teapot_path) > @mtime end |
#reload ⇒ Object
Reload the loader with fresh data.
177 178 179 |
# File 'lib/teapot/loader.rb', line 177 def reload self.class.new(@context, @package, @path) end |
#teapot_path ⇒ Object
The absolute path to the teapot.rb file for this package.
165 166 167 |
# File 'lib/teapot/loader.rb', line 165 def teapot_path @package.path + @path end |