lib/rconf/configurators/ruby_configurator.rb in rconf-0.8.2 vs lib/rconf/configurators/ruby_configurator.rb in rconf-0.8.3

- old
+ new

@@ -42,10 +42,11 @@ Command.set_ruby(version, gemset) report_check("Checking whether #{version} is the active ruby") out = Command.execute('rvm', 'list').output if out =~ /^=> #{version.gsub('.', '\\.')}/ report_success + check_rvmrc else report_failure report_check("Switching to #{version}") out = Command.execute('rvm', 'use', version).output case out @@ -210,23 +211,24 @@ # Check .rvmrc and its content # # === Return # true:: Always return true def check_rvmrc - return true if File.exist?('.rvmrc') - report_check('Setting up .rvmrc') - begin - File.open('.rvmrc', 'w') do |f| - f.puts "rvm #{version}@#{gemset}" - f.puts "type -P rconf &>/dev/null && { rconf; }" - f.puts "type -P rconf &>/dev/null || { echo 'rconf not installed, skipping (see .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 "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 + aborting(true) + rescue Exception => e + report_failure + report_error(e.message) end - report_success - post_note "Configuration required switching the active ruby\nPlease run " + 'cd ..;cd -'.blue + ' to activate it and finish configuration'.green - aborting(true) - rescue Exception => e - report_failure - report_error(e.message) end true end # Setup .bashrc for rvm support