Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Provide an "on_process_run" callback
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Jan 12, 2011
1 parent cc7487a commit 0132771
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/net/ssh/shell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def initialize(session, shell=:default)
@state = :closed
@processes = []
@when_open = []
@on_process_run = nil
@default_process_class = Net::SSH::Shell::Process
open
end
Expand Down Expand Up @@ -62,6 +63,10 @@ def opening?
!open? && !closed?
end

def on_process_run(&callback)
@on_process_run = callback
end

def execute(command, klass=nil, &callback)
klass ||= default_process_class
process = klass.new(self, command, callback)
Expand Down Expand Up @@ -113,7 +118,11 @@ def on_channel_close(channel)
private

def run_next_process
processes.first.run if processes.any?
if processes.any?
process = processes.first
@on_process_run.call(process) if @on_process_run
process.run
end
end

def open_succeeded(channel)
Expand Down

0 comments on commit 0132771

Please sign in to comment.