Module: Ukiryu::Tool::ExecutableDiscovery Private

Included in:
Ukiryu::Tool
Defined in:
lib/ukiryu/tool/executable_discovery.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.

Executable discovery and inspection

Provides methods to find tool executables and discover how they were found (PATH vs shell alias).

Instance Method Summary collapse

Instance Method Details

#alias?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 the tool was found via shell alias

Returns:

  • (Boolean)

    true if executable is a shell alias



57
58
59
# File 'lib/ukiryu/tool/executable_discovery.rb', line 57

def alias?
  @executable_info&.alias? || false
end

#discovery_descriptionString?

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.

Get discovery description

Returns:

  • (String, nil)

    human-readable description of how tool was found



71
72
73
# File 'lib/ukiryu/tool/executable_discovery.rb', line 71

def discovery_description
  @executable_info&.description
end

#find_executableString?

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 the executable path using ExecutableLocator

Searches for the tool executable by:

  1. Checking shell aliases

  2. Checking system PATH

Sets @executable_info with discovery metadata.

Returns:

  • (String, nil)

    the executable path or nil if not found



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/ukiryu/tool/executable_discovery.rb', line 21

def find_executable
  # Use executable_name from command profile, falling back to profile name
  executable_name = @command_profile.executable_name || @profile.name

  # Debug logging for executable discovery
  Logger.debug("Tool: #{@profile.name}", category: :executable)
  Logger.debug("Command profile executable_name: #{@command_profile.executable_name.inspect}",
               category: :executable)
  Logger.debug("Profile name: #{@profile.name.inspect}", category: :executable)
  Logger.debug("Resolved executable_name: #{executable_name.inspect}", category: :executable)
  Logger.debug("Profile aliases: #{@profile.aliases.inspect}", category: :executable)
  Logger.debug("Shell: #{@shell.inspect}", category: :executable)
  Logger.debug("Platform: #{@platform.inspect}", category: :executable)

  result = ::Ukiryu::ExecutableLocator.find_with_info(
    tool_name: executable_name,
    aliases: @profile.aliases || [],
    platform: @platform
  )

  if result
    Logger.debug("Found executable: #{result[:path]}", category: :executable)
    Logger.debug("Discovery source: #{result[:info].source.inspect}", category: :executable)
  else
    Logger.debug('EXECUTABLE NOT FOUND!', category: :executable)
  end

  return nil unless result

  @executable_info = result[:info]
  result[:path]
end

#path_found?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 the tool was found in PATH

Returns:

  • (Boolean)

    true if executable was found in PATH



64
65
66
# File 'lib/ukiryu/tool/executable_discovery.rb', line 64

def path_found?
  @executable_info&.path? || false
end