Skip to content

Commit

Permalink
build: 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
javiergarea committed Jan 10, 2024
1 parent 61d48a7 commit a363702
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{erl_opts, [warnings_as_errors]}.

{deps, [
{ndto, {git, "[email protected]:nomasystems/ndto.git", {branch, "main"}}}
{ndto, {git, "[email protected]:nomasystems/ndto.git", {tag, "0.2.0"}}}
]}.

{project_plugins, [
Expand Down
4 changes: 2 additions & 2 deletions rebar.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
1},
{<<"ndto">>,
{git,"[email protected]:nomasystems/ndto.git",
{ref,"48941b5b29498d45bfbb9c6d05c18ec17c66e051"}},
{ref,"02890286d8846f6e0449b815b2d494edb4a9fa8f"}},
0},
{<<"njson">>,
{git,"[email protected]:nomasystems/njson.git",
{ref,"76ab40033ee977f876e7b3addca5de981ff4a9ef"}},
{ref,"b230b3e6fb5e35320aeaa203762f3f12277c9970"}},
1}].
2 changes: 1 addition & 1 deletion src/rebar3_ndto.app.src
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{application, rebar3_ndto, [
{description, "A rebar3 plugin for the automatic generation of ndto modules."},
{vsn, "0.1.0"},
{vsn, "0.2.0"},
{registered, []},
{applications, [kernel, stdlib, ndto]},
{env, []}
Expand Down
17 changes: 7 additions & 10 deletions src/rebar3_ndto.erl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

%%% MACROS
-define(DEFAULT_OUTPUT_DIR, "_gen/dtos").
-define(DEFAULT_PARSER, ndto_parser_json_schema_draft_04).
-define(DEFAULT_PARSER, ndto_parser_json_schema).

%%%-----------------------------------------------------------------------------
%%% INIT/STOP EXPORTS
Expand Down Expand Up @@ -89,13 +89,10 @@ clean(AppInfo, State) ->
%%% INTERNAL FUNCTIONS
%%%-----------------------------------------------------------------------------
compile(AppDir, OutputDir, Parser, RawSpec) ->
Spec = filename:join(AppDir, RawSpec),
Basename = filename:basename(Spec),
Extension = filename:extension(Basename),
Namespace = erlang:list_to_atom(string:trim(Basename, trailing, Extension)),
case ndto_parser:parse(Parser, Namespace, Spec) of
SpecPath = unicode:characters_to_binary(filename:join(AppDir, RawSpec)),
case ndto_parser:parse(Parser, SpecPath) of
{error, Reason} ->
rebar_utils:abort("[rebar3_ndto] Failed parsing ~s spec: ~p\n", [Spec, Reason]);
rebar_utils:abort("[rebar3_ndto] Failed parsing ~s spec: ~p\n", [SpecPath, Reason]);
{ok, Schemas} ->
case filelib:ensure_path(OutputDir) of
{error, Reason} ->
Expand All @@ -104,10 +101,10 @@ compile(AppDir, OutputDir, Parser, RawSpec) ->
]);
ok ->
lists:foreach(
fun({Name, Schema}) ->
DTO = ndto:generate(Name, Schema),
fun({SchemaName, Schema}) ->
DTO = ndto:generate(SchemaName, Schema),
OutputFile = filename:join(
OutputDir, erlang:atom_to_list(Name) ++ ".erl"
OutputDir, erlang:atom_to_list(SchemaName) ++ ".erl"
),
case ndto:write(DTO, OutputFile) of
{error, Reason} ->
Expand Down

0 comments on commit a363702

Please sign in to comment.