From 61a0aff3a23d0b747798c2b0077fb3400e104271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20G=C3=B3rny?= Date: Wed, 25 Jul 2018 17:52:17 +0200 Subject: [PATCH] swap meanings of 'all' and 'none' in field limits --- src/recon_rec.erl | 13 ++++++++----- test/recon_rec_SUITE.erl | 10 +++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/recon_rec.erl b/src/recon_rec.erl index 4a928df..a6adc86 100644 --- a/src/recon_rec.erl +++ b/src/recon_rec.erl @@ -79,7 +79,10 @@ get_list() -> Lst = lists:map(fun make_list_entry/1, ets:tab2list(ets_table_name())), lists:sort(Lst). -%% @doc Limit output to selected fields of a record (can be 'all', 'none', a field or a list of fields). +%% @doc Limit output to selected fields of a record (can be 'none', 'all', a field or a list of fields). +%% Limit set to 'none' means there is no limit, and all fields are displayed; limit 'all' means that +%% all fields are squashed and only record name will be shown. +%% @end -spec limit(record_name(), arity(), limit()) -> ok | {error, record_unknown}. limit(Name, Arity, Limit) -> case lookup_record(Name, Arity) of @@ -104,7 +107,7 @@ format_tuple(Tuple) -> make_list_entry({{Name, _}, Fields, Module, Limits}) -> FmtLimit = case Limits of - [] -> all; + [] -> none; Other -> Other end, {Module, Name, Fields, FmtLimit}. @@ -161,7 +164,7 @@ ensure_table_exists() -> ets_table_name() -> recon_record_definitions. rec_info({Name, Fields}, Module) -> - {{Name, length(Fields)}, field_names(Fields), Module, all}. + {{Name, length(Fields)}, field_names(Fields), Module, none}. rem_for_module({_, _, Module, _} = Rec, Module) -> ets:delete_object(ets_table_name(), Rec); @@ -214,8 +217,8 @@ format_record(Rec, {{Name, Arity}, Fields, _, Limits}) -> format_kv(Key, Val) -> [recon_lib:format_trace_output(true, Key), "=", recon_lib:format_trace_output(true, Val)]. -apply_limits(List, all) -> List; -apply_limits(_List, none) -> []; +apply_limits(List, none) -> List; +apply_limits(_List, all) -> []; apply_limits(List, Field) when is_atom(Field) -> [{Field, proplists:get_value(Field, List)}, {more, '...'}]; apply_limits(List, Limits) -> diff --git a/test/recon_rec_SUITE.erl b/test/recon_rec_SUITE.erl index a7f1490..934953d 100644 --- a/test/recon_rec_SUITE.erl +++ b/test/recon_rec_SUITE.erl @@ -51,17 +51,17 @@ lists_and_limits(_Config) -> recon_rec:import(records1), recon_rec:import(records2), List = recon_rec:get_list(), - [{records1,another,[ddd,eee,fff],all}, - {records1,state,[aaa,bbb,ccc],all}, - {records2,another,[one,two,three,four],all}] = List, + [{records1,another,[ddd,eee,fff],none}, + {records1,state,[aaa,bbb,ccc],none}, + {records2,another,[one,two,three,four],none}] = List, recon_rec:limit(another, 3, ddd), - {records1,another,[ddd,eee,fff], [ddd]} = hd(recon_rec:get_list()), + {records1,another,[ddd,eee,fff], ddd} = hd(recon_rec:get_list()), recon_rec:limit(another, 3, [ddd, eee]), {records1,another,[ddd,eee,fff], [ddd, eee]} = hd(recon_rec:get_list()), recon_rec:limit(another, 3, all), {records1,another,[ddd,eee,fff], all} = hd(recon_rec:get_list()), recon_rec:clear(records2), - {error, record_unknown} = recon_rec:limit(another, 4, all), + {error, record_unknown} = recon_rec:limit(another, 4, none), ok. %%%%%%%%%% HELPERS