Class: Loom::Shell::CmdResult

Inherits:
Object
  • Object
show all
Defined in:
lib/loom/shell/cmd_result.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, stdout, stderr, exit_status, is_test, shell) ⇒ CmdResult

Returns a new instance of CmdResult.



3
4
5
6
7
8
9
10
11
# File 'lib/loom/shell/cmd_result.rb', line 3

def initialize(command, stdout, stderr, exit_status, is_test, shell)
  @command = command
  @stdout = stdout
  @stderr = stderr
  @exit_status = exit_status
  @is_test = is_test
  @time = Time.now
  @shell = shell
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



13
14
15
# File 'lib/loom/shell/cmd_result.rb', line 13

def command
  @command
end

#exit_statusObject (readonly)

Returns the value of attribute exit_status.



13
14
15
# File 'lib/loom/shell/cmd_result.rb', line 13

def exit_status
  @exit_status
end

#is_testObject (readonly)

Returns the value of attribute is_test.



13
14
15
# File 'lib/loom/shell/cmd_result.rb', line 13

def is_test
  @is_test
end

#stderrObject (readonly)

Returns the value of attribute stderr.



13
14
15
# File 'lib/loom/shell/cmd_result.rb', line 13

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



13
14
15
# File 'lib/loom/shell/cmd_result.rb', line 13

def stdout
  @stdout
end

#timeObject (readonly)

Returns the value of attribute time.



13
14
15
# File 'lib/loom/shell/cmd_result.rb', line 13

def time
  @time
end

Class Method Details

.create_from_sshkit_command(cmd, is_test, shell) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/loom/shell/cmd_result.rb', line 24

def self.create_from_sshkit_command(cmd, is_test, shell)
  CmdResult.new cmd.command,
                    cmd.full_stdout,
                    cmd.full_stderr,
                    cmd.exit_status,
                    is_test,
                    shell
end

Instance Method Details

#pipe(*cmd, fd: :stdout) ⇒ Object



19
20
21
22
# File 'lib/loom/shell/cmd_result.rb', line 19

def pipe(*cmd, fd: :stdout)
  puts "stdout >>> " + @stdout.inspect
  @shell.pipe [:"/bin/echo", "-e", @stdout], [*cmd]
end

#success?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/loom/shell/cmd_result.rb', line 15

def success?
  @exit_status == 0
end