Module: Proclib
- Defined in:
- lib/proclib.rb,
lib/proclib/errors.rb,
lib/proclib/result.rb,
lib/proclib/channel.rb,
lib/proclib/process.rb,
lib/proclib/version.rb,
lib/proclib/executor.rb,
lib/proclib/invocation.rb,
lib/proclib/ssh_session.rb,
lib/proclib/commands/ssh.rb,
lib/proclib/output_cache.rb,
lib/proclib/commands/base.rb,
lib/proclib/commands/local.rb,
lib/proclib/output_handler.rb,
lib/proclib/command_monitor.rb,
lib/proclib/loggers/console.rb,
lib/proclib/string_formatting.rb
Defined Under Namespace
Modules: Commands, Loggers, StringFormatting Classes: Channel, CommandMonitor, Executor, Invocation, OutputHandler, Result
Constant Summary collapse
- Error =
Class.new(StandardError)
- VERSION =
"0.2.3"
Class Method Summary collapse
- .run(cmd, tag: nil, log_to_console: false, capture_output: true, env: {}, stdin: nil, on_output: nil, cwd: nil, ssh: nil) ⇒ Object
- .ssh_session(user:, host:, password: nil, port: nil, paranoid: nil) ⇒ Object
Class Method Details
.run(cmd, tag: nil, log_to_console: false, capture_output: true, env: {}, stdin: nil, on_output: nil, cwd: nil, ssh: nil) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/proclib.rb', line 6 def self.run(cmd, tag: nil, log_to_console: false, capture_output: true, env: {}, stdin: nil, on_output: nil, cwd: nil, ssh: nil ) inv = Invocation.new(cmd, tag: tag, env: env, cwd: cwd, stdin: stdin, ssh: ssh) executor = Executor.new(inv.commands, log_to_console: log_to_console, cache_output: capture_output ).tap do |ex| ex.on_output(&on_output) unless on_output.nil? end executor.run_sync rescue Invocation::Invalid => e raise ArgumentError, e. end |
.ssh_session(user:, host:, password: nil, port: nil, paranoid: nil) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/proclib.rb', line 35 def self.ssh_session(user:, host:, password: nil, port: nil, paranoid: nil) ssh_opts = { user: user, host: host } ssh_opts[:port] = port unless port.nil? ssh_opts[:paranoid] = paranoid unless paranoid.nil? ssh_opts[:password] = password unless password.nil? SshSession.new(ssh_opts) end |