Sha256: e123885e97e44ee328c63103758bcaf2299ad0f74878ee1199bff374a76d812d

Contents?: true

Size: 425 Bytes

Versions: 4

Compression:

Stored size: 425 Bytes

Contents

module Devcenter::Previewer

  class FileListener
    require 'listen'

    def initialize(file_path, callback)
      dir = File.dirname(file_path)
      basename = File.basename(file_path)
      @listener = Listen.to(dir)
      @listener.filter(%r{#{basename}})
      @listener.change(&callback)
    end

    def start
      @listener.start(false) # non-blocking
    end

    def stop
      @listener.stop
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
devcenter-0.0.4 lib/devcenter/previewer/file_listener.rb
devcenter-0.0.3 lib/devcenter/previewer/file_listener.rb
devcenter-0.0.2 lib/devcenter/previewer/file_listener.rb
devcenter-0.0.1 lib/devcenter/previewer/file_listener.rb