Sha256: 952739c5a3727d24f27df4d3486427243ad7212bea5a9d7f96bcf595850eacce
Contents?: true
Size: 767 Bytes
Versions: 5
Compression:
Stored size: 767 Bytes
Contents
# frozen_string_literal: true module AIRefactor class Context def initialize(files:, text:, logger:) @files = files @text = text @logger = logger end def prepare_context context = read_contexts&.compact file_context = (context && context.size.positive?) ? "Here is some related files:\n\n#{context.join("\n")}" : "" if @text.nil? || @text.empty? file_context else "\n#{file_context}\n\n#{@text}\n" end end private def read_contexts @files&.map do |file| unless File.exist?(file) @logger.warn "Context file #{file} does not exist" next end "#---\n# File '#{file}':\n\n```#{File.read(file)}```\n" end end end end
Version data entries
5 entries across 5 versions & 1 rubygems