ranmocy / guard-rails

Guard-Rails is watching on your development servers as you wish!
http://ranmocy.github.com/guard-rails
MIT License
137 stars 25 forks source link

add restart_done hook #27

Closed mickey closed 10 years ago

mickey commented 10 years ago

This allows me to be able to livereload on backend changes:

guard 'rails', daemon: true, pid_file: 'rack.pid', CLI: 'bundle exec rackup -p 3000 -s thin -P rack.pid' do
  watch('Gemfile.lock')
  watch('config.ru')
  watch('app.rb')
  callback(:restart_done) {  Guard.plugins.find {|p| p.class == LiveReload}.reactor.reload_browser(["whatever"]) }
end

I didn't include specs as I'm not sure how to test this. If you have any pointers it would be much appreciated.

Cheers,

ranmocy commented 10 years ago

I still prefer not add this hook. Guard itself already support bunch of hooks: start, stop, reload, run_all, run_on_changes The doc is here.

And you can do what you expected by:

guard 'rails' do
  watch('app.rb')
  callback(:run_on_changes_end) {  Guard.plugins.find {|p| p.class == LiveReload}.reactor.reload_browser(["whatever"]) }
end