class Novika::Resolver::RunnableRoot

Overview

Runnable root is available to all containers, and therefore allows any runnable to escape deep nesting if need be.

Runnable root stores a pointer to the Disk object, used throughout the resolver to cache file system requests (the resolver is quite ample in making them). It also stores the set of flags, which help making OS-specific decisions using flag conditions in manifests.

Additionally, runnable root allows runnables to #wish queries to be resolved later, as requirements, and to talk to each other via Signals and the SignalReceiver interface (see #send).

There's a lot more, but that's the gist.

Defined in:

novika/resolver.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(disk : Disk, cwd : Path) #

Instance Method Detail

def assign(group : RunnableGroup, *, container : RunnableContainer, overwrite = true) : RunnableContainer #

Assigns container to the given group.

This is the only way someone from the outside can (reliably) get the container of a group.

overwrite specifies whether the existing container for group should be overwritten with container.

Returns the container that was assigned to group.


def assign(group : RunnableGroup, *, preamble : String) #

Assigns preamble to the given runnable group.


def containerof(group : RunnableGroup) : RunnableContainer #

Returns the container assigned to group.

Raises if group is neither an application nor a library.


def containerof?(group : RunnableGroup) : RunnableContainer | Nil #

Returns the container of an application or library group, or nil if group is neither an application nor a library.


def cwd : Path #

Returns the user's current working directory. It is also sometimes referred to as the "primary origin", "origin" as in "primary origin (source) of files".


def default_env : RunnableEnvironment #

Returns the default runnable environment.

Currently, current working directory environment is used as the default runnable environment.

Note that if the current working directory does not have an environment, a "virtual", pathless environment is returned (see #defenv).


def defenv(path : Path | Nil) #

Returns the RunnableEnvironment for path, creating one if it does not exist.

Note that path can be nil, which means the created/returned environment will be so to speak "virtual". The only difference being the "virtual" environment's response to disk-related questions. Namely it'll answer does-not-exist (or something like that) to any disk-related question.

Note also, that only one pathless environment can ever created; as a consequence, all runnable containers that have no environments will share one pathless runnable environment.


def defexplicit(query : RunnableQuery) #

Marks query as explicit ("hand-written") within this runnable root.


Returns the disk used by this runnable root.


def each_set_flag(& : String -> ) #

Yields all set (true) flags.


def each_wish(& : RunnableQuery -> ) #

Yields queries from this runnable root's wishlist of queries.

See #wish.


def new_primary_container : RunnableContainer #

Creates and returns a new primary RunnableContainer.


def preambleof?(group : RunnableGroup) : String | Nil #

Returns the preamble of group, or nil if it has none.


def send(signal : Signal) #

Sends signal to all SignalReceivers subscribed to this runnable root.


def serve_permissions(to env : RunnableEnvironment) : PermissionServer #

Creates and returns a permission server in the given runnable environment env and capability collection caps.


def set_flag(name : String, state : Bool) #

Assigns state to a boolean flag with the given name.

Note that by design, an unset flag is a false flag, and vice versa: if state is false, the flag is either not created, or removed.

root.set_flag("happy", true)
root.set_flag("sad", false)

def subscribe(receiver : SignalReceiver) #

Subscribes receiver to this runnable root.


def unsubscribe(receiver : SignalReceiver) #

Unsubscribes receiver from this runnable root.


def wish(query : RunnableQuery) #

Appends query to the wishlist of this runnable root (the wishlist is like "outbound queries" or "preload requests").

Wishes are picked up from the wishlist by outer infrastructure and loaded distinctly. The only guarantee is that they will indeed be preloaded relative to the query that made the wish, meaning loaded some time before it.

Does nothing if query is already in the wishlist.