Class: Popo::RVM

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/popo/rvm.rb

Constant Summary

Constants included from Constants

Constants::COLOR_GREEN, Constants::COLOR_NONE, Constants::COLOR_RED, Constants::COLOR_YELLOW, Constants::DEFAULT_CONFIG_FILE, Constants::DEFAULT_POPO_TARGET, Constants::POPORC, Constants::POPO_COMMANDS, Constants::POPO_CONFIG, Constants::POPO_DIR_KEY, Constants::POPO_KEY_VALUES, Constants::POPO_WORK_PATH, Constants::POPO_YML_FILE, Constants::POST_INSTALL_NOTE, Constants::REQUIRED_COMMANDS

Instance Method Summary collapse

Constructor Details

#initialize(runner) ⇒ RVM

Returns a new instance of RVM.



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

def initialize(runner)
  @db       = runner.database
  @repos    = runner.args
  @rvm_bin  = File.join(runner.app_root, 'rvm/bin/rvm')
  @app_root = runner.app_root

  if @db.has_key?("rvm.gems.source")
    @default_gem_source = @db.get("rvm.gems.source")
  end

  get_rubies
  set_rubies
end

Instance Method Details

#get_rubiesObject



19
20
21
# File 'lib/popo/rvm.rb', line 19

def get_rubies
  @rubies = @db.get("rvm.rubies").split(",")
end

#install_default_gems(ruby_version) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/popo/rvm.rb', line 52

def install_default_gems(ruby_version)
  gem_source = ''
  gem_bin = File.join(@app_root, 'rvm', 'bin', "gem-#{ruby_version}")

  @default_gems.each do |g|
    if @db.has_key?("rvm.gems.default.#{g}.source")
      gem_source = @db.get("rvm.gems.default.#{g}.source")
    end

    if !gem_source.empty?
     gem_cmd = "#{gem_bin} install #{g} --source #{gem_source} --no-ri --no-rdoc"
    elsif !@default_gem_source.empty?
     gem_cmd = "#{gem_bin} install #{g} --source #{@default_gem_source} --no-ri --no-rdoc"
    else
     gem_cmd = "#{gem_bin} install #{g} --no-ri --no-rdoc"
    end

    system(gem_cmd)
  end
end

#set_rubiesObject



23
24
25
26
# File 'lib/popo/rvm.rb', line 23

def set_rubies
  @default_ruby = @db.get("rvm.ruby.default")
  @default_gems = @db.get_children("rvm.gems.default")
end

#setupObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/popo/rvm.rb', line 28

def setup
  Utils.say "Rubies to be installed #{@rubies}...\n"

  @rubies.each do |r|
    patch = File.join(@app_root, 'rvm', "#{r}.patch")

    if File.exists?(patch)
      Utils.say("Patch for #{r} is found at #{patch}")
      cmd = "#{@rvm_bin} install #{r} --patch #{patch} --force"
    else
      cmd = "#{@rvm_bin} install #{r} --force"
    end

    system(cmd)
    install_default_gems(r)
  end

  Utils.say_with_time "Setting #{@default_ruby} as default ruby..." do
   `#{@rvm_bin} --default #{@default_ruby}`
  end

  Utils.say(POST_INSTALL_NOTE)
end