Skip to content

Commit

Permalink
色々整理
Browse files Browse the repository at this point in the history
  • Loading branch information
voluntas committed Jul 28, 2024
1 parent 66934ee commit 0c97851
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
ci:
runs-on: ubuntu-latest
container:
image: shiguredo/shiguredo-erlang:otp-26.0.2-openssl-3.1.2-ubuntu-22.04-x86_64
image: shiguredo/erlang:otp-27.0.1-openssl-3.3.1-ubuntu-24.04-x86_64
steps:
- uses: actions/checkout@v4
- run: make
Expand Down
8 changes: 6 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

## develop

- [UPDATE] rebar3 3.22.1 に更新する
- [CHANGE] rebar3 の minimum_otp_vsn を 27.0 にする
- @voluntas
- [UPDATE] GitHub Actions の docker の OTP を 26.0.2 / OpenSSL 3.1.2 に上げる
- [UPDATE] rebar3 3.23.0 に更新する
- @voluntas
- [UPDATE] GitHub Actions の docker の OTP を 27.0.1 / OpenSSL 3.3.1 に上げる
- @voluntas
- [FIX] import を利用しないようにする
- @voluntas

## 2023.1.0
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ Erlang 向けの Base32 ライブラリです。次の種類のバージョン

## ビルド

```shell
$ rebar3 compile
```bash
rebar3 compile
```

## 利用

例:

```
```bash
$ rebar3 shell
1> base32:decode(clockwork, <<"AXQQEB10D5T20WK5C5P6RY90EXQQ4TVK44">>).
<<"Wow, it really works!">>
Expand All @@ -39,8 +39,8 @@ $ rebar3 shell
## ライセンス
```
Copyright 2021-2023, Shiguredo Inc.
```text
Copyright 2021-2024, Shiguredo Inc.
Copyright 2021, SUZUKI Tetsuya (Original Author)
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
11 changes: 6 additions & 5 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{minimum_otp_vsn, "26.0"}.
{minimum_otp_vsn, "27.0"}.

{erl_opts, [{i, "src"},
warnings_as_errors,
warn_shadow_vars,
warn_export_all,
warn_unused_import]}.

Expand All @@ -12,13 +13,13 @@
deprecated_functions]}.

%% https://rebar3.org/docs/configuration/configuration/#dialyzer
{dialyzer, [{warnings, [extra_return,
{dialyzer, [{warnings, [error_handling,
extra_return,
missing_return,
no_unknown
%% overspecs
%% underspecs,
unmatched_returns
%% overspecs
%% specdiffs
%% error_handling
]},
incremental,
{plt_apps, top_level_deps},
Expand Down
Binary file modified rebar3
Binary file not shown.
8 changes: 3 additions & 5 deletions src/base32_clockwork.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

-export([encode/1, decode/1]).

-import(base32_utils, [rev_bits_list_to_binary/1, bits_list_size/1]).


-spec encode(binary()) -> binary().
encode(Data) ->
Expand Down Expand Up @@ -58,15 +56,15 @@ symbol(30) -> $Y;
symbol(31) -> $Z.


-spec decode(binary()) -> {ok, binary()} | {error, atom()}.
-spec decode(binary()) -> {ok, binary()} | {error, invalid_size | invalid_format}.
decode(Data) ->
decode0(Data, []).


decode0(<<>>, []) ->
{ok, <<>>};
decode0(<<>>, Accu = [Last | Prev]) ->
Size = bits_list_size(Accu),
Size = base32_utils:bits_list_size(Accu),
Last1 = case Size rem 8 of
0 ->
Last;
Expand All @@ -75,7 +73,7 @@ decode0(<<>>, Accu = [Last | Prev]) ->
<<Last2:BodySize/bitstring, _/bitstring>> = Last,
Last2
end,
{ok, rev_bits_list_to_binary([Last1 | Prev])};
{ok, base32_utils:rev_bits_list_to_binary([Last1 | Prev])};
decode0(<<_:8>>, []) ->
{error, invalid_size};
decode0(<<"0", Next/binary>>, Accu) ->
Expand Down
6 changes: 2 additions & 4 deletions src/base32_crockford.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

-export([encode/1, encode_check/1, decode/1, decode_check/1]).

-import(base32_utils, [rev_bits_list_to_binary/1]).


data_to_integer(Data, Padding) ->
data_to_integer0(Data, Padding, 0).
Expand Down Expand Up @@ -121,7 +119,7 @@ decode(Data) when is_binary(Data) ->
decode0(Data, []).


-spec decode_check(binary()) -> {ok, binary()} | {error, atom()}.
-spec decode_check(binary()) -> {ok, binary()} | {error, invalid}.
decode_check(Data) ->
Size = (size(Data) - 1) * 8,
<<Data0:Size/bitstring, Expectedcheck:8>> = Data,
Expand All @@ -134,7 +132,7 @@ decode_check(Data) ->


decode0(<<>>, Accu) ->
Decoded0 = rev_bits_list_to_binary(Accu),
Decoded0 = base32_utils:rev_bits_list_to_binary(Accu),
DecodedSize = bit_size(Decoded0),
case DecodedSize rem 8 of
0 ->
Expand Down
6 changes: 2 additions & 4 deletions src/base32_rfc4648.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

-export([encode/1, decode/1]).

-import(base32_utils, [rev_bits_list_to_binary/1]).


-spec encode(binary()) -> binary().
encode(Data) ->
Expand Down Expand Up @@ -160,13 +158,13 @@ encode1(<<1:1>>, Accu) ->
[$Q | Accu].


-spec decode(binary()) -> {ok, binary()} | {error, atom()}.
-spec decode(binary()) -> {ok, binary()} | {error, invalid_format}.
decode(Data) ->
decode0(Data, []).


decode0(<<>>, Accu) ->
{ok, rev_bits_list_to_binary(Accu)};
{ok, base32_utils:rev_bits_list_to_binary(Accu)};
decode0(<<"A", Next/bitstring>>, Accu) ->
decode0(Next, [<<0:5>> | Accu]);
decode0(<<"B", Next/bitstring>>, Accu) ->
Expand Down

0 comments on commit 0c97851

Please # to comment.