Fix code clarity

This commit is contained in:
Tuncer Ayaz 2011-01-07 14:58:30 +01:00
parent 1f1793cc5e
commit a8870807fc
3 changed files with 24 additions and 20 deletions

View file

@ -58,20 +58,23 @@ new(ParentConfig) ->
%% Load terms from rebar.config, if it exists %% Load terms from rebar.config, if it exists
Dir = rebar_utils:get_cwd(), Dir = rebar_utils:get_cwd(),
ConfigFile = filename:join([Dir, ConfName]), ConfigFile = filename:join([Dir, ConfName]),
case file:consult(ConfigFile) of Opts = case file:consult(ConfigFile) of
{ok, Terms} -> {ok, Terms} ->
%% Found a config file with some terms. We need to be able to %% Found a config file with some terms. We need to
%% distinguish between local definitions (i.e. from the file %% be able to distinguish between local definitions
%% in the cwd) and inherited definitions. To accomplish this, %% (i.e. from the file in the cwd) and inherited
%% we use a marker in the proplist (since order matters) between %% definitions. To accomplish this, we use a marker
%% in the proplist (since order matters) between
%% the new and old defs. %% the new and old defs.
Opts = Terms ++ [local] ++ [Opt || Opt <- ParentConfig#config.opts, Opt /= local]; Terms ++ [local] ++
[Opt || Opt <- ParentConfig#config.opts, Opt /= local];
{error, enoent} -> {error, enoent} ->
Opts = [local] ++ [Opt || Opt <- ParentConfig#config.opts, Opt /= local]; [local] ++
[Opt || Opt <- ParentConfig#config.opts, Opt /= local];
Other -> Other ->
Opts = undefined, % Keep erlc happy
?ABORT("Failed to load ~s: ~p\n", [ConfigFile, Other]) ?ABORT("Failed to load ~s: ~p\n", [ConfigFile, Other])
end, end,
#config { dir = Dir, opts = Opts }. #config { dir = Dir, opts = Opts }.
get(Config, Key, Default) -> get(Config, Key, Default) ->

View file

@ -453,7 +453,8 @@ execute(Command, Modules, Config, ModuleFile) ->
?FAIL; ?FAIL;
{Module, {error, _} = Other} -> {Module, {error, _} = Other} ->
?ABORT("~p failed while processing ~s in module ~s: ~s\n", ?ABORT("~p failed while processing ~s in module ~s: ~s\n",
[Command, Dir, Module, io_lib:print(Other, 1,80,-1)]); [Command, Dir, Module,
io_lib:print(Other, 1, 80, -1)]);
Other -> Other ->
?ABORT("~p failed while processing ~s: ~s\n", ?ABORT("~p failed while processing ~s: ~s\n",
[Command, Dir, io_lib:print(Other, 1, 80, -1)]) [Command, Dir, io_lib:print(Other, 1, 80, -1)])

View file

@ -263,8 +263,8 @@ write_file(Output, Data, Force) ->
%% perform the function if we're allowed, %% perform the function if we're allowed,
%% otherwise just process the next template %% otherwise just process the next template
if case Force =:= "1" orelse FileExists =:= false of
Force =:= "1"; FileExists =:= false -> true ->
ok = filelib:ensure_dir(Output), ok = filelib:ensure_dir(Output),
if if
{Force, FileExists} =:= {"1", true} -> {Force, FileExists} =:= {"1", true} ->
@ -280,7 +280,7 @@ write_file(Output, Data, Force) ->
?ABORT("Failed to write output file ~p: ~p\n", ?ABORT("Failed to write output file ~p: ~p\n",
[Output, Reason]) [Output, Reason])
end; end;
true -> false ->
{error, exists} {error, exists}
end. end.