Class: Gitw::ExecResult

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/gitw/exec.rb

Overview

exec result

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(commands:, options:, status:, stdout:, stderr:) ⇒ ExecResult

Returns a new instance of ExecResult.



42
43
44
45
46
47
48
# File 'lib/gitw/exec.rb', line 42

def initialize(commands:, options:, status:, stdout:, stderr:)
  @commands = commands
  @options = options
  @status = status
  @stdout = stdout
  @stderr = stderr
end

Instance Attribute Details

#commandsObject (readonly)

Returns the value of attribute commands.



40
41
42
# File 'lib/gitw/exec.rb', line 40

def commands
  @commands
end

#optionsObject (readonly)

Returns the value of attribute options.



40
41
42
# File 'lib/gitw/exec.rb', line 40

def options
  @options
end

#statusObject (readonly)

Returns the value of attribute status.



40
41
42
# File 'lib/gitw/exec.rb', line 40

def status
  @status
end

#stderrObject (readonly)

Returns the value of attribute stderr.



40
41
42
# File 'lib/gitw/exec.rb', line 40

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



40
41
42
# File 'lib/gitw/exec.rb', line 40

def stdout
  @stdout
end

Class Method Details

.from_exception(exception, commands: nil, options: nil) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/gitw/exec.rb', line 56

def self.from_exception(exception, commands: nil, options: nil)
  exception.extend AsAProcessStatus
  new(commands: commands,
      options: options,
      status: exception,
      stdout: nil,
      stderr: "Exception: #{exception}")
end

Instance Method Details

#raise_on_failure(exception = RuntimeError) ⇒ Object

Raises:

  • (exception)


50
51
52
53
54
# File 'lib/gitw/exec.rb', line 50

def raise_on_failure(exception = RuntimeError)
  return if success?

  raise exception, "git exited #{exitstatus}: #{stderr}"
end