Class: PostSetupHandlers::FileWatcher
- Defined in:
- lib/gamebox/post_setup_handlers/file_watcher.rb
Class Method Summary collapse
Class Method Details
.filepaths ⇒ Object
9 10 11 |
# File 'lib/gamebox/post_setup_handlers/file_watcher.rb', line 9 def self.filepaths [ "src/behaviors/", "src/actors" ] end |
.setup(argv, env, config) ⇒ Object
5 6 7 |
# File 'lib/gamebox/post_setup_handlers/file_watcher.rb', line 5 def self.setup(argv,env,config) start_file_watcher if config[:debug] or argv.include?('--debug') end |
.start_file_watcher ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/gamebox/post_setup_handlers/file_watcher.rb', line 13 def self.start_file_watcher log "File Watcher is now watching (#{filepaths.join(', ')}) for changes." Thread.abort_on_exception = true Thread.new do require 'listen' Listen.to(*filepaths, filter: /\.rb$/) do |modified, added, removed| (modified + added).each do |path| path[/([^\/]*)\.rb/] filename = $1 case path when /behaviors/ reload_behavior filename when /actors/ load_actor filename end end end end end |