clojurecup2015-mailhead/src/mailhead/visualize.clj
2015-12-05 23:41:04 +01:00

32 lines
977 B
Clojure

(ns mailhead.visualize
(:use [tangle.core])
(:require [mailhead.parser :as parser]))
(defn nodes [receive-path] ["home" "servera" "target"])
(defn edges [receive-path] [["home" "servera" {:label "200ms" :fillcolor "gray" :color "gray"}]
["servera" "target" {:label "50min" :fillcolor "gray" :color "gray"}]])
(defn draw-path [receive-path]
(-> (graph->dot
(nodes receive-path)
(edges receive-path)
{:node {:shape :box
:fontname "Arial"
:fontsize 12
:style "filled"
:fillcolor "darkgoldenrod1"
:color "darkgoldenrod3"}
:edge {:fontname "Arial"
:fontsize 10}
:directed? true
:graph {:rankdir :LR
:color "transparent"}})
(dot->image "png")))
(defn draw [filename]
(draw-path (parser/parse-from-file filename)))
(draw "/home/aaron/workbench/clojurecup2015/sample-data/header1.eml")