From 585dc242d648f9fd33e5d3fff93abacd3df7e8af Mon Sep 17 00:00:00 2001 From: Joel Moss Date: Thu, 25 Aug 2011 15:26:04 +0100 Subject: [PATCH 1/4] Added support for setting the debugger (-u flag) --- lib/guard/rails.rb | 3 ++- lib/guard/rails/runner.rb | 1 + spec/lib/guard/rails/runner_spec.rb | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/guard/rails.rb b/lib/guard/rails.rb index 11758bc..a29636e 100644 --- a/lib/guard/rails.rb +++ b/lib/guard/rails.rb @@ -13,7 +13,8 @@ module Guard :start_on_start => true, :force_run => false, :timeout => 20, - :server => nil + :server => nil, + :debugger => nil } def initialize(watchers = [], options = {}) diff --git a/lib/guard/rails/runner.rb b/lib/guard/rails/runner.rb index 322005c..67c49ce 100644 --- a/lib/guard/rails/runner.rb +++ b/lib/guard/rails/runner.rb @@ -33,6 +33,7 @@ module Guard rails_options = [ '-e', options[:environment], '-p', options[:port], + '-u', options[:debugger], '--pid', pid_file ] diff --git a/spec/lib/guard/rails/runner_spec.rb b/spec/lib/guard/rails/runner_spec.rb index 73f6b76..122482b 100644 --- a/spec/lib/guard/rails/runner_spec.rb +++ b/spec/lib/guard/rails/runner_spec.rb @@ -46,6 +46,14 @@ describe Guard::RailsRunner do runner.build_rails_command.should match(%r{ -d}) end end + + context 'debugger' do + let(:options) { default_options.merge(:debugger => true) } + + it "should have a debugger switch" do + runner.build_rails_command.should match(%r{ -u}) + end + end context 'custom server' do let(:options) { default_options.merge(:server => 'thin') } From 1dcbbd4d11ad5c85cdd18cdd8fb399be7dc6d9b3 Mon Sep 17 00:00:00 2001 From: Joel Moss Date: Thu, 25 Aug 2011 15:30:30 +0100 Subject: [PATCH 2/4] Updated README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f05602a..52e7b68 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ Lots of fun options! * `:start_on_start` will start the server when starting Guard (default `true`) * `:force_run` kills any process that's holding open the listen port before attempting to (re)start Rails (default `false`). * `:daemon` runs the server as a daemon, without any output to the terminal that ran `guard` (default `false`). +* `:debugger` runs the server with the debugger enabled (default `false`). Required ruby-debug gem. * `:timeout` waits this number of seconds when restarting the Rails server before reporting there's a problem (default `20`). This is super-alpha, but it works for me! Only really hand-tested in Mac OS X. Feel free to fork'n'fix for other From 7a81802b8cec554568e194d286004f28d9220a5c Mon Sep 17 00:00:00 2001 From: Joel Moss Date: Thu, 25 Aug 2011 15:42:39 +0100 Subject: [PATCH 3/4] Doh! APpending -u flag instead of iincluding in default --- lib/guard/rails/runner.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/guard/rails/runner.rb b/lib/guard/rails/runner.rb index 67c49ce..dff1d80 100644 --- a/lib/guard/rails/runner.rb +++ b/lib/guard/rails/runner.rb @@ -23,7 +23,7 @@ module Guard FileUtils.rm pid_file end end - + def restart stop start @@ -33,11 +33,11 @@ module Guard rails_options = [ '-e', options[:environment], '-p', options[:port], - '-u', options[:debugger], '--pid', pid_file ] rails_options << '-d' if options[:daemon] + rails_options << '-u' if options[:debugger] rails_options << options[:server] if options[:server] %{sh -c 'cd #{Dir.pwd} && rails s #{rails_options.join(' ')} &'} From 3d897a7665faa69f0e5f783d8109827d73e8e965 Mon Sep 17 00:00:00 2001 From: Joel Moss Date: Thu, 25 Aug 2011 15:53:20 +0100 Subject: [PATCH 4/4] debugger is false by default --- lib/guard/rails.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/guard/rails.rb b/lib/guard/rails.rb index a29636e..02c9394 100644 --- a/lib/guard/rails.rb +++ b/lib/guard/rails.rb @@ -14,7 +14,7 @@ module Guard :force_run => false, :timeout => 20, :server => nil, - :debugger => nil + :debugger => false } def initialize(watchers = [], options = {})