Class: Populus::RemoteRunner
- Inherits:
-
Object
- Object
- Populus::RemoteRunner
- Defined in:
- lib/populus/remote_runner.rb
Instance Method Summary collapse
- #create_file(path, template = "", context = nil) ⇒ Object
- #execute(*command) ⇒ Object
-
#initialize(backend, &run_it) ⇒ RemoteRunner
constructor
A new instance of RemoteRunner.
- #upload_dir(to_dir, local: nil) ⇒ Object
- #upload_file(to_path, local: nil) ⇒ Object
Constructor Details
#initialize(backend, &run_it) ⇒ RemoteRunner
Returns a new instance of RemoteRunner.
8 9 10 11 |
# File 'lib/populus/remote_runner.rb', line 8 def initialize(backend, &run_it) @backend = backend instance_exec(&run_it) end |
Instance Method Details
#create_file(path, template = "", context = nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# 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) ⇒ Object
13 14 15 16 17 18 19 20 |
# 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 |