Module: Ukiryu::ExecutableLocator
- Defined in:
- lib/ukiryu/executable_locator.rb
Overview
Executable locator for finding tool executables
Uses OOP discovery strategies:
-
AliasDiscovery (via Shell class)
-
SystemCommandDiscovery (which/where/command -v)
-
PathDiscovery (manual PATH search)
Defined Under Namespace
Modules: AliasDiscovery, DiscoveryResult, DiscoveryStrategy, PathDiscovery, PathScanner, SystemCommandDiscovery, SystemCommandExecutor Classes: DiscoveryContext, PathExtensions
Constant Summary collapse
- INTERNAL_COMMAND_TIMEOUT =
5
Class Method Summary collapse
-
.find(tool_name:, aliases: [], platform: nil) ⇒ String?
Find an executable by name.
-
.find_in_path(command, additional_paths: []) ⇒ String?
Find an executable in the system PATH.
-
.find_with_info(tool_name:, aliases: [], platform: nil) ⇒ Hash?
Find an executable with full discovery information.
Class Method Details
.find(tool_name:, aliases: [], platform: nil) ⇒ String?
Find an executable by name
28 29 30 31 |
# File 'lib/ukiryu/executable_locator.rb', line 28 def find(tool_name:, aliases: [], platform: nil) result = find_with_info(tool_name: tool_name, aliases: aliases, platform: platform) result&.dig(:path) end |
.find_in_path(command, additional_paths: []) ⇒ String?
Find an executable in the system PATH
73 74 75 |
# File 'lib/ukiryu/executable_locator.rb', line 73 def find_in_path(command, additional_paths: []) PathScanner.find(command, additional_paths: additional_paths) end |
.find_with_info(tool_name:, aliases: [], platform: nil) ⇒ Hash?
Find an executable with full discovery information
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/ukiryu/executable_locator.rb', line 39 def find_with_info(tool_name:, aliases: [], platform: nil) platform ||= Ukiryu::Runtime.instance.platform context = DiscoveryContext.new(platform) # Debug logging for Windows CI if ENV['UKIRYU_DEBUG_EXECUTABLE'] || (platform == :windows && ENV['CI']) warn "[UKIRYU DEBUG ExecutableLocator] Searching for tool: #{tool_name.inspect}" warn "[UKIRYU DEBUG ExecutableLocator] Aliases: #{aliases.inspect}" warn "[UKIRYU DEBUG ExecutableLocator] Detected shell: #{context.shell_sym.inspect}" warn "[UKIRYU DEBUG ExecutableLocator] Shell class: #{context.shell_class.inspect}" end # Try primary name first result = DiscoveryStrategy.discover(tool_name, context) warn "[UKIRYU DEBUG ExecutableLocator] Found #{tool_name}: #{result[:path]}" if result && (ENV['UKIRYU_DEBUG_EXECUTABLE'] || (platform == :windows && ENV['CI'])) return result if result # Try aliases aliases.each do |alias_name| result = DiscoveryStrategy.discover(alias_name, context) warn "[UKIRYU DEBUG ExecutableLocator] Found alias #{alias_name}: #{result[:path]}" if result && (ENV['UKIRYU_DEBUG_EXECUTABLE'] || (platform == :windows && ENV['CI'])) return result if result end warn "[UKIRYU DEBUG ExecutableLocator] NO EXECUTABLE FOUND for #{tool_name} or aliases #{aliases}" if ENV['UKIRYU_DEBUG_EXECUTABLE'] || (platform == :windows && ENV['CI']) nil end |