Browse files

Simplify some IO code using c.c.duck-streams

  • Loading branch information...
1 parent 34b9c7e commit 01cd7af90d0eb932d86ea6540828c92ef3486064 @purcell purcell committed with Licenser Aug 8, 2010
Showing with 6 additions and 6 deletions.
  1. +6 −6 src/leiningen/update_repo.clj
View
12 src/leiningen/update_repo.clj
@@ -1,7 +1,7 @@
(ns leiningen.update-repo
"Updates the clojars.org repositories index."
- (:use clojure.contrib.duck-streams)
- (:import (java.io File InputStreamReader PushbackReader) java.util.zip.GZIPInputStream java.net.URL))
+ (:use [clojure.contrib.duck-streams :only (reader writer with-out-writer)])
+ (:import (java.io File) java.util.zip.GZIPInputStream java.net.URL))
(def *lein-dir* (str (System/getProperty "user.home") "/.lein"))
@@ -27,14 +27,14 @@
version-comparison)))
(defn read-index [url]
- (with-open [r (PushbackReader. (InputStreamReader. (GZIPInputStream. (.openStream (URL. url)))))]
+ (with-open [r (reader (GZIPInputStream. (.openStream (URL. url))))]
(loop [result [] code (read r false false)]
(if code
(recur (conj result code) (read r false false))
result))))
(defn update-repo [project & args]
(if (not (.exists (File. *lein-dir*))) (.mkdirs (File. *lein-dir*)))
- (with-open [w (writer (str *lein-dir* "/clojars"))]
- (println "Getting the list of packages on clojars.org ...")
- (binding [*out* w] (pr (read-index "http://clojars.org/repo/feed.clj.gz")))))
+ (println "Getting the list of packages on clojars.org ...")
+ (with-out-writer (writer (str *lein-dir* "/clojars"))
+ (pr (read-index "http://clojars.org/repo/feed.clj.gz"))))

0 comments on commit 01cd7af

Please sign in to comment.