Created
December 14, 2011 16:53
-
-
Save TwP/1477410 to your computer and use it in GitHub Desktop.
Test scripts for the directory_watcher gem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
$:.unshift 'lib' | |
Thread.abort_on_exception = true | |
require 'logging' | |
include Logging.globally | |
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
STDOUT.sync | |
#cmds = ['rm -f ', 'echo "hello" >> '] | |
cmds = ['rm -f ', 'touch ', 'echo "hello" >> '] | |
while true | |
cmd = cmds[rand(cmds.length)].dup | |
cmd << "%d.tmp" % rand(10) | |
puts cmd | |
system cmd | |
sleep 0.2 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment