Skip to content

Commit

Permalink
better usability for edoc
Browse files Browse the repository at this point in the history
  • Loading branch information
Henning Diedrich committed Jan 10, 2011
1 parent d068016 commit 4c3dab5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -5,4 +5,4 @@ samples/*.beam
*.dump
priv/*.config
*~
/doc
# /doc
3 changes: 2 additions & 1 deletion Makefile
@@ -1,5 +1,6 @@
LIBDIR=$(shell erl -eval 'io:format("~s~n", [code:lib_dir()])' -s init stop -noshell)
PKGNAME=emysql
APP_NAME=emysql

MODULES=$(shell ls -1 src/*.erl | awk -F[/.] '{ print "\t\t" $$2 }' | sed '$$q;s/$$/,/g')

Expand Down Expand Up @@ -28,4 +29,4 @@ install:

test: all
(cd t;$(MAKE))
prove t/*.t
prove t/*.t
14 changes: 7 additions & 7 deletions src/emysql.erl
Expand Up @@ -108,22 +108,22 @@ execute(PoolId, Query, Timeout) when is_atom(PoolId) andalso (is_list(Query) ore
execute(PoolId, StmtName, Timeout) when is_atom(PoolId), is_atom(StmtName), is_integer(Timeout) ->
execute(PoolId, StmtName, [], Timeout).

%% @spec execute(PoolId, Query, Args, Timeout) -> Result
%% @spec execute(PoolId, Query|StmtName, Args, Timeout) -> Result
%% PoolId = atom()
%% Query = binary() | string()
%% StmtName = atom()
%% Args = [any()]
%% Timeout = integer()
%% Result = ok_packet() | result_packet() | error_packet()
%%
%% @doc execute query
%%
%% Timeout is the query timeout in milliseconds
%%
execute(PoolId, Query, Args, Timeout) when is_atom(PoolId) andalso (is_list(Query) orelse is_binary(Query)) andalso is_list(Args) andalso is_integer(Timeout) ->
Connection = emysql_conn_mgr:wait_for_connection(PoolId),
monitor_work(Connection, Timeout, {emysql_conn, execute, [Connection, Query, Args]});

%% @spec execute(PoolId, StmtName, Args, Timeout) -> Result
%% PoolId = atom()
%% StmtName = atom()
%% Args = [any()]
%% Timeout = integer()
%% Result = ok_packet() | result_packet() | error_packet()
execute(PoolId, StmtName, Args, Timeout) when is_atom(PoolId), is_atom(StmtName), is_list(Args) andalso is_integer(Timeout) ->
Connection = emysql_conn_mgr:wait_for_connection(PoolId),
monitor_work(Connection, Timeout, {emysql_conn, execute, [Connection, StmtName, Args]}).
Expand Down
1 change: 1 addition & 0 deletions src/emysql_tracer.erl
@@ -1,4 +1,5 @@
-module(emysql_tracer).
-export([trace_module/1]).
-compile(export_all).

trace_module(Fun) ->
Expand Down
12 changes: 9 additions & 3 deletions src/emysql_util.erl
Expand Up @@ -23,6 +23,9 @@
%% FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
%% OTHER DEALINGS IN THE SOFTWARE.
-module(emysql_util).
-export([field_names/1, as_record/4, as_record/3, length_coded_binary/1, length_coded_string/1,
null_terminated_string/2, asciz/1, bxor_binary/1, bxor_binary/2, dualmap/3, hash/1,
rnd/3, encode/1, encode/2, quote/1]).
-compile(export_all).

-include("emysql.hrl").
Expand All @@ -37,13 +40,17 @@ field_names(Result) when is_record(Result, result_packet) ->
%% Fun = fun()
%% Result = [Row]
%% Row = [record()]
%%
%% @doc package row data as records
%%
%% RecordName is the name of the record to generate.
%% Fields are the field names to generate for each record.
%%
%% -module(fetch_example).
%%
%% fetch_foo() ->
%% Res = emysql:execute(pool1, "select * from foo"),
%% Res:as_record(foo, record_info(fields, foo)).
%% Res:as_record(foo, record_info(fields, foo)).
as_record(Result, RecordName, Fields, Fun) when is_record(Result, result_packet), is_atom(RecordName), is_list(Fields), is_function(Fun) ->
{Lookup, _} = lists:mapfoldl(
fun(#field{name=Name}, Acc) ->
Expand Down Expand Up @@ -220,5 +227,4 @@ quote([34 | Rest], Acc) -> %% 34 is $"
quote([26 | Rest], Acc) ->
quote(Rest, [$Z, $\\ | Acc]);
quote([C | Rest], Acc) ->
quote(Rest, [C | Acc]).

quote(Rest, [C | Acc]).

0 comments on commit 4c3dab5

Please sign in to comment.