Permalink
Browse files

covert into a leiningen plugin

  • Loading branch information...
1 parent 79fa21f commit 14f9787d54611337de223dd122af9671b7590f45 @kurtharriger committed Mar 28, 2012
Showing with 24 additions and 12 deletions.
  1. +5 −0 project.clj
  2. +19 −12 dep.clj → src/leiningen/depgraph.clj
View
@@ -0,0 +1,5 @@
+(defproject org.clojars.kurtharriger/lein-depgraph "0.1.0"
+ :description "Generate a namespace dependency graph as an svg file"
+ :url "https://github.com/kurtharriger/clojure-dependency-graph"
+;; :dependencies [[org.clojure/clojure "1.3.0"]]
+ :eval-in-leiningen true)
@@ -1,4 +1,6 @@
-(ns hiredman.deps)
+(ns leiningen.depgraph
+ "Generate a namespace dependency graph as an svg file"
+ (:use [clojure.java.shell :only [sh]]))
(defn ffile [file]
@@ -113,16 +115,21 @@
(fn [x]
(reduce str (map #(format "%s->%s;\n" (safe-name (first %)) (safe-name (second %))) x)))))
-
-(-> (first *command-line-args*) parse-directory
- ((partial remove (comp nil? first)))
- restructure
- (safe-name-and-label :java)
- (safe-name-and-label :clojure)
- edges
- dot
- ((fn [out]
- (binding [*out* (-> (second *command-line-args*) java.io.File. java.io.FileWriter.)]
- (println out)))))
+(defn depgraph
+ "Generate a namespace dependency graph as svg file"
+ [project]
+ (let [source-path (:source-path project "src")
+ dotfile (str (:name project) ".dot")
+ svgfile (str (:name project) ".svg")]
+ (-> source-path
+ parse-directory
+ ((partial remove (comp nil? first)))
+ restructure
+ (safe-name-and-label :java)
+ (safe-name-and-label :clojure)
+ edges
+ dot
+ ((partial spit dotfile)))
+ (sh "dot" "-Tsvg" (str "-o" svgfile ) dotfile) ))

0 comments on commit 14f9787

Please sign in to comment.