Class: Contextizer::Providers::Base::FileSystem

Inherits:
Contextizer::Providers::BaseProvider show all
Defined in:
lib/contextizer/providers/base/file_system.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context:, config:) ⇒ FileSystem



13
14
15
16
17
# File 'lib/contextizer/providers/base/file_system.rb', line 13

def initialize(context:, config:)
  @context = context
  @config = config.settings["filesystem"]
  @target_path = Pathname.new(context.target_path)
end

Class Method Details

.call(context:, config:) ⇒ Object



9
10
11
# File 'lib/contextizer/providers/base/file_system.rb', line 9

def self.call(context:, config:)
  new(context: context, config: config).collect_files
end

Instance Method Details

#collect_filesObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/contextizer/providers/base/file_system.rb', line 19

def collect_files
  file_paths = find_matching_files

  file_paths.each do |path|
    content = read_file_content(path)
    next unless content

    @context.files << {
      path: path.relative_path_from(@target_path).to_s,
      content: content
    }
  end
end