View Source GitHubActions.Config (GitHubActions v0.2.1)

A simple keyword-based configuration API.

examples

Examples

This module is used to define the configuration for GitHubActions.

import GitHubActions.Config

config :linux,
  name: "Ubuntu",
  runs_on: "ubuntu-latest"

config key: "value"

Link to this section Summary

Functions

Returns the configuration.

Adds the given data to the configuration.

Adds the given value to the configuration under the given key.

Returns the value for key or keys.

Returns the value for key or keys in a tuple.

Returns the value for key or keys.

Reads the configuration from the given path.

Link to this section Types

@type config() :: keyword()
@type key() :: atom()
@type keys() :: [atom()]
@type value() :: any()

Link to this section Functions

@spec config() :: config()

Returns the configuration.

@spec config(config()) :: config() | nil

Adds the given data to the configuration.

Returns the configuration that was previously stored.

@spec config(key(), value()) :: config() | nil

Adds the given value to the configuration under the given key.

Returns the configuration that was previously stored.

@spec fetch!(key() | keys()) :: value()

Returns the value for key or keys.

examples

Examples

iex> Config.fetch!(:jobs)
[:linux]

iex> Config.fetch!([:linux, :runs_on])
"ubuntu-latest"

iex> Config.fetch!([:linux, :foo])
** (KeyError) key :foo not found in: [name: "Ubuntu", runs_on: "ubuntu-latest"]
@spec fetch(key() | keys()) :: value()

Returns the value for key or keys in a tuple.

If the configuration parameter does not exist, the function returns error.

examples

Examples

iex> Config.fetch(:jobs)
{:ok, [:linux]}

iex> Config.fetch(:foo)
:error

iex> Config.fetch([:linux, :name])
{:ok, "Ubuntu"}
Link to this function

get(keys, default \\ nil)

View Source
@spec get(key() | keys(), value()) :: value()

Returns the value for key or keys.

If the configuration parameter does not exist, the function returns the default value.

examples

Examples

iex> Config.get(:jobs)
[:linux]

iex> Config.get(:foo, :bar)
:bar

iex> Config.get([:linux, :runs_on])
"ubuntu-latest"

iex> Config.get(:foo)
nil
@spec read(Path.t()) :: :ok | {:error, :enonet}

Reads the configuration from the given path.