Class: Plywood::CommandReport

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/plywood/command_report.rb

Overview

A small report to show after the command has run.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, status) ⇒ CommandReport

Returns a new instance of CommandReport.

Raises:

  • (ArgumentError)


12
13
14
15
16
17
# File 'lib/plywood/command_report.rb', line 12

def initialize(command, status)
  raise ArgumentError, "command is nil" if command.nil?
  raise ArgumentError, "status is nil" if status.nil?
  @command = command
  @status = status
end

Class Method Details

.gather(status, commands) ⇒ Object



19
20
21
22
# File 'lib/plywood/command_report.rb', line 19

def self.gather(status, commands)
  command = commands.find { |item| item.pid == status.pid }
  new(command, status)
end

Instance Method Details

#to_sObject



24
25
26
27
28
29
30
# File 'lib/plywood/command_report.rb', line 24

def to_s
  if success?
    "#{name} was successful."
  else
    "#{name} failed with exit status #{to_i} (`#{command}`)."
  end
end