diff options
author | Stuart Preston <stuart@chef.io> | 2018-03-05 11:00:00 -0800 |
---|---|---|
committer | Stuart Preston <stuart@chef.io> | 2018-03-05 11:00:00 -0800 |
commit | 888a0407123ee0a75f9a18e1f788ce02f58440d4 (patch) | |
tree | 1b66a67bc297b52fcea2e7908d752cf711788734 /lib/chef/powershell.rb | |
parent | 3c084d24b13067741f41b3f372829df675fa87db (diff) | |
download | chef-888a0407123ee0a75f9a18e1f788ce02f58440d4.tar.gz |
Addressing initial feedback from review
Signed-off-by: Stuart Preston <stuart@chef.io>
Diffstat (limited to 'lib/chef/powershell.rb')
-rw-r--r-- | lib/chef/powershell.rb | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/chef/powershell.rb b/lib/chef/powershell.rb index 32a3a2f532..d46b430259 100644 --- a/lib/chef/powershell.rb +++ b/lib/chef/powershell.rb @@ -32,11 +32,18 @@ class Chef # # @param script [String] script to run # @return [Object] output - def initialize(*command_args) - raise "This class can only be used on the Windows platform." unless RUBY_PLATFORM =~ /mswin|mingw32|windows/ - exec(command_args.first) + def initialize(script) + raise "Chef::PowerShell can only be used on the Windows platform." unless RUBY_PLATFORM =~ /mswin|mingw32|windows/ + exec(script) end + def error? + return true if errors.count > 0 + false + end + + private + def exec(script) ps = WIN32OLE.new("Chef.PowerShell") outcome = ps.ExecuteScript(script) @@ -44,10 +51,5 @@ class Chef @result = Chef::JSONCompat.parse(hashed_outcome["result"]) @errors = hashed_outcome["errors"] end - - def error? - return true if errors.count > 0 - false - end end end |