Class RVM::Environment
In: lib/rvm/environment.rb
lib/rvm/environment/cleanup.rb
lib/rvm/environment/configuration.rb
lib/rvm/environment/tools.rb
lib/rvm/environment/info.rb
lib/rvm/environment/env.rb
lib/rvm/environment/rubies.rb
lib/rvm/environment/list.rb
lib/rvm/environment/wrapper.rb
lib/rvm/environment/gemset.rb
lib/rvm/environment/sets.rb
lib/rvm/environment/utility.rb
lib/rvm/environment/alias.rb
Parent: Object

Implements the actual wrapper around the api. For more information about this design, see the RVM module.

Methods

alias_create   alias_delete   alias_list   alias_show   aliases   chdir   cleanup   compatible_with_current?   config_value_for   config_value_for   current   current_environment_id   current_ruby_string   default_rvm_path   default_wrappers   define_config_accessor   defined_config   env   env_contents   env_path   environment_with_gemset   exec   expanded_name   extract_environment!   extract_identifier!   extract_options!   gemset   gemset_copy   gemset_create   gemset_delete   gemset_dump   gemset_empty   gemset_export   gemset_globalcache   gemset_import   gemset_intial   gemset_list   gemset_load   gemset_pristine   gemset_prune   gemset_update   gemset_use   gemset_use!   hash_to_options   identifier_to_ruby_string   info   inspect   install   list   list_default   list_gemsets   list_known   list_known_strings   list_ruby_svn_tags   list_strings   new   normalize   normalize_array   normalize_listing_output   normalize_option_value   normalize_ruby_string   normalize_set_identifier   path_for   perform_set_operation   rake   rearrange_options!   remove   reset_current!   ruby   ruby_eval   ruby_run   ruby_string   rvm   source_rvm_environment   specs   system   tests   tools   tools_identifier   tools_path_identifier   tools_strings   uninstall   use   use!   use_env_from_result!   use_from_path!   use_rvm_environment   which   wrapper   wrapper_path_for  

Included Modules

ConfigMixin

Classes and Modules

Module RVM::Environment::ConfigMixin
Class RVM::Environment::AliasWrapper
Class RVM::Environment::CleanupWrapper
Class RVM::Environment::EnvWrapper
Class RVM::Environment::GemsetWrapper
Class RVM::Environment::ListWrapper
Class RVM::Environment::ToolsWrapper

Constants

PREFIX_OPTIONS = [:trace, :json, :yaml]

Attributes

environment_name  [R] 
shell_wrapper  [R] 

Public Class methods

Gets the default option or the current environment variable for a given env var.

[Source]

# File lib/rvm/environment/configuration.rb, line 40
    def self.config_value_for(value)
      value = value.to_s
      config[value] || ENV[value]
    end

Returns the currentl environment. Note that when the ruby is changed, this is reset - Also, if the gemset is changed it will also be reset.

[Source]

# File lib/rvm/environment/utility.rb, line 38
    def self.current
      @current_environment ||= Environment.new(current_environment_id)
    end

Returns the environment identifier for the current environment, as determined from the GEM_HOME.

[Source]

# File lib/rvm/environment/utility.rb, line 13
    def self.current_environment_id
      @current_environment_id ||= begin
        gem_home = ENV['GEM_HOME'].to_s.strip
        if !gem_home.empty? && gem_home =~ /rvm\/gems\//
          File.basename(gem_home)
        else
          matching_path = $:.select { |item| item =~ /rvm\/rubies/ }.first
          matching_path.to_s.gsub(/^.*rvm\/rubies\//, '').split('/')[0] || "system"
        end
      end
    end

Returns the ruby string that represents the current environment.

[Source]

# File lib/rvm/environment/utility.rb, line 26
    def self.current_ruby_string
      identifier_to_ruby_string(current_environment_id)
    end

[Source]

# File lib/rvm/environment/utility.rb, line 6
    def self.default_rvm_path
      value = `bash '#{File.expand_path('../shell/calculate_rvm_path.sh', File.dirname(__FILE__))}'`.strip
      $?.success? && !value.empty? ? File.expand_path(value) : nil
    end

Define the config accessor, which basically uses config_value_for and the linke to set the env variable.

[Source]

# File lib/rvm/environment/configuration.rb, line 6
    def self.define_config_accessor(*args)
      singleton = (class << self; self; end)
      args.each do |arg|
        singleton.send(:define_method, arg)        { RVM::Environment.config_value_for(arg) }
        singleton.send(:define_method, "#{arg}=""#{arg}=") { |v| RVM::Environment.merge_config! arg => v }
      end
    end

Converts a ruby identifier (string + gemset) to just the ruby string.

[Source]

# File lib/rvm/environment/utility.rb, line 31
    def self.identifier_to_ruby_string(identifier)
      identifier.gsub(/@.*$/, '')
    end

Creates a new environment with the given name and optionally a set of extra environment variables to be set on load.

[Source]

# File lib/rvm/environment.rb, line 22
    def initialize(environment_name = "default", options = {})
      merge_config! options
      @environment_name = environment_name
      @shell_wrapper = Shell.default_wrapper.new
      @shell_wrapper.setup do |s|
        source_rvm_environment
        use_rvm_environment
      end
    end

Sets the current environment back to the currently running ruby or the system env (if it can‘t be determined from GEM_HOME).

[Source]

# File lib/rvm/environment/utility.rb, line 44
    def self.reset_current!
      @current_environment = nil
    end

Protected Class methods

Given an environment identifier, it will add the the given gemset to the end to form a qualified identifier name.

[Source]

# File lib/rvm/environment/utility.rb, line 110
    def self.environment_with_gemset(environment, gemset)
      environment_name, gemset_name = environment.split("@", 2)
      environment_name = "default"     if environment_name.to_s.empty?
      environment_name << "@#{gemset}" unless gemset.to_s.empty?
      environment_name
    end

Public Instance methods

Creates an alias with the given name.

[Source]

# File lib/rvm/environment/alias.rb, line 27
    def alias_create(name, ruby_string)
      rvm(:alias, :create, name.to_s, ruby_string.to_s).successful?
    end

Deletes an alias and returns the exit status.

[Source]

# File lib/rvm/environment/alias.rb, line 22
    def alias_delete(name)
      rvm(:alias, :delete, name.to_s).successful?
    end

Returns a hash of aliases.

[Source]

# File lib/rvm/environment/alias.rb, line 5
    def alias_list
      lines = normalize_array(rvm(:alias, :list).stdout)
      lines.inject({}) do |acc, current|
        alias_name, ruby_string = current.to_s.split(" => ")
        unless alias_name.empty? || ruby_string.empty?
          acc[alias_name] = ruby_string
        end
        acc
      end
    end

Shows the full ruby string that a given alias points to.

[Source]

# File lib/rvm/environment/alias.rb, line 17
    def alias_show(name)
      normalize rvm(:alias, :show, name.to_s).stdout
    end

Returns an aliases proxy which can be used in a more Ruby-like manner.

[Source]

# File lib/rvm/environment/alias.rb, line 32
    def aliases
      @aliases ||= AliasWrapper.new(self)
    end

Run commands inside the given directory.

[Source]

# File lib/rvm/environment/utility.rb, line 72
    def chdir(dir)
      run_silently :pushd, dir.to_s
      result = Dir.chdir(dir) { yield }
      run_silently :popd
      result
    end

Returns the ruby-like interface defined by CleanupWrapper

[Source]

# File lib/rvm/environment/cleanup.rb, line 12
    def cleanup
      @cleanup_wrapper ||= CleanupWrapper.new(self)
    end

Returns the value for a configuration option (mapping to an environment variable). If check_live is true (which it is by default), it will also check the environment for a value.

[Source]

# File lib/rvm/environment/configuration.rb, line 48
    def config_value_for(key, default = nil, check_live = true)
      key = key.to_s
      value = check_live ? self[key.to_s] : nil
      value || config[key] || self.class.config_value_for(key) || default
    end

Generates the default wrappers.

[Source]

# File lib/rvm/environment/wrapper.rb, line 11
    def default_wrappers(ruby_string, *binaries)
      wrapper ruby_string, '', *binaries
    end

Returns a hash of all of the user defined configuration.

[Source]

# File lib/rvm/environment/configuration.rb, line 55
    def defined_config
      self.class.config.merge(self.config)
    end

Returns a ruby-like wrapper for the env functions

[Source]

# File lib/rvm/environment/env.rb, line 15
    def env
      @env_wrapper ||= EnvWrapper.new(self)
    end

Returns the contents of the env file.

[Source]

# File lib/rvm/environment/env.rb, line 5
    def env_contents
      rvm(:env, environment_name).stdout
    end

Returns the path to the env file

[Source]

# File lib/rvm/environment/env.rb, line 10
    def env_path
      rvm(:env, environment_name, :path => true).stdout.strip
    end

Executes a command, replacing the current shell. exec is a bit of an odd ball compared to the others, since it has to use the Kernel.exec builtin.

[Source]

# File lib/rvm/environment/sets.rb, line 63
    def exec(command, *args)
      command = @shell_wrapper.build_cli_call(:exec, [command] + args)
      Kernel.exec "bash", "-c", "source '#{env_path}'; #{command}"
    end

Returns the expanded name, using the same method as used by the rvm command line.

[Source]

# File lib/rvm/environment.rb, line 37
    def expanded_name
      @expanded_name ||= tools_identifier.to_s
    end

Returns the Ruby-like wrapper for gemset operations.

[Source]

# File lib/rvm/environment/gemset.rb, line 107
    def gemset
      @gemset_wrapper ||= GemsetWrapper.new(self)
    end

Copies the gems between two different gemsets.

[Source]

# File lib/rvm/environment/gemset.rb, line 31
    def gemset_copy(from, to)
      rvm(:gemset, :copy, from, to).successful?
    end

Creates a new gemset with the given name.

[Source]

# File lib/rvm/environment/gemset.rb, line 25
    def gemset_create(*names)
      names = names.flatten
      rvm(:gemset, :create, *names).successful?
    end

Deletes the gemset with a given name.

[Source]

# File lib/rvm/environment/gemset.rb, line 36
    def gemset_delete(name)
      run("echo 'yes' | rvm", :gemset, :delete, name.to_s).successful?
    end
gemset_dump(gemset_or_file = nil)

Alias for gemset_export

Removes all gem-related stuff from the current gemset.

[Source]

# File lib/rvm/environment/gemset.rb, line 41
    def gemset_empty
      run("echo 'yes' | rvm", :gemset, :empty).successful?
    end

Exports a gemset.

[Source]

# File lib/rvm/environment/gemset.rb, line 14
    def gemset_export(gemset_or_file = nil)
      args = [gemset_or_file].compact
      rvm(:gemset, :export, *args).successful?
    end

Enable or disable the rvm gem global cache.

[Source]

# File lib/rvm/environment/gemset.rb, line 66
    def gemset_globalcache(enable = true)
      case enable
        when "enabled", :enabled
          run(:__rvm_using_gemset_globalcache).successful?
        when true, "enable", :enable
          rvm(:gemset, :globalcache, :enable).successful?
        when false, "disable", :disable
          rvm(:gemset, :globalcache, :disable).successful?
        else
          false
      end
    end

Loads a gemset into the current environment. If an argument is given, it will load it from file_prefix.gems

[Source]

# File lib/rvm/environment/gemset.rb, line 7
    def gemset_import(file_prefix = nil)
      args = [file_prefix].compact
      rvm(:gemset, :import, *args).successful?
    end

Initializes gemsets for a given ruby.

[Source]

# File lib/rvm/environment/gemset.rb, line 61
    def gemset_intial
      rvm(:gemset, :initial).successful?
    end

[Source]

# File lib/rvm/environment/gemset.rb, line 20
    def gemset_list
      normalize_array rvm(:gemset, :list).stdout
    end
gemset_load(file_prefix = nil)

Alias for gemset_import

Resets the current gemset to a pristine state.

[Source]

# File lib/rvm/environment/gemset.rb, line 46
    def gemset_pristine
      rvm(:gemset, :pristine).successful?
    end

Prunes the gem cache for the current ruby.

[Source]

# File lib/rvm/environment/gemset.rb, line 56
    def gemset_prune
      rvm(:gemset, :prune).successful?
    end

Updates all gems in the current gemset.

[Source]

# File lib/rvm/environment/gemset.rb, line 51
    def gemset_update
      rvm(@environment_name, :gemset, :update).successful?
    end

Changes the current environments gemset. If :replace_env is passed and the ruby is compatible, it will attempt to replace the current processes gem home and path with the one requested.

[Source]

# File lib/rvm/environment/gemset.rb, line 82
    def gemset_use(gemset, options = {})
      replace_env = options.delete(:replace_env)
      result = rvm(:gemset, :use, gemset, options)
      if result.successful?
        gemset_name = result[:rvm_gemset_name]
        @environment_name = self.class.environment_with_gemset(@environment_name, gemset_name)
        @expanded_name    = nil
        self.class.reset_current!
        use_env_from_result! result if replace_env
        true
      end
    end

Like gemset_use, but replaces the env by default.

[Source]

# File lib/rvm/environment/gemset.rb, line 96
    def gemset_use!(name, options = {})
      gemset_use name, {:replace_env => true}.merge(options)
    end

[Source]

# File lib/rvm/environment/info.rb, line 6
    def info(*ruby_strings)
      ruby_string = normalize_ruby_string(ruby_strings)
      res = rvm(:info, ruby_string)
      res.successful? ? YAML.load(res.stdout) : {}
    end

[Source]

# File lib/rvm/environment.rb, line 32
    def inspect
      "#<#{self.class.name} environment_name=#{@environment_name.inspect}>"
    end

Installs the given ruby

[Source]

# File lib/rvm/environment/rubies.rb, line 5
    def install(rubies, opts = {})
      rvm(:install, normalize_ruby_string(rubies), opts).successful?
    end

Returns an interface to a more Ruby-like interface for list.

[Source]

# File lib/rvm/environment/list.rb, line 35
    def list
      @list_helper ||= ListWrapper.new(self)
    end

Lists the default ruby (minus gemset)

[Source]

# File lib/rvm/environment/list.rb, line 15
    def list_default
      normalize rvm(:list, :default, :string).stdout
    end

Returns a raw array list of ruby + gemset combinations.

[Source]

# File lib/rvm/environment/list.rb, line 5
    def list_gemsets
      normalize_listing_output rvm(:list, :gemsets, :strings).stdout
    end

Lists all known ruby strings (raw, filtered output)

[Source]

# File lib/rvm/environment/list.rb, line 20
    def list_known
      normalize_listing_output rvm(:list, :known).stdout
    end

Lists all known ruby strings

[Source]

# File lib/rvm/environment/list.rb, line 25
    def list_known_strings
      normalize_listing_output rvm(:list, :known_strings).stdout
    end

Lists all known svn tags.

[Source]

# File lib/rvm/environment/list.rb, line 30
    def list_ruby_svn_tags
      normalize_listing_output rvm(:list, :ruby_svn_tags).stdout
    end

Returns a raw array list of installed ruby strings, including aliases.

[Source]

# File lib/rvm/environment/list.rb, line 10
    def list_strings
      normalize_listing_output rvm(:list, :strings).stdout.tr(' ', "\n")
    end

Returns the path for the given command

[Source]

# File lib/rvm/environment/env.rb, line 20
    def path_for(command)
      run(:command, "-v", command).stdout.strip
    end

Execute rake (optionally taking the path to a rake file), then change back.

[Source]

# File lib/rvm/environment/sets.rb, line 31
    def rake(file = nil, options = {})
      if file.nil?
        perform_set_operation :rake, options
      else
        file = File.expand_path(file)
        chdir(File.dirname(file)) do
          perform_set_operation(:rake, options.merge(:rakefile => file))
        end
      end
    end

Removes a given ruby from being managed by rvm.

[Source]

# File lib/rvm/environment/rubies.rb, line 15
    def remove(rubies, opts = {})
      rvm(:remove, normalize_ruby_string(rubies), opts).successful?
    end

Passed either something containing ruby code or a path to a ruby file, will attempt to exectute it in the current environment.

[Source]

# File lib/rvm/environment/sets.rb, line 7
    def ruby(runnable, options = {})
      if runnable.respond_to?(:path)
        # Call the path
        ruby_run runnable.path, options
      elsif runnable.respond_to?(:to_str)
        runnable = runnable.to_str
        File.exist?(runnable) ? ruby_run(runnable, options) : ruby_eval(runnable, options)
      elsif runnable.respond_to?(:read)
        ruby_run runnable.read
      end
    end

Eval the given code within ruby.

[Source]

# File lib/rvm/environment/sets.rb, line 20
    def ruby_eval(code, options = {})
      perform_set_operation :ruby, "-e", code.to_s, options
    end

Run the given path as a ruby script.

[Source]

# File lib/rvm/environment/sets.rb, line 25
    def ruby_run(path, options = {})
      perform_set_operation :ruby, path.to_s, options
    end

Lets you build a command up, without needing to see the output. As an example,

 rvm :use, "ree@rails3", :install => true

Will call the following:

 rvm use ree@rails3 --install

[Source]

# File lib/rvm/environment/utility.rb, line 57
    def rvm(*args)
      options = extract_options!(args)
      silent = options.delete(:silent)
      rearrange_options!(args, options)
      args += hash_to_options(options)
      args.map! { |a| a.to_s }

      if silent
        run_silently('rvm', *args)
      else
        run('rvm', *args)
      end
    end

Use the rvm spec runner for specs.

[Source]

# File lib/rvm/environment/sets.rb, line 48
    def specs(options = {})
      perform_set_operation :specs, options
    end

Like Kernel.system, but evaluates it within the environment. Also note that it doesn‘t support redirection etc.

[Source]

# File lib/rvm/environment/sets.rb, line 54
    def system(command, *args)
      identifier = extract_identifier!(args)
      args = [identifier, :exec, command, *args].compact
      rvm(*args).successful?
    end

Use the rvm test runner for unit tests.

[Source]

# File lib/rvm/environment/sets.rb, line 43
    def tests(options = {})
      perform_set_operation :tests, options
    end

Return the tools wrapper.

[Source]

# File lib/rvm/environment/tools.rb, line 34
    def tools
      @tools_wrapper ||= ToolsWrapper.new(self)
    end

Gets the full name for the current env.

[Source]

# File lib/rvm/environment/tools.rb, line 5
    def tools_identifier
      normalize rvm(:tools, :identifier).stdout
    end

Gets the identifier after cd‘ing to a path, no destructive.

[Source]

# File lib/rvm/environment/tools.rb, line 10
    def tools_path_identifier(path)
      path_identifier = rvm(:tools, "path-identifier", path.to_s)
      if path_identifier.exit_status == 2
        error_message = "The rvmrc located in '#{path}' could not be loaded, likely due to trust mechanisms."
        error_message << " Please run 'rvm rvmrc {trust,untrust} \"#{path}\"' to continue, or set rvm_trust_rvmrcs to 1."
        raise ErrorLoadingRVMRC, error_message
      end
      return normalize(path_identifier.stdout)
    end

[Source]

# File lib/rvm/environment/tools.rb, line 20
    def tools_strings(*rubies)
      rubies = rubies.flatten.join(",").split(",").uniq
      names = {}
      value = rvm(:tools, :strings, *rubies)
      if value.successful?
        parts = value.stdout.split
        rubies.each_with_index do |key, index|
          names[key] = normalize(parts[index])
        end
      end
      names
    end

Uninstalls a ruby (remove but keeps src etc)

[Source]

# File lib/rvm/environment/rubies.rb, line 10
    def uninstall(rubies, opts = {})
      rvm(:uninstall, normalize_ruby_string(rubies), opts).successful?
    end

Changes the ruby string for the current environment.

[Source]

# File lib/rvm/environment/rubies.rb, line 20
    def use(ruby_string, opts = {})
      ruby_string = ruby_string.to_s
      result = rvm(:use, ruby_string)
      if result.successful?
        @environment_name = ruby_string
        @expanded_name    = nil
        use_env_from_result! result if opts[:replace_env]
      end
    end

Like use but with :replace_env defaulting to true.

[Source]

# File lib/rvm/environment/rubies.rb, line 31
    def use!(ruby_string, opts = {})
      use ruby_string, opts.merge(:replace_env => true)
    end

Will get the ruby from the given path. If there is a compatible ruby found, it will then attempt to use the associated gemset. e.g. RVM::Environment.current.use_from_path! Dir.pwd

[Source]

# File lib/rvm/environment/rubies.rb, line 39
    def use_from_path!(path)
     use! tools.path_identifier(path)
    end
which(command)

Alias for path_for

Generates wrappers with the specified prefix, pointing to ruby_string.

[Source]

# File lib/rvm/environment/wrapper.rb, line 6
    def wrapper(ruby_string, wrapper_prefix, *binaries)
      rvm(:wrapper, ruby_string, wrapper_prefix, *binaries).successful?
    end

If available, return the path to the wrapper for the given executable. Will return ni if the wrapper is unavailable.

[Source]

# File lib/rvm/environment/wrapper.rb, line 18
    def wrapper_path_for(executable)
      raise NotImplementedError
    end

Protected Instance methods

Checks whether the given environment is compatible with the current ruby interpeter.

[Source]

# File lib/rvm/environment/utility.rb, line 104
    def compatible_with_current?(result)
      ruby_string(result) == self.class.current_ruby_string
    end

From an options hash, extract the environment identifier.

[Source]

# File lib/rvm/environment/sets.rb, line 89
    def extract_environment!(options)
      values = []
      [:environment, :env, :rubies, :ruby].each do |k|
        values << options.delete(k)
      end
      values.compact.first
    end

Shorthand to extra an identifier from args. Since we

[Source]

# File lib/rvm/environment/sets.rb, line 99
    def extract_identifier!(args)
      options = extract_options!(args)
      identifier = normalize_set_identifier(extract_environment!(options))
      args << options
      identifier
    end

Extract options from a hash.

[Source]

# File lib/rvm/environment/utility.rb, line 129
    def extract_options!(args)
      args.last.is_a?(Hash) ? args.pop : {}
    end

Converts a hash of options to an array of command line argumets. If the value is false, it wont be added but if it is true only the key will be added. Lastly, when the value is neither true or false, to_s will becalled on it and it shall be added to the array.

[Source]

# File lib/rvm/environment/utility.rb, line 137
    def hash_to_options(options)
      result = []
      options.each_pair do |key, value|
        real_key = "--#{key.to_s.gsub("_", "-")}"
        if value == true
          result << real_key
        elsif value != false
          result << real_key
          result << value.to_s
        end
      end
      result
    end

Returns a value, or nil if it is blank.

[Source]

# File lib/rvm/environment/utility.rb, line 118
    def normalize(value)
      value = value.to_s.strip
      value.empty? ? nil : value
    end

Normalizes an array, removing blank lines.

[Source]

# File lib/rvm/environment/utility.rb, line 124
    def normalize_array(value)
      value.split("\n").map { |line| line.strip }.reject { |line| line.empty? }
    end

Takes a list of rubies / items, 1 per line and strips comments and blank lines.

[Source]

# File lib/rvm/environment/list.rb, line 114
    def normalize_listing_output(results)
      lines = []
      results.each_line do |line|
        line = line.gsub(/#.*/, '').strip
        lines << line unless line.empty?
      end
      lines.sort
    end

Recursively normalize options.

[Source]

# File lib/rvm/environment/utility.rb, line 152
    def normalize_option_value(value)
      case value
      when Array
        value.map { |option| normalize_option_value(option) }.join(",")
      else
        value.to_s
      end
    end

[Source]

# File lib/rvm/environment/rubies.rb, line 45
    def normalize_ruby_string(rubies)
      Array(rubies).join(",")
    end

Converts the given identifier to a rvm-friendly form. Unlike using sets directly, a nil identifier is set to mean the current ruby (not all). :all or "all" will instead return the a blank identifier / run it against all rubies.

[Source]

# File lib/rvm/environment/sets.rb, line 75
    def normalize_set_identifier(identifier)
      case identifier
      when nil, ""
        @environment_name
      when :all, "all"
        nil
      when Array
        identifier.map { |i| normalize_set_identifier(i) }.uniq.join(",")
      else
        identifier.to_s
      end
    end

Performs a set operation. If the :env or :environment option is given, it will return a yaml summary (instead of the stdout / stderr etc via a Result object.

[Source]

# File lib/rvm/environment/sets.rb, line 109
    def perform_set_operation(*args)
      options     = extract_options!(args)
      environment = extract_environment!(options)
      identifier  = normalize_set_identifier(environment)
      # Uses yaml when we have multiple identifiers.
      uses_yaml   = !environment.nil?
      options.merge!(:yaml => true) if uses_yaml
      args.unshift(identifier) unless identifier.nil?
      args << options
      result = rvm(*args)
      uses_yaml ? YAML.load(result.stdout) : result
    end

Moves certain options (e.g. yaml, json etc) to the front of the arguments list, making stuff like sets work.

[Source]

# File lib/rvm/environment/utility.rb, line 83
    def rearrange_options!(args, options)
      prefix_options = {}
      (PREFIX_OPTIONS + PREFIX_OPTIONS.map { |o| o.to_s }).each do |k|
        if options.has_key?(k)
          value = options.delete(k)
          prefix_options[k.to_sym] = value
        end
      end
      hash_to_options(prefix_options).reverse.each { |o| args.unshift(o) }
    end

[Source]

# File lib/rvm/environment/utility.rb, line 94
    def ruby_string(result)
      if result && result[:rvm_ruby_string]
        result[:rvm_ruby_string]
      else
        self.class.identifier_to_ruby_string(expanded_name)
      end
    end

Automatically load rvm config from the multiple sources.

[Source]

# File lib/rvm/environment.rb, line 48
    def source_rvm_environment
      rvm_path = config_value_for(:rvm_path, self.class.default_rvm_path, false)
      actual_config = defined_config.merge('rvm_path' => rvm_path)
      config = []
      actual_config.each_pair do |k, v|
        config << "#{k}=#{escape_argument(v.to_s)}"
      end
      run_silently :export, config.join(" ")
      run_silently :source, File.join(rvm_path, "scripts", "rvm")
    end

[Source]

# File lib/rvm/environment/utility.rb, line 161
    def use_env_from_result!(result)
      if compatible_with_current?(result)
        ENV['GEM_HOME']    = result[:GEM_HOME]
        ENV['GEM_PATH']    = result[:GEM_PATH]
        ENV['BUNDLE_PATH'] = result[:BUNDLE_PATH]
        Gem.clear_paths if defined?(Gem)
      else
        raise IncompatibleRubyError.new(result, "The given ruby environment requires #{ruby_string(result)} (versus #{self.class.current_ruby_string})")
      end
    end

[Source]

# File lib/rvm/environment.rb, line 59
    def use_rvm_environment
      rvm :use, @environment_name, :silent => true
    end

[Validate]