From cbd9e6b1cbe66c4fe6303d9a0bffa5cd0a96c75d Mon Sep 17 00:00:00 2001 From: Jean Niklas L'orange Date: Sat, 24 Aug 2013 16:56:29 +0200 Subject: [PATCH] Clean up helper docstrings. --- test/leiningen/test/helper.clj | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/test/leiningen/test/helper.clj b/test/leiningen/test/helper.clj index 47b5fd90f..5bc567557 100644 --- a/test/leiningen/test/helper.clj +++ b/test/leiningen/test/helper.clj @@ -42,14 +42,14 @@ (defn abort-msg "Catches main/abort thrown by calling f on its args and returns its error - message." + message." [f & args] (apply helper/abort-msg f args)) ;; grumble, grumble; why didn't this make it into clojure.java.io? (defn delete-file-recursively "Delete file f. If it's a directory, recursively delete all its contents. -Raise an exception if any deletion fails unless silently is true." + Raise an exception if any deletion fails unless silently is true." [f & [silently]] (System/gc) ; This sometimes helps release files for deletion on windows. (let [f (io/file f)] @@ -62,13 +62,12 @@ Raise an exception if any deletion fails unless silently is true." (defn fix-path-delimiters [input-str] (clojure.string/replace input-str "/" java.io.File/separator)) -;so paths would work under windows too which adds a drive letter and changes the path separator +;; So paths would work under Windows too, which adds a drive letter and changes +;; the path separator. (defn pathify - " -pass only absolute paths, will throw if not -because if not absolute then .getAbsolutePath will resolve them relative to current directory - " - [in-str-or-file] + "Converts paths to absolute paths. Will throw if not, because if the path is + not absolute, then .getAbsolutePath will resolve them relative to current + directory." [in-str-or-file] (cond (or (nil? in-str-or-file) (not (or @@ -76,13 +75,18 @@ because if not absolute then .getAbsolutePath will resolve them relative to curr (and (>= (.length in-str-or-file) 3) (= ":\\" (.substring in-str-or-file 1 3)))))) - (throw (new RuntimeException (str "bad usage, passed: `" in-str-or-file "`"))) + (throw (RuntimeException. (str "Bad usage, passed: `" in-str-or-file "`."))) :else (.getAbsolutePath (io/as-file in-str-or-file)))) -(defn entries [zipfile] +(defn entries + "Returns a lazy seq of all the entries in a zipfile." + [zipfile] (enumeration-seq (.entries zipfile))) -(defn walkzip [fileName f] - (with-open [z (java.util.zip.ZipFile. fileName)] +(defn walkzip + "Applies f to all ZipEntries in the ZipFile filename and returns the result as + a vector." + [filename f] + (with-open [z (java.util.zip.ZipFile. filename)] (reduce #(conj %1 (f %2)) [] (entries z))))