Module hex_tarball
Data Types
checksum()
checksum() = binary()
contents()
contents() = #{filename() => binary()}
filename()
filename() = string()
files()
files() = [filename() | {filename(), filename()}] | contents()
metadata()
metadata() = map()
tarball()
tarball() = binary()
Function Index
create/2 | Creates a package tarball. |
create_docs/1 | Creates a docs tarball. |
format_checksum/1 | Returns base16-encoded representation of checksum. |
format_error/1 | Converts an error reason term to a human-readable error message string. |
unpack/2 | Unpacks a package tarball. |
Function Details
create/2
create(Metadata::metadata(), Files::files()) -> {ok, {tarball(), checksum()}}
Creates a package tarball.
Examples:
> Metadata = #{<<"name">> => <<"foo">>, <<"version">> => <<"1.0.0">>},
> Files = [{"src/foo.erl", <<"-module(foo).">>}],
> {ok, {Tarball, Checksum}} = hex_tarball:create(Metadata, Files).
> Tarball.
<<86,69,...>>
> Checksum.
<<40,32,...>>
create_docs/1
create_docs(Files::files()) -> {ok, {tarball(), checksum()}}
Creates a docs tarball.
Examples:
> Files = [{"doc/index.html", <<"Docs">>}],
> {ok, {Tarball, Checksum}} = hex_tarball:create_docs(Files).
> Tarball.
%%=> <<86,69,...>>
> Checksum.
%%=> <<40,32,...>>
format_checksum/1
format_checksum(Checksum::checksum()) -> binary()
Returns base16-encoded representation of checksum.
format_error/1
format_error(X1::term()) -> string()
Converts an error reason term to a human-readable error message string.
unpack/2
unpack(Tarball::tarball(), Output::memory) -> {ok, #{checksum => checksum(), metadata => metadata(), contents => contents()}} | {error, term()}
Unpacks a package tarball.
Examples:
> hex_tarball:unpack(Tarball, memory).
{ok,#{checksum => <<...>>,
contents => [{"src/foo.erl",<<"-module(foo).">>}],
metadata => #{<<"name">> => <<"foo">>, ...}}}
> hex_tarball:unpack(Tarball, "path/to/unpack").
{ok,#{checksum => <<...>>,
metadata => #{<<"name">> => <<"foo">>, ...}}}