From e4c7bafd276049c805039b240e0a83346c31f41b Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Sun, 20 Sep 2020 16:55:36 +0200 Subject: Initial release --- doc/COVERAGE.md | 52 +++++++++++++++++++++++ doc/README.md | 85 +++++++++++++++++++++++++++++++++++++ doc/images/graph-post-exec.svg | 59 ++++++++++++++++++++++++++ doc/images/graph-pre-exec.svg | 95 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 291 insertions(+) create mode 100644 doc/COVERAGE.md create mode 100644 doc/README.md create mode 100644 doc/images/graph-post-exec.svg create mode 100644 doc/images/graph-pre-exec.svg (limited to 'doc') diff --git a/doc/COVERAGE.md b/doc/COVERAGE.md new file mode 100644 index 0000000..43cf0e4 --- /dev/null +++ b/doc/COVERAGE.md @@ -0,0 +1,52 @@ +# TOC + - [test/graph.js](#testgraphjs) + - [It colorizes the graph based on execution results](#it-colorizes-the-graph-based-on-execution-results) + + + +# test/graph.js +It throws an error if you try to run a non-existing vertex. + + +It runs a vertex if no dependencies are defined. + + +It does not run a vertex if it has unfulfilled dependencies. + + +It runs dependent vertices on completion of a vertex's action. + + +It ensures dependencies state is available before running dependents. + + +It gives dependent vertices a state including their dependencies' results. + + +It throws an error if a vertex throws an error. + + +It runs a vertex only once. + + +It can convert to a string representing the graph in graphviz format. + + + +## It colorizes the graph based on execution results +It throws an error if a sub-step fails. + + +It adds the right colors according to execution. + + + +ok - It colorizes the graph based on execution results + +ok - test/graph.js +----------|----------|----------|----------|----------|-------------------| +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | +----------|----------|----------|----------|----------|-------------------| +All files | 100 | 100 | 100 | 100 | | + graph.js | 100 | 100 | 100 | 100 | | +----------|----------|----------|----------|----------|-------------------| diff --git a/doc/README.md b/doc/README.md new file mode 100644 index 0000000..44ae3f8 --- /dev/null +++ b/doc/README.md @@ -0,0 +1,85 @@ +## Classes + +
+
Grafn
+
+
+ +## Typedefs + +
+
tVertex : object
+

The definition of a vertex that can be executed in the graph.

+
+
+ + + +## Grafn +**Kind**: global class + +* [Grafn](#Grafn) + * [new Grafn()](#new_Grafn_new) + * [.run(vertexName)](#Grafn+run) + * [.vertex(vertex)](#Grafn+vertex) + * [.toString()](#Grafn+toString) ⇒ string + + + +### new Grafn() +Represents a graph of functions. You can call run on any specific vertex, +which will trigger execution of it and its dependencies. + +It guarantees that each vertex will only run once. + +It can be represented in graphviz format, highlighting fulfilled and +rejected vertices. + + + +### grafn.run(vertexName) +Executes the named vertex and all its dependents + +**Kind**: instance method of [Grafn](#Grafn) +**Throws**: + +- Will throw an error if a requested vertex does not exist + + +| Param | Type | Description | +| --- | --- | --- | +| vertexName | string | the name of the vertex to run | + + + +### grafn.vertex(vertex) +Adds a vertex to the graph. + +**Kind**: instance method of [Grafn](#Grafn) + +| Param | Type | Description | +| --- | --- | --- | +| vertex | [tVertex](#tVertex) | the definition of the vertex to add | + + + +### grafn.toString() ⇒ string +Converts the graph to a graphviz digraph. If vertices have been executed, +they will be highlighted depending on whether they fulfilled or rejected. + +**Kind**: instance method of [Grafn](#Grafn) +**Returns**: string - The graphviz digraph representation + + +## tVertex : object +The definition of a vertex that can be executed in the graph. + +**Kind**: global typedef +**Properties** + +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| name | string | | The name of the vertex | +| [dependencies] | Array.<string> | [] | The names of vertices that need to run before this one | +| action | function | | The action to execute | + diff --git a/doc/images/graph-post-exec.svg b/doc/images/graph-post-exec.svg new file mode 100644 index 0000000..557ef42 --- /dev/null +++ b/doc/images/graph-post-exec.svg @@ -0,0 +1,59 @@ + + + + + + +%0 + + + +root + +root + + + +successfulDependent + +successfulDependent + + + +root->successfulDependent + + + + + +failedDependent + +failedDependent + + + +root->failedDependent + + + + + +final + +final + + + +successfulDependent->final + + + + + +failedDependent->final + + + + + \ No newline at end of file diff --git a/doc/images/graph-pre-exec.svg b/doc/images/graph-pre-exec.svg new file mode 100644 index 0000000..e739550 --- /dev/null +++ b/doc/images/graph-pre-exec.svg @@ -0,0 +1,95 @@ + + + + + + +%0 + + + +root + +root + + + +addition + +addition + + + +root->addition + + + + + +subtraction + +subtraction + + + +root->subtraction + + + + + +multiplication + +multiplication + + + +root->multiplication + + + + + +division + +division + + + +root->division + + + + + +tally + +tally + + + +addition->tally + + + + + +subtraction->tally + + + + + +multiplication->tally + + + + + +division->tally + + + + + \ No newline at end of file -- cgit