lib/custom_facts/util/parser.rb in facter-4.0.9.pre vs lib/custom_facts/util/parser.rb in facter-4.0.10.pre

- old
+ new

@@ -129,11 +129,11 @@ extension_matches?(filename, 'json') end class ScriptParser < Base def parse_results - parse_executable_output(LegacyFacter::Core::Execution.exec(quote(filename))) + parse_executable_output(Facter::Core::Execution.exec(quote(filename))) end private def quote(filename) @@ -141,37 +141,37 @@ end end register(ScriptParser) do |filename| if LegacyFacter::Util::Config.windows? - extension_matches?(filename, %w[bat cmd com exe]) && File.file?(filename) + extension_matches?(filename, %w[bat cmd com exe]) && FileTest.file?(filename) else - File.executable?(filename) && File.file?(filename) && !extension_matches?(filename, %w[bat cmd com exe]) + File.executable?(filename) && FileTest.file?(filename) && !extension_matches?(filename, %w[bat cmd com exe]) end end # Executes and parses the key value output of Powershell scripts class PowershellParser < Base # Returns a hash of facts from powershell output def parse_results powershell = - if File.exist?("#{ENV['SYSTEMROOT']}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe") + if File.readable?("#{ENV['SYSTEMROOT']}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe") "#{ENV['SYSTEMROOT']}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe" - elsif File.exist?("#{ENV['SYSTEMROOT']}\\system32\\WindowsPowershell\\v1.0\\powershell.exe") + elsif File.readable?("#{ENV['SYSTEMROOT']}\\system32\\WindowsPowershell\\v1.0\\powershell.exe") "#{ENV['SYSTEMROOT']}\\system32\\WindowsPowershell\\v1.0\\powershell.exe" else 'powershell.exe' end shell_command = "\"#{powershell}\" -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass -File \"#{filename}\"" - output = LegacyFacter::Core::Execution.exec(shell_command) + output = Facter::Core::Execution.exec(shell_command) parse_executable_output(output) end end register(PowershellParser) do |filename| - LegacyFacter::Util::Config.windows? && extension_matches?(filename, 'ps1') && File.file?(filename) + LegacyFacter::Util::Config.windows? && extension_matches?(filename, 'ps1') && FileTest.file?(filename) end # A parser that is used when there is no other parser that can handle the file # The return from results indicates to the caller the file was not parsed correctly. class NothingParser