diff --git a/src/liberator/graph.clj b/src/liberator/graph.clj index 68e4b45..1741b78 100644 --- a/src/liberator/graph.clj +++ b/src/liberator/graph.clj @@ -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 @@ -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" @@ -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) diff --git a/src/liberator/trace.svg b/src/liberator/trace.svg index 73aa649..5c91397 100644 --- a/src/liberator/trace.svg +++ b/src/liberator/trace.svg @@ -4,1157 +4,963 @@ - - + + %3 - + start - -start + +start service-available? - -service-available? + +service-available? start->service-available? - - + + handle-service-not-available - -503 -service-not-available + +503 +service-not-available service-available?->handle-service-not-available - - -false + + +false known-method? - -known-method? + +known-method? service-available?->known-method? - - -true + + +true post! - -post! + +post! post-redirect? - -post-redirect? + +post-redirect? post!->post-redirect? - - + + patch! - -patch! + +patch! respond-with-entity? - -respond-with-entity? + +respond-with-entity? patch!->respond-with-entity? - - + + put! - -put! + +put! new? - -new? + +new? put!->new? - - + + delete! - -delete! + +delete! delete-enacted? - -delete-enacted? + +delete-enacted? delete!->delete-enacted? - - + + + + +initialize-context + +initialize-context + + +initialize-context->service-available? + + handle-see-other - -303 -see-other + +303 +see-other handle-multiple-representations - -300 -multiple-representations + +300 +multiple-representations handle-moved-permanently - -301 -moved-permanently + +301 +moved-permanently handle-moved-temporarily - -307 -moved-temporarily + +307 +moved-temporarily handle-not-modified - -304 -not-modified + +304 +not-modified handle-ok - -200 -ok + +200 +ok handle-no-content - -204 -no-content + +204 +no-content handle-created - -201 -created + +201 +created handle-accepted - -202 -accepted + +202 +accepted handle-options - -200 -options + +200 +options handle-not-found - -404 -not-found + +404 +not-found handle-gone - -410 -gone + +410 +gone handle-conflict - -409 -conflict + +409 +conflict handle-precondition-failed - -412 -precondition-failed + +412 +precondition-failed handle-unprocessable-entity - -422 -unprocessable-entity + +422 +unprocessable-entity handle-not-acceptable - -406 -not-acceptable + +406 +not-acceptable handle-request-entity-too-large - -413 -request-entity-too-large + +413 +request-entity-too-large handle-unsupported-media-type - -415 -unsupported-media-type + +415 +unsupported-media-type handle-forbidden - -403 -forbidden + +403 +forbidden handle-unauthorized - -401 -unauthorized + +401 +unauthorized handle-malformed - -400 -malformed + +400 +malformed handle-method-not-allowed - -405 -method-not-allowed + +405 +method-not-allowed handle-uri-too-long - -414 -uri-too-long + +414 +uri-too-long handle-not-implemented - -501 -not-implemented + +501 +not-implemented handle-unknown-method - -501 -unknown-method + +501 +unknown-method handle-exception - -500 -exception + +500 +exception multiple-representations? - -multiple-representations? + +multiple-representations? multiple-representations?->handle-multiple-representations - - -true + + +true multiple-representations?->handle-ok - - -false + + +false respond-with-entity?->handle-no-content - - -false + + +false respond-with-entity?->multiple-representations? - - -true + + +true new?->handle-created - - -true + + +true new?->respond-with-entity? - - -false + + +false post-redirect?->handle-see-other - - -true + + +true post-redirect?->new? - - -false + + +false can-post-to-missing? - -can-post-to-missing? + +can-post-to-missing? can-post-to-missing?->post! - - -true + + +true can-post-to-missing?->handle-not-found - - -false + + +false post-to-missing? - -post-to-missing? + +post-to-missing? post-to-missing?->handle-not-found - - -false + + +false post-to-missing?->can-post-to-missing? - - -true + + +true can-post-to-gone? - -can-post-to-gone? + +can-post-to-gone? can-post-to-gone?->post! - - -true + + +true can-post-to-gone?->handle-gone - - -false + + +false post-to-gone? - -post-to-gone? + +post-to-gone? post-to-gone?->handle-gone - - -false + + +false post-to-gone?->can-post-to-gone? - - -true + + +true moved-temporarily? - -moved-temporarily? + +moved-temporarily? moved-temporarily?->handle-moved-temporarily - - -true + + +true moved-temporarily?->post-to-gone? - - -false + + +false moved-permanently? - -moved-permanently? + +moved-permanently? moved-permanently?->handle-moved-permanently - - -true + + +true moved-permanently?->moved-temporarily? - - -false + + +false existed? - -existed? + +existed? existed?->post-to-missing? - - -false + + +false existed?->moved-permanently? - - -true + + +true conflict? - -conflict? + +conflict? conflict?->put! - - -false + + +false conflict?->handle-conflict - - -true + + +true can-put-to-missing? - -can-put-to-missing? + +can-put-to-missing? can-put-to-missing?->handle-not-implemented - - -false + + +false can-put-to-missing?->conflict? - - -true + + +true put-to-different-url? - -put-to-different-url? + +put-to-different-url? put-to-different-url?->handle-moved-permanently - - -true + + +true put-to-different-url?->can-put-to-missing? - - -false + + +false method-put? - -method-put? + +method-put? method-put?->existed? - - -false + + +false method-put?->put-to-different-url? - - -true + + +true if-match-star-exists-for-missing? - -if-match-star-exists-for-missing? + +if-match-star-exists-for-missing? if-match-star-exists-for-missing?->handle-precondition-failed - - -true + + +true if-match-star-exists-for-missing?->method-put? - - -false + + +false if-none-match? - -if-none-match? + +if-none-match? if-none-match?->handle-not-modified - - -true + + +true if-none-match?->handle-precondition-failed - - -false + + +false put-to-existing? - -put-to-existing? + +put-to-existing? put-to-existing?->multiple-representations? - - -false + + +false put-to-existing?->conflict? - - -true + + +true post-to-existing? - -post-to-existing? + +post-to-existing? post-to-existing?->post! - - -true + + +true post-to-existing?->put-to-existing? - - -false + + +false delete-enacted?->handle-accepted - - -false + + +false delete-enacted?->respond-with-entity? - - -true + + +true method-patch? - -method-patch? + +method-patch? method-patch?->patch! - - -true + + +true method-patch?->post-to-existing? - - -false + + +false method-delete? - -method-delete? + +method-delete? method-delete?->delete! - - -true + + +true method-delete?->method-patch? - - -false + + +false modified-since? - -modified-since? + +modified-since? modified-since?->handle-not-modified - - -false + + +false modified-since?->method-delete? - - -true - - -if-modified-since-valid-date? - -if-modified-since-valid-date? - - -if-modified-since-valid-date?->method-delete? - - -false - - -if-modified-since-valid-date?->modified-since? - - -true - - -if-modified-since-exists? - -if-modified-since-exists? - - -if-modified-since-exists?->method-delete? - - -false - - -if-modified-since-exists?->if-modified-since-valid-date? - - -true + + +true etag-matches-for-if-none? - -etag-matches-for-if-none? + +etag-matches-for-if-none? etag-matches-for-if-none?->if-none-match? - - -true - - -etag-matches-for-if-none?->if-modified-since-exists? - - -false - - -if-none-match-star? - -if-none-match-star? - - -if-none-match-star?->if-none-match? - - -true - - -if-none-match-star?->etag-matches-for-if-none? - - -false - - -if-none-match-exists? - -if-none-match-exists? - - -if-none-match-exists?->if-modified-since-exists? - - -false - - -if-none-match-exists?->if-none-match-star? - - -true + + +true + + +etag-matches-for-if-none?->modified-since? + + +false unmodified-since? - -unmodified-since? + +unmodified-since? unmodified-since?->handle-precondition-failed - - -true - - -unmodified-since?->if-none-match-exists? - - -false - - -if-unmodified-since-valid-date? - -if-unmodified-since-valid-date? - - -if-unmodified-since-valid-date?->if-none-match-exists? - - -false - - -if-unmodified-since-valid-date?->unmodified-since? - - -true - - -if-unmodified-since-exists? - -if-unmodified-since-exists? - - -if-unmodified-since-exists?->if-none-match-exists? - - -false - - -if-unmodified-since-exists?->if-unmodified-since-valid-date? - - -true + + +true + + +unmodified-since?->etag-matches-for-if-none? + + +false etag-matches-for-if-match? - -etag-matches-for-if-match? + +etag-matches-for-if-match? etag-matches-for-if-match?->handle-precondition-failed - - -false - - -etag-matches-for-if-match?->if-unmodified-since-exists? - - -true - - -if-match-star? - -if-match-star? - - -if-match-star?->if-unmodified-since-exists? - - -true - - -if-match-star?->etag-matches-for-if-match? - - -false - - -if-match-exists? - -if-match-exists? - - -if-match-exists?->if-unmodified-since-exists? - - -false - - -if-match-exists?->if-match-star? - - -true + + +false + + +etag-matches-for-if-match?->unmodified-since? + + +true exists? - -exists? + +exists? exists?->if-match-star-exists-for-missing? - - -false + + +false - -exists?->if-match-exists? - - -true + +exists?->etag-matches-for-if-match? + + +true processable? - -processable? + +processable? processable?->handle-unprocessable-entity - - -false + + +false processable?->exists? - - -true + + +true encoding-available? - -encoding-available? + +encoding-available? encoding-available?->handle-not-acceptable - - -false + + +false encoding-available?->processable? - - -true - - -accept-encoding-exists? - -accept-encoding-exists? - - -accept-encoding-exists?->processable? - - -false - - -accept-encoding-exists?->encoding-available? - - -true + + +true charset-available? - -charset-available? + +charset-available? charset-available?->handle-not-acceptable - - -false - - -charset-available?->accept-encoding-exists? - - -true - - -accept-charset-exists? - -accept-charset-exists? - - -accept-charset-exists?->accept-encoding-exists? - - -false - - -accept-charset-exists?->charset-available? - - -true + + +false + + +charset-available?->encoding-available? + + +true language-available? - -language-available? + +language-available? language-available?->handle-not-acceptable - - -false - - -language-available?->accept-charset-exists? - - -true - - -accept-language-exists? - -accept-language-exists? - - -accept-language-exists?->accept-charset-exists? - - -false - - -accept-language-exists?->language-available? - - -true + + +false + + +language-available?->charset-available? + + +true media-type-available? - -media-type-available? + +media-type-available? media-type-available?->handle-not-acceptable - - -false - - -media-type-available?->accept-language-exists? - - -true - - -accept-exists? - -accept-exists? - - -accept-exists?->accept-language-exists? - - -false - - -accept-exists?->media-type-available? - - -true + + +false + + +media-type-available?->language-available? + + +true is-options? - -is-options? + +is-options? is-options?->handle-options - - -true + + +true - -is-options?->accept-exists? - - -false + +is-options?->media-type-available? + + +false valid-entity-length? - -valid-entity-length? + +valid-entity-length? valid-entity-length?->handle-request-entity-too-large - - -false + + +false valid-entity-length?->is-options? - - -true + + +true known-content-type? - -known-content-type? + +known-content-type? known-content-type?->handle-unsupported-media-type - - -false + + +false known-content-type?->valid-entity-length? - - -true + + +true valid-content-header? - -valid-content-header? + +valid-content-header? valid-content-header?->handle-not-implemented - - -false + + +false valid-content-header?->known-content-type? - - -true + + +true allowed? - -allowed? + +allowed? allowed?->handle-forbidden - - -false + + +false allowed?->valid-content-header? - - -true + + +true authorized? - -authorized? + +authorized? authorized?->handle-unauthorized - - -false + + +false authorized?->allowed? - - -true + + +true malformed? - -malformed? + +malformed? malformed?->handle-malformed - - -true + + +true malformed?->authorized? - - -false + + +false method-allowed? - -method-allowed? + +method-allowed? method-allowed?->handle-method-not-allowed - - -false + + +false method-allowed?->malformed? - - -true + + +true uri-too-long? - -uri-too-long? + +uri-too-long? uri-too-long?->handle-uri-too-long - - -true + + +true uri-too-long?->method-allowed? - - -false + + +false known-method?->handle-unknown-method - - -false + + +false known-method?->uri-too-long? - - -true + + +true