Skip to content

Commit 21dd621

Browse files
author
David Cao
authored
Version.0.1.0
* Add Elixir binding with rebar3_elixir plugin * Add specs definitions * Version 0.1.0 * Version 0.1.0
1 parent 55fd426 commit 21dd621

5 files changed

Lines changed: 26 additions & 7 deletions

File tree

File renamed without changes.

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ defmodule Kylie.Mixfile do
44
def project do
55
[
66
app: :kylie,
7-
version: "0.0.1",
7+
version: "0.1.0",
88
elixir: "~> 1.2",
99
build_embedded: Mix.env == :prod,
1010
start_permanent: Mix.env == :prod,

rebar.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@
6464

6565
%% == Shell ==
6666

67-
{shell, [{apps, [sync]}]}.
68-
{sys_config, "rel/sys.config"}.
67+
{shell, [{apps, [kylie]}]}.
68+
{sys_config, "config/sys.config"}.

src/kylie.app.src

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,21 @@
22
[
33
{description,
44
"Kylie is a Erlang application for Cayley graph data base"},
5-
{vsn, "0.0.1"},
5+
{vsn, "0.1.0"},
66
{applications, [kernel, stdlib, hackney]},
77
{modules, []},
88
{registered, []},
9+
{files, [ "src/*"
10+
, "include/*"
11+
, "lib/*"
12+
, "Makefile"
13+
, "erlang.mk"
14+
, "README.md"
15+
, "rebar.config"
16+
, "rebar.lock"
17+
, "mix.exs"
18+
, "mix.lock"
19+
]},
920
{maintainers, ["David Cesar Hernan Cao"]},
1021
{licenses, ["MIT"]},
1122
{links, [{"Github", "https://github.com/davecaos/kylie"}]},

src/kylie.erl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,23 @@
1919
-define(DELETE_URI, "/api/v1/delete").
2020
-define(QUERY_GREMBLIN_URI, "/api/v1/query/gremlin").
2121

22+
-spec start() -> ok.
2223
start() -> ok.
2324

25+
-spec stop() -> ok.
2426
stop() -> ok.
2527

28+
-spec add(squad:squad4()) -> tuple().
2629
add(Squad) ->
2730
JsonBody = jsx:encode([Squad]),
2831
{200, _Response} = cayley_http_call(?WRITE_URI, JsonBody).
2932

33+
-spec delete(squad:squad4()) -> tuple().
3034
delete(Squad) ->
3135
JsonBody = jsx:encode([Squad]),
3236
{200, _Response} = cayley_http_call(?DELETE_URI, JsonBody).
3337

38+
-spec get_result(binary(), binary()) -> {ok | error, list()}.
3439
get_result(Subject, Predicate) ->
3540
Query = io_lib:format(<<"g.V('~s').Out('~s').All()">>, [Subject, Predicate]),
3641
query(Query).
@@ -43,9 +48,11 @@ filter_query_result(#{<<"result">> := Results}) ->
4348
end,
4449
lists:map(Fun, Results).
4550

51+
-spec build_gremblin_human_readable(list()) -> binary().
4652
build_gremblin_human_readable(PropLisps) ->
4753
erlang:iolist_to_binary(build_gremblin(PropLisps)).
4854

55+
-spec build_gremblin(list()) -> binary().
4956
build_gremblin(PropLisps) ->
5057
lists:map(fun build_query/1, PropLisps).
5158

@@ -83,14 +90,15 @@ build_query(all) ->
8390
build_query(Node) ->
8491
Node.
8592

93+
-spec query(binary()) -> {ok | error, list()}.
8694
query(Query) ->
8795
get_cayley_error(cayley_http_call(?QUERY_GREMBLIN_URI, Query)).
8896

8997
-spec cayley_http_call(string(), iodata()) -> map().
9098
cayley_http_call(Uri, Body) ->
91-
{ok, Port} = application:get_env(kylie, port),
92-
{ok, Host} = application:get_env(kylie, host),
93-
{ok, Timeout} = application:get_env(kylie, timeout),
99+
{ok, Port} = application:get_env(kylie, port, {ok, 64210}),
100+
{ok, Host} = application:get_env(kylie, host, {ok, "127.0.0.1"}),
101+
{ok, Timeout} = application:get_env(kylie, timeout, {ok, 3000}),
94102
Headers = [{<<"Content-Type">>, <<"application/json">>}],
95103
List = [Host, <<":">>, integer_to_list(Port), Uri],
96104
URL = iolist_to_binary(List),

0 commit comments

Comments
 (0)