class Aruba::Platforms::WindowsWhich
Implement `which(command)` for windows
@private
Attributes
whiches[R]
Public Class Methods
new()
click to toggle source
# File lib/aruba/platforms/windows_which.rb, line 72 def initialize @whiches = [] @whiches << AbsoluteOrRelativePathWhich @whiches << ProgramWhich @whiches << DefaultWhich end
Public Instance Methods
call(program, path = ENV['PATH'])
click to toggle source
Find fully quallified path for program
@param [String] program
Name of program
@param [String] path
ENV['PATH']
# File lib/aruba/platforms/windows_which.rb, line 86 def call(program, path = ENV['PATH']) raise ArgumentError, "ENV['PATH'] cannot be empty" if path.nil? || path.empty? program = program.to_s program += windows_executable_extentions if File.extname(program).empty? whiches.find { |w| w.match? program }.new.call(program, path) end
Private Instance Methods
windows_executable_extentions()
click to toggle source
# File lib/aruba/platforms/windows_which.rb, line 97 def windows_executable_extentions ENV['PATHEXT'] ? format('.{%s}', ENV['PATHEXT'].tr(';', ',').tr('.','')).downcase : '.{exe,com,bat}' end