Add typespecs to the functions

This commit is contained in:
Carlos Martín Nieto
2013-01-25 03:33:02 +01:00
parent 3c6b1ddaf5
commit 78e0693b8a
4 changed files with 13 additions and 4 deletions

View File

@@ -3,5 +3,6 @@
-include("geef_records.hlr").
-spec exists(odb(), string()) -> boolean().
exists(#odb{handle=Handle}, Sha) ->
geef:odb_object_exists(Handle, Sha).

View File

@@ -2,4 +2,6 @@
-record(repo, {handle}).
-record(odb, {handle}).
-type repo() :: repo.
-type ref() :: #ref{}.
-type repo() :: #repo{}.
-type odb() :: #odb{}.

View File

@@ -4,11 +4,12 @@
-include("geef_records.hlr").
-spec new(term()) -> ref().
new(Handle) ->
Type = geef:reference_type(Handle),
#ref{handle=Handle, type=Type}.
-spec lookup(term(), iolist()) -> term().
-spec lookup(repo(), iolist()) -> {ok, ref()} | {error, term()}.
lookup(#repo{handle=Handle}, Refname) ->
case geef:reference_lookup(Handle, Refname) of
{ok, Ref} ->
@@ -17,6 +18,7 @@ lookup(#repo{handle=Handle}, Refname) ->
Other
end.
-spec resolve(ref()) -> {ok, ref()} | {error, term()}.
resolve(#ref{handle=Handle}) ->
case geef:reference_resolve(Handle) of
{ok, Ref} ->
@@ -25,6 +27,6 @@ resolve(#ref{handle=Handle}) ->
Other
end.
-spec target(term()) -> binary().
-spec target(ref()) -> binary().
target(#ref{handle=Handle, type=oid}) ->
geef:reference_target(Handle).

View File

@@ -4,19 +4,23 @@
-include("geef_records.hlr").
-spec path(repo()) -> binary().
path(#repo{handle=Handle}) ->
geef:repository_get_path(Handle).
-spec workdir(repo()) -> binary().
workdir(#repo{handle=Handle}) ->
geef:repository_get_workdir(Handle).
-spec is_bare(repo()) -> boolean().
is_bare(#repo{handle=Handle}) ->
geef:repository_is_bare(Handle).
-spec references(repo()) -> [binary()].
references(#repo{handle=Handle}) ->
geef:reference_list(Handle).
-spec open(iolist()) -> {ok, term()} | {error, term()}.
-spec open(iolist()) -> {ok, repo()} | {error, term()}.
open(Path) ->
case geef:repository_open(Path) of
{ok, Handle} ->