9 | | * name of the modules: {{{[{il1,[one1,one2]},{il2,[two1]}]}}}, |
10 | | * module nodes: {{{[{il1,[{'gn',module,2},{'gn',module,4}]},{il2,[{'gn',module,6}]}]}}}, |
11 | | * list of regexps: {{{[{il1,["^(/home/user)/[a-zA-Z0-9_/]+(/layer1)$"]},{il2,["(/layer2)$","^(/home/user/layer2/src)$"]}]}}}, |
12 | | * file, that contain regexps: {{{[{il1,["layer1"]}, {il2,["layer2"]}]}}}. In this example ''layer1'' and ''layer2'' are files, which contain regexps. |
13 | | |
14 | | We can mix the ways of specifications. |
| 9 | ||Erlang term||Description||Example||Example description|| |
| 10 | ||{{{atom()}}}||the name of a loaded module||{{{one1}}}||the module {{{one1}}}|| |
| 11 | ||{'gn',module,!ModIdx}||the identifier of a module node||{'gn',module,2}||module !#2 in the graph representation|| |
| 12 | ||{{{string()}}} containing a regexp||a regular expression for module names||{{{"^(/home/user)/[a-zA-Z0-9_/]+(/layer1)$"}}}||files from a layer1 directory under /home/user|| |
| 13 | ||{{{string()}}}||name of a file that contains regexps||{{{"layer1_regexps.txt"}}}||regexps inside layer1_regexps.txt|| |
18 | | Between two layers we can define a relation, which allows function calls from the first to the second layer. The definition of these additional relations available with a list, that contains this pairs in tuples. We can refer to interface layers with their names. Suppose, that we want to allow function calls from ''il1'' to ''il2'' as well as from ''il2'' to ''il4'' layer: {{{[{il1,il2},{il2,il4}]}}}. |
| 17 | Sometimes, it is desirable to allow calls between layers that do not conform to the above. For that purpose, we use a list of {{{{AllowFrom, AllowTo} :: {atom(), atom()}}}} pairs, where {{{AllowFrom}}} and {{{AllowTo}}} are layer names. |
| 18 | |
| 19 | == Interface functions == |
| 20 | |
| 21 | We currently have two interface functions in the {{{ri}}} module: {{{check_layered_arch/2}}} and {{{show_layered_arch/2}}}. Both take two parameters, {{{{Name, ModSpecs}}}} and {{{{AllowFrom, AllowTo}}}} as described above. The function {{{ri:check_layered_arch/2}}} outputs the functions that violate the layer access restrictions, while {{{ri:show_layered_arch/2}}} visualises the layers in a graph with the layer violations highlighted. |
22 | | ri:check_layered_arch([ {il1,["^(/home/user/layers/layer1)$"]}, |
23 | | {il2,["^(/home/user/layers/layer2)$"]}, {il3,["regexp3"]}],[]). |
| 26 | ri:check_layered_arch( |
| 27 | [ {il1,["^(/home/user/layers/layer1)$"]}, |
| 28 | {il2,["^(/home/user/layers/layer2)$"]}, |
| 29 | {il3,["regexp3"]}], |
| 30 | []). |
26 | | ri:show_layered_arch([ {il1,["^(/home/user/layers/layer1)$"]}, |
27 | | {il2,["^(/home/user/layers/layer2)$"]}, {il3,["regexp3"]}],[]). |
| 34 | ri:show_layered_arch( |
| 35 | [ {il1,["^(/home/user/layers/layer1)$"]}, |
| 36 | {il2,["^(/home/user/layers/layer2)$"]}, |
| 37 | {il3,["regexp3"]}], |
| 38 | []). |
30 | | ri:show_layered_arch([ {il1,["^(/home/user/layers/layer1)$"]}, |
31 | | {il2,["^(/home/user/layers/layer2)$"]}, {il3,["regexp3"]}], |
32 | | [{il1,il3}]). |
| 42 | ri:show_layered_arch( |
| 43 | [ {il1,["^(/home/user/layers/layer1)$"]}, |
| 44 | {il2,["^(/home/user/layers/layer2)$"]}, |
| 45 | {il3,["regexp3"]}], |
| 46 | [{il1,il3}]). |