Sha256: 4e12212ea07f73a29a48c414f983c04fac1c183812677669c0554d4ab65e98e0

Contents?: true

Size: 592 Bytes

Versions: 6

Compression:

Stored size: 592 Bytes

Contents

# frozen_string_literal: true

class Rustic::Wrapper
  include Console

  class ExitStatusError < Rustic::Error; end
  class ExecutionError < Rustic::Error; end

  def initialize(argv, env_variables = {})
    @argv = argv
    @env_variables = env_variables
  end

  def run
    logger.info(self, "Executing:", @argv)
    begin
      status = Async::Process.spawn(@env_variables, *@argv)
    rescue StandardError
      raise ExecutionError
    end
    return if status.exitstatus.zero? # TODO: check #success?

    raise ExitStatusError, "Exit status is not 0: #{status.exitstatus}"
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rustic-0.4.0 lib/rustic/wrapper.rb
rustic-0.3.3 lib/rustic/wrapper.rb
rustic-0.3.2 lib/rustic/wrapper.rb
rustic-0.3.1 lib/rustic/wrapper.rb
rustic-0.3.0 lib/rustic/wrapper.rb
rustic-0.1.0 lib/rustic/wrapper.rb