forked from videlalvaro/claude
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f4dc5af
Showing
7 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/target | ||
/lib | ||
/classes | ||
/checkouts | ||
pom.xml | ||
*.jar | ||
*.class | ||
.lein-deps-sum | ||
.lein-failures | ||
.lein-plugins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Introduction to claude | ||
|
||
TODO: write [great documentation](http://jacobian.org/writing/great-documentation/what-to-write/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(ns claude.core-test | ||
(:use clojure.test | ||
claude.core)) | ||
|
||
(deftest a-test | ||
(testing "FIXME, I fail." | ||
(is (= 0 1)))) |