Closed joedevivo closed 10 years ago
eunit tests pass: https://gist.github.com/metadave/8845130
+1 from me.
I EQC'd and found some edge cases where variable names are whitespace or "foo)bar", but it seems like you are asking for trouble and maybe you SHOULD be punished if you do that?
here's my crappy/"cheaty"/incomplete EQC:
not_empty(G) ->
?SUCHTHAT(X, G, X /= [] andalso X /= <<>>).
lower_char() ->
choose(16#20, 16#7f).
non_blank_string() ->
%% don't allow whitespace at either end, but it's fine in the middle
?LET(X, not_empty(list(lower_char())), list_to_binary("X" ++ X ++ "X")).
prop_sub() ->
?FORALL({Var0, Val0}, {non_blank_string(), non_blank_string() },
begin
Var = erlang:binary_to_list(Var0),
Val = erlang:binary_to_list(Val0),
Conf = [
{[Var,"b","c"], "#(" ++ Var ++ ".b)/c"},
{[Var,"b"], Val}
],
{NewConf, Errors} = value_sub(Conf),
?assertEqual([], Errors),
ABC = proplists:get_value([Var,"b","c"], NewConf),
Val ++ "/c" == ABC
end).
+1, tests pass fine, code reads fine.
+1
This is the ability to have settings depend on other settings, either explicitly or by default.
Imagine a
riak.conf
file:If you change
platform_data_dir
,ring.state_dir
will also changeThe effective config will still display the relative value:
But the generated
app.config
will have a hard substitutionThis will allow for a more consistent experience when sub directories in riak.
Here are some caveats:
I'll open up a PR against riak_core so you can see how this would work in practice.