Toml Elixir v1.1.0 TomlElixir View Source
TomlElixir
TOML parser for elixir.
Installation
The package can be installed by adding toml_elixir
to your list of
dependencies in mix.exs
:
def deps do
[{:toml_elixir, "~> 1.1.0"}]
end
Usage
TomlElixir is used by calling parse functions
Link to this section Summary
Types
Toml group means list of values
Toml ident is same as value tuple but this means identifier or key
Toml key value means tuple with toml identifier and value
Multi is same as group but with difference that it’s a list of maps
Toml return is just list of any toml types
Toml value is a tuple with type and actual value
Functions
Parse toml string to map or return toml tuple list
Same as parse/2
, but raises error on failure
Parse toml file, uses same options as parse/2
Same as parse_file/2
, but raises error on failure
Link to this section Types
Toml group means list of values
First list is list of identifiers which point to place in map
Example
Toml:
[key]
example = ["value", true]
Tuple:
{:group,
[{:identifier, "key"}, {:identifier, "example"}],
[{:string, "value"}, {:boolean, true}]}
Map:
%{
"key" => %{
"example" => ["value", true]
}
}
Toml ident is same as value tuple but this means identifier or key
Toml key value means tuple with toml identifier and value
Example
Toml:
key = value
Tuple:
{{:identifier, "key"}, {:string, "value"}}
Map:
%{"key" => "val"}
Multi is same as group but with difference that it’s a list of maps
Example
Toml:
[[key]]
example1 = val1
[[key]]
example2 = val2
Tuple:
[
{:multi,
[{:identifier, "key"}, {:identifier, "example1"}],
[{:string, "val1"}]},
{:multi,
[{:identifier, "key"}, {:identifier, "example2"}],
[{:string, "val2"}]},
]
Map:
%{
"key" => [
%{"example1" => "val1"},
%{"example2" => "val2"},
]
}
toml_return() :: [toml_key_val | toml_multi | toml_group] | []
Toml return is just list of any toml types
toml_value :: {:string, binary} | {:datetime, tuple} | {:number, number} | {:boolean, boolean}
Toml value is a tuple with type and actual value
Link to this section Functions
Parse toml string to map or return toml tuple list.
Example
TomlElixir.parse("toml = true")
Same as parse/2
, but raises error on failure
Example
TomlElixir.parse!("toml = true")
Parse toml file, uses same options as parse/2
Example
TomlElixir.parse_file("path/to/example.toml")
Same as parse_file/2
, but raises error on failure
Example
TomlElixir.parse_file!("path/to/example.toml")