Workspace.State (Workspace v0.2.1)

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 root mix.exs file.
  • :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
  • :config - the workspace's configuration, check Workspace.Config for more details.

Summary

Types

t()

Struct holding the workspace state.

Functions

Initializes a new workspace from the given settings.

Types

t()

@type t() :: %Workspace.State{
  config: keyword(),
  cwd: binary(),
  git_root_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 root mix.exs.
  • :workspace_path - The workspace root path.
  • :git_root_path - The git root path, of the repository containing the workspace.
  • :cwd - The directory from which the workspace was generated.
  • :graph - The DAG (directed acyclic graph) of the workspace.
  • :status_updated? - Set to true if the workspace status has been updated.

Functions

new(path, mix_path, config, projects)

@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:

  • path is the root path of the workspace
  • mix_path is the root mix file, usually a mix.exs in the path
  • config is the workspace configuration
  • projects is a list of workspace projects

Notice that no validation is applied at this level.