lib/rconf/configurators/ruby_configurator.rb in rconf-0.6.25 vs lib/rconf/configurators/ruby_configurator.rb in rconf-0.6.30
- old
+ new
@@ -34,10 +34,11 @@
#
# === Return
# true:: Always return true
def run_linux
check_rvm(RVM_VERSION)
+ 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
else
@@ -45,12 +46,14 @@
report_check("Switching to #{version}")
out = Command.execute('rvm', 'use', version).output
case out
when /is not installed\./
report_failure
- report_fatal "Failed to install #{ruby}: #{@out}" if @out
- @out = install_ruby(version)
+ report_fatal "Failed to install #{ruby}" if @tried
+ install_ruby(version)
+ @tried = true
+ Command.execute_in_ruby('gem', 'install', 'rconf') unless gemset
run
return true
when /^Using /
report_success
check_rvmrc
@@ -67,18 +70,28 @@
else
report_failure
report_check("Creating gemset #{gemset} for #{version}")
Command.execute('rvm', version, 'gemset', 'create', gemset,
:abort_on_failure => "Failed to create gemset '#{gemset}'")
- Command.execute('rvm', "#{version}@#{gemset}", 'gem', 'install', 'rconf')
+ Command.execute_in_ruby('gem', 'install', 'rconf')
report_success
end
report_check("Switching to gemset #{gemset}")
Command.execute('rvm', version, 'gemset', 'use', gemset,
:abort_on_failure => "Failed to switch to gemset '#{gemset}'")
report_success
end
+ report_check("Checking whether rubygems #{rubygems} is installed")
+ res = Command.execute_in_ruby('gem', '--version')
+ if res.success? && res.output.chomp == rubygems
+ report_success
+ else
+ report_failure
+ report_check("Installing rubygems #{rubygems}")
+ Command.execute_in_ruby('rubygems', rubygems, :abort_on_failure => 'Failed to install rubygems')
+ report_success
+ end
true
end
alias :run_darwin :run_linux
# Switch to ruby version defined in settings
@@ -93,11 +106,11 @@
# Re-create .rvmrc if needed
#
# === Return
# true:: Always return true
def post_process
- Command.set_prefix("rvm #{version}@#{gemset} exec --")
+ Command.set_ruby(version, gemset)
check_rvmrc
true
end
protected
@@ -140,17 +153,16 @@
#
# === Parameters
# ruby(String):: Ruby version compatible with rvm
#
# === Return
- # out(String):: Installation output
+ # true:: Always return true
def install_ruby(ruby)
Platform.dispatch(ruby) { :install_ruby_prerequesites }
report_check("Installing #{ruby} (this will take a while, please be patient)")
Command.execute('rvm', 'install', ruby, :abort_on_failure => 'Failed to install ruby')
- res = Command.execute('rvm', ruby, 'gem', 'install', 'rconf')
report_success
- res.output
+ true
end
# Make sure to install all required linux packages first
#
# === Return