Skip to content

Commit

Permalink
Implement :'rvm:use'. See #5, #39.
Browse files Browse the repository at this point in the history
  • Loading branch information
rstacruz committed Aug 7, 2012
1 parent 5c9b260 commit 4d82d2c
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lib/mina/rvm.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Common usage:
#
# task :environment do
# invoke :'rvm:use[ruby-1.9.3-p125@gemset_name]'
# end
#
# task :deploy => :environment do
# ...
# end
#
set_default :rvm_path, "$HOME/.rvm/scripts/rvm"

task :'rvm:use', :env do |t, args|
unless args[:env]
print_error "Task 'rvm:use' needs an RVM environment name as an argument."
print_error "Example: invoke :'rvm:use[ruby-1.9.2@default]'"
die
end

queue %{
echo "-----> Using RVM environment '#{args[:env]}'"
if [[ ! -s "#{rvm_path}" ]]; then
echo "! Ruby Version Manager not found"
echo "! If RVM is installed, check your :rvm_path setting."
exit 1
fi
source #{rvm_path}
#{echo_cmd %{rvm use "#{args[:env]}"}} || exit 1
}
end

0 comments on commit 4d82d2c

Please sign in to comment.