Class: Chef::PowerShell
- Inherits:
-
Object
- Object
- Chef::PowerShell
- Extended by:
- FFI::Library
- Defined in:
- lib/chef/powershell.rb
Defined Under Namespace
Classes: CommandFailed
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #error! ⇒ Object
-
#error? ⇒ Boolean
Was there an error running the command.
-
#initialize(script) ⇒ Object
constructor
Run a command under PowerShell via FFI This implementation requires the managed dll and native wrapper to be in the library search path on Windows (i.e. c:windowssystem32 or in the same location as ruby.exe).
Constructor Details
#initialize(script) ⇒ Object
Run a command under PowerShell via FFI This implementation requires the managed dll and native wrapper to be in the library search path on Windows (i.e. c:windowssystem32 or in the same location as ruby.exe).
Requires: .NET Framework 4.0 or higher on the target machine.
36 37 38 39 40 |
# File 'lib/chef/powershell.rb', line 36 def initialize(script) raise "Chef::PowerShell can only be used on the Windows platform." unless RUBY_PLATFORM =~ /mswin|mingw32|windows/ exec(script) end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
26 27 28 |
# File 'lib/chef/powershell.rb', line 26 def errors @errors end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
25 26 27 |
# File 'lib/chef/powershell.rb', line 25 def result @result end |
Instance Method Details
#error! ⇒ Object
58 59 60 |
# File 'lib/chef/powershell.rb', line 58 def error! raise Chef::PowerShell::CommandFailed, "Unexpected exit in PowerShell command: #{@errors}" if error? end |
#error? ⇒ Boolean
Was there an error running the command
47 48 49 50 51 |
# File 'lib/chef/powershell.rb', line 47 def error? return true if errors.count > 0 false end |