Class: ContextSpook::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/context_spook/generator.rb

Overview

The Generator class provides a DSL parser that interprets context definition files and constructs structured context objects containing project metadata, file contents, command outputs, and variables for AI assistance.

Defined Under Namespace

Classes: Context

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Generator

The initialize method sets up the object by evaluating the provided block in the object’s context.

Parameters:

  • block (Proc)

    A block of code to be evaluated within the object’s context. If no block is given, the method does nothing.



37
38
39
# File 'lib/context_spook/generator.rb', line 37

def initialize(&block)
  block and instance_eval(&block)
end

Instance Method Details

#context(&block) ⇒ Context

The context method creates or returns a context object.

Parameters:

  • block (Proc)

    optional block to initialize the context

Returns:



46
47
48
49
50
51
52
53
# File 'lib/context_spook/generator.rb', line 46

def context(&block)
  if block
    @context and raise ArgumentError, "only one context allowed"
    @context = Context.new(&block)
  else
    @context
  end
end