Class: OllamaAgent::Topology::Linker::Discovery

Inherits:
Object
  • Object
show all
Defined in:
lib/ollama_agent/topology/linker/discovery.rb

Overview

Collects Ruby sources under project roots while skipping bulky / vendored trees.

Constant Summary collapse

EXCLUDED_DIR_NAMES =
%w[node_modules vendor/bundle tmp log .git].freeze

Class Method Summary collapse

Class Method Details

.files_under_root(root, extensions) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ollama_agent/topology/linker/discovery.rb', line 17

def self.files_under_root(root, extensions)
  return [] unless File.directory?(root)

  found = []
  Find.find(root) do |path|
    if File.directory?(path)
      Find.prune if EXCLUDED_DIR_NAMES.include?(File.basename(path))
      next
    end
    found << File.expand_path(path) if extensions.any? { |ext| path.end_with?(ext) }
  end
  found
end

.find_files(roots:, extensions: %w[.rb])) ⇒ Object



12
13
14
15
# File 'lib/ollama_agent/topology/linker/discovery.rb', line 12

def self.find_files(roots:, extensions: %w[.rb])
  expanded = Array(roots).map { |r| File.expand_path(r.to_s) }
  expanded.flat_map { |root| files_under_root(root, extensions) }.uniq.sort
end