Skip to content

Commit

Permalink
added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Maier committed Dec 21, 2019
1 parent 848f2fc commit b6f1c0f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
23 changes: 16 additions & 7 deletions lib/hocon_url_resolver.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
defmodule HoconUrlResolver do
@moduledoc """
This module is responsible for loading resources from internet.
This module is responsible for loading resources from the internet.
It uses the `HTTPoison` client to fetch the configuration. It is used with `Hocon` to include URL configuration by using
the module with the Keyword `:url_resolver`:
## Example
iex> Hocon.decode( ~s( b : { include url\("https://raw.githubusercontent.com/zookzook/hocon-url-resolver/master/test/data/config-1.conf"\) }), url_resolver: HoconUrlResolver )
{:ok, %{"b" => %{"a" => "The answer is 42"}}}
"""

@behaviour Hocon.Resolver
Expand All @@ -9,9 +18,9 @@ defmodule HoconUrlResolver do
Returns `true` if `resource` exists.
## Example
iex> HoconUrlResolver.exists?("https://where")
iex> HoconUrlResolver.exists?("https://raw.githubusercontent.com/zookzook/hocon-url-resolver/master/test/data/config-2.conf")
false
iex> HoconUrlResolver.exists?("https://where")
iex> HoconUrlResolver.exists?("https://raw.githubusercontent.com/zookzook/hocon-url-resolver/master/test/data/config-1.conf")
true
"""
Expand All @@ -28,10 +37,10 @@ defmodule HoconUrlResolver do
Returns a tuple with the content of the `resource`
## Example
iex> HoconUrlResolver.load("app.conf")
{:error, :enoent}
iex> HoconUrlResolver.load("./test/data/include-1.conf")
{:ok, "{ x : 10, y : ${a.x} }"}
iex> HoconUrlResolver.load("https://raw.githubusercontent.com/zookzook/hocon-url-resolver/master/test/data/config-2.conf")
{:error, "not found"}
iex> HoconUrlResolver.load("https://raw.githubusercontent.com/zookzook/hocon-url-resolver/master/test/data/config-1.conf")
{:ok, "{\\n a : \\"The answer is 42\\"\\n}"}
"""
@spec load(Path.t()) :: {:ok, binary} | {:error, File.posix}
def load(url) do
Expand Down
1 change: 1 addition & 0 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ defmodule HoconUrlResolver.MixProject do
defp deps do
[
{:excoveralls, "~> 0.12.1", only: :test},
{:ex_doc, "~> 0.21", only: :dev, runtime: false},
{:httpoison, "~> 1.6"},
{:hocon, "~> 0.1.5"}
]
Expand Down
5 changes: 5 additions & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
%{
"certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"},
"earmark": {:hex, :earmark, "1.4.3", "364ca2e9710f6bff494117dbbd53880d84bebb692dafc3a78eb50aa3183f2bfd", [:mix], [], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.21.2", "caca5bc28ed7b3bdc0b662f8afe2bee1eedb5c3cf7b322feeeb7c6ebbde089d6", [:mix], [{:earmark, "~> 1.3.3 or ~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
"excoveralls": {:hex, :excoveralls, "0.12.1", "a553c59f6850d0aff3770e4729515762ba7c8e41eedde03208182a8dc9d0ce07", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
"hackney": {:hex, :hackney, "1.15.2", "07e33c794f8f8964ee86cebec1a8ed88db5070e52e904b8f12209773c1036085", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.5", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
"hocon": {:hex, :hocon, "0.1.5", "448e47a56a29a3e82914954d7ae0462e271f58ff0bbc78bb64cc307f162ea723", [:mix], [], "hexpm"},
"httpoison": {:hex, :httpoison, "1.6.2", "ace7c8d3a361cebccbed19c283c349b3d26991eff73a1eaaa8abae2e3c8089b6", [:mix], [{:hackney, "~> 1.15 and >= 1.15.2", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"},
"idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
"jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
"makeup": {:hex, :makeup, "1.0.0", "671df94cf5a594b739ce03b0d0316aa64312cee2574b6a44becb83cd90fb05dc", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"},
"makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"},
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"},
"mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm"},
"nimble_parsec": {:hex, :nimble_parsec, "0.5.3", "def21c10a9ed70ce22754fdeea0810dafd53c2db3219a0cd54cf5526377af1c6", [:mix], [], "hexpm"},
"parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.5", "6eaf7ad16cb568bb01753dbbd7a95ff8b91c7979482b95f38443fe2c8852a79b", [:make, :mix, :rebar3], [], "hexpm"},
"unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm"},
Expand Down

0 comments on commit b6f1c0f

Please sign in to comment.