Sha256: 3b5edf69c65a09548c8bd5fb362555b7922e9fd87b9ed8e05919e39cc0e09150

Contents?: true

Size: 1016 Bytes

Versions: 16

Compression:

Stored size: 1016 Bytes

Contents

module RVM
  class Environment

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

    # Returns the path to the env file
    def env_path
      rvm(:env, environment_name, :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 & 2 rubygems

Version Path
rvm-1.0.19 lib/rvm/environment/env.rb
rvm-1.0.18 lib/rvm/environment/env.rb
rvm-1.0.17 lib/rvm/environment/env.rb
rvm-1.0.15 lib/rvm/environment/env.rb
gemrage-1.0.0 vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/env.rb
gemrage-0.4.1 vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/env.rb
gemrage-0.4.0 vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/env.rb
gemrage-0.3.2 vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/env.rb
gemrage-0.3.1 vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/env.rb
gemrage-0.3.0 vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/env.rb
gemrage-0.2.0 vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/env.rb
gemrage-0.1.2 vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/env.rb
rvm-1.0.14 lib/rvm/environment/env.rb
rvm-1.0.13 lib/rvm/environment/env.rb
rvm-1.0.11 lib/rvm/environment/env.rb
rvm-1.0.10 lib/rvm/environment/env.rb