Skip to content

Commit a88d07b

Browse files
author
Brujo Benavides
authored
NextRoll-ize this Project (#1)
1 parent 8915cca commit a88d07b

7 files changed

+113
-37
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
doc/
12
.rebar3
23
_*
34
.eunit
@@ -13,5 +14,6 @@ erl_crash.dump
1314
.rebar
1415
logs
1516
_build
17+
rebar3.crashdump
1618
priv/libzstd/libzstd.a
1719
priv/zstd_nif.so

.travis.yml

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
language: erlang
2+
3+
os:
4+
- linux
5+
26
otp_release:
3-
- 18.3
4-
- 19.2
5-
- 20.2
7+
- 22.3
8+
9+
notifications:
10+
11+
12+
script:
13+
- rebar3 --version
14+
- erl -version
15+
- rebar3 format --verify
16+
- rebar3 test

elvis.config

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[{elvis,
2+
[{config,
3+
[#{dirs => ["src"],
4+
filter => "*.erl",
5+
ruleset => erl_files},
6+
#{dirs => ["test"],
7+
filter => "*.erl",
8+
ruleset => erl_files,
9+
rules =>
10+
%% Variables in eunit macros are called, for instance, __V
11+
[{elvis_style, variable_naming_convention, #{regex => "^_?_?([A-Z][0-9a-zA-Z]*)_?$"}}]},
12+
#{dirs => ["."],
13+
filter => "*rebar.config",
14+
ruleset => rebar_config},
15+
#{dirs => ["."],
16+
filter => "elvis.config",
17+
ruleset => elvis_config}]}]}].

rebar.config

+48-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,52 @@
1-
{erl_opts, [debug_info]}.
1+
{erl_opts,
2+
[warn_unused_vars,
3+
warn_export_all,
4+
warn_shadow_vars,
5+
warn_unused_import,
6+
warn_unused_function,
7+
warn_bif_clash,
8+
warn_unused_record,
9+
warn_deprecated_function,
10+
warn_obsolete_guard,
11+
strict_validation,
12+
warn_export_vars,
13+
warn_exported_vars,
14+
debug_info]}.
15+
16+
{minimum_otp_vsn, "21"}.
17+
218
{deps, []}.
319

420
{pre_hooks,
5-
[{"(linux|darwin|solaris)", compile, "make MOREFLAGS=-fPIC -C priv/zstd/lib libzstd.a"},
6-
{"(linux|darwin|solaris)", compile, "make -C c_src"},
7-
{"(freebsd)", compile, "gmake MOREFLAGS=-fPIC -C priv/zstd/lib libzstd.a"},
8-
{"(freebsd)", compile, "gmake -C c_src"}]}.
21+
[{"(linux|darwin|solaris)", compile, "make MOREFLAGS=-fPIC -C priv/zstd/lib libzstd.a"},
22+
{"(linux|darwin|solaris)", compile, "make -C c_src"},
23+
{"(freebsd)", compile, "gmake MOREFLAGS=-fPIC -C priv/zstd/lib libzstd.a"},
24+
{"(freebsd)", compile, "gmake -C c_src"}]}.
25+
926
{post_hooks,
10-
[{"(linux|darwin|solaris)", clean, "make -C c_src clean"},
11-
{"(linux|darwin|solaris)", clean, "make -C priv/zstd/lib clean"},
12-
{"(freebsd)", clean, "gmake -C c_src clean"},
13-
{"(freebsd)", clean, "gmake -C priv/zstd/lib clean"}]}.
27+
[{"(linux|darwin|solaris)", clean, "make -C c_src clean"},
28+
{"(linux|darwin|solaris)", clean, "make -C priv/zstd/lib clean"},
29+
{"(freebsd)", clean, "gmake -C c_src clean"},
30+
{"(freebsd)", clean, "gmake -C priv/zstd/lib clean"}]}.
31+
32+
{dialyzer,
33+
[{warnings, [no_return, error_handling]},
34+
{plt_apps, top_level_deps},
35+
{plt_extra_apps, []},
36+
{plt_location, local},
37+
{base_plt_apps, [erts, stdlib, kernel]},
38+
{base_plt_location, global}]}.
39+
40+
{xref_checks,
41+
[undefined_function_calls,
42+
locals_not_used,
43+
deprecated_function_calls,
44+
deprecated_functions]}.
45+
46+
{alias, [{test, [format, lint, hank, xref, dialyzer, eunit]}]}.
47+
48+
{project_plugins,
49+
[{rebar3_format, "~> 0.10.0"}, {rebar3_lint, "~> 0.3.2"}, {rebar3_hank, "~> 0.2.1"}]}.
50+
51+
%% @todo Remove this when rebar3_hank reaches 0.3.0
52+
{hank, [{ignore, [{"src/zstd.erl", unused_ignored_function_params}]}]}.

src/zstd.app.src

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
{application,zstd,
2-
[{description,"Zstd binding for Erlang/Elixir"},
3-
{vsn,"0.2.0"},
4-
{registered,[]},
5-
{applications,[kernel,stdlib]},
6-
{env,[]},
7-
{modules,[]},
8-
{maintainers,["Yuki Ito"]},
9-
{licenses,["BSD"]},
10-
{links,[{"GitHub","https://github.com/mururu/zstd-erlang"}]}]}.
1+
{application,
2+
zstd,
3+
[{description, "Zstd binding for Erlang/Elixir"},
4+
{vsn, "0.2.0"},
5+
{registered, []},
6+
{applications, [kernel, stdlib]},
7+
{env, []},
8+
{modules, []},
9+
{maintainers, ["Yuki Ito"]},
10+
{licenses, ["BSD"]},
11+
{links, [{"GitHub", "https://github.com/mururu/zstd-erlang"}]}]}.

src/zstd.erl

+17-13
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
-export([compress/1, compress/2]).
44
-export([decompress/1]).
55

6-
-on_load(init/0).
6+
-on_load init/0.
77

88
-define(APPNAME, zstd).
99
-define(LIBNAME, zstd_nif).
@@ -12,7 +12,8 @@
1212
compress(Binary) ->
1313
compress(Binary, 1).
1414

15-
-spec compress(Uncompressed :: binary(), CompressionLevel :: 0..22) -> Compressed :: binary().
15+
-spec compress(Uncompressed :: binary(), CompressionLevel :: 0..22) ->
16+
Compressed :: binary().
1617
compress(_, _) ->
1718
erlang:nif_error(?LINE).
1819

@@ -21,15 +22,18 @@ decompress(_) ->
2122
erlang:nif_error(?LINE).
2223

2324
init() ->
24-
SoName = case code:priv_dir(?APPNAME) of
25-
{error, bad_name} ->
26-
case filelib:is_dir(filename:join(["..", priv])) of
27-
true ->
28-
filename:join(["..", priv, ?LIBNAME]);
29-
_ ->
30-
filename:join([priv, ?LIBNAME])
31-
end;
32-
Dir ->
33-
filename:join(Dir, ?LIBNAME)
34-
end,
25+
SoName =
26+
case code:priv_dir(?APPNAME) of
27+
{error, bad_name} ->
28+
case filelib:is_dir(
29+
filename:join(["..", priv]))
30+
of
31+
true ->
32+
filename:join(["..", priv, ?LIBNAME]);
33+
_ ->
34+
filename:join([priv, ?LIBNAME])
35+
end;
36+
Dir ->
37+
filename:join(Dir, ?LIBNAME)
38+
end,
3539
erlang:load_nif(SoName, 0).

test/zstd_tests.erl

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
-include_lib("eunit/include/eunit.hrl").
44

55
zstd_test() ->
6-
Data = <<"Hello, World!">>,
7-
?assertEqual(Data, zstd:decompress(zstd:compress(Data))).
6+
Data = <<"Hello, World!">>,
7+
?assertEqual(Data,
8+
zstd:decompress(
9+
zstd:compress(Data))).

0 commit comments

Comments
 (0)