Compare commits

..

1 Commits

Author SHA1 Message Date
Roberto Vasquez Angel
2b0d43bd01 Added rails_root option for engine support. 2012-08-04 15:19:53 +02:00
5 changed files with 22 additions and 6 deletions

View File

@ -1,5 +1,3 @@
_This fork is no longer maintained. Visit [https://github.com/ranmocy/guard-rails](https://github.com/ranmocy/guard-rails) for the current official fork._
[![Build Status](http://travis-ci.org/johnbintz/guard-rails.png)](http://travis-ci.org/johnbintz/guard-rails)
Want to restart your Rails development server whilst you work? Now you can!
@ -19,6 +17,7 @@ Lots of fun options!
* `: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`).
* `:server` lets you specify the webserver engine to use (try `:server => :thin`).
* `:rails_root` lets you specify the root directory of your app (try `:rails_root => 'test/dummy` for engines).
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
OSes, and to add some more real tests.

View File

@ -14,7 +14,8 @@ module Guard
:force_run => false,
:timeout => 30,
:server => nil,
:debugger => false
:debugger => false,
:rails_root => nil
}
def initialize(watchers = [], options = {})

View File

@ -40,11 +40,19 @@ module Guard
rails_options << '-u' if options[:debugger]
rails_options << options[:server] if options[:server]
%{sh -c 'cd #{Dir.pwd} && RAILS_ENV=#{options[:environment]} rails s #{rails_options.join(' ')} &'}
%{sh -c 'cd #{build_rails_path} && RAILS_ENV=#{options[:environment]} rails s #{rails_options.join(' ')} &'}
end
def build_rails_path
if options[:rails_root]
File.join(Dir.pwd, options[:rails_root])
else
Dir.pwd
end
end
def pid_file
File.expand_path("tmp/pids/#{options[:environment]}.pid")
File.expand_path(File.join(options[:rails_root].to_s, "tmp/pids/#{options[:environment]}.pid"))
end
def pid

View File

@ -1,4 +1,4 @@
module GuardRails
VERSION = '0.1.1'
VERSION = '0.1.0'
end

View File

@ -63,6 +63,14 @@ describe Guard::RailsRunner do
runner.build_rails_command.should match(%r{thin})
end
end
context 'custom app path' do
let(:options) { default_options.merge(:app_path => 'spec/dummy') }
it "should have the app path" do
runner.build_rails_command.should match(%r{spec/dummy})
end
end
end
describe '#start' do