Sha256: 1086f14b548819920adf16eb9db383d7a3af18f78354acaa2c79509579a14514
Contents?: true
Size: 603 Bytes
Versions: 2
Compression:
Stored size: 603 Bytes
Contents
require_relative 'web_app' module Devcenter::Previewer class FileListener require 'listen' def initialize(file_path) dir = File.dirname(file_path) basename = File.basename(file_path) @listener = Listen.to(dir) do |modified, added, removed| modified.each{ |f| Devcenter::Logger.log "File modified: #{f}" } WebApp.send_server_event end @listener.only(%r{#{basename}}) end def start @thread = Thread.new { @listener.start } end def stop @listener.stop rescue ThreadError Thread.kill(@thread) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
devcenter-1.3.0 | lib/devcenter/previewer/file_listener.rb |
devcenter-1.2.0 | lib/devcenter/previewer/file_listener.rb |