class ApartmentAcmeClient::FileManipulation::Real

Public Instance Methods

copy_file(from, to) click to toggle source
# File lib/apartment_acme_client/file_manipulation/real.rb, line 6
def copy_file(from, to)
  run_command("sudo cp #{from} #{to}")
end
restart_service(service) click to toggle source
# File lib/apartment_acme_client/file_manipulation/real.rb, line 10
def restart_service(service)
  run_command("sudo service #{service} restart")
end

Private Instance Methods

run_command(command) click to toggle source
# File lib/apartment_acme_client/file_manipulation/real.rb, line 16
def run_command(command)
  Open3.popen3(command) do |_stdin, stdout, stderr, wait_thr|
    stdout_lines = stdout.read
    # puts "stdout is:" + stdout_lines

    # to watch the output as it runs:
    # while line = stdout.gets
    #   puts line
    # end

    stderr_lines = stderr.read
    # puts "stderr is:" + stderr_lines
    exit_status = wait_thr.value

    unless exit_status.success?
      abort "FAILED !!! #{command}"
    end
  end
end