Permalink
Browse files

Initial commit.

  • Loading branch information...
0 parents commit 36c6b4176284a5a97946207f20be3c3cb816cb4f @technomancy committed May 23, 2010
@@ -0,0 +1,4 @@
+pom.xml
+*jar
+lib
+classes
@@ -0,0 +1,20 @@
+# lein-play
+
+Play sounds when your tests pass or fail.
+
+## Installation
+
+Add this to your project.clj's :dev-dependencies:
+
+ [lein-play "1.0.0-SNAPSHOT"]
+
+Place a leiningen/(pass|fail).mp3 on your classpath to override the
+built-in sounds.
+
+## License
+
+Copyright (C) 2010 Phil Hagelberg
+
+The code is licensed under the Eclipse Public License. The sound
+effects are licensed under Creative Commons Attribution Sharealike
+license.
@@ -0,0 +1,5 @@
+(defproject lein-play "1.0.0-SNAPSHOT"
+ :description "Play a sound when your tests pass or fail."
+ :dependencies [[org.clojars.technomancy/jlayer "1.0"]]
+ :dev-dependencies [[clojure "1.2.0-master-SNAPSHOT"]
+ [swank-clojure "1.2.1"]])
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,18 @@
+(ns leiningen.hooks.play
+ (:use [leiningen.core :only [add-hook]])
+ (:import [java.io FileInputStream BufferedInputStream]
+ [javazoom.jl.player Player]))
+
+(defn play [name]
+ (let [r (.getResourceAsStream (.getContextClassLoader
+ (Thread/currentThread))
+ (format "leiningen/%s.mp3" name))]
+ (-> (BufferedInputStream. r)
+ (Player.)
+ (.play))))
+
+(add-hook 'test (fn [f]
+ (let [code (f)]
+ (play (if (zero? code)
+ "pass" "fail"))
+ code)))
@@ -0,0 +1,8 @@
+(ns leiningen.test-play-hook
+ (:use [clojure.test]))
+
+(deftest flip-flop
+ (let [flop (java.io.File. "/tmp/test-lein-play")]
+ (if (.exists flop)
+ (is (not (.delete flop)))
+ (with-open [w (java.io.FileOutputStream. flop)]))))

0 comments on commit 36c6b41

Please sign in to comment.