Move is_skipped_app/0 to rebar_app_utils

This commit is contained in:
Tuncer Ayaz 2011-12-12 17:16:29 +01:00
parent b1d84514f0
commit a5e39c2c54
3 changed files with 39 additions and 41 deletions

View file

@ -31,7 +31,8 @@
app_src_to_app/1, app_src_to_app/1,
app_name/1, app_name/1,
app_applications/1, app_applications/1,
app_vsn/1]). app_vsn/1,
is_skipped_app/0]).
-export([load_app_file/1]). % TEMPORARY -export([load_app_file/1]). % TEMPORARY
@ -104,6 +105,41 @@ app_vsn(AppFile) ->
[AppFile, Reason]) [AppFile, Reason])
end. end.
%%
%% Return: true, if we are in the context of a 'Skipped App', else: false
%% (Example: rebar xref skip_app=mochiweb,webmachine)
is_skipped_app() ->
case rebar_config:get_global(skip_app, undefined) of
undefined ->
%% no skip list
false;
SkipApps ->
case string:tokens(SkipApps, ",") of
[] ->
%% no tokens
false;
SkipAppsTokens ->
%% Where we are at the moment
Cwd = rebar_utils:get_cwd(),
%% Return true if app should be skipped
SkipPred = fun(App) ->
case re:run(Cwd, App) of
{match,_} -> true;
_ -> false
end
end,
%% Check if 'we' are among the skipped apps.
lists:foldl(fun(SkippedApp, Bool) ->
SkipPred(SkippedApp) or Bool
end, false, SkipAppsTokens)
end
end.
%% =================================================================== %% ===================================================================
%% Internal functions %% Internal functions

View file

@ -43,8 +43,7 @@
prop_check/3, prop_check/3,
expand_code_path/0, expand_code_path/0,
deprecated/4, deprecated/5, deprecated/4, deprecated/5,
expand_env_variable/3, expand_env_variable/3
is_skipped_app/0
]). ]).
-include("rebar.hrl"). -include("rebar.hrl").
@ -201,43 +200,6 @@ expand_env_variable(InStr, VarName, RawVarValue) ->
re:replace(InStr, RegEx, [VarValue, "\\2"], ReOpts) re:replace(InStr, RegEx, [VarValue, "\\2"], ReOpts)
end. end.
%%
%% Return: true , if we are in the context of a 'Skipped App', else: false
%% (Example: rebar xref skip_app=mochiweb,webmachine)
is_skipped_app() ->
case rebar_config:get_global(skip_app, undefined) of
undefined ->
%% no skip list
false;
SkipApps ->
case string:tokens(SkipApps, ",") of
[] ->
%% no tokens
false;
SkipAppsTokens ->
%% Where we are at the moment
Cwd = rebar_utils:get_cwd(),
%% Return true if app should be skipped
SkipPred = fun(App) ->
case re:run(Cwd, App) of
{match,_} -> true;
_ -> false
end
end,
%% Check if 'we' are among the skipped apps.
lists:foldl(fun(SkippedApp, Bool) ->
SkipPred(SkippedApp) or Bool
end, false, SkipAppsTokens)
end
end.
%% ==================================================================== %% ====================================================================
%% Internal functions %% Internal functions
%% ==================================================================== %% ====================================================================

View file

@ -41,7 +41,7 @@
%% =================================================================== %% ===================================================================
xref(Config, _X) -> xref(Config, _X) ->
case rebar_utils:is_skipped_app() of case rebar_app_utils:is_skipped_app() of
true -> ok; true -> ok;
false -> xref0(Config, _X) false -> xref0(Config, _X)
end. end.