Workspace. State
(Workspace v0.4.2)
View Source
The low-level API and the workspace state struct.
The %Workspace.State{} structure
Every workspace is stored internally as a struct containing the following fields:
:projects- a map of the form%{atom => Workspace.Project.t()}where the key is the defined project name. It includes all detected workspace projects excluding any ignored ones.:cwd- the directory from which the generation of the workspace struct occurred.:mix_path- absolute path to the workspace's rootmix.exsfile.:workspace_path- absolute path of the workspace, this is by default the folder containing the workspace mix file.:git_root_path- the absolute path of the git repository containing the workspace:git_workspace_path- the absolute path of the workspace within the git repository. It differs from the:workspace_pathonly if the workspace path is a symlink pointing inside the repository.:config- the workspace's configuration, checkWorkspace.Configfor more details.
Summary
Functions
Returns the absolute path of a file given relative to the git root.
Initializes a new workspace from the given settings.
Types
@type t() :: %Workspace.State{ config: keyword(), cwd: binary(), git_root_path: binary() | nil, git_workspace_path: binary() | nil, graph: :digraph.graph(), mix_path: binary(), projects: %{required(atom()) => Workspace.Project.t()}, status_updated?: boolean(), workspace_path: binary() }
Struct holding the workspace state.
It contains the following:
:projects- A map with all workspace projects.:config- The workspace configuration settings.:mix_path- The path to the workspace's rootmix.exs.:workspace_path- The workspace root path.:git_root_path- The git root path, of the repository containing the workspace.:git_workspace_path- The workspace path within the git repository.:cwd- The directory from which the workspace was generated.:graph- The DAG (directed acyclic graph) of the workspace, including the:affected_bypaths of the projects as:pathnodes.:status_updated?- Set totrueif the workspace status has been updated.
Functions
Returns the absolute path of a file given relative to the git root.
The path is returned in the form of the workspace path, e.g. if the workspace path is a symlink pointing inside the repository, the returned path is under the symlinked workspace path, so that it can be compared with the projects paths.
The workspace is expected to be in a git repository.
@spec new( path :: String.t(), mix_path :: String.t(), config :: keyword(), projects :: [Workspace.Project.t()] ) :: t()
Initializes a new workspace from the given settings.
It expects the following:
pathis the root path of the workspacemix_pathis the root mix file, usually amix.exsin thepathconfigis the workspace configurationprojectsis a list of workspace projects
Notice that no validation is applied at this level.