couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vatam...@apache.org
Subject [25/50] meck commit: updated refs/heads/master to 3544aca
Date Thu, 28 Sep 2017 21:02:33 GMT
fix behavio(u)r attributes validation on Erlang R20

R20 now checks whether behavio(u)r attribute contains a
valid module name. The attributes content was simply take
from module_info/0. However, module_info/0 contains a list
of behavior and the attribute should only contain as single
module name.

Expand the list of behavio(u)rs into a list of attrbiutes
to make erl_lint happy.


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

Branch: refs/heads/master
Commit: 7c5548e1a971790f9c8990cc4767df0619b7587b
Parents: ad8374c
Author: Andreas Schultz <aschultz@tpip.net>
Authored: Thu Jun 22 17:37:49 2017 +0200
Committer: Adam Lindberg <hello@alind.io>
Committed: Thu Jun 22 18:07:58 2017 +0200

----------------------------------------------------------------------
 src/meck_code_gen.erl | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-meck/blob/7c5548e1/src/meck_code_gen.erl
----------------------------------------------------------------------
diff --git a/src/meck_code_gen.erl b/src/meck_code_gen.erl
index 918161b..e6bb9f3 100644
--- a/src/meck_code_gen.erl
+++ b/src/meck_code_gen.erl
@@ -59,11 +59,23 @@ get_current_call() ->
 %%% Internal functions
 %%%============================================================================
 
+attribute({Key, _Value}, Attrs)
+    when Key =:= vsn;
+	 Key =:= deprecated;
+	 Key =:= optional_callbacks ->
+    Attrs;
+attribute({Key, Value}, Attrs)
+  when (Key =:= behaviour orelse Key =:= behavior)
+       andalso is_list(Value) ->
+    lists:foldl(fun(Behavior, Acc) -> [?attribute(Key, Behavior) | Acc] end,
+		Attrs, Value);
+attribute({Key, Value}, Attrs) ->
+    [?attribute(Key, Value) | Attrs].
+
 attributes(Mod) ->
     try
-        [?attribute(Key, Val) || {Key, Val} <-
-            proplists:get_value(attributes, Mod:module_info(), []),
-            Key =/= vsn, Key =/= deprecated, Key =/= optional_callbacks]
+	lists:foldl(fun attribute/2, [],
+		    proplists:get_value(attributes, Mod:module_info(), []))
     catch
         error:undef -> []
     end.


Mime
View raw message