diff --git a/src/liberator/graph.clj b/src/liberator/graph.clj
index 3f7f233..f44ac19 100644
--- a/src/liberator/graph.clj
+++ b/src/liberator/graph.clj
@@ -1,4 +1,5 @@
-(ns liberator.graph)
+(ns liberator.graph
+ (:require [liberator.core :as liberator]))
(defn extract
([_ name then else] [name then else])
@@ -7,16 +8,21 @@
(defn clean-id [str]
(clojure.string/replace str #"[^a-zA-Z0-9_]+" ""))
+(def default-style "color=\"#b2df8a\"")
+
(defn to-graph [[& args]]
(condp = (first args)
'defdecision
- (let [[name then else] (apply extract args)]
+ (let [[name then else] (apply extract args)
+ default (get liberator/default-functions (keyword name))
+ then-default (if (true? default) default-style "")
+ else-default (if (false? default) default-style "")]
(format (str "\"%s\" [id = \"%s\"] \n "
- "\"%s\" -> \"%s\" [label = \"true\", id = \"%s\"] \n"
- "\"%s\" -> \"%s\" [label = \"false\", id = \"%s\"]\n")
+ "\"%s\" -> \"%s\" [label = \"true\", id = \"%s\" %s] \n"
+ "\"%s\" -> \"%s\" [label = \"false\", id = \"%s\" %s]\n")
name (clean-id name)
- name then (clean-id (str name "_" then))
- name else (clean-id (str name "_" else))))
+ name then (clean-id (str name "_" then)) then-default
+ name else (clean-id (str name "_" else)) else-default))
'defaction
(let [[_ name then] args]
(format (str "\"%s\"[shape=\"ellipse\" id = \"%s\"];\n"
diff --git a/src/liberator/trace.svg b/src/liberator/trace.svg
index 31562dc..8c4a56f 100644
--- a/src/liberator/trace.svg
+++ b/src/liberator/trace.svg
@@ -286,8 +286,8 @@
multiple-representations?->handle-ok
-
-
+
+
false
@@ -299,8 +299,8 @@
respond-with-entity?->handle-no-content
-
-
+
+
false
@@ -319,8 +319,8 @@
new?->handle-created
-
-
+
+
true
@@ -346,8 +346,8 @@
post-redirect?->new?
-
-
+
+
false
@@ -360,8 +360,8 @@
post-enacted?->post-redirect?
-
-
+
+
true
@@ -374,8 +374,8 @@
put-enacted?->new?
-
-
+
+
true
@@ -387,8 +387,8 @@
can-post-to-missing?->post!
-
-
+
+
true
@@ -474,8 +474,8 @@
moved-temporarily?->post-to-gone?
-
-
+
+
false
@@ -494,8 +494,8 @@
moved-permanently?->moved-temporarily?
-
-
+
+
false
@@ -507,8 +507,8 @@
existed?->post-to-missing?
-
-
+
+
false
@@ -528,8 +528,8 @@
patch-enacted?->respond-with-entity?
-
-
+
+
true
@@ -568,8 +568,8 @@
conflict?->method-post?
-
-
+
+
false
@@ -588,8 +588,8 @@
can-put-to-missing?->conflict?
-
-
+
+
true
@@ -608,8 +608,8 @@
put-to-different-url?->can-put-to-missing?
-
-
+
+
false
@@ -722,8 +722,8 @@
delete-enacted?->respond-with-entity?
-
-
+
+
true
@@ -1022,8 +1022,8 @@
exists?->if-match-exists?
-
-
+
+
true
@@ -1042,8 +1042,8 @@
processable?->exists?
-
-
+
+
true
@@ -1242,8 +1242,8 @@
valid-entity-length?->is-options?
-
-
+
+
true
@@ -1262,8 +1262,8 @@
known-content-type?->valid-entity-length?
-
-
+
+
true
@@ -1282,8 +1282,8 @@
@@ -1302,8 +1302,8 @@
@@ -1322,8 +1322,8 @@
authorized?->allowed?
-
-
+
+
true
@@ -1342,8 +1342,8 @@
malformed?->authorized?
-
-
+
+
false
@@ -1382,8 +1382,8 @@
uri-too-long?->method-allowed?
-
-
+
+
false
@@ -1422,8 +1422,8 @@
service-available?->known-method?
-
-
+
+
true