couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From beno...@apache.org
Subject [10/23] goldrush commit: updated refs/heads/import-master to 71e6321
Date Thu, 13 Feb 2014 16:35:43 GMT
Add wildcard op, .gitignore & update rebar.configs


Project: http://git-wip-us.apache.org/repos/asf/couchdb-goldrush/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-goldrush/commit/7ff9b03e
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-goldrush/tree/7ff9b03e
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-goldrush/diff/7ff9b03e

Branch: refs/heads/import-master
Commit: 7ff9b03e4038e83732b241d92ccee2322c4ece5e
Parents: 3f99650
Author: Pedram Nimreezi <deadzen@deadzen.com>
Authored: Tue Mar 19 00:56:42 2013 -0400
Committer: Pedram Nimreezi <deadzen@deadzen.com>
Committed: Tue Apr 9 16:47:16 2013 -0400

----------------------------------------------------------------------
 .gitignore       |  8 ++++++++
 Makefile         |  4 ++--
 rebar.config     |  6 ------
 src/glc.erl      |  8 +++++++-
 src/glc_code.erl | 11 +++++++----
 src/glc_lib.erl  | 12 +++++++++++-
 src/glc_ops.erl  | 10 +++++++++-
 7 files changed, 44 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-goldrush/blob/7ff9b03e/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ff8fc4b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,8 @@
+.eunit
+*.beam
+ebin
+doc
+*.swp
+erl_crash.dump
+.project
+log

http://git-wip-us.apache.org/repos/asf/couchdb-goldrush/blob/7ff9b03e/Makefile
----------------------------------------------------------------------
diff --git a/Makefile b/Makefile
index 616e9cd..7be9a3e 100644
--- a/Makefile
+++ b/Makefile
@@ -20,10 +20,10 @@ clean:
 tests: clean app eunit ct
 
 eunit:
-	@$(REBAR) eunit skip_deps=true
+	@$(REBAR) -C rebar.test.config eunit skip_deps=true
 
 ct:
-	@$(REBAR) ct skip_deps=true
+	@$(REBAR) -C rebar.test.config ct skip_deps=true
 
 build-plt:
 	@$(DIALYZER) --build_plt --output_plt .$(APPNAME)_dialyzer.plt \

http://git-wip-us.apache.org/repos/asf/couchdb-goldrush/blob/7ff9b03e/rebar.config
----------------------------------------------------------------------
diff --git a/rebar.config b/rebar.config
index ef5b0d8..3faf52a 100644
--- a/rebar.config
+++ b/rebar.config
@@ -1,12 +1,6 @@
 {cover_enabled, true}.
-{eunit_opts, [{report, {eunit_surefire, [{dir, "."}]}}]}.
 {erl_opts, [
 %%	bin_opt_info,
 %%	warn_missing_spec,
-	warnings_as_errors,
 	warn_export_all
 ]}.
-{deps, [
-    {proper, ".*",
-        {git, "git://github.com/manopapad/proper.git", "master"}}
-]}.

http://git-wip-us.apache.org/repos/asf/couchdb-goldrush/blob/7ff9b03e/src/glc.erl
----------------------------------------------------------------------
diff --git a/src/glc.erl b/src/glc.erl
index 269adea..ecca4b7 100644
--- a/src/glc.erl
+++ b/src/glc.erl
@@ -30,6 +30,8 @@
 %% glc:eq(a, 0).
 %% %% Select all events where 'a' exists and is less than 0.
 %% glc:lt(a, 0).
+%% %% Select all events where 'a' exists and is anything.
+%% glc:wc(a).
 %%
 %% %% Select no input events. Used as black hole query.
 %% glc:null(false).
@@ -68,7 +70,8 @@
 -export([
     lt/2,
     eq/2,
-    gt/2
+    gt/2,
+    wc/1
 ]).
 
 -export([
@@ -100,6 +103,9 @@ eq(Key, Term) ->
 gt(Key, Term) ->
     glc_ops:gt(Key, Term).
 
+-spec wc(atom()) -> glc_ops:op().
+wc(Key) ->
+    glc_ops:wc(Key).
 
 %% @doc Filter the input using multiple filters.
 %%

http://git-wip-us.apache.org/repos/asf/couchdb-goldrush/blob/7ff9b03e/src/glc_code.erl
----------------------------------------------------------------------
diff --git a/src/glc_code.erl b/src/glc_code.erl
index f927055..810ca3c 100644
--- a/src/glc_code.erl
+++ b/src/glc_code.erl
@@ -27,7 +27,7 @@
 
 compile(Module, ModuleData) ->
     {ok, forms, Forms} = abstract_module(Module, ModuleData),
-    {ok, Module, Binary} = compile_forms(Forms, []),
+    {ok, Module, Binary} = compile_forms(Forms, [nowarn_unused_vars]),
     {ok, loaded, Module} = load_binary(Module, Binary),
     {ok, Module}.
 
@@ -150,6 +150,10 @@ abstract_filter_({null, true}, OnMatch, _OnNomatch, State) ->
     OnMatch(State);
 abstract_filter_({null, false}, _OnMatch, OnNomatch, State) ->
     OnNomatch(State);
+abstract_filter_({Key, '*'}, OnMatch, OnNomatch, State) ->
+    abstract_getkey(Key,
+        _OnMatch=fun(#state{}=State2) -> OnMatch(State2) end,
+        _OnNomatch=fun(State2) -> OnNomatch(State2) end, State);
 abstract_filter_({Key, Op, Value}, OnMatch, OnNomatch, State)
         when Op =:= '>'; Op =:= '='; Op =:= '<' ->
     Op2 = case Op of '=' -> '=:='; Op -> Op end,
@@ -176,7 +180,6 @@ abstract_opfilter(Key, Opname, Value, OnMatch, OnNomatch, State) ->
                     OnNomatch(State2))])] end,
         _OnNomatch=fun(State2) -> OnNomatch(State2) end, State).
 
-
 %% @private Generate an `all' filter.
 %% An `all' filter is evaluated by testing all conditions that must hold. If
 %% any of the conditions does not hold the evaluation is short circuted at that
@@ -334,8 +337,8 @@ abstract_getcount(Counter) ->
 
 %% @private Compile an abstract module.
 -spec compile_forms(term(), [term()]) -> {ok, atom(), binary()}.
-compile_forms(Forms, _Opts) ->
-    case compile:forms(Forms) of
+compile_forms(Forms, Opts) ->
+    case compile:forms(Forms, Opts) of
         {ok, Module, Binary} ->
             {ok, Module, Binary};
         {ok, Module, Binary, _Warnings} ->

http://git-wip-us.apache.org/repos/asf/couchdb-goldrush/blob/7ff9b03e/src/glc_lib.erl
----------------------------------------------------------------------
diff --git a/src/glc_lib.erl b/src/glc_lib.erl
index 014054b..427551f 100644
--- a/src/glc_lib.erl
+++ b/src/glc_lib.erl
@@ -69,6 +69,11 @@ matches({Key, '>', Term}, Event) ->
     case gre:find(Key, Event) of
         {true, Term2} -> Term2 > Term;
         false -> false
+    end;
+matches({Key, '*'}, Event) ->
+    case gre:find(Key, Event) of
+        {true, _} -> true;
+        false -> false
     end.
 
 %% @private Repeatedly apply a function to a query.
@@ -88,6 +93,8 @@ onoutput({_, '=', _}) ->
     output;
 onoutput({_, '>', _}) ->
     output;
+onoutput({_, '*'}) ->
+    output;
 onoutput(Query) ->
     erlang:error(badarg, [Query]).
 
@@ -237,6 +244,8 @@ is_valid({Field, '=', _Term}) when is_atom(Field) ->
     true;
 is_valid({Field, '>', _Term}) when is_atom(Field) ->
     true;
+is_valid({Field, '*'}) when is_atom(Field) ->
+    true;
 is_valid({null, true}) ->
     true;
 is_valid({null, false}) ->
@@ -344,7 +353,8 @@ delete_from_any_test() ->
 default_is_output_test_() ->
     [?_assertEqual(output, glc_lib:onoutput(glc:lt(a, 1))),
      ?_assertEqual(output, glc_lib:onoutput(glc:eq(a, 1))),
-     ?_assertEqual(output, glc_lib:onoutput(glc:gt(a, 1)))
+     ?_assertEqual(output, glc_lib:onoutput(glc:gt(a, 1))),
+     ?_assertEqual(output, glc_lib:onoutput(glc:wc(a)))
     ].
 
 -ifdef(PROPER).

http://git-wip-us.apache.org/repos/asf/couchdb-goldrush/blob/7ff9b03e/src/glc_ops.erl
----------------------------------------------------------------------
diff --git a/src/glc_ops.erl b/src/glc_ops.erl
index 4be831e..05067c4 100644
--- a/src/glc_ops.erl
+++ b/src/glc_ops.erl
@@ -4,7 +4,8 @@
 -export([
     lt/2,
     eq/2,
-    gt/2
+    gt/2,
+    wc/1
 ]).
 
 -export([
@@ -22,6 +23,7 @@
     {atom(), '<', term()} |
     {atom(), '=', term()} |
     {atom(), '>', term()} |
+    {atom(), '*'} |
     {any, [op(), ...]} |
     {all, [op(), ...]} |
     {null, true|false}.
@@ -49,6 +51,12 @@ gt(Key, Term) when is_atom(Key) ->
 gt(Key, Term) ->
     erlang:error(badarg, [Key, Term]).
 
+%% @doc Test that a field value is exists.
+-spec wc(atom()) -> op().
+wc(Key) when is_atom(Key) ->
+    {Key, '*'};
+wc(Key) ->
+    erlang:error(badarg, [Key]).
 
 %% @doc Filter the input using multiple filters.
 %%


Mime
View raw message