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.1.0 lib/rvm/install_command_dumper.rb
rvm-1.0.23 lib/rvm/install_command_dumper.rb
rvm-1.0.22 lib/rvm/install_command_dumper.rb
rvm-1.0.21 lib/rvm/install_command_dumper.rb
rvm-1.0.20 lib/rvm/install_command_dumper.rb
rvm-1.0.19 lib/rvm/install_command_dumper.rb
rvm-1.0.18 lib/rvm/install_command_dumper.rb
rvm-1.0.17 lib/rvm/install_command_dumper.rb
rvm-1.0.15 lib/rvm/install_command_dumper.rb
gemrage-1.0.0 vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/install_command_dumper.rb
gemrage-0.4.1 vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/install_command_dumper.rb
gemrage-0.4.0 vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/install_command_dumper.rb
gemrage-0.3.2 vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/install_command_dumper.rb
gemrage-0.3.1 vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/install_command_dumper.rb
gemrage-0.3.0 vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/install_command_dumper.rb
gemrage-0.2.0 vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/install_command_dumper.rb
gemrage-0.1.2 vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/install_command_dumper.rb
rvm-1.0.14 lib/rvm/install_command_dumper.rb
rvm-1.0.13 lib/rvm/install_command_dumper.rb
rvm-1.0.11 lib/rvm/install_command_dumper.rb