Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


https instead of http; jiffy instead of mochijson; *_tests instead of *_test #1

wants to merge 11 commits into from

3 participants

Ivan Uemlianin Luca Spiller Dmitrii 'Mamut' Dimandt
Ivan Uemlianin

Dear Luca Spiller

I'm using your twerl and I've made a few changes so I thought I'd send a pull request.

  1. Twitter wouldn't accept requests without https;

  2. I've switched to using jiffy instead of mochijson2. Mainly as I'm a bit more familiar with it (haven't seen mochijson2 about much recently);

  3. The tests in test/*_test.erl didn't seem to be picked up by eunit, and the erlang docs say use _tests.erl (see below). I renamed the modules and the number of tests passing went up by about 20.

Thanks very much for your work on twerl!

Best wishes


p.s. This is my first pull request, so many apologies for verbosity and any breaches of etiquette.

** Putting tests in separate modules

If you want to separate your test code from your normal code (at least for testing the exported functions), you can simply write the test functions in a module named m_tests (note: not m_test), if your module is named m. Then, whenever you ask EUnit to test the module m, it will also look for the module m_tests and run those tests as well.

Luca Spiller
Ivan Uemlianin
llaisdy and others added some commits
Ivan Uemlianin llaisdy Add ssl start to make dev start up conf a6d91c4
Ivan Uemlianin llaisdy Client usage from readme now in quicktest.erl 4c710b7
Ivan Uemlianin llaisdy return [] to callback if twitter returns <<"\r\n">> a891673
Dmitrii 'Mamut' Dimandt dmitriid Update rebar.config
rebar fails with

Ivan Uemlianin llaisdy Merge pull request #1 from dmitriid/patch-2
Update rebar.config
Luca Spiller

Hey, sorry for not getting around to this sooner. I've been busy doing other stuff, but I've come back to working on this now.

I've cherry-picked a few of your changes:

  • using Jiffy
  • Handling <<"\r\n">>

I've changed a lot on the project (I completely forgot about this, I did the SSL myself too :P), so that's all that is really relavent now. Thanks!

Luca Spiller lucaspiller closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 29, 2012
  1. Ivan Uemlianin
Commits on Aug 29, 2012
  1. Ivan Uemlianin

    Use current rebar

    llaisdy authored
  2. Ivan Uemlianin

    Use jiffy instead of mochijson2

    llaisdy authored
    stream_client_util_test:decode_test() passes.
  3. Ivan Uemlianin

    For eunit use *_tests.erl instead of *_test.erl

    llaisdy authored
    Now make eunit gets "56 tests passed" instead of "38 tests passed"
  4. Ivan Uemlianin
  5. Ivan Uemlianin
  6. Ivan Uemlianin
  7. Ivan Uemlianin
  8. Ivan Uemlianin
Commits on Dec 16, 2012
  1. Dmitrii 'Mamut' Dimandt

    Update rebar.config

    dmitriid authored
    rebar fails with
Commits on Dec 18, 2012
  1. Ivan Uemlianin

    Merge pull request #1 from dmitriid/patch-2

    llaisdy authored
    Update rebar.config
This page is out of date. Refresh to see the latest.
2  Makefile
@@ -7,7 +7,7 @@ compile: deps
./rebar compile
dev: compile
- erl -pa deps/*/ebin -pa ebin -s inets start -s reloader start
+ erl -pa deps/*/ebin -pa ebin -s inets start -s ssl start -s reloader start
eunit: compile
./rebar eunit app=twerl
BIN  rebar
Binary file not shown
5 rebar.config
@@ -1,6 +1,7 @@
-{erl_opts, [debug_info]}.
+%%-*- mode: erlang -*-
- {mochijson2, "0.*", {git, "git://", {branch, "master"}}},
+ {jiffy, ".*", {git, "git://", "master"}},
{meck, ".*", {git, "", "master"}}
+{erl_opts, [debug_info]}.
16 src/quicktest.erl
@@ -0,0 +1,16 @@
+-export([test/1, test/2]).
+test(UP) ->
+ test(UP, ["erlang"]).
+test({Username, Password}, KeyWordList) ->
+ Headers = stream_client_util:generate_auth_headers(Username, Password),
+ {ok, Params} = stream_client_util:keywords_to_track(KeyWordList),
+ Callback = fun(Data) ->
+ Tweet = proplists:get_value(<<"text">>, Data),
+ io:format("Erlang <3: ~s~n", [Tweet])
+ end,
+ stream_client:connect(stream_client_util:filter_url(),
+ Headers, Params, Callback).
11 src/stream_client_util.erl
@@ -52,9 +52,14 @@ args_to_params(Method, [Current | Remaining], Acc) ->
-spec filter_url() -> string().
filter_url() ->
- "".
+ "".
-spec decode(binary()) -> list().
decode(Data) ->
- {struct, Decoded} = mochijson2:decode(Data),
- Decoded.
+ case Data of
+ <<"\r\n">> ->
+ [];
+ _ ->
+ {Decoded} = jiffy:decode(Data),
+ Decoded
+ end.
2  test/stream_client_test.erl → test/stream_client_tests.erl
@@ -1,4 +1,4 @@
2  test/stream_client_util_test.erl → test/stream_client_util_tests.erl
@@ -1,4 +1,4 @@
2  test/stream_manager_test.erl → test/stream_manager_tests.erl
@@ -1,4 +1,4 @@
Something went wrong with that request. Please try again.