Merge pull request #42 from ericbmerritt/next
minor bugfixes and cleanup
This commit is contained in:
commit
0fbd4576ce
3 changed files with 12 additions and 25 deletions
6
Makefile
6
Makefile
|
@ -15,9 +15,9 @@ endif
|
|||
|
||||
ERLWARE_COMMONS_PLT=$(CURDIR)/.erlware_commons_plt
|
||||
|
||||
.PHONY: all compile doc clean test shell distclean pdf get-deps rebuild #dialyzer typer #fail on Travis.
|
||||
.PHONY: all compile doc clean test shell distclean pdf get-deps rebuild dialyzer typer
|
||||
|
||||
all: compile doc test #dialyzer #fail on travis
|
||||
all: compile doc test
|
||||
|
||||
deps: .DEV_MODE
|
||||
$(REBAR) get-deps compile
|
||||
|
@ -91,4 +91,4 @@ distclean: clean
|
|||
rm -rvf $(CURDIR)/deps
|
||||
rm -rvf .DEV_MODE
|
||||
|
||||
rebuild: distclean get-deps all
|
||||
rebuild: distclean all
|
||||
|
|
|
@ -22,8 +22,7 @@
|
|||
md5sum/1,
|
||||
read/1,
|
||||
write/2,
|
||||
write_term/2,
|
||||
consult/1
|
||||
write_term/2
|
||||
]).
|
||||
|
||||
-export_type([
|
||||
|
@ -174,16 +173,6 @@ mkdir_path(Path) ->
|
|||
mkdir_p(Path).
|
||||
|
||||
|
||||
%% @doc consult an erlang term file from the file system.
|
||||
%% Provide user readible exeption on failure.
|
||||
-spec consult(FilePath::file:name()) -> term().
|
||||
consult(FilePath) ->
|
||||
case file:consult(FilePath) of
|
||||
{ok, [Term]} ->
|
||||
Term;
|
||||
Error ->
|
||||
Error
|
||||
end.
|
||||
%% @doc read a file from the file system. Provide UEX exeption on failure.
|
||||
-spec read(FilePath::file:filename()) -> binary() | {error, Reason::term()}.
|
||||
read(FilePath) ->
|
||||
|
@ -327,12 +316,10 @@ file_test() ->
|
|||
filelib:ensure_dir(TermFile),
|
||||
filelib:ensure_dir(TermFileCopy),
|
||||
write_term(TermFile, "term"),
|
||||
?assertMatch("term", consult(TermFile)),
|
||||
?assertMatch({ok, <<"\"term\". ">>}, read(TermFile)),
|
||||
copy(filename:dirname(TermFile),
|
||||
filename:dirname(TermFileCopy),
|
||||
[recursive]),
|
||||
?assertMatch("term", consult(TermFileCopy)).
|
||||
[recursive]).
|
||||
|
||||
teardown_test() ->
|
||||
Dir = insecure_mkdtemp(),
|
||||
|
|
|
@ -18,19 +18,19 @@ parse(Input) when is_binary(Input) ->
|
|||
release_memo(), Result.
|
||||
|
||||
'semver'(Input, Index) ->
|
||||
p(Input, Index, 'semver', fun(I,D) -> (p_seq([fun 'major_minor_patch_min_patch'/2, p_optional(p_seq([p_string(<<"-">>), fun 'alpha_part'/2, p_zero_or_more(p_seq([p_string(<<".">>), fun 'alpha_part'/2]))])), p_optional(p_seq([p_string(<<"+">>), fun 'alpha_part'/2, p_zero_or_more(p_seq([p_string(<<".">>), fun 'alpha_part'/2]))])), p_not(p_anything())]))(I,D) end, fun(Node, _Idx) -> ec_semver:internal_parse_version(Node) end).
|
||||
p(Input, Index, 'semver', fun(I,D) -> (p_seq([fun 'major_minor_patch_min_patch'/2, p_optional(p_seq([p_string(<<"-">>), fun 'alpha_part'/2, p_zero_or_more(p_seq([p_string(<<".">>), fun 'alpha_part'/2]))])), p_optional(p_seq([p_string(<<"+">>), fun 'alpha_part'/2, p_zero_or_more(p_seq([p_string(<<".">>), fun 'alpha_part'/2]))])), p_not(p_anything())]))(I,D) end, fun(Node, _Idx) -> ec_semver:internal_parse_version(Node) end).
|
||||
|
||||
'major_minor_patch_min_patch'(Input, Index) ->
|
||||
p(Input, Index, 'major_minor_patch_min_patch', fun(I,D) -> (p_seq([p_choose([p_seq([p_optional(p_string(<<"v">>)), fun 'numeric_part'/2]), fun 'alpha_part'/2]), p_optional(p_seq([p_string(<<".">>), fun 'version_part'/2])), p_optional(p_seq([p_string(<<".">>), fun 'version_part'/2])), p_optional(p_seq([p_string(<<".">>), fun 'version_part'/2]))]))(I,D) end, fun(Node, Idx) ->transform('major_minor_patch_min_patch', Node, Idx) end).
|
||||
p(Input, Index, 'major_minor_patch_min_patch', fun(I,D) -> (p_seq([p_choose([p_seq([p_optional(p_string(<<"v">>)), fun 'numeric_part'/2]), fun 'alpha_part'/2]), p_optional(p_seq([p_string(<<".">>), fun 'version_part'/2])), p_optional(p_seq([p_string(<<".">>), fun 'version_part'/2])), p_optional(p_seq([p_string(<<".">>), fun 'version_part'/2]))]))(I,D) end, fun(Node, Idx) -> transform('major_minor_patch_min_patch', Node, Idx) end).
|
||||
|
||||
'version_part'(Input, Index) ->
|
||||
p(Input, Index, 'version_part', fun(I,D) -> (p_choose([fun 'numeric_part'/2, fun 'alpha_part'/2]))(I,D) end, fun(Node, Idx) ->transform('version_part', Node, Idx) end).
|
||||
p(Input, Index, 'version_part', fun(I,D) -> (p_choose([fun 'numeric_part'/2, fun 'alpha_part'/2]))(I,D) end, fun(Node, Idx) -> transform('version_part', Node, Idx) end).
|
||||
|
||||
'numeric_part'(Input, Index) ->
|
||||
p(Input, Index, 'numeric_part', fun(I,D) -> (p_one_or_more(p_charclass(<<"[0-9]">>)))(I,D) end, fun(Node, _Idx) ->erlang:list_to_integer(erlang:binary_to_list(erlang:iolist_to_binary(Node))) end).
|
||||
p(Input, Index, 'numeric_part', fun(I,D) -> (p_one_or_more(p_charclass(<<"[0-9]">>)))(I,D) end, fun(Node, _Idx) -> erlang:list_to_integer(erlang:binary_to_list(erlang:iolist_to_binary(Node))) end).
|
||||
|
||||
'alpha_part'(Input, Index) ->
|
||||
p(Input, Index, 'alpha_part', fun(I,D) -> (p_one_or_more(p_charclass(<<"[A-Za-z0-9]">>)))(I,D) end, fun(Node, _Idx) ->erlang:iolist_to_binary(Node) end).
|
||||
p(Input, Index, 'alpha_part', fun(I,D) -> (p_one_or_more(p_charclass(<<"[A-Za-z0-9]">>)))(I,D) end, fun(Node, _Idx) -> erlang:iolist_to_binary(Node) end).
|
||||
|
||||
|
||||
transform(_,Node,_Index) -> Node.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue