Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit e4f97e08c1a69627c2f921d24ee0f2fb67cadd35 1 parent 4800c48
@dakrone authored
View
4 .gitignore
@@ -0,0 +1,4 @@
+pom.xml
+*jar
+lib
+classes
View
21 README.markdown
@@ -0,0 +1,21 @@
+# cd-client
+
+A tiny client for the http://clojuredocs.org API
+
+## Usage
+
+ (examples "clojure.core" "map")
+ (search "pmap")
+ (search "clojure.core" "map")
+ (comments "clojure.contrib.json" "read-json")
+ (see-also "clojure.test" "are")
+
+## Installation
+
+ lein jar
+
+## License
+
+Copyright (C) 2010 Lee Hinman
+
+Distributed under the Eclipse Public License, the same as Clojure.
View
6 project.clj
@@ -0,0 +1,6 @@
+(defproject cd-client "0.1.0-SNAPSHOT"
+ :description "A client for the clojuredocs API"
+ :dependencies [[org.clojure/clojure "1.2.0"]
+ [org.clojure/clojure-contrib "1.2.0"]
+ [clj-http "0.1.1"]
+ [org.danlarkin/clojure-json "1.1"]])
View
41 src/cd_client/core.clj
@@ -0,0 +1,41 @@
+(ns cd-client.core
+ (:require [org.danlarkin.json :as json])
+ (:require [clj-http.client :as http]))
+
+
+; For testing purposes use localhost:8080
+(def *clojuredocs-root* "http://clojuredocs.org")
+;(def *clojuredocs-root* "http://localhost:8080")
+
+(def *examples-api* (str *clojuredocs-root* "/examples/"))
+(def *search-api* (str *clojuredocs-root* "/search/"))
+(def *comments-api* (str *clojuredocs-root* "/comments/"))
+(def *seealso-api* (str *clojuredocs-root* "/see-also/"))
+
+
+(defn examples
+ "Return examples for a given namespace and method name."
+ [ns name]
+ (json/decode-from-str (:body (http/get (str *examples-api* ns "/" name)))))
+
+
+(defn search
+ "Search for a method name within an (optional) namespace"
+ ([name]
+ (json/decode-from-str (:body (http/get (str *search-api* name)))))
+ ([ns name]
+ (json/decode-from-str (:body (http/get (str *search-api* ns "/" name))))))
+
+
+(defn comments
+ "Return comments for a given namespace and method name."
+ [ns name]
+ (json/decode-from-str (:body (http/get (str *comments-api* ns "/" name)))))
+
+
+(defn see-also
+ "Return methods to 'see also' for a given namespace and method name."
+ [ns name]
+ (json/decode-from-str (:body (http/get (str *seealso-api* ns "/" name)))))
+
+
View
6 test/cd_client/test/core.clj
@@ -0,0 +1,6 @@
+(ns cd-client.test.core
+ (:use [cd-client.core] :reload)
+ (:use [clojure.test]))
+
+(deftest replace-me ;; FIXME: write
+ (is false "No tests have been written."))
Please sign in to comment.
Something went wrong with that request. Please try again.