Sha256: c29a92a5254084570e6c0ddd1ed2476796b24fd988251652270ff8048f6d198c

Contents?: true

Size: 1.52 KB

Versions: 3

Compression:

Stored size: 1.52 KB

Contents

module VagrantPlugins
  module Ventriloquist
    module Cap
      module Debian
        module ElixirInstall
          ELIXIR_PRECOMPILED = "https://github.com/elixir-lang/elixir/releases/download/vVERSION/vVERSION.zip"

          def self.elixir_install(machine,version)
            @version = version

            machine.communicate.tap do |comm|
              if ! comm.test('which iex > /dev/null')
                bin_path = "/usr/local/elixir/bin"
                ELIXIR_PRECOMPILED.gsub!(/VERSION/,@version)

                machine.env.ui.info("Installing Elixir #{@version}")

                path = download_path(comm)

                unless comm.test("test -f #{path}")
                  machine.guest.capability(:download, ELIXIR_PRECOMPILED, path)
                end

                comm.sudo('apt-get install -y unzip')
                comm.sudo("unzip -o #{path} -d /usr/local/elixir")

                if ! comm.test("grep -q '#{bin_path}' /etc/profile.d/ventriloquist.sh 2>/dev/null")
                  comm.sudo("echo 'export PATH=$PATH:#{bin_path}' >> /etc/profile.d/ventriloquist.sh")
                end
              end
            end
          end

          private

          def self.download_path(comm)
            # If vagrant-cachier apt cache bucket is available, drop it there
            if comm.test("test -d /tmp/vagrant-cache")
              "/tmp/vagrant-cache/elixir-v#{@version}.zip"
            else
              "/tmp/elixir-v#{@version}.zip"
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ventriloquist-0.3.2 lib/ventriloquist/cap/debian/elixir_install.rb
ventriloquist-0.3.1 lib/ventriloquist/cap/debian/elixir_install.rb
ventriloquist-0.3.0 lib/ventriloquist/cap/debian/elixir_install.rb