Sha256: 6ce14b6829e07fe174c52e5807a8049d50e2c61c627a9e08c3eb5ca710973588

Contents?: true

Size: 1.34 KB

Versions: 36

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, :mput, :ree)
    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

36 entries across 36 versions & 2 rubygems

Version Path
rvm-1.0.10 lib/rvm/install_command_dumper.rb
rvm-1.0.9 lib/rvm/install_command_dumper.rb
rvm-1.0.8 lib/rvm/install_command_dumper.rb
rvm-1.0.7 lib/rvm/install_command_dumper.rb
rvm-1.0.6 lib/rvm/install_command_dumper.rb
rvm-1.0.5 lib/rvm/install_command_dumper.rb
rvm-1.0.4 lib/rvm/install_command_dumper.rb
rvm-1.0.3 lib/rvm/install_command_dumper.rb
rvm-1.0.2 lib/rvm/install_command_dumper.rb
rvm-1.0.1 lib/rvm/install_command_dumper.rb
rvm-1.0.0 lib/rvm/install_command_dumper.rb
rvm-0.1.47 lib/rvm/install_command_dumper.rb
rvm-0.1.46 lib/rvm/install_command_dumper.rb
rvm-0.1.45 lib/rvm/install_command_dumper.rb
rvm-0.1.44 lib/rvm/install_command_dumper.rb
rvm-0.1.43 lib/rvm/install_command_dumper.rb