class WinRM::Shells::ShellFactory
Factory for creating concrete shell instances
Public Class Methods
Source
# File lib/winrm/shells/shell_factory.rb, line 27 def initialize(connection_opts, transport, logger) @connection_opts = connection_opts @transport = transport @logger = logger end
Creates a new ShellFactory
instance @param connection_opts [ConnectionOpts] The WinRM
connection options @param transport [HttpTransport] The WinRM
SOAP transport for sending messages @param logger [Logger] The logger to log messages to
Public Instance Methods
Source
# File lib/winrm/shells/shell_factory.rb, line 37 def create_shell(shell_type, shell_opts = {}) type = shell_type.to_s.capitalize.to_sym args = [ @connection_opts, @transport, @logger ] # winrm-elevated has an initializer with no shell_opts so don't break it args << shell_opts unless shell_opts.nil? || shell_opts.empty? if Shells.constants.include?(type) WinRM::Shells.const_get(type).new(*args) else message = "#{type} is not a valid WinRM shell type. " \ 'Expected either :cmd, :powershell or pluggable shell.' raise WinRM::InvalidShellError, message end end
Creates a new shell instance based off the shell_type @param shell_type [Symbol] The shell type :cmd or :powershell @param shell_opts [Hash] Options targeted for the created shell @return The ready to use shell instance