Class: R10K::Util::Subprocess::Result Private

Inherits:
Object
  • Object
show all
Defined in:
lib/r10k/util/subprocess/result.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv, stdout, stderr, exit_code) ⇒ Result

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Result.



24
25
26
27
28
29
30
# File 'lib/r10k/util/subprocess/result.rb', line 24

def initialize(argv, stdout, stderr, exit_code)
  @argv = argv
  @cmd = argv.join(' ')
  @stdout = stdout.chomp
  @stderr = stderr.chomp
  @exit_code = exit_code
end

Instance Attribute Details

#argvObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



6
7
8
# File 'lib/r10k/util/subprocess/result.rb', line 6

def argv
  @argv
end

#cmdObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
# File 'lib/r10k/util/subprocess/result.rb', line 10

def cmd
  @cmd
end

#exit_codeObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



22
23
24
# File 'lib/r10k/util/subprocess/result.rb', line 22

def exit_code
  @exit_code
end

#stderrObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



18
19
20
# File 'lib/r10k/util/subprocess/result.rb', line 18

def stderr
  @stderr
end

#stdoutObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



14
15
16
# File 'lib/r10k/util/subprocess/result.rb', line 14

def stdout
  @stdout
end

Instance Method Details

#failed?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


49
50
51
# File 'lib/r10k/util/subprocess/result.rb', line 49

def failed?
  exit_code != 0
end

#format(with_cmd = true) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/r10k/util/subprocess/result.rb', line 32

def format(with_cmd = true)
  msg = []
  if with_cmd
    msg << "Command: #{@cmd}"
  end
  if !@stdout.empty?
    msg << "Stdout:"
    msg << @stdout
  end
  if !@stderr.empty?
    msg << "Stderr:"
    msg << @stderr
  end
  msg << "Exit code: #{@exit_code}"
  msg.join("\n")
end

#success?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


53
54
55
# File 'lib/r10k/util/subprocess/result.rb', line 53

def success?
  exit_code == 0
end