aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric <[email protected]>2012-10-26 17:21:24 -0500
committerJordan Wilberding <[email protected]>2012-10-30 09:54:42 -0600
commit0ffe8cd1a2a4e039a48d1096fc250b3f6bd3dcd1 (patch)
tree5ba4eb976bc8a113e6d38839173f26c0036e69db /src
parentb8d54a7736f3b75d442de1f0239a7b5b3c0f8528 (diff)
downloadrelx-0ffe8cd1a2a4e039a48d1096fc250b3f6bd3dcd1.tar.gz
relx-0ffe8cd1a2a4e039a48d1096fc250b3f6bd3dcd1.tar.bz2
relx-0ffe8cd1a2a4e039a48d1096fc250b3f6bd3dcd1.zip
make `is_valid_constraint` public in rcl_depsolver
Signed-off-by: Jordan Wilberding <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/rcl_depsolver.erl69
1 files changed, 36 insertions, 33 deletions
diff --git a/src/rcl_depsolver.erl b/src/rcl_depsolver.erl
index 4d61d6c..e74cf3b 100644
--- a/src/rcl_depsolver.erl
+++ b/src/rcl_depsolver.erl
@@ -88,6 +88,7 @@
add_package_version/3,
add_package_version/4,
parse_version/1,
+ is_valid_constraint/1,
filter_packages/2]).
%% Internally Exported API. This should *not* be used outside of the rcl_depsolver
@@ -250,7 +251,7 @@ solve({?MODULE, DepGraph0}, RawGoals)
end
end.
-%% Parse a string version into a tuple based version
+%% @doc Parse a string version into a tuple based version
-spec parse_version(raw_vsn() | vsn()) -> vsn().
parse_version(RawVsn)
when erlang:is_list(RawVsn);
@@ -260,6 +261,40 @@ parse_version(Vsn)
when erlang:is_tuple(Vsn) ->
Vsn.
+%% @doc check that a specified constraint is a valid constraint.
+-spec is_valid_constraint(constraint()) -> boolean().
+is_valid_constraint(Pkg) when is_atom(Pkg) orelse is_binary(Pkg) ->
+ true;
+is_valid_constraint({_Pkg, Vsn}) when is_tuple(Vsn) ->
+ true;
+is_valid_constraint({_Pkg, Vsn, '='}) when is_tuple(Vsn) ->
+ true;
+is_valid_constraint({_Pkg, _LVsn, gte}) ->
+ true;
+is_valid_constraint({_Pkg, _LVsn, '>='}) ->
+ true;
+is_valid_constraint({_Pkg, _LVsn, lte}) ->
+ true;
+is_valid_constraint({_Pkg, _LVsn, '<='}) ->
+ true;
+is_valid_constraint({_Pkg, _LVsn, gt}) ->
+ true;
+is_valid_constraint({_Pkg, _LVsn, '>'}) ->
+ true;
+is_valid_constraint({_Pkg, _LVsn, lt}) ->
+ true;
+is_valid_constraint({_Pkg, _LVsn, '<'}) ->
+ true;
+is_valid_constraint({_Pkg, _LVsn, pes}) ->
+ true;
+is_valid_constraint({_Pkg, _LVsn, '~>'}) ->
+ true;
+is_valid_constraint({_Pkg, _LVsn1, _LVsn2, between}) ->
+ true;
+is_valid_constraint(_InvalidConstraint) ->
+ false.
+
+
%% @doc given a list of package name version pairs, and a list of constraints
%% return every member of that list that matches all constraints.
-spec filter_packages([{pkg_name(), raw_vsn()}], [raw_constraint()]) ->
@@ -422,38 +457,6 @@ dep_pkg({Pkg, _Vsn1, _Vsn2, _}) ->
dep_pkg(Pkg) when is_atom(Pkg) orelse is_binary(Pkg) ->
Pkg.
--spec is_valid_constraint(constraint()) -> boolean().
-is_valid_constraint(Pkg) when is_atom(Pkg) orelse is_binary(Pkg) ->
- true;
-is_valid_constraint({_Pkg, Vsn}) when is_tuple(Vsn) ->
- true;
-is_valid_constraint({_Pkg, Vsn, '='}) when is_tuple(Vsn) ->
- true;
-is_valid_constraint({_Pkg, _LVsn, gte}) ->
- true;
-is_valid_constraint({_Pkg, _LVsn, '>='}) ->
- true;
-is_valid_constraint({_Pkg, _LVsn, lte}) ->
- true;
-is_valid_constraint({_Pkg, _LVsn, '<='}) ->
- true;
-is_valid_constraint({_Pkg, _LVsn, gt}) ->
- true;
-is_valid_constraint({_Pkg, _LVsn, '>'}) ->
- true;
-is_valid_constraint({_Pkg, _LVsn, lt}) ->
- true;
-is_valid_constraint({_Pkg, _LVsn, '<'}) ->
- true;
-is_valid_constraint({_Pkg, _LVsn, pes}) ->
- true;
-is_valid_constraint({_Pkg, _LVsn, '~>'}) ->
- true;
-is_valid_constraint({_Pkg, _LVsn1, _LVsn2, between}) ->
- true;
-is_valid_constraint(_InvalidConstraint) ->
- false.
-
-spec add_constraint(pkg_name(), vsn(), [constraint()],constraint()) -> ordered_constraints().
add_constraint(SrcPkg, SrcVsn, PkgsConstraints, PkgConstraint) ->
case is_valid_constraint(PkgConstraint) of