Skip to content

Commit f333752

Browse files
starbellywojtekmach
authored andcommitted
Fix type spec definitions and function specs (#81)
1 parent aa33cc8 commit f333752

File tree

5 files changed

+24
-16
lines changed

5 files changed

+24
-16
lines changed

src/hex_api_organization_member.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ get(Config, UsernameOrEmail) when is_map(Config) and is_binary(UsernameOrEmail)
6565
%% '''
6666
%% @end
6767
-spec add(hex_core:config(), binary(), role()) -> hex_api:response().
68-
add(Config, UsernameOrEmail, Role) when is_map(Config) and is_binary(UsernameOrEmail) and is_binary(Role) ->
68+
add(Config, UsernameOrEmail, Role) when is_map(Config) and is_binary(UsernameOrEmail) and is_atom(Role) ->
6969
Path = hex_api:build_organization_path(Config, ["members"]),
7070
Params = #{<<"name">> => UsernameOrEmail, <<"role">> => Role},
7171
hex_api:post(Config, Path, Params).
@@ -86,7 +86,7 @@ add(Config, UsernameOrEmail, Role) when is_map(Config) and is_binary(UsernameOrE
8686
%% '''
8787
%% @end
8888
-spec update(hex_core:config(), binary(), role()) -> hex_api:response().
89-
update(Config, UsernameOrEmail, Role) when is_map(Config) and is_binary(UsernameOrEmail) and is_binary(Role) ->
89+
update(Config, UsernameOrEmail, Role) when is_map(Config) and is_binary(UsernameOrEmail) and is_atom(Role) ->
9090
Path = hex_api:build_organization_path(Config, ["members", UsernameOrEmail]),
9191
Params = #{<<"role">> => Role},
9292
hex_api:post(Config, Path, Params).

src/hex_core.erl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ J1i2xWFndWa6nfFnRxZmCStCOZWYYPlaxr+FZceFbpMwzTNs4g3d4tLNUcbKAIH4
5959
http_adapter => module(),
6060
http_etag => binary() | undefined,
6161
http_adapter_config => map(),
62+
http_headers => map(),
6263
http_user_agent_fragment => binary(),
6364
repo_key => binary() | undefined,
6465
repo_name => binary(),
@@ -86,5 +87,6 @@ default_config() ->
8687
repo_url => <<"https://repo.hex.pm">>,
8788
repo_organization => undefined,
8889
repo_verify => true,
89-
repo_verify_origin => true
90+
repo_verify_origin => true,
91+
http_headers => #{}
9092
}.

src/hex_erl_tar.hrl

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
%% Options used when adding files to a tar archive.
2323
-record(add_opts, {
2424
read_info, %% Fun to use for read file/link info.
25-
chunk_size = 0, %% For file reading when sending to sftp. 0=do not chunk
26-
verbose = false, %% Verbose on/off.
27-
atime = undefined,
28-
mtime = undefined,
29-
ctime = undefined,
30-
uid = 0,
31-
gid = 0}).
25+
chunk_size = 0 :: integer(), %% For file reading when sending to sftp. 0=do not chunk
26+
verbose = false :: boolean(), %% Verbose on/off.
27+
atime = undefined :: undefined | integer(),
28+
mtime = undefined :: undefined | integer(),
29+
ctime = undefined :: undefined | integer(),
30+
uid = 0 :: integer(),
31+
gid = 0 :: integer()}).
3232
-type add_opts() :: #add_opts{}.
3333

3434
%% Options used when reading a tar archive.
@@ -41,9 +41,15 @@
4141
verbose = false :: boolean()}). %% Verbose on/off.
4242
-type read_opts() :: #read_opts{}.
4343

44-
-type add_opt() :: dereference |
45-
verbose |
46-
{chunks, pos_integer()}.
44+
-type add_opt() :: dereference
45+
| verbose
46+
| {chunks, pos_integer()}
47+
| {atime, integer()}
48+
| {mtime, integer()}
49+
| {ctime, integer()}
50+
| {uid, integer()}
51+
| {gid, integer()}.
52+
4753

4854
-type extract_opt() :: {cwd, string()} |
4955
{files, [string()]} |

src/hex_registry.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ decode_signed(Signed) ->
9191

9292
%% @doc
9393
%% Decode message created with sign_protobuf/2 and verify it against public key.
94-
-spec decode_and_verify_signed(map(), public_key()) -> {ok, binary()} | {error, term()}.
94+
-spec decode_and_verify_signed(binary(), public_key()) -> {ok, binary()} | {error, term()}.
9595
decode_and_verify_signed(Signed, PublicKey) ->
9696
#{payload := Payload, signature := Signature} = decode_signed(Signed),
9797
case verify(Payload, Signature, PublicKey) of

src/hex_tarball.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
-type checksum() :: binary().
1919
-type contents() :: #{filename() => binary()}.
2020
-type filename() :: string().
21-
-type files() :: [filename() | {filename(), filename()}] | contents().
21+
-type files() :: [{filename(), filename() | binary()}].
2222
-type metadata() :: map().
2323
-type tarball() :: binary().
2424

@@ -43,7 +43,7 @@
4343
%% inner_checksum => <<178,12,...>>}}
4444
%% '''
4545
%% @end
46-
-spec create(metadata(), files()) -> {ok, {tarball(), checksum()}}.
46+
-spec create(metadata(), files()) -> {ok, {tarball(), checksum()}} | {error, term()}.
4747
create(Metadata, Files) ->
4848
MetadataBinary = encode_metadata(Metadata),
4949
ContentsTarball = create_memory_tarball(Files),

0 commit comments

Comments
 (0)