Module: Freyr::RVM

Extended by:
RVM
Included in:
RVM
Defined in:
lib/freyr/rvm.rb

Instance Method Summary collapse

Instance Method Details

#gemsets_for(ruby) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/freyr/rvm.rb', line 20

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

#installed?(ruby = nil) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
9
10
11
12
13
14
# File 'lib/freyr/rvm.rb', line 5

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

#rubiesObject



16
17
18
# File 'lib/freyr/rvm.rb', line 16

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