Class: RubyAiGemContext::FileCollector
- Inherits:
-
Object
- Object
- RubyAiGemContext::FileCollector
- Defined in:
- lib/ruby_ai_gem_context/file_collector.rb
Overview
Collects and reads files from the project for context generation
Instance Attribute Summary collapse
-
#folders ⇒ Object
readonly
Returns the value of attribute folders.
-
#root_path ⇒ Object
readonly
Returns the value of attribute root_path.
Instance Method Summary collapse
-
#collect ⇒ Hash
Collect all relevant files based on configuration.
-
#initialize(root_path = Dir.pwd, folders: nil) ⇒ FileCollector
constructor
A new instance of FileCollector.
-
#summary ⇒ Hash
Get a summary of what will be collected.
Constructor Details
#initialize(root_path = Dir.pwd, folders: nil) ⇒ FileCollector
Returns a new instance of FileCollector.
10 11 12 13 |
# File 'lib/ruby_ai_gem_context/file_collector.rb', line 10 def initialize(root_path = Dir.pwd, folders: nil) @root_path = root_path @folders = normalize_folders(folders) end |
Instance Attribute Details
#folders ⇒ Object (readonly)
Returns the value of attribute folders.
6 7 8 |
# File 'lib/ruby_ai_gem_context/file_collector.rb', line 6 def folders @folders end |
#root_path ⇒ Object (readonly)
Returns the value of attribute root_path.
6 7 8 |
# File 'lib/ruby_ai_gem_context/file_collector.rb', line 6 def root_path @root_path end |
Instance Method Details
#collect ⇒ Hash
Collect all relevant files based on configuration
17 18 19 20 21 22 23 24 25 |
# File 'lib/ruby_ai_gem_context/file_collector.rb', line 17 def collect files = {} scan_paths.each do |scan_path| collect_from_path(scan_path, files) end files end |
#summary ⇒ Hash
Get a summary of what will be collected
29 30 31 32 33 34 35 36 |
# File 'lib/ruby_ai_gem_context/file_collector.rb', line 29 def summary files = collect { total_files: files.size, total_size: files.values.sum(&:bytesize), by_extension: count_by_extension(files) } end |