Sha256: 42c924643903521e9e95ae92cd50ad2c24f70fb44b9fdcb8ac89b650cfc5035d

Contents?: true

Size: 843 Bytes

Versions: 4

Compression:

Stored size: 843 Bytes

Contents

module Packer
  module Binary
    # This module handles running the actual CLI commands
    module Command
      module_function

      # Raised when a command either fails or is invalid
      class CommandFailure < StandardError; end

      # Runs the given command with `Core::Kernel.system`
      # Example `run('sub-command -var "key=value" -machine-readable')`
      # @param [String] command the full sub-command to run (including cli arguments)
      # @return [String] true or {CommandFailure}
      def run(command)
        system("#{binary} #{command}") || (raise CommandFailure)
      end

      # Downloads, extracts and returns the path to the binary
      # @return [String] absolute path of the binary
      def binary
        e = Executable.new
        e.download
        e.extract
        e.binary
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
packer-binary-0.2.3 lib/packer/binary/command.rb
packer-binary-0.2.2 lib/packer/binary/command.rb
packer-binary-0.2.1 lib/packer/binary/command.rb
packer-binary-0.2.0 lib/packer/binary/command.rb