Module: Legate::ToolLoader
- Defined in:
- lib/legate/tool_loader.rb
Overview
Responsible for discovering and loading tool definition files from the filesystem. This decouples filesystem traversal and file loading from the Agent execution logic.
Class Method Summary collapse
-
.load_from_paths(paths) ⇒ void
Discovers and loads tool definition files from specified paths.
Class Method Details
.load_from_paths(paths) ⇒ void
This method returns an undefined value.
Discovers and loads tool definition files from specified paths.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/legate/tool_loader.rb', line 12 def self.load_from_paths(paths) return if paths.nil? || paths.empty? Legate.logger.debug("Starting tool discovery in paths: #{paths.inspect}") paths.each do |path| absolute_dir_path = File.(path, Dir.pwd) unless Dir.exist?(absolute_dir_path) Legate.logger.warn("Tool discovery path does not exist or is not a directory: '#{path}' (resolved to '#{absolute_dir_path}'). Skipping.") next end Dir.glob(File.join(absolute_dir_path, '*.rb')).each do |absolute_file_path| Legate.logger.debug("Attempting to load tool file using 'require': #{absolute_file_path}") # Use require instead of load to prevent re-registration issues require absolute_file_path Legate.logger.debug("Successfully required (or already required): #{absolute_file_path}") rescue LoadError, SyntaxError => e Legate.logger.error("Failed to require/eval tool file '#{absolute_file_path}': #{e.class} - #{e.}") rescue StandardError => e Legate.logger.error("Error encountered while requiring/processing tool file '#{absolute_file_path}': #{e.class} - #{e.}") end end Legate.logger.debug('Finished tool discovery.') end |