Created
February 6, 2012 22:28
-
-
Save jdcantrell/1755432 to your computer and use it in GitHub Desktop.
FeDev Guard (better)
This file contains 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
# Add files and commands to this file, like the example: | |
# watch('file/path') { `command(s)` } | |
# | |
# | |
$username = 'jcantrell' | |
guard :shell do | |
$last_call = Time.now | |
Notifier.turn_on | |
def sync(from, to) | |
#doing svn up will cause us to sync a ton of times, but we only need | |
#to sync the first time, so lets only sync every .5 secs at most | |
if Time.now - $last_call > 0.5 | |
system("rsync -avz ./#{from}/ #{$username}@fedev.utah.trulia.com:#{to}/ --exclude '.svn'") | |
Notifier.notify("#{from} is up to date.", {title: "Sync Complete"}) | |
end | |
$last_call = Time.now | |
end | |
def sync_common(from, to, file) | |
#todo move this if check to regex | |
if file.index(".svn") == nil | |
sync(from, "/home/#{$username}/svn/#{to}") | |
end | |
end | |
def sync_www(from, to, file) | |
if file.index(".svn") == nil | |
sync(from, "/home/#{$username}/public_html/#{to}") | |
end | |
end | |
#common repos | |
watch( %r{^common/.*} ) { |m| sync_common('common', 'common', m[0]) } | |
#playground and others | |
watch( %r{^playground/.*} ) { |m| sync_www('playground', 'playground', m[0]) } | |
#current working branches | |
watch( %r{^cm/.*} ) { |m| sync_www('cm', 'cm', m[0]) } | |
watch( %r{^filters/.*} ) { |m| sync_www("filters", "filters", m[0]) } | |
watch( %r{^rt/.*} ) { |m| sync_www("rt", "rt", m[0]) } | |
watch( %r{^sdm/.*} ) { |m| sync_www("sdm", "sdm", m[0]) } | |
watch( %r{^common_property_class/.*} ) { |m| sync_common("common_property_class", "common_property_class", m[0]) } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment