Skip to content

Commit

Permalink
Clean up helper docstrings.
Browse files Browse the repository at this point in the history
  • Loading branch information
hypirion committed Aug 24, 2013
1 parent 762544a commit cbd9e6b
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions test/leiningen/test/helper.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -62,27 +62,31 @@ 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
(.startsWith in-str-or-file "/")
(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))))

0 comments on commit cbd9e6b

Please sign in to comment.