Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added atleast: version prefix

  • Loading branch information...
commit 5688d6ab5b67ec30b8e0729cf37b76b8417265b1 1 parent 504775b
@yrashk yrashk authored
View
BIN  rebar
Binary file not shown
View
8 src/agner.erl
@@ -100,12 +100,12 @@ main(_) ->
spec(Name) ->
spec(Name, {branch, "master"}).
-spec(Name, Version) when is_list(Version) ->
- spec(Name, agner_spec:list_to_version(Version));
-
spec(Name, Version) when is_atom(Name) ->
spec(atom_to_list(Name),Version);
+spec(Name, Version) when is_list(Version) ->
+ spec(Name, agner_spec:list_to_version(Name, Version));
+
spec(Name, Version) ->
gen_server:call(agner_server, {spec, Name, Version}).
@@ -121,7 +121,7 @@ fetch(Name, Directory) ->
fetch(Name, {branch, "master"}, Directory).
fetch(Name, Version, Directory) when is_list(Version) ->
- fetch(Name, agner_spec:list_to_version(Version), Directory);
+ fetch(Name, agner_spec:list_to_version(Name, Version), Directory);
fetch(Name, Version, Directory) ->
gen_server:call(agner_server, {fetch, Name, Version, Directory}, infinity). %% fetch might be time consuming
View
12 src/agner_server.erl
@@ -167,11 +167,11 @@ handle_spec(Name, Version, From, [Mod0|Rest]) ->
handle_spec(Name, Version, From, Rest);
_ ->
case sha1(Mod, Name, Version) of
- undefined ->
- gen_server:reply(From, {error, bad_version});
- SHA1 ->
+ SHA1 when is_list(SHA1) ->
Data = Mod:spec(Name, SHA1),
- gen_server:reply(From, Data)
+ gen_server:reply(From, Data);
+ _ ->
+ gen_server:reply(From, {error, bad_version})
end
end.
@@ -223,7 +223,9 @@ sha1(Mod, Name, Version) ->
proplists:get_value(Branch, Branches);
{tag, Tag} ->
Tags = Mod:tags(Name),
- proplists:get_value(Tag, Tags)
+ proplists:get_value(Tag, Tags);
+ no_such_version ->
+ no_such_version
end.
View
21 src/agner_spec.erl
@@ -1,6 +1,6 @@
-module(agner_spec).
-include_lib("agner.hrl").
--export([parse/1, list_to_version/1, version_to_list/1]).
+-export([parse/1, list_to_version/2, version_to_list/1]).
-type agner_spec_source() :: string().
@@ -21,11 +21,21 @@ parse(S) ->
[[Token]]
end, [], Tokens)))).
--spec list_to_version(string()) -> agner_spec_version().
+-spec list_to_version(agner_spec_name(), string()) -> agner_spec_version().
-list_to_version("@" ++ Version) ->
+list_to_version(Name, "atleast:" ++ Version) ->
+ case lists:reverse(lists:dropwhile(fun(V) ->
+ V < {tag, Version}
+ end, lists:usort(agner:versions(Name)))) of
+ [] ->
+ no_such_version;
+ [_|_] = L ->
+ hd(L)
+ end;
+
+list_to_version(_, "@" ++ Version) ->
{branch, Version};
-list_to_version(Version) ->
+list_to_version(_, Version) ->
{tag, Version}.
-spec version_to_list(agner_spec_version()) -> string().
@@ -34,6 +44,3 @@ version_to_list({branch, Version}) ->
"@" ++ Version;
version_to_list({tag, Version}) ->
Version.
-
-
-
Please sign in to comment.
Something went wrong with that request. Please try again.