Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 3 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
Showing with 53 additions and 38 deletions.
  1. +3 −1 .gitignore
  2. +0 −20 README
  3. +24 −0 README.md
  4. +5 −2 project.clj
  5. +19 −14 src/leiningen/hooks/play.clj
  6. +2 −1 test/leiningen/test_play_hook.clj
View
4 .gitignore
@@ -1,4 +1,6 @@
pom.xml
*jar
lib
-classes
+classes
+/.lein-failures
+/target/stale/dependencies
View
20 README
@@ -1,20 +0,0 @@
-# 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.
View
24 README.md
@@ -0,0 +1,24 @@
+# lein-play
+
+Play sounds when your tests pass or fail.
+
+## Installation
+
+Add this to `:plugins` in your `:user` profile in `~/.lein/profiles.clj`:
+
+ [lein-play "2.0.0"]
+
+And this to the `:hooks` entry:
+
+ `leiningen.hooks.play`
+
+Place a pass.mp3 or fail.mp3 in `~/.lein` to override the built-in sounds.
+
+## License
+
+Code Copyright © 2010, 2012 Phil Hagelberg
+
+The code is licensed under the Eclipse Public License.
+
+The sound effects are licensed under Creative Commons Attribution
+Sharealike license.
View
7 project.clj
@@ -1,4 +1,7 @@
-(defproject lein-play "1.0.0-SNAPSHOT"
+(defproject lein-play "2.0.0"
:description "Play a sound when your tests pass or fail."
+ :url "https://github.com/technomancy/lein-play"
+ :license {:name "Eclipse Public License"
+ :url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojars.technomancy/jlayer "1.0"]]
- :eval-in-leinigen test)
+ :eval-in-leiningen true)
View
33 src/leiningen/hooks/play.clj
@@ -1,20 +1,25 @@
(ns leiningen.hooks.play
- (:use [robert.hooke :only [add-hook]])
- (:require [leiningen.test])
- (:import [java.io FileInputStream BufferedInputStream]
- [javazoom.jl.player Player]))
+ (:require [leiningen.test]
+ [leiningen.core.user :as user]
+ [robert.hooke :as hooke]
+ [clojure.java.io :as io])
+ (: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)
+ (let [user-file (io/file (user/leiningen-home) (str name ".mp3"))
+ is (io/input-stream (if (.exists user-file)
+ user-file
+ (io/resource (format "leiningen/%s.mp3" name))))]
+ (-> (BufferedInputStream. is)
(Player.)
(.play))))
-(add-hook #'leiningen.test/test
- (fn play-hook [f & args]
- (let [code (apply f args)]
- (play (if (zero? code)
- "pass" "fail"))
- code)))
+(defn activate []
+ (hooke/add-hook #'leiningen.test/test
+ (fn play-hook [f & args]
+ (try (apply f args)
+ (play "pass")
+ (catch Exception e
+ (play "fail")
+ (throw e))))))
View
3 test/leiningen/test_play_hook.clj
@@ -1,5 +1,6 @@
(ns leiningen.test-play-hook
- (:use [clojure.test]))
+ (:use [clojure.test]
+ [leiningen.hooks.play]))
(deftest flip-flop
(let [flop (java.io.File. "/tmp/test-lein-play")]

No commit comments for this range

Something went wrong with that request. Please try again.