Skip to content

Instantly share code, notes, and snippets.

@TwP
Created June 6, 2011 18:06
Show Gist options
  • Save TwP/1010734 to your computer and use it in GitHub Desktop.
Save TwP/1010734 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
Thread.abort_on_exception = true
require 'directory_watcher'
STDOUT.sync = true
puts "Directory Watcher v #{DirectoryWatcher.version}"
dw = DirectoryWatcher.new 'temp.dir', :glob => ['**/*.tmp'], :scanner => :coolio
dw.interval = 0.25 # seconds
dw.stable = 8 # intervals (2 seconds)
dw.persist = 'tmp.yml'
dw.add_observer {|*args| args.each {|e| puts e.to_s}}
#log = File.open('tmp.log','w')
#dw.add_observer {|*args| args.each {|e| log.puts "[#{e.type}] #{e.path}"}}
dw.start
gets
dw.stop
log.close if defined? log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment