Sha256: e3608821d4c89cfe5fa7f2522715b32f7fd4d5869934c52fa9f5ac99d402ec10
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
require 'specinfra' require 'erb' require 'tempfile' require 'fileutils' module Populus class RemoteRunner def initialize(backend, &run_it) @backend = backend instance_exec(&run_it) end 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 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 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 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 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
populus-0.0.4 | lib/populus/remote_runner.rb |