Module: RubynCode::Tools::Registry
- Defined in:
- lib/rubyn_code/tools/registry.rb
Constant Summary collapse
- IDE_ONLY_TOOLS =
IDE-only tools that require an ide_client to function.
%w[ide_diagnostics ide_symbols].freeze
Class Method Summary collapse
- .all ⇒ Object
- .get(name) ⇒ Object
- .load_all! ⇒ Object
-
.load_ide_tools! ⇒ Object
Register IDE-only tools when an ide_client is available.
- .register(tool_class) ⇒ Object
- .reset! ⇒ Object
- .tool_definitions ⇒ Object
- .tool_names ⇒ Object
Class Method Details
.all ⇒ Object
20 21 22 |
# File 'lib/rubyn_code/tools/registry.rb', line 20 def all @tools.values end |
.get(name) ⇒ Object
14 15 16 17 18 |
# File 'lib/rubyn_code/tools/registry.rb', line 14 def get(name) @tools.fetch(name) do raise ToolNotFoundError, "Unknown tool: #{name}. Available: #{tool_names.join(', ')}" end end |
.load_all! ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rubyn_code/tools/registry.rb', line 39 def load_all! tool_files = Dir[File.join(__dir__, '*.rb')] tool_files.each do |file| basename = File.basename(file, '.rb') next if %w[base registry schema executor].include?(basename) next if IDE_ONLY_TOOLS.include?(basename) require_relative basename end end |
.load_ide_tools! ⇒ Object
Register IDE-only tools when an ide_client is available.
51 52 53 54 55 |
# File 'lib/rubyn_code/tools/registry.rb', line 51 def load_ide_tools! IDE_ONLY_TOOLS.each do |name| require_relative name end end |
.register(tool_class) ⇒ Object
9 10 11 12 |
# File 'lib/rubyn_code/tools/registry.rb', line 9 def register(tool_class) name = tool_class.tool_name @tools[name] = tool_class end |
.reset! ⇒ Object
32 33 34 |
# File 'lib/rubyn_code/tools/registry.rb', line 32 def reset! @tools = {} end |
.tool_definitions ⇒ Object
24 25 26 |
# File 'lib/rubyn_code/tools/registry.rb', line 24 def tool_definitions @tools.values.map(&:to_schema) end |
.tool_names ⇒ Object
28 29 30 |
# File 'lib/rubyn_code/tools/registry.rb', line 28 def tool_names @tools.keys.sort end |