Permalink
Browse files

Merge remote branch 'Licenser/master'

Conflicts:
	project.clj
	src/lein_search/core.clj
	src/leiningen/search.clj
	src/leiningen/update_repo.clj
  • Loading branch information...
purcell committed Sep 2, 2010
2 parents b8469e3 + 4ec0949 commit 62cac9b92f18727a6522e4f436c20f6647f49064
Showing with 37 additions and 18 deletions.
  1. +4 −0 README
  2. +4 −1 project.clj
  3. +2 −2 src/lein_search/core.clj
  4. +26 −13 src/leiningen/search.clj
  5. +1 −2 src/leiningen/update_repo.clj
View
4 README
@@ -21,3 +21,7 @@ org.clojars.wuschel/lein-search "42.2.3" - a non official release, and it's lat
Copyright © 2009 Heinz N. Gies.
This code is published under the EPL, have fun! See LICENSE.html for the booring stuff.
+
+## Thanks
+
+Big thanks to purcell@github for a bunch of improvements and cleanup in the code.
View
@@ -1 +1,4 @@
-(defproject lein-search "0.3.0-SNAPSHOT" :description "Leiningen plugin to search and add dependencies from clojars" :dependencies [[org.clojure/clojure "[1.1,1.2]"] [org.clojure/clojure-contrib "[1.1,1.2]"]] :dev-dependencies [[lein-clojars "0.5.0"] [swank-clojure/swank-clojure "1.1.0"]])
+(defproject lein-search "0.3.3"
+ :description "Leiningen plugin to search and add dependencies from clojars"
+ :dependencies [[org.clojure/clojure "1.1.0"] [org.clojure/clojure-contrib "1.1.0"]]
+ :dev-dependencies [[lein-clojars "0.5.0"] [swank-clojure/swank-clojure "1.1.0"]])
View
@@ -4,7 +4,7 @@
(:require [clojure.zip :as zip])
(:import (java.io File PushbackReader) java.util.zip.GZIPInputStream java.net.URL))
-
+;; TODO: check to see if leiningen.core/home-dir is defined; use it if so.
(def *lein-dir* (str (System/getProperty "user.home") "/.lein"))
;;; User input functions
@@ -188,4 +188,4 @@ the supplied zip move function each time"
article-id
(str group-id "/" article-id)))
([{artifact-id :artifact-id group-id :group-id}]
- (clojars-artifact-name group-id artifact-id)))
+ (clojars-artifact-name group-id artifact-id)))
View
@@ -1,17 +1,30 @@
(ns leiningen.search
- "Searches the indexed clojars.org repository. Giving -v as first argument prints the versions instead of the description."
+ "Searches the indexed clojars.org repository. Giving -v as first argument
+prints the versions instead of the description."
(:use [clojure.contrib.str-utils :only (str-join re-sub)]
- lein-search.core)
+ lein-search.core
+ leiningen.update-repo)
(:import java.io.File))
-
-(defn search [project what & args]
- (let [show-versions (= "-v" what)
- what (if show-versions (first args) what)]
- (if (.exists (File. (str *lein-dir* "/clojars")))
- (let [m (search-clojar what)]
- (println "Results for " what ":")
- (if show-versions
- (println (str-join "\n" (map (fn [{versions :versions artifact-id :artifact-id group-id :group-id}] (str (clojars-artifact-name group-id artifact-id) ": " (str-join ", " versions))) m)))
- (println (str-join "\n" (map (fn [{description :description artifact-id :artifact-id group-id :group-id}] (format "%-40s - %s" (clojars-artifact-name group-id artifact-id) (re-sub #"\n\s*" " " (or description "No description given")))) m)))))
- (println "No repo index found, please run lein update first."))))
+(defn search [what & args]
+ (if (map? what)
+ ;; To be backwards-compatible with Leiningen 1.2 and prior, we
+ ;; must accept and discard a project argument. Current Leiningen (1.3+)
+ ;; inspects the arg list and only passes in the project if needed.
+ (apply search args)
+ (let [show-versions (= "-v" what)
+ what (if show-versions (first args) what)]
+ (if (.exists (File. (str *lein-dir* "/clojars")))
+ (let [results (search-clojar what)]
+ (println (format "Results for %s:" what))
+ (doseq [{:keys [description versions artifact-id group-id]} results
+ :let [name (clojars-artifact-name group-id artifact-id)
+ versions-string (str-join ", " versions)
+ description (or description "No description given")
+ desc (re-sub #"\n\s*" " " description)]]
+ (println (if show-versions
+ (format "%s: %s" name versions-string)
+ (format "%-40s - %s" name desc)))))
+ ;; If there's no index found, fetch it and try again.
+ (do (update-repo)
+ (apply search what args))))))
@@ -2,7 +2,6 @@
"Updates the clojars.org repositories index."
(:use lein-search.core))
-
-(defn update-repo [project & args]
+(defn update-repo [& _]
(println "Getting the list of packages on clojars.org ...")
(write-clojars-cache))

0 comments on commit 62cac9b

Please sign in to comment.