guard: Ruby DSL for creating filesystem watchers
Watching the filesystem and re-running test suites have long been the sweet spot for Autotest and Watchr. As more and more preprocessed tools like CoffeeScript and Sass are more widely adopted, there are a growing number of scenarios where you may want to watch the file system and act on the changes.
Rémy Coutable and Thibaud Guillaume-Gentil are developing Guard, a Ruby-based utility and DSL for building filesystem watchers. Guard uses FSEvent on OS X and lnotify on Linux to watch the filesystem and Growl on OS X and libnotify on Linux for notifications.
Guard is a gem so install with RubyGems:
gem install guardTo create a new Guard, just derive from the provided Guard base class, as in the Rspec example:
require 'guard' require 'guard/guard' module Guard class RSpec < Guard autoload :Runner, 'guard/rspec/runner' autoload :Inspector, 'guard/rspec/inspector' def start Runner.set_rspec_version(options) end def run_all Runner.run ["spec"], :message => "Running all specs" end def run_on_change(paths) paths = Inspector.clean(paths) Runner.run(paths) unless paths.empty? end end endNow you can use the guard using the Guard DSL
guard 'rspec' do watch('^spec/(.*)_spec.rb') watch('^lib/(.*)\.rb') { |m| "spec/lib/#{m[1]}_spec.rb" } watch('^spec/spec_helper.rb') { "spec" } endCurrently, Guard has released guard-rspec and guard-livereload, but is looking for the community to pile on perhaps with some of the following:
- guard-spork
- guard-cucumber
- guard-test
- guard-sass
- guard-bundler
Why not fork the project and contribute?
31 notes
-
a1027meadnews liked this
-
suddenharebr liked this
-
reparatiifrigidere liked this
-
last--minute liked this
-
jobs49 liked this
-
chezmimorin liked this
-
atm09td reblogged this from ukar and added:
Watching the filesystem and re-running test suites have long been the sweet spot for Autotest and Watchr. As more and...
-
ukar reblogged this from thechangelog
-
ukar reblogged this from thechangelog
-
pahanix liked this
-
layer22 reblogged this from thechangelog
-
thechangelog posted this