1
0
Fork 0
mirror of https://github.com/processone/ejabberd synced 2025-10-05 02:29:34 +02:00

Convert code to use Fast YAML

This commit is contained in:
Mickael Remond 2016-02-03 11:30:48 +01:00
parent b137ee3beb
commit 0de222d998
3 changed files with 6 additions and 6 deletions

View file

@ -252,7 +252,7 @@ start_apps() ->
crypto:start(), crypto:start(),
ejabberd:start_app(sasl), ejabberd:start_app(sasl),
ejabberd:start_app(ssl), ejabberd:start_app(ssl),
ejabberd:start_app(p1_yaml), ejabberd:start_app(fast_yaml),
ejabberd:start_app(p1_tls), ejabberd:start_app(p1_tls),
ejabberd:start_app(p1_xml), ejabberd:start_app(p1_xml),
ejabberd:start_app(stringprep), ejabberd:start_app(stringprep),

View file

@ -162,7 +162,7 @@ convert_to_yaml(File, Output) ->
fun({Host, Opts1}) -> fun({Host, Opts1}) ->
{host_config, [{Host, Opts1}]} {host_config, [{Host, Opts1}]}
end, HOpts), end, HOpts),
Data = p1_yaml:encode(lists:reverse(NewOpts)), Data = fast_yaml:encode(lists:reverse(NewOpts)),
case Output of case Output of
stdout -> stdout ->
io:format("~s~n", [Data]); io:format("~s~n", [Data]);
@ -226,14 +226,14 @@ get_plain_terms_file(File1, Opts) ->
consult(File) -> consult(File) ->
case filename:extension(File) of case filename:extension(File) of
Ex when (Ex == ".yml") or (Ex == ".yaml") -> Ex when (Ex == ".yml") or (Ex == ".yaml") ->
case p1_yaml:decode_from_file(File, [plain_as_atom]) of case fast_yaml:decode_from_file(File, [plain_as_atom]) of
{ok, []} -> {ok, []} ->
{ok, []}; {ok, []};
{ok, [Document|_]} -> {ok, [Document|_]} ->
{ok, parserl(Document)}; {ok, parserl(Document)};
{error, Err} -> {error, Err} ->
Msg1 = "Cannot load " ++ File ++ ": ", Msg1 = "Cannot load " ++ File ++ ": ",
Msg2 = p1_yaml:format_error(Err), Msg2 = fast_yaml:format_error(Err),
{error, Msg1 ++ Msg2} {error, Msg1 ++ Msg2}
end; end;
_ -> _ ->

View file

@ -589,10 +589,10 @@ rebar_dep({App, _, {git, Url, Ref}}) ->
%% -- YAML spec parser %% -- YAML spec parser
consult(File) -> consult(File) ->
case p1_yaml:decode_from_file(File, [plain_as_atom]) of case fast_yaml:decode_from_file(File, [plain_as_atom]) of
{ok, []} -> {ok, []}; {ok, []} -> {ok, []};
{ok, [Doc|_]} -> {ok, [format(Spec) || Spec <- Doc]}; {ok, [Doc|_]} -> {ok, [format(Spec) || Spec <- Doc]};
{error, Err} -> {error, p1_yaml:format_error(Err)} {error, Err} -> {error, fast_yaml:format_error(Err)}
end. end.
format({Key, Val}) when is_binary(Val) -> format({Key, Val}) when is_binary(Val) ->