Module: VagrantPlugins::Ventriloquist::Cap::Debian::PhantomjsInstall

Defined in:
lib/ventriloquist/cap/platforms/debian/phantomjs_install.rb

Class Method Summary collapse

Class Method Details

.phantomjs_install(machine, version) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ventriloquist/cap/platforms/debian/phantomjs_install.rb', line 6

def self.phantomjs_install(machine, version)
  if machine.communicate.test('which phantomjs > /dev/null')
    machine.env.ui.info("Skipping phantomjs installation")
    return
  end

  src_1      = "https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-#{version}-linux-x86_64.tar.bz2"
  src_2      = "https://phantomjs.googlecode.com/files/phantomjs-#{version}-linux-x86_64.tar.bz2"
  executable = "/usr/local/share/phantomjs-#{version}-linux-x86_64/bin/phantomjs"

  machine.env.ui.info("Installing phantomjs #{version}")
  machine.communicate.tap do |comm|
    comm.sudo('apt-get install -y fontconfig libfreetype6 curl -y -q')
    path = download_path(comm, version)
    unless comm.test("test -f #{path}")
      machine.guest.capability(:download, [src_1, src_2], path)
    end
    comm.sudo("tar xjfv #{path} -C /usr/local/share")
    comm.sudo("ln -s #{executable} /usr/local/bin/phantomjs")
  end
end