Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/filmor/tomerl
Erlang TOML Parser
https://github.com/filmor/tomerl
Last synced: 2 months ago
JSON representation
Erlang TOML Parser
- Host: GitHub
- URL: https://github.com/filmor/tomerl
- Owner: filmor
- License: other
- Created: 2020-04-27T15:10:37.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-09-09T11:57:39.000Z (over 1 year ago)
- Last Synced: 2024-10-14T13:14:04.771Z (2 months ago)
- Language: Erlang
- Size: 257 KB
- Stars: 22
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
TOML Parser for Erlang
======================[![CI](https://github.com/filmor/tomerl/workflows/CI/badge.svg)](https://github.com/filmor/tomerl/actions)
[![Hex](https://img.shields.io/hexpm/v/tomerl)](https://hex.pm/packages/tomerl)
[![TOML](https://img.shields.io/badge/TOML-1.0.0-blue)](https://toml.io/en/v1.0.0)
[![License](https://img.shields.io/hexpm/l/tomerl)](./LICENSE.md)`tomerl` is an Erlang library for parsing
[TOML 1.0.0](https://toml.io/en/v1.0.0) data, forked from [toml](https://github.com/dozzie/toml)
by Stanisław Klekot.The documentation at [Hexdocs](https://hexdocs.pm/tomerl) is updated on release, it can be generated locally via `rebar3 edoc`.
Usage Example
-------------Assuming an input file called `config.toml` with the following content:
```toml
lipsum = "lorem ipsum dolor sit amet"[apples]
count = 2[berry.black]
has_some = true
```the data can be read in Erlang like this:
```erlang
{ok, Data} = tomerl:read_file("config.toml").>>> Data = #{
<<"lipsum">> => <<"lorem ipsum dolor sit amet">>,
<<"apples">> => #{ <<"count">> => 2 },
<<"berry">> => #{ <<"black">> => #{ <<"has_some">> => true }}
}.
```To access the data, there is a simple `get` function that accepts lists of strings, binaries and atoms:
```erlang
{ok, true} = tomerl:get(Data, [berry, black, has_some]),
{ok, 2} = tomerl:get(Data, ["apples", <<"count">>]),
{error, not_found} = tomerl:get(Data, [something, undefined]).
```