Permalink
Browse files

Add count option to specify number of workers, tweak template to show…

… available options, add tests
  • Loading branch information...
1 parent f95c863 commit 19444cbf9294c0c02c9482ee5313836c9e417605 @jredville jredville committed Oct 5, 2011
Showing with 44 additions and 1 deletion.
  1. +1 −0 .gitignore
  2. +1 −0 README.markdown
  3. +4 −0 lib/guard/resque.rb
  4. +6 −0 lib/guard/resque/templates/Guardfile
  5. +1 −1 lib/guard/resque/version.rb
  6. +31 −0 spec/guard/resque_spec.rb
View
@@ -2,3 +2,4 @@
.bundle
Gemfile.lock
pkg/*
+.rvmrc
View
@@ -40,6 +40,7 @@ You can customize the resque task via the following options:
* `environment`: the rails environment to run the workers in (defaults to `"development"`)
* `task`: the name of the rake task to use (defaults to `"resque:work"`)
* `queue`: the resque queue to run (defaults to `"*"`)
+* `count`: the number of workers to include (defaults to `"1"`)
* `verbose`: whether to use verbose logging (defaults to `false`)
* `trace`: whether to include `--trace` on the rake command (defaults to `false`)
* `stop_signal`: how to kill the process when restarting (defaults to `KILL`)
View
@@ -8,6 +8,7 @@ class Resque < Guard
# :environment e.g. 'test'
# :task .e.g 'resque:work'
# :queue e.g. '*'
+ # :count e.g. 3
# :verbose e.g. true
# :trace e.g. true
# :stop_signal e.g. KILL
@@ -70,6 +71,9 @@ def cmd
# queue setting
command << "QUEUE=#{@options[:queue] || '*'} "
+ #count setting
+ command << "COUNT=#{@options[:count] || '1'} "
+
# verbose setting
command << "VVERBOSE=1 " if @options[:verbose]
@@ -1,3 +1,9 @@
+# other available options
+# :task (defaults to resque:work)
+# :verbose
+# :trace
+# :queue (defaults to "*")
+# :count (defaults to 1)
guard 'resque', :environment => 'development' do
watch(%r{^app/(.+)\.rb})
watch(%r{^lib/(.+)\.rb})
@@ -1,5 +1,5 @@
module Guard
module ResqueVersion
- VERSION = "0.0.2"
+ VERSION = "0.0.3"
end
end
@@ -16,5 +16,36 @@
subject.start
Dir.glob("tmp/pids/resque*.pid").should_not be_empty
end
+
+ it "should accept environment option" do
+ obj = Guard::Resque.new [], :environment => 'foo'
+ obj.send(:cmd).should match /RAILS_ENV=foo/
+ end
+
+ it "should accept queue option" do
+ obj = Guard::Resque.new [], :queue => 'foo'
+ obj.send(:cmd).should match /QUEUE=foo/
+ end
+
+ it "should accept count option" do
+ obj = Guard::Resque.new [], :count => 2
+ obj.send(:cmd).should match /COUNT=2/
+ end
+
+ it "should accept verbose option" do
+ obj = Guard::Resque.new [], :verbose => true
+ obj.send(:cmd).should match /VVERBOSE=1/
+ end
+
+ it "should accept trace option" do
+ obj = Guard::Resque.new [], :trace => true
+ obj.send(:cmd).should match /--trace/
+ end
+
+ it "should accept task option" do
+ obj = Guard::Resque.new [], :task => 'environment foo'
+ obj.send(:cmd).should match /environment foo/
+ obj.send(:cmd).should_not match /resque:work/
+ end
end
end

0 comments on commit 19444cb

Please sign in to comment.