class Novika::Resolver::PermissionServer

Overview

Permission server allows to prompt the user for permissions, and save the user's choices in the permissions file.

Included Modules

Defined in:

novika/resolver.cr

Constructors

Instance Method Summary

Instance methods inherited from module Novika::Resolver::SignalReceiver

receive(signal : Signal) receive

Constructor Detail

def self.new(env : RunnableEnvironment, explicit : Array(RunnableQuery)) #

Creates a new permission server.

resolver is the resolver with which this server will talk about resolver-related things.

explicit is a list of explicit runnable queries. An explicit query is that query which was specified manually, e.g. via the arguments. In other words, the user had to type it here and now rather than "acquire" it from somewhere unknowingly. This list is mainly used to be less annoying when it comes to asking for permissions.


Instance Method Detail

def answer(answer : String) #

Prints answer so that it can be seen by the user.


def ask?(question : String) : String | Nil #

Asks user a question, and returns the answer or an empty string in case EOF was received.


def brief(dependency : RunnableCapability) : String #

Returns a brief description of dependency.


def explicit?(dependency : Resolution::Dependency) : Bool #

Returns whether dependency is explicit.

This is done by checking whether the first RunnableQuery ancestor of dependency is in the explicit list. See .new to learn what "explicitness" means.


def load #

Fills the permissions hash with saved permissions.


def query_permission?(container : RunnableContainer, dependency : Resolution::Dependency) #

Queries (possibly prompts) and returns the permission state of dependency for the given container.


def receive(signal : Signal) #
Description copied from module Novika::Resolver::SignalReceiver

Receives and reacts to a signal sent by RunnableRoot.


def save #

Flushes the internal permissions store to disk. Can create the permissions file, if necessary.

Note: this method does nothing in case the internal permissions store is empty.