Skip to content

Commit

Permalink
Dim internal decisions in graph
Browse files Browse the repository at this point in the history
  • Loading branch information
ordnungswidrig committed Nov 29, 2015
1 parent a03aefd commit 5fab141
Show file tree
Hide file tree
Showing 2 changed files with 494 additions and 682 deletions.
20 changes: 13 additions & 7 deletions src/liberator/graph.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@
(defn to-graph [[& args]]
(condp = (first args)
'defdecision
(let [[name then else] (apply extract args)]
(format (str "\"%s\" [id = \"%s\"] \n "
(let [[name then else] (apply extract args)
internal? (#{"is-options?"
"method-put?"
"method-delete?"
"method-patch?"
"post-to-existing?"
"post-to-missing?"
"post-to-gone?"
"put-to-existing?"} (str name))]
(format (str "\"%s\" [id = \"%s\" %s] \n "
"\"%s\" -> \"%s\" [label = \"true\", id = \"%s\"] \n"
"\"%s\" -> \"%s\" [label=\"false\", id = \"%s\"]\n")
name (clean-id name)
name (clean-id name) (if internal? "style=\"filled\" fillcolor=\"#CCCCCC\"" "")
name then (clean-id (str name "_" then))
name else (clean-id (str name "_" else ))))
'defaction
Expand All @@ -31,9 +39,7 @@
:else "#ffffff")]
(format "\"%s\"[id=\"%s\" label=\"%s\\n%s\" style=\"filled\" fillcolor=\"%s\"];\n"
name (clean-id name) status (clojure.string/replace name #"^handle-" "") color))
nil)

)
nil))

(defn rank-max [names]
(str "subgraph {\nrank=max;\n"
Expand Down Expand Up @@ -77,7 +83,7 @@
(let [{:keys [nodes handlers actions]} (parse-source-definitions)]
(->> nodes
(map to-graph)
(filter identity)
(remove nil?)
(concat (rank-handler-groups handlers))
(concat (rank-same actions))
(apply str)
Expand Down
Loading

0 comments on commit 5fab141

Please sign in to comment.