lib/rconf/configurators/ruby_configurator.rb in rconf-0.8.15 vs lib/rconf/configurators/ruby_configurator.rb in rconf-0.8.16

- old
+ new

@@ -230,11 +230,12 @@ def check_rvmrc if !File.exist?('.rvmrc') || IO.read('.rvmrc') !~ /#{version}@#{gemset}/ report_check('Setting up .rvmrc') begin File.open('.rvmrc', 'w') do |f| - f.puts "rvm #{version}@#{gemset}" + f.puts "environment_id=\"#{version}@#{gemset}\"" + f.puts RVM_HOOK f.puts "type -P rconf &>/dev/null && { rconf; }" f.puts "type -P rconf &>/dev/null || { echo 'rconf not installed, skipping (see .rvmrc)'; }" end report_success post_note "Configuration required switching the active ruby\nPlease run " + 'cd ..;cd -'.blue + ' to activate it and finish configuration'.green @@ -244,9 +245,36 @@ report_error(e.message) end end true end + + # rvm mojo for creating and enabling 'environments' + RVM_HOOK = <<-EOF +if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \ + && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]] +then + \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id" + + if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] + then + . "${rvm_path:-$HOME/.rvm}/hooks/after_use" + fi +else + # If the environment file has not yet been created, use the RVM CLI to select. + if ! rvm --create "$environment_id" + then + echo "Failed to create RVM environment '${environment_id}'." + return 1 + fi +fi +if [[ $- == *i* ]] # check for interactive shells +then + echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green +else + echo "Using: $GEM_HOME" # don't use colors in interactive shells +fi + EOF # Setup .bashrc for rvm support # # === Return # true:: Always return true