From bacd2a2f5f038b819f5a2807f8b72b2bf5f61a4c Mon Sep 17 00:00:00 2001 From: Aaron Fischer Date: Sat, 5 Dec 2015 23:01:54 +0100 Subject: [PATCH] Start visualize the header --- project.clj | 1 + src/mailhead/visualize.clj | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/mailhead/visualize.clj diff --git a/project.clj b/project.clj index 04789e2..0c51a71 100644 --- a/project.clj +++ b/project.clj @@ -24,6 +24,7 @@ [clj-time "0.11.0"] [io.forward/clojure-mail "1.0.3"] [macroz/tangle "0.1.9"] + [rhizome "0.2.5"] [org.immutant/web "2.1.1" :exclusions [ch.qos.logback/logback-classic]]] :min-lein-version "2.0.0" diff --git a/src/mailhead/visualize.clj b/src/mailhead/visualize.clj new file mode 100644 index 0000000..9401297 --- /dev/null +++ b/src/mailhead/visualize.clj @@ -0,0 +1,23 @@ +(ns mailhead.visualize + (:use [tangle.core]) + (:require [mailhead.parser :as parser])) + +(defn nodes [receive-path] [:a :b :c]) + +(defn edges [receive-path] [[:a :b {:label "200ms"}] + [:b :c {:label "50min"}]]) + +(defn draw-path [receive-path] + (-> (graph->dot + (nodes receive-path) + (edges receive-path) + {:node {:shape :box} + :directed? true + :graph {:rankdir :LR}}) + (dot->image "png"))) + +(defn draw [filename] + (draw-path (parser/parse-from-file filename))) + +(draw "/home/aaron/workbench/clojurecup2015/sample-data/header1.eml") +