Sha256: 223bd27bd739f14b4a0567dcad85436c5748bb8ecbd584d8f6b7f363d7f56316

Contents?: true

Size: 669 Bytes

Versions: 1

Compression:

Stored size: 669 Bytes

Contents

module Freyr
  module RVM
    extend self

    def installed? ruby=nil
      return !`which rvm`.empty? unless ruby

      ruby, gemset = ruby.split('@')
      if rubies.include? ruby
        gemset ? gemsets_for(ruby).include?(gemset) : true
      else
        false
      end
    end

    def rubies
      @rubies ||= `rvm list strings`.chomp.split("\n")
    end

    def gemsets_for ruby
      @gemsets_for ||= Hash.new do |h,ruby|
        output = `rvm #{ruby} exec rvm gemset list strings`.chomp.split("\n")
        h[ruby] = output.collect do |line|
          line.strip.sub(/\s\(.+\)/,'')
        end.compact
      end
      @gemsets_for[ruby]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
freyr-0.5.2 lib/freyr/rvm.rb