Sha256: 18b22765548da5f8e6e9238fa4608926483dfbbc9cc268800cb8c3857be25a23

Contents?: true

Size: 1.43 KB

Versions: 6

Compression:

Stored size: 1.43 KB

Contents

module RVM
  class Environment

    # Gets the full name for the current env.
    def tools_identifier
      normalize rvm(:tools, :identifier).stdout
    end

    # Gets the identifier after cd'ing to a path, no destructive.
    def tools_path_identifier(path)
      normalize rvm(:tools, "path-identifier", path.to_s).stdout
    end

    def tools_strings(*rubies)
      rubies = rubies.flatten.join(",").split(",").uniq
      names = {}
      value = rvm(:tools, :strings, *rubies)
      if value.successful?
        parts = value.stdout.split("\n").map { |l| l.split }
        rubies.each_with_index do |key, index|
          names[key] = normalize(parts[index])
        end
      end
      names
    end

    # Return the tools wrapper.
    def tools
      @tools_wrapper ||= ToolsWrapper.new(self)
    end

    # Ruby like wrapper for tools
    class ToolsWrapper

      def initialize(parent)
        @parent = parent
      end

      # Returns the current envs expanded identifier
      def identifier
        @parent.tools_identifier
      end

      # Returns the identifier for a path, taking into account
      # things like an rvmrc
      def path_identifier(path)
        @parent.tools_path_identifier(File.expand_path(path))
      end
      alias identifier_for_path path_identifier

      def strings(*rubies)
        @parent.tools_strings(*rubies)
      end

      def expand_string(ruby)
        strings(ruby)[ruby]
      end

    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rvm-1.0.0 lib/rvm/environment/tools.rb
rvm-0.1.47 lib/rvm/environment/tools.rb
rvm-0.1.46 lib/rvm/environment/tools.rb
rvm-0.1.45 lib/rvm/environment/tools.rb
rvm-0.1.44 lib/rvm/environment/tools.rb
rvm-0.1.43 lib/rvm/environment/tools.rb