Class: RailsAiBridge::RubydexAdapter::Indexer
- Inherits:
-
Object
- Object
- RailsAiBridge::RubydexAdapter::Indexer
- Defined in:
- lib/rails_ai_bridge/rubydex_adapter/indexer.rb
Overview
Builds the rubydex graph index from Ruby source files.
Scans a project root for +.rb+ files, excluding common non-source directories, creates a graph, indexes all matching files, and resolves references.
Constant Summary collapse
- EXCLUDED_DIRS =
%w[node_modules tmp log vendor .git .bundle].freeze
Class Method Summary collapse
- .build_index(root) ⇒ Object
- .index_files(graph, root) ⇒ Object
-
.source_files(root) ⇒ Array<String>
Collects all non-excluded Ruby source files under the project root.
Instance Method Summary collapse
-
#build(root) ⇒ Rubydex::Graph
Builds and returns a resolved rubydex graph for the given root.
Class Method Details
.build_index(root) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/rails_ai_bridge/rubydex_adapter/indexer.rb', line 22 def self.build_index(root) graph = ::Rubydex::Graph.new index_files(graph, root) graph.resolve graph end |
.index_files(graph, root) ⇒ Object
29 30 31 |
# File 'lib/rails_ai_bridge/rubydex_adapter/indexer.rb', line 29 def self.index_files(graph, root) graph.index_all(source_files(root)) end |
.source_files(root) ⇒ Array<String>
Collects all non-excluded Ruby source files under the project root.
37 38 39 40 41 42 43 |
# File 'lib/rails_ai_bridge/rubydex_adapter/indexer.rb', line 37 def self.source_files(root) root = File.(root) Dir.glob(File.join(root, '**', '*.rb')).reject do |path| components = path.sub("#{root}/", '').split('/') EXCLUDED_DIRS.intersect?(components) end end |