Module: Ace::Assign::Atoms::AssignFrontmatterParser
- Defined in:
- lib/ace/assign/atoms/assign_frontmatter_parser.rb
Overview
Pure function: extracts and validates ‘assign:` block from markdown frontmatter.
Takes a raw YAML frontmatter hash (already parsed from a .s.md or .wf.md file), extracts the ‘assign:` block, validates fields, and returns a structured result.
No file I/O — reuses existing frontmatter extraction from StepFileParser or ace-support-markdown.
Constant Summary collapse
- VALID_FIELDS =
%w[goal variables hints sub-steps context parent].freeze
- VALID_HINT_ACTIONS =
%w[include skip].freeze
- VALID_CONTEXTS =
%w[fork].freeze
Class Method Summary collapse
-
.parse(frontmatter) ⇒ Hash
Parse and validate the assign: block from frontmatter.
Class Method Details
.parse(frontmatter) ⇒ Hash
Parse and validate the assign: block from frontmatter.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ace/assign/atoms/assign_frontmatter_parser.rb', line 28 def self.parse(frontmatter) return {config: nil, valid: true, errors: []} if frontmatter.nil? || !frontmatter.is_a?(Hash) assign_block = frontmatter["assign"] return {config: nil, valid: true, errors: []} if assign_block.nil? errors = validate(assign_block) return {config: nil, valid: false, errors: errors} if errors.any? config = extract_config(assign_block) {config: config, valid: true, errors: []} end |