Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for chruby #115

Merged
merged 2 commits into from
Aug 30, 2013
Merged
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
49 changes: 49 additions & 0 deletions lib/mina/chruby.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# # Modules: chruby
# Adds settings and tasks for managing [chruby] installations.
#
# [chruby]: https://github.com/postmodern/chruby
#
# require 'mina/chruby'
#
# ## Common usage
#
# task :environment do
# invoke :'chruby[ruby-1.9.3-p392]'
# end
#
# task :deploy => :environment do
# ...
# end

# ## Settings
# Any and all of these settings can be overriden in your `deploy.rb`.

# ### chruby_path
# Path where *chruby* init scripts are installed.
#
set_default :chruby_path, "/etc/profile.d/chruby.sh"

# ## Tasks

# ### chruby[version]
# Switch to given Ruby version

task :chruby, :env do |t, args|
unless args[:env]
print_error "Task 'chruby' needs a Ruby version as an argument."
print_error "Example: invoke :'chruby[ruby-1.9.3-p392]'"
die
end

queue %{
echo "-----> chruby to version: '#{args[:env]}'"

if [[ ! -s "#{chruby_path}" ]]; then
echo "! chruby.sh init file not found"
exit 1
fi

source #{chruby_path}
#{echo_cmd %{chruby "#{args[:env]}"}} || exit 1
}
end