# `Juggernaut.Config.Loader`
[🔗](https://github.com/holsee/juggernaut/blob/v0.4.0/lib/juggernaut/config/loader.ex#L1)

Reads and checks `.juggernaut.exs` (see the [configuration guide](configuration.md)).

Checked in this order, each failure a config error naming the file:

  1. the file evaluates (syntax errors, raises, throws and exits are reported, never
     crash the task);
  2. the result is a keyword list;
  3. no key is given twice, at the top level or inside a nested group (checked before
     NimbleOptions, whose message for that case is `unknown options`);
  4. NimbleOptions validation: unknown keys reported together, nested errors with their
     path.

# `check`

```elixir
@spec check(term()) :: {:ok, keyword()} | {:error, Juggernaut.Error.t()}
```

Checks an evaluated config term and validates it against the schema.

# `error`

```elixir
@spec error(String.t(), map()) :: Juggernaut.Error.t()
```

A config error whose message names the config file.

# `file_name`

```elixir
@spec file_name() :: String.t()
```

The config file name, relative to the project root.

# `load`

```elixir
@spec load(Path.t()) ::
  {:ok, keyword(), Path.t() | nil} | {:error, Juggernaut.Error.t()}
```

Reads the config of the project at `root`: `{:ok, options, path}` with defaults filled
(`path` is `nil` when there is no file), or a config error.

# `read`

```elixir
@spec read(Path.t()) :: {:ok, term()} | {:error, Juggernaut.Error.t()}
```

Evaluates `path`; a missing file is an empty keyword list.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
