Class: Appydave::Tools::GptContext::FileCollector
- Inherits:
-
Object
- Object
- Appydave::Tools::GptContext::FileCollector
- Defined in:
- lib/appydave/tools/gpt_context/file_collector.rb
Overview
Gathers file names and content based on include and exclude patterns
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(options) ⇒ FileCollector
constructor
A new instance of FileCollector.
Constructor Details
#initialize(options) ⇒ FileCollector
Returns a new instance of FileCollector.
9 10 11 12 13 14 15 16 17 |
# File 'lib/appydave/tools/gpt_context/file_collector.rb', line 9 def initialize() @options = @include_patterns = .include_patterns @exclude_patterns = .exclude_patterns @format = .format @working_directory = File.(.working_directory) puts @working_directory @line_limit = .line_limit end |
Instance Method Details
#build ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/appydave/tools/gpt_context/file_collector.rb', line 19 def build FileUtils.cd(@working_directory) if @working_directory && Dir.exist?(@working_directory) formats = @format.split(',') result = formats.map do |fmt| case fmt when 'tree' build_tree when 'content' build_content when 'json' build_json else '' end end.join("\n\n") FileUtils.cd(Dir.home) if @working_directory result end |