Module: Ukiryu::ExecutableLocator::PathScanner Private
- Defined in:
- lib/ukiryu/executable_locator.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Scan PATH for executables (DRY helper)
Class Method Summary collapse
-
.executable?(path) ⇒ Boolean
private
Check if path is an executable (not a directory).
-
.find(command, additional_paths: []) ⇒ String?
private
Find executable in PATH.
Class Method Details
.executable?(path) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if path is an executable (not a directory)
312 313 314 |
# File 'lib/ukiryu/executable_locator.rb', line 312 def executable?(path) File.executable?(path) && !File.directory?(path) end |
.find(command, additional_paths: []) ⇒ String?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Find executable in PATH
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/ukiryu/executable_locator.rb', line 290 def find(command, additional_paths: []) path_extensions = PathExtensions.new search_paths = Platform.executable_search_paths + additional_paths search_paths.uniq! search_paths.each do |dir| path_extensions.each do |ext| exe = File.join(dir, "#{command}#{ext}") # Normalize path separators on Windows (File.join uses forward slashes) exe = exe.gsub('/', '\\') if Platform.windows? return exe if executable?(exe) end end nil end |