Module: Ukiryu::ExecutableLocator::DiscoveryStrategy 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.

OOP Strategy for executable discovery

Tries multiple discovery strategies in order:

  1. Alias discovery (via Shell class)

  2. System command discovery (which/where/command -v)

  3. Manual PATH search

Class Method Summary collapse

Class Method Details

.discover(command, context) ⇒ Hash?

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.

Try all discovery strategies

Parameters:

  • command (String)

    the command to locate

  • context (DiscoveryContext)

    discovery environment

Returns:

  • (Hash, nil)

    discovery result or nil



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/ukiryu/executable_locator.rb', line 106

def discover(command, context)
  warn "[UKIRYU DEBUG DiscoveryStrategy] Discovering: #{command.inspect}" if ENV['UKIRYU_DEBUG_EXECUTABLE'] || (context.platform == :windows && ENV['CI'])

  # Try AliasDiscovery
  result = AliasDiscovery.discover(command, context)
  if result
    warn "[UKIRYU DEBUG DiscoveryStrategy] AliasDiscovery found: #{result[:path]}" if ENV['UKIRYU_DEBUG_EXECUTABLE'] || (context.platform == :windows && ENV['CI'])
    return result
  end

  # Try SystemCommandDiscovery
  result = SystemCommandDiscovery.discover(command, context)
  if result
    warn "[UKIRYU DEBUG DiscoveryStrategy] SystemCommandDiscovery found: #{result[:path]}" if ENV['UKIRYU_DEBUG_EXECUTABLE'] || (context.platform == :windows && ENV['CI'])
    return result
  end

  # Try PathDiscovery
  result = PathDiscovery.discover(command, context)
  if result
    warn "[UKIRYU DEBUG DiscoveryStrategy] PathDiscovery found: #{result[:path]}" if ENV['UKIRYU_DEBUG_EXECUTABLE'] || (context.platform == :windows && ENV['CI'])
    return result
  end

  warn "[UKIRYU DEBUG DiscoveryStrategy] NO STRATEGY FOUND: #{command}" if ENV['UKIRYU_DEBUG_EXECUTABLE'] || (context.platform == :windows && ENV['CI'])

  nil
end