Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

first import

  • Loading branch information...
commit f4dc5af737836d73b3a6327acc100636bdb72c3c 0 parents
@videlalvaro authored
10 .gitignore
@@ -0,0 +1,10 @@
+/target
+/lib
+/classes
+/checkouts
+pom.xml
+*.jar
+*.class
+.lein-deps-sum
+.lein-failures
+.lein-plugins
21 LICENSE
@@ -0,0 +1,21 @@
+The MIT License
+
+Copyright (c) 2012 Alvaro Videla
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
53 README.md
@@ -0,0 +1,53 @@
+# claude
+
+A Clojure library designed to ease integration with Cloud Foundry
+
+NOTE: Work In Progress
+
+## Usage
+
+With leiningen add it to your project dependencies like this:
+
+ [claude "0.1.0-SNAPSHOT"]
+
+And with Maven you can do:
+
+ <dependency>
+ <groupId>claude</groupId>
+ <artifactId>claude</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ </dependency>
+
+Then on your code you can use it this way:
+
+ (ns my.namespace
+ (use: [claude.core :as cf]
+ [langohr.core :as lhc]
+ [monger.core :as mg]))
+
+ (defonce default-url "mongodb://127.0.0.1/cloudstagram")
+
+ (defn mongo-connect []
+ (if (cf/cloudfoundry?)
+ (mg/connect-via-uri! (cf/mongo-url))
+ (mg/connect-via-uri! default-url)))
+
+ (defn rabbitmq-connect []
+ (if (cf/cloudfoundry?)
+ (lhc/connect (lhc/settings-from (cf/rabbit-url)))
+ (lhc/connect)))
+
+ (defonce ^Connection conn (rabbitmq-connect))
+
+## TODO
+
+- Add a proper `groupId` for the Maven repositories
+- Improve Integration with Cloud Foundry services
+- Improve API for obatining services credentials/info
+
+
+## License
+
+Copyright © 2012 FIXME
+
+Distributed under the Eclipse Public License, the same as Clojure.
3  doc/intro.md
@@ -0,0 +1,3 @@
+# Introduction to claude
+
+TODO: write [great documentation](http://jacobian.org/writing/great-documentation/what-to-write/)
8 project.clj
@@ -0,0 +1,8 @@
+(defproject claude "0.1.0-SNAPSHOT"
+ :description "Utilities to connect Clojure apps to Cloud Foundry"
+ :url "http://example.com/FIXME"
+ :license {:name "The MIT License"
+ :url "http://opensource.org/licenses/mit-license.php"}
+ :dependencies [[org.clojure/clojure "1.4.0"]
+ [org.clojure/data.json "0.1.3"]]
+ :plugins [[lein-swank "1.4.4"]])
29 src/claude/core.clj
@@ -0,0 +1,29 @@
+(ns claude.core
+ (:use [clojure.data.json :only [read-json]]))
+
+(defn cloudfoundry? []
+ (not (nil? (System/getenv "VCAP_SERVICES"))))
+
+(defn service-config [label key]
+ (if-let [services (System/getenv "VCAP_SERVICES")]
+ (let [services-dict (read-json services false)]
+ (-> services-dict
+ (get label)
+ first ;; maybe in the future allow to use multiple services
+ (get "credentials")
+ (get key)))))
+
+(defn mongo-config [key]
+ (service-config "mongodb-2.0" key))
+
+(defn rabbit-config [key]
+ (service-config "rabbitmq-2.4" key))
+
+(defn redis-config [key]
+ (service-config "redis-2.2" key))
+
+(defn mongo-url []
+ (mongo-config "url"))
+
+(defn rabbit-url []
+ (rabbit-config "url"))
7 test/claude/core_test.clj
@@ -0,0 +1,7 @@
+(ns claude.core-test
+ (:use clojure.test
+ claude.core))
+
+(deftest a-test
+ (testing "FIXME, I fail."
+ (is (= 0 1))))
Please sign in to comment.
Something went wrong with that request. Please try again.