2014-08-30 23:50:03 -07:00
|
|
|
desc "Install/update rbenv & all rubies"
|
2014-04-13 08:46:20 -07:00
|
|
|
task :rbenv => 'rbenv:update'
|
2014-04-11 00:31:44 -07:00
|
|
|
|
|
|
|
namespace :rbenv do
|
2014-08-30 23:50:03 -07:00
|
|
|
task :install do
|
|
|
|
unless rbenv_installed?
|
|
|
|
echo "Installing rbenv"
|
|
|
|
if is_mac?
|
|
|
|
rbenv_reqs.each { |pkg| Package.install pkg }
|
|
|
|
elsif is_linux?
|
|
|
|
sh_safe "curl https://raw.githubusercontent.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash"
|
|
|
|
end
|
2014-04-11 00:31:44 -07:00
|
|
|
end
|
2014-08-30 23:50:03 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
task :update => "rbenv:install" do
|
|
|
|
rbenv_versions do |v|
|
|
|
|
echo "Updating ruby #{v}"
|
2014-04-11 00:31:44 -07:00
|
|
|
|
2014-08-30 23:50:03 -07:00
|
|
|
cmd = "gem"
|
|
|
|
cmd = "sudo #{cmd}" if v == "system"
|
|
|
|
|
|
|
|
sh_safe "RBENV_VERSION=#{version} #{cmd} #{GEM_BIN} update"
|
|
|
|
sh_safe "RBENV_VERSION=#{version} #{cmd} #{GEM_BIN} clean"
|
2014-04-13 08:46:20 -07:00
|
|
|
end
|
2014-08-30 23:50:03 -07:00
|
|
|
end
|
2014-04-11 00:31:44 -07:00
|
|
|
|
2014-08-30 23:50:03 -07:00
|
|
|
desc "Remove rbenv & installed rubies"
|
|
|
|
task :remove do
|
|
|
|
if rbenv_installed?
|
|
|
|
echo "rbenv isn't installed!"
|
|
|
|
else
|
|
|
|
echo "Deleting rbenv"
|
|
|
|
if is_mac?
|
|
|
|
rbenv_reqs.each { |pkg| Package.remove pkg }
|
|
|
|
elsif is_linux?
|
|
|
|
sh_safe "rm -rf $RBENV_ROOT"
|
|
|
|
end
|
2014-04-11 00:31:44 -07:00
|
|
|
end
|
2014-08-30 23:50:03 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
####
|
|
|
|
|
|
|
|
def rbenv_installed?
|
|
|
|
system("which rbenv")
|
|
|
|
end
|
|
|
|
|
|
|
|
def rbenv_versions
|
|
|
|
`ls -1 $RBENV_ROOT/versions`.split("\n")
|
|
|
|
end
|
2014-04-11 00:31:44 -07:00
|
|
|
|
2014-08-30 23:50:03 -07:00
|
|
|
def rbenv_reqs
|
|
|
|
%w{rbenv ruby-build rbenv-vars rbenv-gem-rehash}
|
2014-04-11 00:31:44 -07:00
|
|
|
end
|