Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
#!/usr/bin/env ruby # Erik Kastner - git-r-up.rb # daemon to watch for changes in a directory and sync them to a directory under source control (like rails + git) # also adds and commits files to git (just git init in the FETCH_ROOT) require 'rubygems' require 'simple-daemon' require 'git' PUBLIC_ROOT = "/path/to/rails/project/current/public" FETCH_ROOT = "/home/myuser/website" class Watcher < SimpleDaemon::Base SimpleDaemon::WORKING_DIRECTORY = "/tmp/git-watcher" def self.start puts "Starting Watcher" g = Git.open(FETCH_ROOT) loop do unless g.status.untracked.empty? && g.status.changed.empty? %x{cp -r #{FETCH_ROOT}/* #{PUBLIC_ROOT}} g.add g.commit_all("auto from watcher") end end end def self.end puts "Stopping Watcher" end end Watcher.daemonize
Pasted March 26, 200811:49AM EDT
by Erik Kastner (kastner)
Embed