Rename the object module to geef_obj
This leaves us geef_object as the record to match against.
This commit is contained in:
19
lib/geef/object.ex
Normal file
19
lib/geef/object.ex
Normal file
@@ -0,0 +1,19 @@
|
||||
defrecord :geef_object, Record.extract(:geef_object, from: "src/geef_records.hrl")
|
||||
|
||||
defmodule Geef.Object do
|
||||
|
||||
def lookup(repo, id), do: :geef_obj.lookup(repo, id)
|
||||
def lookup!(repo, id) do
|
||||
case :geef_obj.lookup(repo, id) do
|
||||
{:ok, obj} ->
|
||||
obj
|
||||
{:error, err} ->
|
||||
raise err
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def lookup(repo, id, type), do: :geef_obj.lookup(repo, id, type)
|
||||
def id(obj), do: :geef_obj.id(obj)
|
||||
|
||||
end
|
||||
@@ -10,11 +10,11 @@
|
||||
|
||||
-spec lookup(pid(), geef_oid() | iolist()) -> geef_object().
|
||||
lookup(Repo, Id) ->
|
||||
geef_object:lookup(Repo, Id, blob).
|
||||
geef_obj:lookup(Repo, Id, blob).
|
||||
|
||||
-spec id(geef_object()) -> geef_oid().
|
||||
id(Obj = #geef_object{type=blob}) ->
|
||||
geef_object:id(Obj).
|
||||
geef_obj:id(Obj).
|
||||
|
||||
size(#geef_object{type=blob, handle=Handle}) ->
|
||||
geef_nif:blob_size(Handle).
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
-module(geef_object).
|
||||
-module(geef_obj).
|
||||
|
||||
-ifdef(TEST).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
-include("geef_records.hrl").
|
||||
|
||||
-export([lookup/2, lookup/3, id/1, type/1]).
|
||||
-export([lookup/2, lookup/3, id/1]).
|
||||
|
||||
-spec lookup(pid(), geef_oid() | iolist()) -> {ok, geef_object()} | {error, term()}.
|
||||
lookup(Repo, #geef_oid{oid=Oid}) ->
|
||||
@@ -38,10 +38,6 @@ id(#geef_object{handle=Handle}) ->
|
||||
Other
|
||||
end.
|
||||
|
||||
-spec type(geef_object()) -> atom().
|
||||
type(#geef_object{type=Type}) ->
|
||||
Type.
|
||||
|
||||
-ifdef(TEST).
|
||||
|
||||
lookup_test() ->
|
||||
@@ -23,7 +23,7 @@ id(Obj = #geef_object{type=tree}) ->
|
||||
|
||||
-spec lookup(pid(), geef_oid() | iolist()) -> {ok, geef_object()} | {error, term()}.
|
||||
lookup(Repo, Id) ->
|
||||
geef_object:lookup(Repo, Id, tree).
|
||||
geef_obj:lookup(Repo, Id, tree).
|
||||
|
||||
-ifdef(TEST).
|
||||
|
||||
@@ -31,7 +31,7 @@ lookup(Repo, Id) ->
|
||||
%% but it's good enough for now
|
||||
bypath_test() ->
|
||||
{ok, Repo} = geef_repo:open(".."),
|
||||
{ok, Tree} = geef_object:lookup(Repo, geef_oid:parse("395e1c39cb203640b78da8458a42afdb92bef7aa")),
|
||||
{ok, Tree} = geef_obj:lookup(Repo, geef_oid:parse("395e1c39cb203640b78da8458a42afdb92bef7aa")),
|
||||
Id = geef_oid:parse("80d5c15a040c93a4f98f4496a05ebf30cdd58650"),
|
||||
{ok, 8#100644, blob, Id, <<"README.md">>} = geef_tree:get(Tree, "README.md").
|
||||
-endif.
|
||||
|
||||
Reference in New Issue
Block a user