Module: Vangrail::Colang::Library

Defined in:
lib/vangrail/colang/library.rb

Overview

The flows a configuration can name without defining.

A config folder that lists self check input under rails.input.flows and ships no .co file is the ordinary case: those flows are built into the toolkit. They are written out here as Colang rather than hand-built AST, so the parser this gem ships is the same one that reads them, and a bug in it fails loudly on the built-ins instead of hiding until someone writes their own flow.

Constant Summary collapse

SOURCE =
<<~COLANG
  define flow self check input
    $allowed = execute self_check_input
    if not $allowed
      bot refuse to respond
      stop

  define flow self check output
    $allowed = execute self_check_output
    if not $allowed
      bot refuse to respond
      stop

  define flow self check facts
    $accurate = execute self_check_facts
    if not $accurate
      bot inform answer unknown
      stop

  define bot refuse to respond
    "I'm sorry, I can't respond to that."

  define bot inform answer unknown
    "I don't know the answer to that."
COLANG

Class Method Summary collapse

Class Method Details

.flow_namesObject



48
49
50
# File 'lib/vangrail/colang/library.rb', line 48

def flow_names
  program.flow_names
end

.programObject



44
45
46
# File 'lib/vangrail/colang/library.rb', line 44

def program
  @program ||= Parser.parse(SOURCE, filename: 'built-in')
end