My goal is to build a simple custom guard with Guard. The gem install and bundler install for my app went fine. My Guardfile contains:
notification :growl
guard 'eyeball' do
watch %r{^app/(.*)}
watch %r{^config/(.*)}
watch %r{^lib/(.*)}
end
Ok, next, I need to tell Guard what to do when a match happens. But I don't know where to do that. (In this case, I want to watch my application for changes and run some arbitrary code. Assume that there isn't a guard available for what I want. I want to learn how to do it myself.)
In true 'blunder and see what errors pop up next' style, when I run guard
I get this error message:
ERROR: Could not load 'guard/eyeball' or find class Guard::Eyeball ERROR: cannot load such file -- guard/eyeball ERROR: Invalid Guardfile, original error is: undefined method `new' for nil:NilClass ERROR: No guards found in Guardfile, please add at least one. Guard uses Growl to send notifications. Guard is now watching at '/Users/my-user-name/dev/my-project-name'
So, that gives me a hint that I need to create a guard/eyeball.rb
file. Maybe? But how was I supposed to know this from the documentation?
I've read (several times) the very detailed and useful Guard README but haven't found a good simple example that shows someone how to do 'just the basics' of writing your own guard. Unexpectedly, RailsCasts didn't really answer my question either: see RailsCast #264 Guard.
Did I overlook something in the Guard README? Can you help or point to a good example? Thanks!
Sweet! I just found a Wiki page on the Guard wiki titled Create a guard that answers my questions. It was not mentioned in the README, so I had to dig for it.