Sha256: eb47893b5031d75893b3f42168140cc3b623e4425f694b9d98199ae6be8a123b

Contents?: true

Size: 836 Bytes

Versions: 8

Compression:

Stored size: 836 Bytes

Contents

module PostSetupHandlers

  class FileWatcher

    def self.setup(argv,env,config)
      start_file_watcher if config[:debug] or argv.include?('--debug')
    end

    def self.filepaths
      [ "src/behaviors/", "src/actors" ]
    end

    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

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
gamebox-0.5.5 lib/gamebox/post_setup_handlers/file_watcher.rb
gamebox-0.5.4 lib/gamebox/post_setup_handlers/file_watcher.rb
gamebox-0.5.2 lib/gamebox/post_setup_handlers/file_watcher.rb
gamebox-0.5.1 lib/gamebox/post_setup_handlers/file_watcher.rb
gamebox-0.5.0 lib/gamebox/post_setup_handlers/file_watcher.rb
gamebox-0.4.1 lib/gamebox/post_setup_handlers/file_watcher.rb
gamebox-0.4.0 lib/gamebox/post_setup_handlers/file_watcher.rb
gamebox-0.4.0.rc11 lib/gamebox/post_setup_handlers/file_watcher.rb