# econfig - simple Erlang config handler using INI files #

Copyright (c) 2012-2015 Benoît Chesneau.

__Version:__ 0.6.2

# econfig

econfig is a simple Erlang config handler to manage a config from INI

[![Build Status](](
[![Hex pm](](

econfig can be use to read and update INI files. Values are cached in an
ETS table and you can manage multiple configuration profiles. A process
can also subscribe to config updates events.

Autoreload of the config when an INI file is updated is supported, you can even
manage changes from a full config directory.

See the [NEWS](
for last changes.

#### Useful modules are:

- [`econfig`]( main module. It contains all the API.

## Examples

Quick usage example:

1> application:ensure_all_started(econfig).
2> econfig:register_config(test, ["test/fixtures/test.ini", "test/fixtures/test2.ini"], [autoreload]).
3> econfig:subscribe(test).
4> econfig:get_value(test, "section1").
[{"key 3","value 3"},
 {"key2","value 2"},
 {"key4","value 4"},
5> econfig:set_value(test, "section1", "key6", "value6").
6> flush().
Shell got {config_updated,test,{set,{"section1","key6"}}}

## Advanced features

### on_change hook

Some application may want to handle changes without suscribing to change. This change allows a user to pass a change function when registering the configuation. This function will be called each time a change happen.

### helpers functions

econfig do not guess datatypes of values in configuration files, always storing them internally as strings. This means that if you need other datatypes, you should convert on your own. Some helpers are provided to do it:

- `econfig:get_boolean/{3, 4}`: to convert to boolean
- `econfig:get_integer/{3, 4}`: to convert to integer
- `econfig:get_float/{3, 4}`: to convert to float
- `econfig:get_list/{3, 4}`: to convert a list of string separated by `,` to a list.
- `econfig:get_binary/{3, 4}`: to convert to a binary

For issues, comments or feedback please [create an issue!] [1]

[1]: "econfig issues"