New tool for the belt: guard

As I’m currently updating a blog post a lot I was looking for a tool to watch a directoy and execute a callback on changes. The tool I found is guard. It has special support for all kinds of callbacks, e.g. rspec but I just use guard-shell. In the directory of this Jekyll site I have a shell script which calls jekyll and publishes the site via scp. Note that this script works even when it is called concurrently and only publishes consistent views of the site by copying the site to a directory containing an aggregate sha1 digest of the site and then linking the web server root directoy to it.

The Guardfile for publishing the site:

guard :shell do
  watch(/(.*).md$/) {|m| 
	system './_publish.sh'
  }
end
-- Matthias Schütz 25 Aug 2012

Impressum