Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ You can customize the resque task via the following options:
* `verbose`: whether to use verbose logging (defaults to `nil`)
* `vverbose`: whether to use very verbose logging (defaults to `nil`)
* `trace`: whether to include `--trace` on the rake command (defaults to `nil`)
* `load_environment`: whether to include 'environment' on the rake command (defaults to `nil`)
* `stop_signal`: how to kill the process when restarting (defaults to `QUIT`)


Expand Down
5 changes: 4 additions & 1 deletion lib/guard/resque.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Resque < Guard
# - :vverbose e.g. true
# - :trace e.g. true
# - :stop_signal e.g. :QUIT or :SIGQUIT
# - :load_environment e.g. false
def initialize(watchers = [], options = {})
@options = options
@pid = nil
Expand Down Expand Up @@ -85,7 +86,9 @@ def restart
private

def cmd
command = ['bundle exec rake', @options[:task].to_s]
command = ['bundle exec rake']
command << 'environment' if @options[:load_environment]
command << @options[:task].to_s

# trace setting
command << '--trace' if @options[:trace]
Expand Down
1 change: 1 addition & 0 deletions lib/guard/resque/templates/Guardfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# - :task (defaults to 'resque:work' if :count is 1; 'resque:workers', otherwise)
# - :verbose / :vverbose (set them to anything but false to activate their respective modes)
# - :trace
# - :load_environment
# - :queue (defaults to "*")
# - :count (defaults to 1)
# - :environment (corresponds to RAILS_ENV for the Resque worker)
Expand Down
5 changes: 5 additions & 0 deletions spec/guard/resque_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
obj.send(:cmd).should include '--trace'
end

it 'should accept :load_environment option' do
obj = Guard::Resque.new [], :load_environment => true
obj.send(:cmd).should include 'environment'
end

it 'should accept :task option' do
task = 'environment foo'

Expand Down