Skip to content

Instantly share code, notes, and snippets.

@jacob414
Created March 29, 2011 20:15
Show Gist options
  • Save jacob414/893148 to your computer and use it in GitHub Desktop.
Save jacob414/893148 to your computer and use it in GitHub Desktop.
Ruby FSEvents & rsync insanely easy to write directory mirror
# Just added a subprocess call to rsync to one of rb-fsevent's example
# scripts. Spookily easy.
require 'rubygems'
require 'rb-fsevent'
require 'open3'
include Open3
fsevent = FSEvent.new
fsevent.watch Dir.pwd do |directories|
popen3('rsync',
'-avr',
'--exclude=.hg',
'--exclude=env/vpython',
'.',
'thehost:~/src/the-src-repo') do |stdin, stdout, stderr|
stdout.read.split("\n").each do |line|
puts "rsync: #{line}"
end
end
end
fsevent.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment