Sha256: 2b5d29505dd0e913f80bca5a68552edc45fa329c27bf76cebcb1e1fb0234e1ad

Contents?: true

Size: 741 Bytes

Versions: 14

Compression:

Stored size: 741 Bytes

Contents

module PluginTool

  class WatcherPoll
    def initialize(dirs)
      @dirs = dirs
      @last_contents = make_contents
    end
    def wait(timeout)
      while timeout > 0
        c = make_contents
        if @last_contents != c
          @last_contents = c
          return
        end
        timeout -= 1
        sleep 1
      end
    end
    def make_contents
      c = ''
      @dirs.each do |dir|
        Dir.glob("#{dir}/**/*").each do |file|
          c << file
          c << ":#{File.mtime(file).to_i}\n"
        end
      end
      c
    end
  end
  
  def self.make_watcher(dirs)
    # TODO: Option to use external watcher task
    # pipe = IO.popen(watcher_cmd)
    # wait with pipe.read
    WatcherPoll.new(dirs)
  end

end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
haplo-2.1.0-java lib/watchers.rb
oneis-2.0.6-java lib/watchers.rb
oneis-2.0.5-java lib/watchers.rb
oneis-2.0.4-java lib/watchers.rb
oneis-2.0.3-java lib/watchers.rb
oneis-2.0.2-java lib/watchers.rb
oneis-2.0.1-java lib/watchers.rb
oneis-1.2.2-java lib/watchers.rb
oneis-1.2.1-java lib/watchers.rb
oneis-1.2.0-java lib/watchers.rb
oneis-1.1.0-java lib/watchers.rb
oneis-1.0.4-java lib/watchers.rb
oneis-1.0.1-java lib/watchers.rb
oneis-1.0.0-java lib/watchers.rb