Skip to content

Instantly share code, notes, and snippets.

@jebberjeb
Created March 26, 2017 22:56
Show Gist options
  • Save jebberjeb/7a36ed8671becd7cd64945292822d58f to your computer and use it in GitHub Desktop.
Save jebberjeb/7a36ed8671becd7cd64945292822d58f to your computer and use it in GitHub Desktop.
(use '[specviz.graphviz])
(def states {:no-warn {:missed-first-name :first-name-required
:missed-last-name :last-name-required
:missed-dob-day :dob-required
:missed-dob-month :dob-required
:missed-dob-year :dob-required
:missed-ssn-area :ssn-required
:missed-ssn-group :ssn-required
:missed-ssn-serial :ssn-required
:missed-zip :zip-required
:submit-invalid-dob :invalid-dob
:submit-invalid-ssn :invalid-ssn
:submit-invalid-zip :invalid-zip}
:first-name-required {:set-first-name :no-warn}
:last-name-required {:set-last-name :no-warn}
:dob-required {:set-dob-day :no-warn
:set-dob-month :no-warn
:set-dob-year :no-warn}
:ssn-required {:set-ssn-area :no-warn
:set-ssn-group :no-warn
:set-ssn-serial :no-warn}
:zip-required {:set-zip :no-warn}
:invalid-dob {:set-dob-day :no-warn
:set-dob-month :no-warn
:set-dob-year :no-warn}
:invalid-ssn {:set-ssn-area :no-warn
:set-ssn-group :no-warn
:set-ssn-serial :no-warn}
:invalid-zip {:set-zip :no-warn}})
(defn safe-name [s] (string/replace s "-" ""))
;; Generates fsm.png
(generate-image! (dot-string (mapcat (fn [[from tx-map]]
(mapcat (fn [[trans to]]
[#_{::name (safe-name (name from))
::shape "circle"}
{::from (safe-name (name from))
::label trans
::to (safe-name (name to))}
#_{::name (safe-name (name to))
::shape "circle"}]) tx-map)) states))
"fsm")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment