Class: Aidp::Interfaces::PathBinaryChecker
- Inherits:
-
Object
- Object
- Aidp::Interfaces::PathBinaryChecker
- Includes:
- BinaryCheckerInterface
- Defined in:
- lib/aidp/interfaces/binary_checker_interface.rb
Overview
PathBinaryChecker checks the system PATH for binaries. This is the standard implementation used by AIDP.
Instance Method Summary collapse
-
#available?(binary_name) ⇒ Boolean
Check if a binary is available in the system PATH.
-
#path_for(binary_name) ⇒ String?
Get the full path to a binary.
Instance Method Details
#available?(binary_name) ⇒ Boolean
Check if a binary is available in the system PATH.
113 114 115 |
# File 'lib/aidp/interfaces/binary_checker_interface.rb', line 113 def available?(binary_name) !path_for(binary_name).nil? end |
#path_for(binary_name) ⇒ String?
Get the full path to a binary. Searches the PATH environment variable for the binary.
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/aidp/interfaces/binary_checker_interface.rb', line 122 def path_for(binary_name) return nil if binary_name.nil? || binary_name.empty? # Get extensions to check (Windows support) extensions = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""] # Search each PATH directory ENV["PATH"].to_s.split(File::PATH_SEPARATOR).each do |dir| extensions.each do |ext| path = File.join(dir, "#{binary_name}#{ext}") return path if File.executable?(path) && !File.directory?(path) end end nil end |