File: command_result.rb

package info (click to toggle)
ruby-specinfra 2.76.9-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,144 kB
  • sloc: ruby: 9,280; sh: 4; makefile: 3
file content (28 lines) | stat: -rw-r--r-- 611 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module Specinfra
  class CommandResult
    attr_reader :stdout, :stderr, :exit_status, :exit_signal

    def initialize(args = {})
      @stdout = args[:stdout] || ''
      @stderr = args[:stderr] || ''
      @exit_status = args[:exit_status] || 0
      @exit_signal = args[:exit_signal]
    end

    def success?
      @exit_status == 0
    end

    def failure?
      @exit_status != 0
    end

    def [](x)
      warn "CommandResult#[] is obsolete. Use accessors instead. in #{caller[0]}"
      case x
      when :stdout, :stderr, :exit_status, :exit_signal
        self.send(x)
      end
    end
  end
end