| Class | Atchoum::Reloader |
| In: |
lib/atchoum/reloader.rb
|
| Parent: | Object |
Reloads the application whenever the script is changed. Inspired by _why’s Camping Reloader code.whytheluckystiff.net/svn/camping/trunk/lib/camping/reloader.rb
| class_name | [R] | |
| instance | [R] |
# File lib/atchoum/reloader.rb, line 8
8: def initialize(script)
9: @script = File.expand_path(script)
10: @class_name = script.scan(/(\w+).rb$/)[0].first.capitalize.gsub(/_(\w)/) { $1.to_s.upcase }
11: end
# File lib/atchoum/reloader.rb, line 13
13: def find_class
14: @klass = Object.const_get(Object.constants.grep(/^#{@class_name}$/i)[0]) rescue nil
15: @instance = @klass.new
16: end
Reload the script
# File lib/atchoum/reloader.rb, line 25
25: def reload
26: # TODO maybe check for timestamp ?
27: unload_class
28: load @script
29: find_class
30: end