class Novika::RunnableResolver
- Novika::RunnableResolver
- Reference
- Object
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.crConstructors
-
.new(cwd : Path, args : Array(Query))
Creates a new resolver for the given current working directory cwd and query arguments args.
Instance Method Summary
-
#after_container_rewritten(&callback : RunnableContainer -> )
Called when some container under this resolver was thoroughly rewritten.
-
#after_permissions(&callback : PermissionsHook -> )
Registers callback to run after a valid Novika program is formed, and permissions are given.
-
#after_program(&callback : ProgramHook -> )
Registers callback to run after a valid Novika program is formed.
-
#after_response(&callback : ResponseHook -> )
Registers callback to run after a valid response is formed.
-
#argument?(query : RunnableQuery)
Returns whether query was passed as an argument to this resolver.
-
#on_permissions_gets(&on_permissions_gets : String -> String | Nil)
Registers a handler for permissions
gets
. -
#on_permissions_print(&on_permissions_print : String -> )
Registers a handler for permissions
print
. -
#resolve? : Bool
Performs resolution.
Constructor Detail
Creates a new resolver for the given current working directory cwd and query arguments args.
See RunnableResolver
.
Instance Method Detail
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.
Registers callback to run after a valid Novika program is formed, and permissions are given.
Registers callback to run after a valid Novika program is formed.
See ProgramHook
to learn what is considered a Novika program.
Registers callback to run after a valid response is formed.
Returns whether query was passed as an argument to this resolver.
Registers a handler for permissions gets
. Overrides the previous
handler, if any.
Registers a handler for permissions print
. Overrides the previous
handler, if any.
Performs resolution. Returns true
if resolution is successful,
false
if the resolver had nothing to do (not even an error).