From 888a0407123ee0a75f9a18e1f788ce02f58440d4 Mon Sep 17 00:00:00 2001 From: Stuart Preston Date: Mon, 5 Mar 2018 11:00:00 -0800 Subject: Addressing initial feedback from review Signed-off-by: Stuart Preston --- lib/chef/powershell.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'lib/chef/powershell.rb') 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 -- cgit v1.2.1