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

Commit

Permalink
Allow properties to be passed into the initializer for a process
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Jan 12, 2011
1 parent 5eb4684 commit eff4450
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions lib/net/ssh/shell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,16 @@ 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)
def execute(command, *args, &callback)
# The class is an optional second argument.
klass = default_process_class
klass = args.shift if args.first.is_a?(Class)

# The properties are expected to be the next argument.
props = {}
props = args.shift if args.first.is_a?(Hash)

process = klass.new(self, command, props, callback)
processes << process
run_next_process if processes.length == 1
process
Expand Down
4 changes: 2 additions & 2 deletions lib/net/ssh/shell/process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ class Process
attr_reader :exit_status
attr_reader :properties

def initialize(manager, command, callback)
def initialize(manager, command, properties, callback)
@command = command
@manager = manager
@callback = callback
@properties = {}
@properties = properties
@on_output = nil
@on_error_output = nil
@on_finish = nil
Expand Down

0 comments on commit eff4450

Please sign in to comment.