Sha256: 1980d4118907cd57129e7c9c786a0b57bc776a4dcd2f86f90bff2af13bfe3110

Contents?: true

Size: 980 Bytes

Versions: 16

Compression:

Stored size: 980 Bytes

Contents

module RVM
  class Environment

    # Returns the contents of the env file.
    def env_contents
      rvm(:env).stdout
    end

    # Returns the path to the env file
    def env_path
      rvm(:env, :path => true).stdout.strip
    end

    # Returns a ruby-like wrapper for the env functions
    def env
      @env_wrapper ||= EnvWrapper.new(self)
    end

    # Returns the path for the given command
    def path_for(command)
      run(:command, "-v", command).stdout.strip
    end
    alias which path_for

    # Simple ruby like wrapper for envs.
    class EnvWrapper

      def initialize(parent)
        @parent = parent
      end

      # Contents of the env file.
      def contents
        @parent.env_contents
      end
      alias read contents
      alias to_s contents

      # The path of the env file.
      def path
        @parent.env_path
      end

      # Opens a file on the env file.
      def to_file
        File.open(path)
      end

    end

  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

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