Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Initial commit

  • Loading branch information...
commit e4f97e08c1a69627c2f921d24ee0f2fb67cadd35 1 parent 4800c48
Lee Hinman authored
4 .gitignore
... ... @@ -0,0 +1,4 @@
  1 +pom.xml
  2 +*jar
  3 +lib
  4 +classes
21 README.markdown
Source Rendered
... ... @@ -0,0 +1,21 @@
  1 +# cd-client
  2 +
  3 +A tiny client for the http://clojuredocs.org API
  4 +
  5 +## Usage
  6 +
  7 + (examples "clojure.core" "map")
  8 + (search "pmap")
  9 + (search "clojure.core" "map")
  10 + (comments "clojure.contrib.json" "read-json")
  11 + (see-also "clojure.test" "are")
  12 +
  13 +## Installation
  14 +
  15 + lein jar
  16 +
  17 +## License
  18 +
  19 +Copyright (C) 2010 Lee Hinman
  20 +
  21 +Distributed under the Eclipse Public License, the same as Clojure.
6 project.clj
... ... @@ -0,0 +1,6 @@
  1 +(defproject cd-client "0.1.0-SNAPSHOT"
  2 + :description "A client for the clojuredocs API"
  3 + :dependencies [[org.clojure/clojure "1.2.0"]
  4 + [org.clojure/clojure-contrib "1.2.0"]
  5 + [clj-http "0.1.1"]
  6 + [org.danlarkin/clojure-json "1.1"]])
41 src/cd_client/core.clj
... ... @@ -0,0 +1,41 @@
  1 +(ns cd-client.core
  2 + (:require [org.danlarkin.json :as json])
  3 + (:require [clj-http.client :as http]))
  4 +
  5 +
  6 +; For testing purposes use localhost:8080
  7 +(def *clojuredocs-root* "http://clojuredocs.org")
  8 +;(def *clojuredocs-root* "http://localhost:8080")
  9 +
  10 +(def *examples-api* (str *clojuredocs-root* "/examples/"))
  11 +(def *search-api* (str *clojuredocs-root* "/search/"))
  12 +(def *comments-api* (str *clojuredocs-root* "/comments/"))
  13 +(def *seealso-api* (str *clojuredocs-root* "/see-also/"))
  14 +
  15 +
  16 +(defn examples
  17 + "Return examples for a given namespace and method name."
  18 + [ns name]
  19 + (json/decode-from-str (:body (http/get (str *examples-api* ns "/" name)))))
  20 +
  21 +
  22 +(defn search
  23 + "Search for a method name within an (optional) namespace"
  24 + ([name]
  25 + (json/decode-from-str (:body (http/get (str *search-api* name)))))
  26 + ([ns name]
  27 + (json/decode-from-str (:body (http/get (str *search-api* ns "/" name))))))
  28 +
  29 +
  30 +(defn comments
  31 + "Return comments for a given namespace and method name."
  32 + [ns name]
  33 + (json/decode-from-str (:body (http/get (str *comments-api* ns "/" name)))))
  34 +
  35 +
  36 +(defn see-also
  37 + "Return methods to 'see also' for a given namespace and method name."
  38 + [ns name]
  39 + (json/decode-from-str (:body (http/get (str *seealso-api* ns "/" name)))))
  40 +
  41 +
6 test/cd_client/test/core.clj
... ... @@ -0,0 +1,6 @@
  1 +(ns cd-client.test.core
  2 + (:use [cd-client.core] :reload)
  3 + (:use [clojure.test]))
  4 +
  5 +(deftest replace-me ;; FIXME: write
  6 + (is false "No tests have been written."))

0 comments on commit e4f97e0

Please sign in to comment.
Something went wrong with that request. Please try again.