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

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)

Parameters:

  • path (String)

    path to check

Returns:

  • (Boolean)

    true if executable and not 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

Parameters:

  • command (String)

    command to find

  • additional_paths (Array<String>) (defaults to: [])

    extra paths to search

Returns:

  • (String, nil)

    executable path or nil



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