Class: Servitor::VagrantBoxRubyInstaller

Inherits:
Object
  • Object
show all
Defined in:
lib/provisioners/vagrant_box_ruby_installer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(requirements) ⇒ VagrantBoxRubyInstaller

Returns a new instance of VagrantBoxRubyInstaller.



6
7
8
# File 'lib/provisioners/vagrant_box_ruby_installer.rb', line 6

def initialize(requirements)
  @requirements = requirements
end

Instance Attribute Details

#requirementsObject (readonly)

Returns the value of attribute requirements.



4
5
6
# File 'lib/provisioners/vagrant_box_ruby_installer.rb', line 4

def requirements
  @requirements
end

Instance Method Details

#install(box) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/provisioners/vagrant_box_ruby_installer.rb', line 10

def install(box)
  return if already_installed?(box)
  box.ssh('which curl || sudo apt-get install curl -y')
  case @requirements.ruby_version
  when /jruby/
    box.ssh('sudo apt-get install g++ openjdk-6-jre-headless -y')
  when /ironruby/
    box.ssh('sudo apt-get install mono-2.0-devel -y')
  else
    box.ssh('sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config -y')
  end
  box.ssh('which rvm || curl -L https://get.rvm.io | bash -s stable', :ignore_exit_code => true)
  box.ssh('which curl || sudo apt-get install curl -y')
  box.ssh("rvm install #{@requirements.ruby_version}", :ignore_exit_code => true)
  box.ssh("rvm use #{@requirements.ruby_version} --default")
end