From 1dabd217dbfbebae2f5375160551c35cd1f2a972 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 20 Sep 2014 13:51:14 -0500 Subject: inefficient way, but safer, of checking if an app is already downloaded --- src/rebar_app_utils.erl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/rebar_app_utils.erl') diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl index 1c53743..8c78850 100644 --- a/src/rebar_app_utils.erl +++ b/src/rebar_app_utils.erl @@ -26,7 +26,8 @@ %% ------------------------------------------------------------------- -module(rebar_app_utils). --export([is_app_dir/0, is_app_dir/1, +-export([find/2, + is_app_dir/0, is_app_dir/1, is_app_src/1, app_src_to_app/1, app_name/2, @@ -42,6 +43,17 @@ %% Public API %% =================================================================== +-spec find(binary(), [rebar_app_info:t()]) -> {ok, rebar_app_info:t()} | error. +find(Name, Apps) -> + ec_lists:find(fun(App) -> rebar_app_info:name(App) =:= Name end, Apps). + +-spec find(binary(), binary(), [rebar_app_info:t()]) -> {ok, rebar_app_info:t()} | error. +find(Name, Vsn, Apps) -> + ec_lists:find(fun(App) -> + rebar_app_info:name(App) =:= Name + andalso rebar_app_info:original_vsn(App) =:= Vsn + end, Apps). + is_app_dir() -> is_app_dir(rebar_utils:get_cwd()). -- cgit v1.1 From 3924908f64dec6fdd9c8195b826453602f7b34f1 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 20 Sep 2014 14:01:22 -0500 Subject: more efficient check for existing dep --- src/rebar_app_utils.erl | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/rebar_app_utils.erl') diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl index 8c78850..d1487fb 100644 --- a/src/rebar_app_utils.erl +++ b/src/rebar_app_utils.erl @@ -27,6 +27,7 @@ -module(rebar_app_utils). -export([find/2, + find/3, is_app_dir/0, is_app_dir/1, is_app_src/1, app_src_to_app/1, @@ -54,9 +55,11 @@ find(Name, Vsn, Apps) -> andalso rebar_app_info:original_vsn(App) =:= Vsn end, Apps). +-spec is_app_dir() -> {true, file:name()} | false. is_app_dir() -> is_app_dir(rebar_utils:get_cwd()). +-spec is_app_dir(file:name()) -> {true, file:name()} | false. is_app_dir(Dir) -> SrcDir = filename:join([Dir, "src"]), AppSrc = filename:join([SrcDir, "*.app.src"]), -- cgit v1.1 From e1b1152b219cf65c7f8cd3b77db5cf2156fcbab7 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 20 Sep 2014 22:36:54 -0500 Subject: slowly widdling away at dialyzer errors --- src/rebar_app_utils.erl | 51 +------------------------------------------------ 1 file changed, 1 insertion(+), 50 deletions(-) (limited to 'src/rebar_app_utils.erl') diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl index d1487fb..8fc3df8 100644 --- a/src/rebar_app_utils.erl +++ b/src/rebar_app_utils.erl @@ -33,8 +33,7 @@ app_src_to_app/1, app_name/2, app_applications/2, - app_vsn/2, - is_skipped_app/2]). + app_vsn/2]). -export([load_app_file/2]). % TEMPORARY @@ -124,30 +123,6 @@ app_vsn(Config, AppFile) -> [AppFile, Reason]) end. -is_skipped_app(Config, AppFile) -> - {Config1, ThisApp} = app_name(Config, AppFile), - %% Check for apps global parameter; this is a comma-delimited list - %% of apps on which we want to run commands - Skipped = - case get_apps(Config) of - undefined -> - %% No apps parameter specified, check the skip_apps list.. - case get_skip_apps(Config) of - undefined -> - %% No skip_apps list, run everything.. - false; - SkipApps -> - TargetApps = [list_to_atom(A) || - A <- string:tokens(SkipApps, ",")], - is_skipped(ThisApp, TargetApps) - end; - Apps -> - %% run only selected apps - TargetApps = [list_to_atom(A) || A <- string:tokens(Apps, ",")], - is_selected(ThisApp, TargetApps) - end, - {Config1, Skipped}. - %% =================================================================== %% Internal functions %% =================================================================== @@ -191,27 +166,3 @@ get_value(Key, AppInfo, AppFile) -> Value -> Value end. - -%% apps= for selecting apps -is_selected(ThisApp, TargetApps) -> - case lists:member(ThisApp, TargetApps) of - false -> - {true, ThisApp}; - true -> - false - end. - -%% skip_apps= for filtering apps -is_skipped(ThisApp, TargetApps) -> - case lists:member(ThisApp, TargetApps) of - false -> - false; - true -> - {true, ThisApp} - end. - -get_apps(Config) -> - rebar_config:get_global(Config, apps, undefined). - -get_skip_apps(Config) -> - rebar_config:get_global(Config, skip_apps, undefined). -- cgit v1.1