Class: Roast::Helpers::PromptLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/roast/helpers/prompt_loader.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, target_file) ⇒ PromptLoader

Returns a new instance of PromptLoader.



20
21
22
23
24
25
# File 'lib/roast/helpers/prompt_loader.rb', line 20

def initialize(context, target_file)
  @context = context
  @name = context.name
  @context_path = context.context_path
  @target_file = target_file
end

Class Method Details

.load_prompt(context, target_file) ⇒ String?

Loads a sidecar prompt file for a given context (workflow or step) and target file

Parameters:

  • context (Object)

    The workflow or step instance

  • target_file (String)

    The path to the target file

Returns:

  • (String, nil)

    The processed prompt content, or nil if no prompt is found



15
16
17
# File 'lib/roast/helpers/prompt_loader.rb', line 15

def load_prompt(context, target_file)
  new(context, target_file).load
end

Instance Method Details

#loadObject



27
28
29
30
31
32
# File 'lib/roast/helpers/prompt_loader.rb', line 27

def load
  prompt_content = read_prompt_file(find_prompt_path)
  return unless prompt_content

  process_erb_if_needed(prompt_content)
end