hocon v0.1.8 Hocon.FileResolver View Source

This module is responsible for loading file resources.

By implementing the behaviour Hocon.Resolver it is possible to replace this module. For example to load the resource from a database or from an url.

Link to this section Summary

Functions

Returns true if resource exists.

Returns a tuple with the content of the resource

Link to this section Functions

Link to this function

exists?(resource)

View Source
exists?(Path.t()) :: boolean()

Returns true if resource exists.

Example

iex> Hocon.FileResolver.exists?("app.conf")
false
iex> Hocon.FileResolver.exists?("./test/data/include-1.conf")
true
Link to this function

load(resource)

View Source
load(Path.t()) :: {:ok, binary()} | {:error, File.posix()}

Returns a tuple with the content of the resource

Example

iex> Hocon.FileResolver.load("app.conf")
{:error, :enoent}
iex> Hocon.FileResolver.load("./test/data/include-1.conf")
{:ok, "{ x : 10, y : ${a.x} }"}