Sha256: b83d1002ffbe11ba67c9c22f51df81bae7510cc0c954db8ffe9c1bba4305fc3e

Contents?: true

Size: 1.34 KB

Versions: 59

Compression:

Stored size: 1.34 KB

Contents

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

RUBY_NAME = File.basename(ENV['MY_RUBY_HOME'])
RVM_HOME  = ENV['rvm_path']

def ruby?(*names)
  names.map { |n| n.to_s }.include?(RUBY_NAME.split("-").first)
end

def quote(value)
  value = value.to_s.strip
  value.empty? ? "" : "'#{value.gsub("'", "'\'\'")}'"
end

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

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

# Finally, print the string to install it.
puts "rvm install #{RUBY_NAME} #{arguments_for_install.gsub(/''+/, "'")}".strip

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
rvm-1.9.2 lib/rvm/install_command_dumper.rb
rvm-1.9.1 lib/rvm/install_command_dumper.rb
rvm-1.9.0 lib/rvm/install_command_dumper.rb
rvm-1.8.6 lib/rvm/install_command_dumper.rb
rvm-1.8.5 lib/rvm/install_command_dumper.rb
rvm-1.8.4 lib/rvm/install_command_dumper.rb
rvm-1.8.3 lib/rvm/install_command_dumper.rb
rvm-1.8.2 lib/rvm/install_command_dumper.rb
rvm-1.8.1 lib/rvm/install_command_dumper.rb
rvm-1.7.0 lib/rvm/install_command_dumper.rb
rvm-1.6.32 lib/rvm/install_command_dumper.rb
rvm-1.6.31 lib/rvm/install_command_dumper.rb
rvm-1.6.30 lib/rvm/install_command_dumper.rb
rvm-1.6.29 lib/rvm/install_command_dumper.rb
rvm-1.6.27 lib/rvm/install_command_dumper.rb
rvm-1.6.24 lib/rvm/install_command_dumper.rb
rvm-1.6.23 lib/rvm/install_command_dumper.rb
rvm-1.6.22 lib/rvm/install_command_dumper.rb
rvm-1.6.21 lib/rvm/install_command_dumper.rb
rvm-1.6.20 lib/rvm/install_command_dumper.rb