Class: RubynCode::Tools::Glob
Constant Summary collapse
- TOOL_NAME =
'glob'- DESCRIPTION =
'File pattern matching. Returns sorted list of file paths matching the glob pattern.'- PARAMETERS =
{ pattern: { type: :string, required: true, description: "Glob pattern (e.g. '**/*.rb', 'app/**/*.erb')" }, path: { type: :string, required: false, description: 'Directory to search in (defaults to project root)' } }.freeze
- RISK_LEVEL =
:read- REQUIRES_CONFIRMATION =
false
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
description, #initialize, parameters, requires_confirmation?, risk_level, #safe_path, to_schema, tool_name, #truncate
Constructor Details
This class inherits a constructor from RubynCode::Tools::Base
Class Method Details
.summarize(output, args) ⇒ Object
24 25 26 27 28 |
# File 'lib/rubyn_code/tools/glob.rb', line 24 def self.summarize(output, args) pattern = args['pattern'] || args[:pattern] || '' count = output.to_s.strip.empty? ? 0 : output.to_s.lines.count "glob #{pattern} (#{count} files)" end |
Instance Method Details
#execute(pattern:, path: nil) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rubyn_code/tools/glob.rb', line 30 def execute(pattern:, path: nil) search_dir = resolve_search_dir(path) full_pattern = File.join(search_dir, pattern) matches = Dir.glob(full_pattern, File::FNM_DOTMATCH).sort matches .select { |f| File.file?(f) } .reject { |f| dot_entry?(f) } .map { |f| relative_to_root(f) } .join("\n") end |