class Novika::RunnableResolver

Overview

A very high-level interface to the Novika resolver. Designed as one- shot, meaning you shouldn't reuse the same object twice or call #resolve? twice. In this regard, as a protection, calling #resolve? twice will raise.

See Session and Response if you want a lower-level interface.

resolver = Novika::RunnableResolver.new(cwd: Path[Dir.current], args: ["repl"])

# Define 'gets' and 'print' to ask for permissions.

resolver.on_permissions_gets do |string|
  print string
  gets
end

resolver.on_permissions_print do |string|
  print string
end

# Run "repl" and everything it requested.

resolver.after_permissions(&.run)
resolver.resolve?

Included Modules

Defined in:

novika/resolver.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(cwd : Path, args : Array(Query)) #

Creates a new resolver for the given current working directory cwd and query arguments args.

See RunnableResolver.


Instance Method Detail

def after_container_rewritten(&callback : RunnableContainer -> ) #

Called when some container under this resolver was thoroughly rewritten.

You'll have to do additional checks to figure out where the container came from. This is mainly an inspection method.


def after_permissions(&callback : PermissionsHook -> ) #

Registers callback to run after a valid Novika program is formed, and permissions are given.


def after_program(&callback : ProgramHook -> ) #

Registers callback to run after a valid Novika program is formed. See ProgramHook to learn what is considered a Novika program.


def after_response(&callback : ResponseHook -> ) #

Registers callback to run after a valid response is formed.


def argument?(query : RunnableQuery) #

Returns whether query was passed as an argument to this resolver.


def on_permissions_gets(&on_permissions_gets : String -> String | Nil) #

Registers a handler for permissions gets. Overrides the previous handler, if any.


def on_permissions_print(&on_permissions_print : String -> ) #

Registers a handler for permissions print. Overrides the previous handler, if any.


def resolve? : Bool #

Performs resolution. Returns true if resolution is successful, false if the resolver had nothing to do (not even an error).