Sha256: 5e426eb4e6aafd43c75e7532e499eb79d4a75912f84994d8d55dcb606717d758

Contents?: true

Size: 709 Bytes

Versions: 7

Compression:

Stored size: 709 Bytes

Contents

require 'open3'

module DanarchyDeploy
  class Helpers
    def self.run_command(command, options)
      pid, stdout, stderr = nil
      printf("%14s %0s\n", 'Running:', "#{command}")
      Open3.popen3(command) do |i, o, e, t|
        pid    = t.pid
        (out, err) = o.read, e.read
        stdout = !out.empty? ? out : nil
        stderr = !err.empty? ? err : nil
      end

      if options[:ssh_verbose]
        puts "------\nSTDOUT: ", stdout, '------' if stdout
        puts "------\nSTDERR: ", stderr, '------' if stderr
      end
      
      { pid: pid, stdout: stdout, stderr: stderr }
    end

    def self.decode_base64(data)
      require 'base64'
      Base64.decode64(data)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
danarchy_deploy-0.1.6 lib/danarchy_deploy/helpers.rb
danarchy_deploy-0.1.5 lib/danarchy_deploy/helpers.rb
danarchy_deploy-0.1.4 lib/danarchy_deploy/helpers.rb
danarchy_deploy-0.1.3 lib/danarchy_deploy/helpers.rb
danarchy_deploy-0.1.2 lib/danarchy_deploy/helpers.rb
danarchy_deploy-0.1.1 lib/danarchy_deploy/helpers.rb
danarchy_deploy-0.1.0 lib/danarchy_deploy/helpers.rb