From e1e0b4874b10a2611ff00cc37eeb7a2bae337b34 Mon Sep 17 00:00:00 2001 From: Javier Garea Date: Wed, 10 Jan 2024 09:28:14 +0100 Subject: [PATCH] build: 0.2.0 --- .github/workflows/ci.yml | 3 +-- README.md | 6 +++--- rebar.config | 2 +- rebar.lock | 4 ++-- src/rebar3_ndto.app.src | 2 +- src/rebar3_ndto.erl | 17 +++++++---------- 6 files changed, 15 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e11a667..6c5bfe5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,9 @@ -name: rebar3_ndto ci +name: CI on: push: branches: [main] pull_request: - branches: [main] env: OTP-VERSION: 25.2.3 diff --git a/README.md b/README.md index 902d102..57bc5a3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # rebar3_ndto -![rebar3_ndto ci](https://github.com/nomasystems/rebar3_ndto/actions/workflows/ci.yml/badge.svg) +![CI](https://github.com/nomasystems/rebar3_ndto/actions/workflows/ci.yml/badge.svg) A rebar3 plugin for the automatic generation of [`ndto`](https://github.com/nomasystems/ndto) modules. @@ -8,7 +8,7 @@ A rebar3 plugin for the automatic generation of [`ndto`](https://github.com/noma To use `rebar3_ndto` in your project, you need to declare it in the `plugins` section of your `rebar.config` file: ```erl {plugins, [ - {rebar3_ndto, {git, "https://github.com/nomasystems/rebar3_ndto.git", {branch, "main"}}} + {rebar3_ndto, {git, "https://github.com/nomasystems/rebar3_ndto.git", {tag, "0.2.0"}}} ]}. ``` @@ -26,7 +26,7 @@ Finally, configure the plugin's option under the `ndto` key: ```erl {ndto, [ {output_dir, "foo/foo_output_dir/"}, % defaults to "_gen/dtos" - {parser, foo_parser}, % defaults to ndto_parser_json_schema_draft_04 + {parser, foo_parser}, % defaults to ndto_parser_json_schema_draft {specs, [ "foo/specs/foo.json", % uses default options {"foo/bar/specs/foo_bar.json", [ diff --git a/rebar.config b/rebar.config index aa61b7b..fe64bf5 100644 --- a/rebar.config +++ b/rebar.config @@ -1,7 +1,7 @@ {erl_opts, [warnings_as_errors]}. {deps, [ - {ndto, {git, "git@github.com:nomasystems/ndto.git", {branch, "main"}}} + {ndto, {git, "git@github.com:nomasystems/ndto.git", {tag, "0.2.0"}}} ]}. {project_plugins, [ diff --git a/rebar.lock b/rebar.lock index 5718d26..3b086cd 100644 --- a/rebar.lock +++ b/rebar.lock @@ -4,9 +4,9 @@ 1}, {<<"ndto">>, {git,"git@github.com:nomasystems/ndto.git", - {ref,"48941b5b29498d45bfbb9c6d05c18ec17c66e051"}}, + {ref,"02890286d8846f6e0449b815b2d494edb4a9fa8f"}}, 0}, {<<"njson">>, {git,"git@github.com:nomasystems/njson.git", - {ref,"76ab40033ee977f876e7b3addca5de981ff4a9ef"}}, + {ref,"b230b3e6fb5e35320aeaa203762f3f12277c9970"}}, 1}]. diff --git a/src/rebar3_ndto.app.src b/src/rebar3_ndto.app.src index 1ec60ec..32d18eb 100644 --- a/src/rebar3_ndto.app.src +++ b/src/rebar3_ndto.app.src @@ -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, []} diff --git a/src/rebar3_ndto.erl b/src/rebar3_ndto.erl index fdf1713..39d25a9 100644 --- a/src/rebar3_ndto.erl +++ b/src/rebar3_ndto.erl @@ -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 @@ -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} -> @@ -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} ->