conform v1.0.0-rc3 Conform.Conf
This module is exposed to schemas for usage in transformations, it contains utility functions for fetching configuration information from the current config state.
Summary
Functions
Selects key/value pairs from the conf table which match the provided key, or
are a child of the provided key. Keys can contain variables expressed as $varname
,
which act as wildcards for that element of the key
Parses a .conf from the provided binary, does some initial validation and reformatting, and dumps it into an ETS table for further processing. The table identifier is returned, but the preferred method for manipulating/querying the conf terms is via this module’s API
Parses a .conf located at the provided path, does some initial validation and reformatting, and dumps it into an ETS table for further processing. The table identifier is returned, but the preferred method for manipulating/querying the conf terms is via this module’s API
Selects key/value pairs from the conf table which match the provided key exactly,
or match the provided key+variables exactly. Keys with variables (expressed as $varname
),
act as wildcards for that element of the key, so they can match more than a single setting
Given a string or atom of the form some.path.to.a.setting
,
it breaks it into a list of it’s component parts, ensuring that
embedded module names are preserved, i.e.
"myapp.Some.Module.setting" => ['myapp', 'Some.Module', 'setting']
Removes any key/value pairs from the conf table which match the provided key or are a child of the provided key
Functions
Specs
find(non_neg_integer | atom, String.t | [char_list]) :: [{[atom], term}]
Selects key/value pairs from the conf table which match the provided key, or
are a child of the provided key. Keys can contain variables expressed as $varname
,
which act as wildcards for that element of the key.
Results are returned in the form of {key, value}
where key is the full key of the
setting.
Examples
iex> table = :ets.new(:test, [:set, keypos: 1])
...> :ets.insert(table, {['lager', 'handlers', 'console', 'level'], :info})
...> :ets.insert(table, {['lager', 'handlers', 'file', 'error'], '/var/log/error.log'})
...> Elixir.Conform.Conf.find(table, "lager.handlers.$backend.level")
[{['lager', 'handlers', 'console', 'level'], :info}]
...> Elixir.Conform.Conf.get(table, "lager.handlers.$backend")
[{['lager', 'handlers', 'console', 'level'], :info},
{['lager', 'handlers', 'file', 'error'], '/var/log/error.log'}]
Specs
from_binary(binary) ::
{:error, term} |
{:ok, non_neg_integer | atom}
Parses a .conf from the provided binary, does some initial validation and reformatting, and dumps it into an ETS table for further processing. The table identifier is returned, but the preferred method for manipulating/querying the conf terms is via this module’s API.
Specs
from_file(String.t) ::
{:error, term} |
{:ok, non_neg_integer | atom}
Parses a .conf located at the provided path, does some initial validation and reformatting, and dumps it into an ETS table for further processing. The table identifier is returned, but the preferred method for manipulating/querying the conf terms is via this module’s API.
Specs
get(non_neg_integer | atom, String.t | [char_list]) ::
[{[atom], term}] |
{:error, term}
Selects key/value pairs from the conf table which match the provided key exactly,
or match the provided key+variables exactly. Keys with variables (expressed as $varname
),
act as wildcards for that element of the key, so they can match more than a single setting.
Results are returned in the form of {key, value}
where key is the full key of the
setting.
Examples
iex> table = :ets.new(:test, [:set, keypos: 1])
...> :ets.insert(table, {['lager', 'handlers', 'console', 'level'], :info})
...> :ets.insert(table, {['lager', 'handlers', 'file', 'error'], '/var/log/error.log'})
...> Elixir.Conform.Conf.get(table, "lager.handlers.console.level")
[{['lager', 'handlers', 'console', 'level'], :info}]
...> Elixir.Conform.Conf.get(table, "lager.handlers.$backend.$setting")
[{['lager', 'handlers', 'console', 'level'], :info},
{['lager', 'handlers', 'file', 'error'], '/var/log/error.log'}]
Given a string or atom of the form some.path.to.a.setting
,
it breaks it into a list of it’s component parts, ensuring that
embedded module names are preserved, i.e.
"myapp.Some.Module.setting" => ['myapp', 'Some.Module', 'setting']
Specs
remove(non_neg_integer | atom, String.t | [char_list]) :: :ok
Removes any key/value pairs from the conf table which match the provided key or are a child of the provided key.