Navigation Menu

Skip to content

Commit

Permalink
Use jiffy as the (default) JSON lib.
Browse files Browse the repository at this point in the history
This requires a new rebar which cannot be counted on to be in e.g., homebrew.
  • Loading branch information
squaremo committed Oct 27, 2011
1 parent dc77578 commit f0fab10
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
14 changes: 7 additions & 7 deletions Makefile
@@ -1,21 +1,21 @@
JSON=eep0018
JSON=jiffy
HTTP=cowboy

.PHONY: all deps test test-prep clean distclean

all: deps deps/$(HTTP)
make -C deps/$(HTTP)
rebar compile
./rebar compile

deps:
-rebar get-deps
-./rebar get-deps
# git:// URLs don't work behind some proxies. Grr.
sed -i='' 's|git:|https:|g' deps/cowboy/rebar.config
rebar get-deps
./rebar get-deps

test: test-prep all
erl -pa ebin deps/$(HTTP)/ebin deps/$(HTTP)/deps/*/ebin \
-pa deps/json/ebin -sockjs json_impl $(JSON) \
erl -pa ebin deps/*/ebin \
-sockjs json_impl $(JSON) \
-sockjs http_impl $(HTTP) \
-run sockjs_test

Expand All @@ -39,7 +39,7 @@ deps/misultin:
git clone -b dev https://github.com/ostinelli/misultin.git

clean::
rebar clean
./rebar clean
rm -rf priv/www

distclean::
Expand Down
Binary file added rebar
Binary file not shown.
4 changes: 2 additions & 2 deletions rebar.config
@@ -1,6 +1,6 @@
{deps, [
{cowboy, ".*",
{git, "https://github.com/extend/cowboy.git", {branch, "master"}}},
{json, ".*",
{git, "https://github.com/davisp/eep0018.git", {branch, "master"}}}
{jiffy, "0.2.0",
{git, "https://github.com/davisp/jiffy.git", {tag, "0.2.0"}}}
]}.
2 changes: 1 addition & 1 deletion src/sockjs.app.src
Expand Up @@ -11,5 +11,5 @@
{env, [{sockjs_url, "/lib/sockjs.js"},
{heartbeat_ms, 25000},
{session_close_ms, 5000},
{json_impl, mochijson2}]}
{json_impl, jiffy}]}
]}.
7 changes: 6 additions & 1 deletion src/sockjs_util.erl
@@ -1,7 +1,7 @@
-module(sockjs_util).

-export([encode/1, encode/2, decode/1, encode_list/1]).
-export([mochijson2/2, eep0018/2]).
-export([mochijson2/2, eep0018/2, jiffy/2]).

encode_list([{close, {Code, Reason}}]) ->
encode(<<"c">>, [Code, list_to_binary(Reason)]);
Expand Down Expand Up @@ -32,3 +32,8 @@ mochijson2(JSON, decode) ->

eep0018(Thing, encode) -> {ok, JSON} = json:encode(Thing), JSON;
eep0018(JSON, decode) -> json:decode(JSON).

jiffy(Thing, encode) ->
iolist_to_binary(jiffy:encode(Thing));
jiffy(JSON, decode) ->
{ok, jiffy:decode(JSON)}.

0 comments on commit f0fab10

Please sign in to comment.