Class: RightConf::RubyConfigurator

Inherits:
Object
  • Object
show all
Includes:
Configurator
Defined in:
lib/rconf/configurators/ruby_configurator.rb

Constant Summary collapse

RVM_VERSION =

RVM version used to install rubies

'1.6.2'
RVM_RELEASES_URL =

RVM releases URL

'https://rvm.beginrescueend.com/releases'

Instance Method Summary collapse

Methods included from Configurator

#[], #check, included, #run, #signature, #validate

Methods included from ProgressReporter

included, report_to_file, report_to_stdout

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RightConf::Configurator

Instance Method Details

#check_linuxObject Also known as: check_darwin, check_windows

Let configurator run, it is idempotent

Return

false

Always return false



39
40
41
# File 'lib/rconf/configurators/ruby_configurator.rb', line 39

def check_linux
  false
end

#post_processObject

Set command prefix when already configured Re-create .rvmrc if needed

Return

true

Always return true



126
127
128
129
130
# File 'lib/rconf/configurators/ruby_configurator.rb', line 126

def post_process
  Command.set_ruby(version, gemset)
  check_rvmrc
  true
end

#run_linuxObject Also known as: run_darwin

Switch to ruby version defined in settings Use rvm and install it if needed

Return

true

Always return true



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/rconf/configurators/ruby_configurator.rb', line 50

def run_linux
  check_rvm(RVM_VERSION)
  return true if aborting
  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
    when /is not installed\./
      report_failure
      report_fatal "Failed to install #{ruby}" if @tried
      Platform.dispatch(version) { :install_ruby }
      @tried = true
      Command.execute_in_ruby('gem', 'install', 'rconf') unless gemset
      run
      return true
    when /^Using /
      report_success
      check_rvmrc
    else
      report_fatal("Failed to use #{version}:\n#{out}")
    end
  end
  if gemset
    report_check("Checking whether gemset #{gemset} exists")
    res = Command.execute('rvm', version, 'exec', 'rvm', 'gemset', 'list')
    if res.output =~ /^(\s+|=> )#{gemset}$/
      report_success
    else
      report_failure
      report_check("Creating gemset #{gemset} for #{version}")
      Command.execute('rvm', version, 'exec', 'rvm', 'gemset', 'create',  gemset,
                      :abort_on_failure => "Failed to create gemset '#{gemset}'") 
      Command.execute_in_ruby('gem', 'install', 'rconf')
      report_success
    end
    report_check("Switching to gemset #{gemset}")
    Command.execute('rvm', version, 'exec', 'rvm', 'gemset', 'use',  gemset,
                    :abort_on_failure => "Failed to switch to gemset '#{gemset}'") 
    report_success
  end
  if rubygems
    report_check("Checking whether rubygems #{rubygems} is installed")
    res = Command.execute_in_ruby('gem', '--version')
    if res.success? && res.output =~ /^#{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
  end
  true
end

#run_windowsObject

Switch to ruby version defined in settings TBD

Return

true

Always return true



118
119
# File 'lib/rconf/configurators/ruby_configurator.rb', line 118

def run_windows
end