Sha256: dc8d39f2b3e6fcd96e2467a045b7adb18374b9357e7bafe5bcafe3fc5268426a

Contents?: true

Size: 1018 Bytes

Versions: 3

Compression:

Stored size: 1018 Bytes

Contents

require 'toolrack'

module Dockerun

  module Cli
    
    class CommandResult
      include TR::CondUtils

      attr_reader :out, :err, :result
      def initialize(result, out, err)
        @result = result
        @out = out
        @err = err
      end

      def is_out_stream_empty?
        is_empty?(@out)
      end

      def is_err_stream_empty?
        is_empty?(@err)
      end

      def out_stream
        @out.join("\n") 
      end

      def err_stream
        @err.join("\n")
      end

      def failed?
        if @result.nil?
          true
        else
          @result.failed?
        end
      end

      def success?
        not failed?
      end
      alias_method :successful?, :success?

      def each_output_line(&block)
        out_stream.each_line(&block)
      end

      def each_err_lines(&block)
        err_stream.each_line(&block)
      end

      def output_lines
        out_stream.lines
      end

      def err_lines
        err_stream.lines
      end

    end

  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dockerun-0.4.2 lib/dockerun/cli/command_result.rb
dockerun-0.4.1 lib/dockerun/cli/command_result.rb
dockerun-0.4.0 lib/dockerun/cli/command_result.rb