Created
March 29, 2011 20:15
-
-
Save jacob414/893148 to your computer and use it in GitHub Desktop.
Ruby FSEvents & rsync insanely easy to write directory mirror
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
# 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