Class: WinRM::Shells::ShellFactory
- Inherits:
-
Object
- Object
- WinRM::Shells::ShellFactory
- Defined in:
- lib/winrm/shells/shell_factory.rb
Overview
Factory for creating concrete shell instances
Instance Method Summary collapse
-
#create_shell(shell_type, shell_opts = {}) ⇒ Object
Creates a new shell instance based off the shell_type.
-
#initialize(connection_opts, transport, logger) ⇒ ShellFactory
constructor
Creates a new ShellFactory instance.
Constructor Details
#initialize(connection_opts, transport, logger) ⇒ ShellFactory
Creates a new ShellFactory instance
27 28 29 30 31 |
# File 'lib/winrm/shells/shell_factory.rb', line 27 def initialize(connection_opts, transport, logger) @connection_opts = connection_opts @transport = transport @logger = logger end |
Instance Method Details
#create_shell(shell_type, shell_opts = {}) ⇒ Object
Creates a new shell instance based off the shell_type
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# 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 = "#{type} is not a valid WinRM shell type. " \ 'Expected either :cmd, :powershell or pluggable shell.' raise WinRM::InvalidShellError, end end |