Sha256: d45a395bce516a15504edf4e8fa1096f8e4e8001f3159010583bd9e626026da9

Contents?: true

Size: 546 Bytes

Versions: 9

Compression:

Stored size: 546 Bytes

Contents

module EZAPIClient
  class ExecCommand

    include Virtus.model
    attribute :command, String

    def self.call(command)
      self.new(command: command).()
    end

    def call
      stdout_str, stderr_str, status = Open3.capture3(command)
      unless status.success?
        error_msgs = [
          stdout_str,
          stderr_str,
        ].reject { |str| str == "" }.compact.join("; ")
        msg = ["Error executing command:", error_msgs].join(" ")
        fail ArgumentError, msg
      end
      stdout_str.chomp
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ezapi_client-1.1.2 lib/ezapi_client/services/exec_command.rb
ezapi_client-1.1.1 lib/ezapi_client/services/exec_command.rb
ezapi_client-1.1.0 lib/ezapi_client/services/exec_command.rb
ezapi_client-1.0.3 lib/ezapi_client/services/exec_command.rb
ezapi_client-1.0.2 lib/ezapi_client/services/exec_command.rb
ezapi_client-1.0.1 lib/ezapi_client/services/exec_command.rb
ezapi_client-1.0.0 lib/ezapi_client/services/exec_command.rb
ezapi_client-0.5.0 lib/ezapi_client/services/exec_command.rb
ezapi_client-0.4.0 lib/ezapi_client/services/exec_command.rb