Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial commit

  • Loading branch information...
commit 67590fb24a1be2ba296039c4bca2f95238cda363 0 parents
@klauern authored
8 .classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="clojure.jar" sourcepath="clojure-src.jar"/>
+ <classpathentry kind="lib" path="classes"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
8 .gitignore
@@ -0,0 +1,8 @@
+/pom.xml
+*jar
+/lib
+/classes
+/native
+/.lein-failures
+/checkouts
+/.lein-deps-sum
23 .project
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>stacktraces</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>ccw.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>ccw.nature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
27 README
@@ -0,0 +1,27 @@
+# stacktraces
+
+A hack to create an API for [StackExchange][stx]'s RESTful API in Clojure.
+
+## Usage
+
+I don't have any usage right now. It's still a bunch of hackish scripts
+largely modeled after [Rayne](https://github.com/Raynes/)'s [tentacles](https://github.com/Raynes/tentacles) API,
+and doesn't deviate largely from the structure of that API.
+
+# Note
+
+I'm using this as an experiment to understand Clojure a bit more and try to make
+something useful out of it along the way. If there are things I'm obviously
+doing wrong, I would _love_ to hear about it. Please contact me:
+
+klauer@gmail.com
+
+Twitter: @klauern
+
+## License
+
+Copyright (C) 2012 Nick Klauer (klauer@gmail.com) Twitter: @klauern
+
+Distributed under the Eclipse Public License, the same as Clojure.
+
+[stx]: http://api.stackoverflow.com.com/
11 bin/stacktraces/core.clj
@@ -0,0 +1,11 @@
+(ns stacktraces.core
+ (:require [clj-http.client :as http]
+ [cheshire.core :as json]))
+
+(def default-http-parms {:throw-exceptions false :ignore-unknown-host? true :as :json})
+
+(def url "http://api.stackexchange.com/2.0")
+
+(defn get-errors
+ ([] (http/get (str url "/errors")))
+ ([err-code] (http/get (str url "/errors/" err-code) default-http-parms)))
5 bin/stacktraces/wrapper.clj
@@ -0,0 +1,5 @@
+(ns stacktraces.wrapper)
+
+(defrecord ResponseWrapper [backoff error_id error_message error_name
+ has_more items page page_size quota_max
+ quota_remaining total type])
7 project.clj
@@ -0,0 +1,7 @@
+(defproject stacktraces "1.0.0-SNAPSHOT"
+ :description "http REST client for the v2.0 StackExchange API (http://api.stackoverflow.com)"
+ :dependencies [[org.clojure/clojure "1.3.0"]
+ [clj-http "0.3.2"]
+ [cheshire "2.2.0"]]
+ :dev-dependencies [[marginalia "0.7.0-SNAPSHOT"]
+ [midje "1.3.2-SNAPSHOT"]])
11 src/stacktraces/core.clj
@@ -0,0 +1,11 @@
+(ns stacktraces.core
+ (:require [clj-http.client :as http]
+ [cheshire.core :as json]))
+
+(def default-http-parms {:throw-exceptions false :ignore-unknown-host? true :as :json})
+
+(def url "http://api.stackexchange.com/2.0")
+
+(defn get-errors
+ ([] (http/get (str url "/errors")))
+ ([err-code] (http/get (str url "/errors/" err-code) default-http-parms)))
5 src/stacktraces/wrapper.clj
@@ -0,0 +1,5 @@
+(ns stacktraces.wrapper)
+
+(defrecord ResponseWrapper [backoff error_id error_message error_name
+ has_more items page page_size quota_max
+ quota_remaining total type])
6 test/stacktraces/test/core.clj
@@ -0,0 +1,6 @@
+(ns stacktraces.test.core
+ (:use [stacktraces.core])
+ (: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.