class Populus::RemoteRunner

Public Class Methods

new(backend, &run_it) click to toggle source
# File lib/populus/remote_runner.rb, line 8
def initialize(backend, &run_it)
  @backend = backend
  instance_exec(&run_it)
end

Public Instance Methods

create_file(path, template="", context=nil) click to toggle source
# File lib/populus/remote_runner.rb, line 22
def create_file(path, template="", context=nil)
  file = Tempfile.new(".populus-tmp")
  content = ERB.new(template).result(context || binding)
  file.write content
  file.close
  @backend.send_file(file.path, path)
  Populus.logger.info("Created Successfully: %s" % path)

  FileUtils.rm_f(file.path)
end
execute(*command) click to toggle source
# File lib/populus/remote_runner.rb, line 13
def execute(*command)
  Populus.logger.info("Running command: %s" % command.inspect)

  res = @backend.run_command(command.join(" "))
  Populus.logger.debug("stdout:\n%s" % res.stdout)
  Populus.logger.debug("stderr:\n%s" % res.stderr)
  Populus.logger.info("Command exited: %d" % res.exit_status)
end
upload_dir(to_dir, local: nil) click to toggle source
# File lib/populus/remote_runner.rb, line 39
def upload_dir(to_dir, local: nil)
  raise ArgumentError unless local
  @backend.send_directory(local, to_dir)
  Populus.logger.info("Upload Directory Successfully: %s to %s" % [local, to_dir])
end
upload_file(to_path, local: nil) click to toggle source
# File lib/populus/remote_runner.rb, line 33
def upload_file(to_path, local: nil)
  raise ArgumentError unless local
  @backend.send_file(local, to_path)
  Populus.logger.info("Upload Successfully: %s to %s" % [local, to_path])
end