View Source hex_repo (hex_core v0.10.3)

Repo API.

Summary

Functions

Gets docs tarball from the repository.

Gets names resource from the repository.

Gets package resource from the repository.

Gets the public key from the repository.

Gets tarball from the repository.

Gets versions resource from the repository.

Functions

get_docs(Config, Name, Version)

Gets docs tarball from the repository.

Examples:

  > {ok, {200, _, Docs}} = hex_repo:get_docs(hex_core:default_config(), <<"package1">>, <<"1.0.0">>),
  > hex_tarball:unpack_docs(Docs, memory)
  {ok, [{"index.html", <<"<!doctype>">>}, ...]}

get_names(Config)

Gets names resource from the repository.

Examples:

  > hex_repo:get_names(hex_core:default_config()).
  {ok,{200, ...,
       #{packages => [
             #{name => <<"package1">>},
             #{name => <<"package2">>},
             ...]}}}

get_package(Config, Name)

Gets package resource from the repository.

Examples:

  > hex_repo:get_package(hex_core:default_config(), <<"package1">>).
  {ok, {200, ...,
        #{name => <<"package1">>,
          releases => [
              #{checksum => ..., version => <<"0.5.0">>, dependencies => []},
              #{checksum => ..., version => <<"1.0.0">>, dependencies => [
                    #{package => <<"package2">>, optional => true, requirement => <<"~> 0.1">>}
              ]},
      ]}}}

get_public_key(Config)

Gets the public key from the repository.

Examples:

  > hex_repo:get_public_key(hex_core:default_config())
  {ok, {200, _, PublicKey}}

get_tarball(Config, Name, Version)

Gets tarball from the repository.

Examples:

  > {ok, {200, _, Tarball}} = hex_repo:get_tarball(hex_core:default_config(), <<"package1">>, <<"1.0.0">>),
  > {ok, #{metadata := Metadata}} = hex_tarball:unpack(Tarball, memory).

get_versions(Config)

Gets versions resource from the repository.

Examples:

  > hex_repo:get_versions(Config).
  {ok, {200, ...,
        #{packages => [
              #{name => <<"package1">>, retired => [],
                versions => [<<"1.0.0">>]},
              #{name => <<"package2">>, retired => [<<"0.5.0>>"],
                versions => [<<"0.5.0">>, <<"1.0.0">>]},
              ...]}}}