Permalink
Browse files

Misc cleanup from changes brought to you by Joshua Miller. Updating b…

…uild system and added tests. Bumping version to 0.4 from 0.3.
  • Loading branch information...
1 parent 4df5d2c commit f8b65f32fff9d0b698863d3f9b4b36ddbedf27d7 @ngerakines committed Mar 8, 2009
Showing with 97 additions and 36 deletions.
  1. +0 −1 Emakefile
  2. +18 −8 Makefile
  3. +5 −0 README.markdown
  4. +0 −11 control
  5. +9 −0 src/Makefile
  6. +17 −13 src/twitter_client.erl
  7. +2 −3 src/twitter_client_utils.erl
  8. +37 −0 support/include.mk
  9. +9 −0 t/001-load.t
View
@@ -1 +0,0 @@
-{"src/*", [{outdir, "./"}, {i,"./include"}]}.
View
@@ -1,12 +1,22 @@
-all: code
+LIBDIR=`erl -eval 'io:format("~s~n", [code:lib_dir()])' -s init stop -noshell`
+VERSION=0.4
-code: clean
- erl -make
+all:
+ mkdir -p ebin/
+ (cd src;$(MAKE))
+
+test: all
+ prove -v t/*.t
clean:
- rm -rfv *.beam *.rel *.script *.boot erl_crash.dump erlang_twitter/ *.deb
+ (cd src;$(MAKE) clean)
+ rm -rf erl_crash.dump *.beam *.hrl
+
+package: clean
+ @mkdir erlang_twitter-$(VERSION)/ && cp -rf src eqct support t Makefile mysql.escript README.markdown erlang_twitter-$(VERSION)
+ @COPYFILE_DISABLE=true tar zcf erlang_twitter-$(VERSION).tgz erlang_twitter-$(VERSION)
+ @rm -rf erlang_twitter-$(VERSION)/
-install-osx: code
- mkdir -p erlang_twitter-0.3/ebin/ && cp *.beam erlang_twitter-0.3/ebin/
- mkdir -p erlang_twitter-0.3/include/ && cp include/* erlang_twitter-0.3/include/
- cp -R erlang_twitter-0.3 /usr/local/lib/erlang/lib/
+install:
+ mkdir -p $(LIBDIR)/erlang_twitter-$(VERSION)/{ebin,include}
+ for i in include/*.hrl ebin/*.beam; do install $$i $(LIBDIR)/erlang_twitter-$(VERSION)/$$i ; done
View
@@ -57,3 +57,8 @@ By default, the _base\_url_ is set to "http://twitter.com/".
## Packaging
Use `make package-debian` and `make install-debian` to build a .deb file for Debian deployment.
+
+## Contributions
+
+* Harish Mallipeddi
+* Joshua Miller
View
11 control
@@ -1,11 +0,0 @@
-Package: erlang-twitter
-Version: 0.3
-Section: web
-Priority: optional
-Architecture: all
-Essential: no
-Depends: erlang
-Installed-Size: 1024
-Maintainer: Nick Gerakines <nick@gerakines.net>
-Provides: erlang_twitter
-Description: A simple Twitter/Identi.ca interface library.
View
@@ -0,0 +1,9 @@
+include ../support/include.mk
+
+all: $(EBIN_FILES)
+
+debug:
+ $(MAKE) DEBUG=-DDEBUG
+
+clean:
+ rm -rf $(EBIN_FILES) erl_crash.dump
View
@@ -22,8 +22,8 @@
%% OTHER DEALINGS IN THE SOFTWARE.
%%
%% @author Nick Gerakines <nick@gerakines.net>
-%% @copyright 2008 Nick Gerakines
-%% @version 0.3
+%% @copyright 2008-2009 Nick Gerakines
+%% @version 0.4
%% @doc Provides access to the Twitter web service. Mostly through the
%% clever use of REST-like requests and XML parsing.
%%
@@ -54,7 +54,7 @@
-behaviour(gen_server).
-author("Nick Gerakines <nick@gerakines.net>").
--version("0.3").
+-version("0.4").
-export([
init/1, terminate/2, code_change/3,
@@ -95,16 +95,25 @@ start() ->
%% @doc Start a twitter_client gen_server process for a Twitter user.
add_session(Login, Password) ->
gen_server:call({global, ?MODULE}, {add_session, Login, Password}, infinity).
-
+
+%% @spec exists_session(Login) -> true | false
+%% Login = string()
+%% @doc Determines if a login is know by the twitter client.
exists_session(Login) ->
gen_server:call({global, ?MODULE}, {exists_session, Login}, infinity).
+%% @spec set(Type, Value) -> Response
+%% Type = base_url | delay
+%% value = any()
+%% Response = any()
+%% @doc Sets a configuration value in the twitter client.
set(base_url, Value) ->
gen_server:call({global, ?MODULE}, {base_url, Value}, infinity);
set(delay, Value) ->
gen_server:call({global, ?MODULE}, {delay, Value}, infinity).
+%% @doc Returns information on the twitter client.
info() ->
gen_server:call({global, ?MODULE}, {info}, infinity).
@@ -135,9 +144,6 @@ call(Client, Method) ->
call(Client, Method, Args) ->
gen_server:call({global, ?MODULE}, {Client, Method, Args}, infinity).
-%% % -
-%% % gen_server functions
-
%% @private
init(_) ->
{ok, #erlang_twitter{
@@ -154,13 +160,13 @@ session_from_client(State, Client) ->
true -> gb_trees:get(Client, State#erlang_twitter.sessions)
end.
+%% @private
handle_call({base_url, BaseUrl}, _From, State) ->
{reply, ok, State#erlang_twitter{ base_url = BaseUrl }};
handle_call({delay, Delay}, _From, State) ->
{reply, ok, State#erlang_twitter{ delay = Delay }};
-%% Should work .. I think
handle_call({should_wait}, _From, State) ->
Now = calendar:datetime_to_gregorian_seconds(erlang:universaltime()),
Delay = case State#erlang_twitter.delay of
@@ -251,11 +257,9 @@ terminate(_Reason, _State) -> ok.
%% @private
code_change(_OldVsn, State, _Extra) -> {ok, State}.
-%% % -
-%% % Status API methods
-
-%% @doc Return a list of the most recent tweets as per the public timeline.
-%% This API call ignores the login and password strings given.
+%% @doc Return a list of the most recent tweets as per the public
+%% timeline. This API call ignores the login and password strings
+%% given.
status_public_timeline(RootUrl, _Login, _Password, Args) ->
Url = build_url(RootUrl ++ "statuses/public_timeline.xml", Args),
Body = request_url(get, Url, nil, nil, nil),
@@ -23,8 +23,7 @@ url_encode([H|T]) ->
end
end;
-url_encode([]) ->
- [].
+url_encode([]) -> [].
integer_to_hex(I) ->
case catch erlang:integer_to_list(I, 16) of
@@ -46,4 +45,4 @@ string_to_int(S) ->
case string:to_integer(S) of
{Int,[]} -> Int;
{error,no_integer} -> null
- end.
+ end.
View
@@ -0,0 +1,37 @@
+## -*- makefile -*-
+
+ERL := erl
+ERLC := $(ERL)c
+
+INCLUDE_DIRS := ../include $(wildcard ../deps/*/include)
+EBIN_DIRS := $(wildcard ../deps/*/ebin)
+ERLC_FLAGS := -W $(INCLUDE_DIRS:../%=-I ../%) $(EBIN_DIRS:%=-pa %)
+
+ifndef no_debug_info
+ ERLC_FLAGS += +debug_info
+endif
+
+ifdef debug
+ ERLC_FLAGS += -Ddebug
+endif
+
+EBIN_DIR := ../ebin
+DOC_DIR := ../doc
+EMULATOR := beam
+
+ERL_SOURCES := $(wildcard *.erl)
+ERL_HEADERS := $(wildcard *.hrl) $(wildcard ../include/*.hrl)
+ERL_OBJECTS := $(ERL_SOURCES:%.erl=$(EBIN_DIR)/%.beam)
+ERL_OBJECTS_LOCAL := $(ERL_SOURCES:%.erl=./%.$(EMULATOR))
+APP_FILES := $(wildcard *.app)
+EBIN_FILES = $(ERL_OBJECTS) $(APP_FILES:%.app=../ebin/%.app) $(ERL_TEMPLATES)
+MODULES = $(ERL_SOURCES:%.erl=%)
+
+../ebin/%.app: %.app
+ cp $< $@
+
+$(EBIN_DIR)/%.$(EMULATOR): %.erl
+ $(ERLC) $(ERLC_FLAGS) -o $(EBIN_DIR) $<
+
+./%.$(EMULATOR): %.erl
+ $(ERLC) $(ERLC_FLAGS) -o . $<
View
@@ -0,0 +1,9 @@
+#!/usr/bin/env escript
+%% -*- erlang -*-
+%%! -pa ./ebin -sasl errlog_type error -boot start_sasl -noshell
+
+main(_) ->
+ etap:plan(2),
+ etap_can:loaded_ok(twitter_client, "module 'twitter_client' loaded"),
+ etap_can:loaded_ok(twitter_client, "module 'twitter_client_utils' loaded"),
+ etap:end_tests().

0 comments on commit f8b65f3

Please sign in to comment.