diff --git a/README.md b/README.md index 9614136..0a57d50 100644 --- a/README.md +++ b/README.md @@ -102,17 +102,32 @@ https://github.com/basho/cuttlefish/wiki/Cuttlefish-for-Application-Users ## What's it look like to application packagers? -* [node_package](https://github.com/basho/cuttlefish/wiki/Cuttlefish-for-node_package-users) -* [non node_package](https://github.com/basho/cuttlefish/wiki/Cuttlefish-for-non-node_package-users) +* [node_package](https://github.com/Kyorai/cuttlefish/wiki/Cuttlefish-for-node_package-users) +* [non node_package](https://github.com/Kyorai/cuttlefish/wiki/Cuttlefish-for-non-node_package-users) + ## Current Status Cuttlefish is ready for production deployments. + ## Re-generating parser -``` -rebar3 as dev neotoma +After using Neotoma Rebar3 plugin to re-generate conf_parse.erl, you **MUST** +edit that file to change the exported `file/1` function to this code: + +``` erl +-spec file(file:name()) -> any(). +file(Filename) -> + AbsFilename = filename:absname(Filename), + case erl_prim_loader:get_file(AbsFilename) of + {ok, Bin, _} -> parse(Bin); + error -> {error, undefined} + end. ``` -Please see the *NOTE* in `src/conf_parse.peg` as well. +To regenerate the parser from the PEG grammar: + +``` +rebar3 as dev neotoma compile +``` diff --git a/src/conf_parse.erl b/src/conf_parse.erl index a6f9b86..7f48a0a 100644 --- a/src/conf_parse.erl +++ b/src/conf_parse.erl @@ -126,6 +126,16 @@ included_dir_test() -> ], Conf), ok. +invalid_included_file_test() -> + Conf = conf_parse:file("test/invalid_include_file.conf"), + ?assertMatch({[], _PathWithNewLineAndCarriage, {{line,_}, {column, _}}}, Conf), + ok. + +invalid_included_dir_test() -> + Conf = conf_parse:file("test/invalid_include_dir.conf"), + ?assertMatch({[], _PathWithNewLineAndCarriage, {{line, _},{column, _}}}, Conf), + ok. + escaped_dots_are_removed_test() -> Conf = conf_parse:parse("#comment\nsetting\\.0 = thing0\n"), ?assertEqual([ @@ -225,7 +235,7 @@ parse(Error) -> -spec 'include'(input(), index()) -> parse_result(). 'include'(Input, Index) -> - p(Input, Index, 'include', fun(I,D) -> (p_seq([p_zero_or_more(fun 'ws'/2), p_string(<<"include">>), p_zero_or_more(fun 'ws'/2), fun 'included_file_or_dir'/2, p_optional(fun 'comment'/2)]))(I,D) end, fun(Node, _Idx) -> + p(Input, Index, 'include', fun(I,D) -> (p_seq([p_zero_or_more(fun 'ws'/2), p_string(<<"include">>), p_one_or_more(fun 'ws'/2), fun 'included_file_or_dir'/2, p_optional(fun 'comment'/2)]))(I,D) end, fun(Node, _Idx) -> [_, _Include, _, Included, _] = Node, {include, Included} end). diff --git a/src/conf_parse.peg b/src/conf_parse.peg index c8fecbe..903e210 100644 --- a/src/conf_parse.peg +++ b/src/conf_parse.peg @@ -77,7 +77,7 @@ value <- (!((ws* crlf) / comment) .)+ %{ comment <- ws* "#" (!crlf .)* `comment`; %% An include is a line that begins with 'include' and something. -include <- ws* "include" ws* included_file_or_dir comment? %{ +include <- ws* "include" ws+ included_file_or_dir comment? %{ [_, _Include, _, Included, _] = Node, {include, Included} %}; diff --git a/test/invalid_include_dir.conf b/test/invalid_include_dir.conf new file mode 100644 index 0000000..35cd06f --- /dev/null +++ b/test/invalid_include_dir.conf @@ -0,0 +1,2 @@ +# Missing a space. See Kyorai/cuttlefish#38. +includeconf.d/*.conf diff --git a/test/invalid_include_file.conf b/test/invalid_include_file.conf new file mode 100644 index 0000000..e50386b --- /dev/null +++ b/test/invalid_include_file.conf @@ -0,0 +1,3 @@ +# Missing a space. See Kyorai/cuttlefish#38. +includeriak.conf +