Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add cap rubygems task;

DRY mongrel_cmd and ruby_cmd
  • Loading branch information...
commit 5c0462f3f5bf85adc37529da41bf7be34aea93d0 1 parent cdd9991
Edward Anderson nilbus authored
Showing with 17 additions and 10 deletions.
  1. +2 −0  README.md
  2. +15 −10 lib/capistrano/ext/windows_server.rb
2  README.md
View
@@ -204,6 +204,8 @@ The following new tasks were added:
* `cap deploy:mongrel:setup` - Create mongrel services
* `cap deploy:mongrel:remove` - Remove mongrel services
* `cap rake` - Run a rake task, specified by COMMAND. eg: cap rake COMMAND="gems:install"
+* `cap rubygems` - Run a gem command, specified by COMMAND. eg: cap rubygems COMMAND="install rails"
+* `cap git` - Run a git command, specified by COMMAND. eg: cap rake COMMAND="status"
The following tasks will later be fixed:
25 lib/capistrano/ext/windows_server.rb
View
@@ -12,14 +12,13 @@
set :scm_verbose, true
set :use_sudo, false
- # We can't run rake directly, because the rake script searches for ruby based on windows paths that aren't valid in this environment
- def rake_cmd
- "PATH=\"#{File.dirname ruby_exe_path}:$PATH\" #{ruby_exe_path} -e \"require 'rubygems'; gem 'rake', '>= 0'; load 'rake'\""
+ # We can't run ruby commands directly, because the rake script searches for ruby based on windows paths that aren't valid in this environment
+ def ruby_cmd(cmd)
+ "PATH=\"#{File.dirname ruby_exe_path}:$PATH\" #{ruby_exe_path} -e \"require 'rubygems'; gem '#{cmd}', '>= 0'; load '#{cmd}'\""
end
- # We can't run mongrel directly, because the mongrel script searches for ruby based on windows paths that aren't valid in this environment
- def mongrel_cmd
- "PATH=\"#{File.dirname ruby_exe_path}:$PATH\" #{ruby_exe_path} -e \"require 'rubygems'; gem 'mongrel', '>= 0'; load 'mongrel_rails'\""
+ def rubygems_cmd
+ "PATH=\"#{File.dirname ruby_exe_path}:$PATH\" #{ruby_exe_path} -e \"require 'rubygems';require 'rubygems/gem_runner';require 'rubygems/exceptions';Gem::GemRunner.new.run ARGV.clone\""
end
namespace :deploy do
@@ -78,7 +77,7 @@ def mongrel_cmd
desc "Run pending migrations"
task :migrate do
- run "cd #{current_path} && #{rake_cmd} db:migrate RAILS_ENV=#{rails_env}"
+ run "cd #{current_path} && #{ruby_cmd 'rake'} db:migrate RAILS_ENV=#{rails_env}"
end
desc "Start mongrel"
@@ -108,7 +107,7 @@ def mongrel_cmd
task :setup do
mongrel_instances.each do |n|
run "mkdir -p #{current_path}/{tmp,log}" # These are often not under version control, but their absence keeps mongrel from recognizing the rails app
- run "cd #{current_path} && #{mongrel_cmd} service::install -e #{rails_env} -N #{mongrel_instance_prefix}#{n} -p #{base_port + n - mongrel_instances.first}; true"
+ run "cd #{current_path} && #{ruby_cmd 'mongrel'} service::install -e #{rails_env} -N #{mongrel_instance_prefix}#{n} -p #{base_port + n - mongrel_instances.first}; true"
run %Q(sc.exe config "#{mongrel_instance_prefix}#{n}" start= auto; true)
end
end
@@ -116,7 +115,7 @@ def mongrel_cmd
desc "Remove mongrel services"
task :remove do
mongrel_instances.each do |n|
- run "#{mongrel_cmd} service::remove -N #{mongrel_instance_prefix}#{n}; true"
+ run "#{ruby_cmd 'mongrel'} service::remove -N #{mongrel_instance_prefix}#{n}; true"
end
end
@@ -127,7 +126,13 @@ def mongrel_cmd
desc "Run a rake command in COMMAND"
task :rake do
raise "Specify the command with COMMAND='some:task with_arguments'" unless ENV['COMMAND']
- run "cd #{current_path} && #{rake_cmd} #{ENV['COMMAND']} RAILS_ENV=#{rails_env}"
+ run "cd #{current_path} && #{ruby_cmd 'rake'} #{ENV['COMMAND']} RAILS_ENV=#{rails_env}"
+ end
+
+ desc "Run a rubygems (gem) command in COMMAND"
+ task :rubygems do
+ raise "Specify the command with COMMAND='install rails'" unless ENV['COMMAND']
+ run "cd #{current_path} && #{rubygems_cmd} #{ENV['COMMAND']}"
end
namespace :git do
Please sign in to comment.
Something went wrong with that request. Please try again.