Skip to content

Commit

Permalink
Merge pull request #6 from artefactop/improve_travis
Browse files Browse the repository at this point in the history
Move to rebar3
  • Loading branch information
artefactop committed May 10, 2016
2 parents 1f69601 + 4873fa9 commit a84e997
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 26 deletions.
14 changes: 12 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
.rebar3
_*
.eunit
deps
*.o
*.beam
*.plt
*.swp
*.swo
.erlang.cookie
ebin
log
erl_crash.dump
.rebar
logs
_build
*.plt
*.iml
.idea
ebin
16 changes: 10 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
language: erlang
script: rebar compile && rebar skip_deps=true eunit
otp_release:
- 18.3
- 17.5
- 18.0
- R16B03-1
- R15B02

- 17.1
- 18.3
before_script:
- "./bootstrap_travis.sh"
script: "./rebar3 eunit"
deploy:
provider: script
script: scripts/hex.sh
on:
tags: true
5 changes: 5 additions & 0 deletions bootstrap_travis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

curl -O -L https://s3.amazonaws.com/rebar3/rebar3
chmod +x rebar3
./rebar3 update
3 changes: 1 addition & 2 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{erl_opts, [debug_info, {src_dirs, ["src"]}]}.

{deps, [
{erlsha2, ".*", {git, "https://github.com/vinoski/erlsha2", "2.2.1"}},
{jsx, ".*", {git, "git://github.com/talentdeficit/jsx.git", "2.8.0"}}
{jsx,"2.8.0"}
]}.

{cover_enabled, true}.
14 changes: 14 additions & 0 deletions scripts/hex.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

## Setup hex user
mkdir -p ~/.hex
echo '{username,<<"'${HEX_USERNAME}'">>}.' > ~/.hex/hex.config
echo '{key,<<"'${HEX_KEY}'">>}.' >> ~/.hex/hex.config

## Add the rebar3 hex plugin to global
mkdir -p ~/.config/rebar3
echo '{plugins, [rebar3_hex]}.' > ~/.config/rebar3/rebar.config

./rebar3 hex publish <<EOF
y
EOF
26 changes: 14 additions & 12 deletions src/ejwt.app.src
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{application, ejwt,
[
{description, "Encode/decode JSON Web Token"},
{vsn, git},
{registered, [ejwt]},
{applications, [
kernel,
stdlib,
jsx,
erlsha2
]},
{env, []}
]}.
[
{description, "Encode/decode JSON Web Token"},
{vsn, "git"},
{registered, [ejwt]},
{applications, [
kernel,
stdlib,
jsx
]},
{env, []},
{maintainers, ["Jose Luis Navarro"]},
{licenses, ["Apache"]},
{links, [{"Github", "https://github.com/artefactop/ejwt"}]}
]}.
7 changes: 3 additions & 4 deletions src/ejwt.erl
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ encode(Payload, Key, Algorithm) ->
-spec get_mac(Key :: key(), Data :: binary(), Method :: binary()) -> binary().

get_mac(Key, Data, ?HS256) ->
hmac:hmac256(Key, Data);
crypto:hmac(sha256, Key, Data);
get_mac(Key, Data, ?HS384) ->
hmac:hmac384(Key, Data);
crypto:hmac(sha384, Key, Data);
get_mac(Key, Data, ?HS512) ->
hmac:hmac512(Key, Data).
crypto:hmac(sha512, Key, Data).

-spec decode(JWT :: binary()) -> list() | error.

Expand All @@ -69,4 +69,3 @@ decode(JWT, Key) ->
error
end
end.

0 comments on commit a84e997

Please sign in to comment.