Skip to content

Commit 8c42fd0

Browse files
committed
Merge pull request #10 from inaka/elbrujohalcon.10.add_deps_to_the_app_src_file
Add deps to the app.src file
2 parents e1a4423 + d8389ed commit 8c42fd0

File tree

3 files changed

+36
-8
lines changed

3 files changed

+36
-8
lines changed

Makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
PROJECT = katana_code
22

3-
DEPS = inaka_aleppo elvis_core
4-
TEST_DEPS = mixer
3+
DEPS = aleppo
4+
TEST_DEPS = mixer xref_runner
55
SHELL_DEPS = sync
66
BUILD_DEPS = inaka_mk hexer_mk
77
LOCAL_DEPS = tools compiler syntax_tools common_test hipe
88

9-
dep_inaka_aleppo = hex 0.9.9
10-
dep_mixer = git https://github.com/inaka/mixer.git 0.1.4
11-
dep_elvis_core = git https://github.com/inaka/elvis_core.git efa6df5
9+
dep_aleppo = git https://github.com/inaka/aleppo.git 0.9.10
10+
dep_mixer = git https://github.com/inaka/mixer.git 0.1.5
1211
dep_sync = git https://github.com/rustyio/sync.git 9c78e7b
1312
dep_inaka_mk = git https://github.com/inaka/inaka.mk.git 1.0.0
1413
dep_hexer_mk = git https://github.com/inaka/hexer.mk.git 1.1.0

src/katana_code.app.src

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[
33
{description, "Functions useful for processing Erlang code."},
44
{vsn, "0.0.2"},
5-
{applications, [kernel, stdlib]},
5+
{applications, [kernel, stdlib, aleppo]},
66
{modules, []},
77
{registered, []},
88
{maintainers, ["Inaka"]},

src/ktn_code.erl

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ parse_tree(IncludeDirs, Source) ->
105105
end,
106106

107107
{Comments, CodeTokens} = lists:partition(IsComment, NewTokens),
108-
Forms = ktn_lists:split_when(fun is_dot/1, CodeTokens),
108+
Forms = split_when(fun is_dot/1, CodeTokens),
109109
ParsedForms = lists:map(fun erl_parse:parse_form/1, Forms),
110110
Children = [to_map(Parsed) || {ok, Parsed} <- ParsedForms],
111111

@@ -139,7 +139,7 @@ eval(Source, Bindings) ->
139139
consult(Source) ->
140140
SourceStr = to_str(Source),
141141
{ok, Tokens, _} = erl_scan:string(SourceStr),
142-
Forms = ktn_lists:split_when(fun is_dot/1, Tokens),
142+
Forms = split_when(fun is_dot/1, Tokens),
143143
ParseFun = fun (Form) ->
144144
{ok, Expr} = erl_parse:parse_exprs(Form),
145145
Expr
@@ -751,3 +751,32 @@ to_map(Parsed) when is_tuple(Parsed) ->
751751
throw({unhandled_abstract_form, Parsed});
752752
to_map(Parsed) ->
753753
throw({unexpected_abstract_form, Parsed}).
754+
755+
%% @doc Splits a list whenever an element satisfies the When predicate.
756+
%% Returns a list of lists where each list includes the matched element
757+
%% as its last one.
758+
%% E.g.
759+
%% <code>
760+
%% split_when(fun (X) -> $. == X end, "a.b.c") = ["a.", "b.", "c"]
761+
%% </code>
762+
%% NOTE: Copied from ktn_lists not to bring the whole erlang-katana
763+
%% repo as a dependency here
764+
%% @end
765+
-spec split_when(fun(), list()) -> list().
766+
split_when(When, List) ->
767+
split_when(When, List, [[]]).
768+
769+
split_when(When, [], [[] | Results]) ->
770+
split_when(When, [], Results);
771+
split_when(_When, [], Results) ->
772+
Reversed = lists:map(fun lists:reverse/1, Results),
773+
lists:reverse(Reversed);
774+
split_when(When, [Head | Tail], [Current0 | Rest]) ->
775+
Current = [Head | Current0],
776+
Result = case When(Head) of
777+
true ->
778+
[[], Current | Rest];
779+
false ->
780+
[Current | Rest]
781+
end,
782+
split_when(When, Tail, Result).

0 commit comments

Comments
 (0)