install_command_dumper.rb

Path: lib/rvm/install_command_dumper.rb
Last Update: Mon Apr 18 18:29:41 +0000 2011

Prints out the rvm command (minus rvm install) to install this ruby.

Required files

rbconfig   shellwords  

Methods

Constants

RUBY_NAME = File.basename(ENV['MY_RUBY_HOME'])   Prints out the rvm command (minus rvm install) to install this ruby.
RVM_HOME = ENV['rvm_path']

Public Instance methods

[Source]

# File lib/rvm/install_command_dumper.rb, line 23
def arguments_for_install
  if ruby?(:ruby, :ree, :goruby)
    begin
      require 'rbconfig'
      require 'shellwords'
      # Get the full arguments
      config_args = Shellwords.shellwords(Config::CONFIG['configure_args'].to_s.strip)
      real_arguments = []
      config_args.each do |arg|
        if ruby?(:ree) && arg == "--enable-mbari-api"
          next
        elsif arg =~ /^--prefix/
          next
        elsif arg =~ /^[^\-]/
          next
        else
          real_arguments << normalize_argument(arg)
        end
      end
      config_args = real_arguments.join(",")
      return "-C #{quote(config_args)}" unless config_args.strip.empty?
    rescue LoadError
    end
  end
  return ""
end

[Source]

# File lib/rvm/install_command_dumper.rb, line 15
def normalize_argument(arg)
  real_value, arg_value = arg.split("=", 2)
  if !arg_value.nil?
    real_value << "=#{quote(arg_value)}"
  end
  real_value.gsub("'#{RVM_HOME}", "'\"$rvm_path\"'")
end

[Source]

# File lib/rvm/install_command_dumper.rb, line 10
def quote(value)
  value = value.to_s.strip
  value.empty? ? "" : "'#{value.gsub("'", "'\'\'")}'"
end

[Source]

# File lib/rvm/install_command_dumper.rb, line 6
def ruby?(*names)
  names.map { |n| n.to_s }.include?(RUBY_NAME.split("-").first)
end

[Validate]