(defproject jungerer "0.1.2"
  :description "Clojure network/graph library wrapping JUNG"
  :url "https://github.com/totakke/jungerer"
  :license {:name "The BSD 3-Clause License"
            :url "https://opensource.org/licenses/BSD-3-Clause"}
  :dependencies [[org.clojure/clojure "1.8.0"]
                 [net.sf.jung/jung-algorithms "2.1"]
                 [net.sf.jung/jung-api "2.1"]
                 [net.sf.jung/jung-graph-impl "2.1"]
                 [net.sf.jung/jung-io "2.1"]
                 [net.sf.jung/jung-visualization "2.1"]]
  :profiles {:dev {:global-vars {*warn-on-reflection* true}
                   :resource-paths ["dev-resources"]}
             :1.7 {:dependencies [[org.clojure/clojure "1.7.0"]]
                   :resource-paths ["dev-resources"]}}
  :codox {:source-uri "https://github.com/totakke/jungerer/blob/{version}/{filepath}#L{line}"})

(defproject jungerer "0.1.3-SNAPSHOT"
  :description "Clojure network/graph library wrapping JUNG"
  :url "https://github.com/totakke/jungerer"
  :license {:name "The BSD 3-Clause License"
            :url "https://opensource.org/licenses/BSD-3-Clause"}
  :dependencies [[org.clojure/clojure "1.8.0"]
                 [net.sf.jung/jung-algorithms "2.1"]
                 [net.sf.jung/jung-api "2.1"]
                 [net.sf.jung/jung-graph-impl "2.1"]
                 [net.sf.jung/jung-io "2.1"]
                 [net.sf.jung/jung-visualization "2.1"]]
  :profiles {:dev {:global-vars {*warn-on-reflection* true}
                   :resource-paths ["dev-resources"]}
             :1.7 {:dependencies [[org.clojure/clojure "1.7.0"]]
                   :resource-paths ["dev-resources"]}}
  :codox {:source-uri "https://github.com/totakke/jungerer/blob/{version}/{filepath}#L{line}"})

Prepare for next development iteration (0.1.3-SNAPSHOT)


(defproject onyx-app/lein-template "0.10.0.0-rc3"
  :description "Onyx Leiningen application template"
  :url "https://github.com/onyx-platform/onyx-template"
  :license {:name "MIT License"
            :url "http://choosealicense.com/licenses/mit/#"}
  :repositories {"snapshots" {:url "https://clojars.org/repo"
                              :username :env
                              :password :env
                              :sign-releases false}
                 "releases" {:url "https://clojars.org/repo"
                             :username :env
                             :password :env
                             :sign-releases false}}
  :plugins [[lein-set-version "0.4.1"]]
  :profiles {:dev {:plugins [[lein-set-version "0.4.1"]
                             [lein-update-dependency "0.1.2"]
                             [lein-pprint "1.1.1"]]}}
  :eval-in-leiningen true)

(defproject onyx-app/lein-template "0.10.0.0-SNAPSHOT"
  :description "Onyx Leiningen application template"
  :url "https://github.com/onyx-platform/onyx-template"
  :license {:name "MIT License"
            :url "http://choosealicense.com/licenses/mit/#"}
  :repositories {"snapshots" {:url "https://clojars.org/repo"
                              :username :env
                              :password :env
                              :sign-releases false}
                 "releases" {:url "https://clojars.org/repo"
                             :username :env
                             :password :env
                             :sign-releases false}}
  :plugins [[lein-set-version "0.4.1"]]
  :profiles {:dev {:plugins [[lein-set-version "0.4.1"]
                             [lein-update-dependency "0.1.2"]
                             [lein-pprint "1.1.1"]]}}
  :eval-in-leiningen true)

Prepare for next release cycle.

Prepare for next release cycle.


(ns infinispan.test
  (:gen-class)
  (:import (org.infinispan.client.hotrod RemoteCacheManager
                                         RemoteCache)
           (org.infinispan.client.hotrod.configuration ConfigurationBuilder)
           (org.infinispan.client.hotrod.impl ConfigurationProperties)))

(defn -main
  "Creates simple HR client, puts key/value into remote server and reads it back"
  [& args]
  (def conf (ConfigurationBuilder.))
  (.port (.host (.addServer conf) "127.0.0.1") ConfigurationProperties/DEFAULT_HOTROD_PORT)
  (def cm (RemoteCacheManager. (.build conf)))
  (def cache (.getCache cm))
  (println "Sending key -> value")
  (.put cache "key" "value")
  (def value (.get cache "key"))
  (println "Got key -> " value)
  (.stop cm))

(ns infinispan.test
  (:gen-class)
  (:import (org.infinispan.client.hotrod RemoteCacheManager
                                         RemoteCache)
           (org.infinispan.client.hotrod.configuration ConfigurationBuilder)
           (org.infinispan.client.hotrod.impl ConfigurationProperties)))

(defn -main
  "Creates simple HR client, puts key/value into remote server and reads it back"
  [& args]
  (def conf (ConfigurationBuilder.))
  ;;(.port (.host (.addServer conf) "127.0.0.1") ConfigurationProperties/DEFAULT_HOTROD_PORT)
  (-> (.addServer conf) (.host "127.0.0.1") (.port ConfigurationProperties/DEFAULT_HOTROD_PORT))
  (def cm (RemoteCacheManager. (.build conf)))
  (def cache (.getCache cm))
  (println "Sending key -> value")
  (.put cache "key" "value")
  (def value (.get cache "key"))
  (println "Got key -> " value)
  (.stop cm))

Use more readable conf in Cloure clinet

Use more readable conf in Cloure clinet


(ns blaagh.db.core
    (:require [clojure.java.jdbc :as sql])
    (:require [yesql.core :refer [defqueries]]))

(def db-spec {
    :classname "org.sqlite.JDBC"
    :subprotocol "sqlite"
    :subname "resources/db/blaagh.sqlite3"}) ;; creates DB if not already present

(defqueries "blaagh/db/queries.sql"
   {:connection db-spec})

(defn get-all-names []
    (let [results (get-names)]
        (cond
            (empty? results) {:status 404}
            :else results)))

(defn create-tables []
    (try
        (sql/db-do-commands db-spec
            "CREATE TABLE foo (name text); "
            "CREATE TABLE bar (name text); "
            "CREATE TABLE baz (name text); ")
        (catch Exception e
            (println e))))

(defn populate-tables []
    (try
        (sql/db-do-commands db-spec
            "INSERT INTO foo (name) VALUES
                ('Rick'),
                ('Carol'),
                ('Daryl'),
                ('Michonne'),
                ('Glenn'),
                ('Maggie'),
                ('Carl'),
                ('Sasha'),
                ('Abraham'),
                ('Morgan');")
        (catch Exception e
            (println e))))

(ns blaagh.db.core
    (:require [clojure.java.jdbc :as sql])
    (:require [yesql.core :refer [defqueries]]))

(def db-spec {
    :classname "org.sqlite.JDBC"
    :subprotocol "sqlite"
    :subname "resources/db/blaagh.sqlite3"}) ;; creates DB if not already present

(defqueries "blaagh/db/queries.sql"
   {:connection db-spec})

(defn get-all-names []
    (try
        (let [results (get-names)]
            (cond
                (empty? results) {:status 404}
                :else results))
    (catch Exception e
        (println e))))

(defn create-tables []
    (try
        (sql/db-do-commands db-spec
            "CREATE TABLE foo (name text); "
            "CREATE TABLE bar (name text); "
            "CREATE TABLE baz (name text); ")
        (catch Exception e
            (println e))))

(defn populate-tables []
    (try
        (sql/db-do-commands db-spec
            "INSERT INTO foo (name) VALUES
                ('Rick'),
                ('Carol'),
                ('Daryl'),
                ('Michonne'),
                ('Glenn'),
                ('Maggie'),
                ('Carl'),
                ('Sasha'),
                ('Abraham'),
                ('Morgan');")
        (catch Exception e
            (println e))))

Add a try/catch block to get-all-names

Add a try/catch block to get-all-names


(defproject org.onyxplatform/onyx-bookkeeper "0.8.1.0-alpha6"
  :description "Onyx plugin for BookKeeper"
  :url "https://github.com/onyx-platform/onyx-bookkeeper"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :repositories {"snapshots" {:url "https://clojars.org/repo"
                              :username :env
                              :password :env
                              :sign-releases false}
                 "releases" {:url "https://clojars.org/repo"
                             :username :env
                             :password :env
                             :sign-releases false}}
  :dependencies [[org.clojure/clojure "1.7.0"]
                 ^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}}
                 [org.onyxplatform/onyx "0.8.1-alpha6"]]
  :profiles {:dev {:plugins [[lein-set-version "0.4.1"]
                             [lein-update-dependency "0.1.2"]
                             [lein-pprint "1.1.1"]]}
             :circle-ci {:jvm-opts ["-Xmx4g"]}})

(defproject org.onyxplatform/onyx-bookkeeper "0.8.1.0-SNAPSHOT"
  :description "Onyx plugin for BookKeeper"
  :url "https://github.com/onyx-platform/onyx-bookkeeper"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :repositories {"snapshots" {:url "https://clojars.org/repo"
                              :username :env
                              :password :env
                              :sign-releases false}
                 "releases" {:url "https://clojars.org/repo"
                             :username :env
                             :password :env
                             :sign-releases false}}
  :dependencies [[org.clojure/clojure "1.7.0"]
                 ^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}}
                 [org.onyxplatform/onyx "0.8.1-alpha6"]]
  :profiles {:dev {:plugins [[lein-set-version "0.4.1"]
                             [lein-update-dependency "0.1.2"]
                             [lein-pprint "1.1.1"]]}
             :circle-ci {:jvm-opts ["-Xmx4g"]}})

Prepare for next release cycle.

Prepare for next release cycle.


(defproject net.uncontended/beehive "0.2.0"
  :description "Beehive is a Clojure facade for the Precipice library."
  :url "https://github.com/tbrooks8/Beehive"
  :license {:name "Apache License, Version 2.0"
            :url "http://www.apache.org/licenses/LICENSE-2.0"}
  :profiles {:dev {:dependencies [[org.clojure/core.async "0.1.346.0-17112a-alpha"]
                                  [clj-http "1.0.1"]
                                  [criterium "0.4.3"]]}}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [net.uncontended/Precipice "0.1.0"]])

(defproject net.uncontended/beehive "0.2.0"
  :description "Beehive is a Clojure facade for the Precipice library."
  :url "https://github.com/tbrooks8/Beehive"
  :license {:name "Apache License, Version 2.0"
            :url "http://www.apache.org/licenses/LICENSE-2.0"}
  :signing {:gpg-key "tim@uncontended.net"}
  :profiles {:dev {:dependencies [[org.clojure/core.async "0.1.346.0-17112a-alpha"]
                                  [clj-http "1.0.1"]
                                  [criterium "0.4.3"]]}}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [net.uncontended/Precipice "0.1.0"]])

Add which signing to use

Add which signing to use


(ns leiningen.core
  (:require [leiningen deps test compile]
            [clojure.contrib.with-ns])
  (:gen-class))

(def project nil)

(defmacro defproject [project-name & args]
  ;; This is necessary since we must allow defproject to be eval'd in
  ;; any namespace due to load-file; we can't just create a var with
  ;; def or we would not have access to it once load-file returned.
  `(do (alter-var-root #'project
                       (fn [_#] (assoc (apply hash-map (quote ~args))
                                  :name ~(name project-name)
                                  :root ~(.getParent (java.io.File. *file*)))))
       (def ~project-name project)))

(defn read-project
  ([file] (load-file file)
     project)
  ([] (read-project "project.clj")))

(defn -main [command & args]
  (let [action (ns-resolve (symbol (str "leiningen." command))
                           (symbol command))]
    ;; TODO: ensure tasks run only once
    (apply action (read-project) args)
    ;; In case tests or some other task started any:
    (shutdown-agents)))

(ns leiningen.core
  (:use [clojure.contrib.with-ns])
  (:gen-class))

(def project nil)

(defmacro defproject [project-name & args]
  ;; This is necessary since we must allow defproject to be eval'd in
  ;; any namespace due to load-file; we can't just create a var with
  ;; def or we would not have access to it once load-file returned.
  `(do (alter-var-root #'project
                       (fn [_#] (assoc (apply hash-map (quote ~args))
                                  :name ~(name project-name)
                                  :root ~(.getParent (java.io.File. *file*)))))
       (def ~project-name project)))

;; So it doesn't need to be fully-qualified in project.clj
(with-ns 'user (use ['leiningen.core :only ['defproject]]))

(defn read-project
  ([file] (load-file file)
     project)
  ([] (read-project "project.clj")))

(defn -main [command & args]
  (let [action-ns (symbol (str "leiningen." command))
        _ (require action-ns)
        action (ns-resolve action-ns (symbol command))
        project (read-project)]
    (binding [*compile-path* (or (:compile-path project)
                                 (str (:root project) "/classes/"))]
      ;; TODO: ensure tasks run only once
      (apply action project args)
      ;; In case tests or some other task started any:
      (shutdown-agents))))

Use with-ns so defproject works unqualified. Bind *compile-path* explicitly.

Not sure why explicit *compile-path* is required, but it was getting
reset somehow.


{
 :name "mailit",
 :path "",
 :func (fn [recipient subject intro result-maps]
         (cond
           (pg/eoi? result-maps) (pg/done)

           (every? map? result-maps)
           (let [msgs (for [retmap result-maps]
                        (let [name (retmap :name)
                              [bams csv] (retmap :value)
                              bams (map fs/basename bams)
                              csv (fs/basename csv)
                              exit (retmap :exit)
                              err (retmap :err)]
                          (if (= exit :succss)
                            [exit csv]
                            [exit err [bams csv]])))
                 msg (->> msgs (cons intro) (map str) (str/join "\n"))]
             (pg/send-msg [recipient] subject msg))

           :else
           (let [msg (->> result-maps (cons intro) (map str) (str/join "\n"))]
             (pg/send-msg [recipient] subject msg))))

 :description "General mailer function node. recipient is user account that requested the associated job this node is final pt of DAG, subject is type of job, msg is job finish details."
}

{
 :name "mailit",
 :path "",
 :func (fn [recipient subject intro result-maps]
         (cond
           (pg/eoi? result-maps) (pg/done)

           (every? map? result-maps)
           (let [base (->> result-maps first :value second fs/dirname)
                 msgs (for [retmap result-maps]
                        (let [name (retmap :name)
                              [bams csv] (retmap :value)
                              bams (map fs/basename bams)
                              csv (fs/basename csv)
                              exit (retmap :exit)
                              err (retmap :err)]
                          (if (= exit :success)
                            [exit csv]
                            [exit err [bams csv]])))
                 overall (reduce (fn[R x]
                                   (cond (= x R :success) R
                                         (= x R :fail) R
                                         :else :mixed))
                                 (map first msgs))
                 msg (->> msgs
                          (cons (str "Base '" base "'"))
                          (cons (str "Overall " overall))
                          (cons intro)
                          (map str) (str/join "\n"))]
             (pg/send-msg [recipient] subject msg))

           :else
           (let [msg (->> result-maps (cons intro) (map str) (str/join "\n"))]
             (pg/send-msg [recipient] subject msg))))

 :description "General mailer function node. recipient is user account that requested the associated job this node is final pt of DAG, subject is type of job, msg is job finish details."
}

Adjust job status messaging info

Adjust job status messaging info


(ns whitman.client)

(def source-url [cfg user]
  (format (get cfg "source") user))

(ns whitman.client)

(defn source-url [cfg user]
  (format (get cfg "source") user))

Use defn instead of def

Fix: Use defn instead of def

Oops.


 (ns re-frame.utils)

 (defn warn
   [& args]
   (.warn js/console (apply str args)))

 (defn first-in-vector
  [v]
  (if (vector? v)
    (first v)
    (warn "re-frame: expected a vector event, but got: " v)))

 (ns re-frame.utils)

 (defn warn
   [& args]
   (.warn js/console (apply str args)))

 (defn dbg
   [& args]
   (.debug js/console (apply str args)))

 (defn log
   [& args]
   (.log js/console (apply str args)))

 (defn group
   [& args]
   (.group js/console (apply str args)))

 (defn groupEnd
   []
   (.groupEnd js/console))

 (defn first-in-vector
  [v]
  (if (vector? v)
    (first v)
    (warn "re-frame: expected a vector event, but got: " v)))

Add other round of console API methods. Not very happy about this. But will sort it out later.


(ns bob.test (:use clojure.test))
(load-file "bob.clj")

(deftest responds-to-shouts
  (is (= "Woah, chill out!" (bob/response-for "SHOUTING"))))

(deftest responds-to-questions
  (is (= "Sure." (bob/response-for "A question?"))))

(deftest responds-to-statements
  (is (= "Whatever." (bob/response-for "A statement."))))

(deftest responds-to-silence
  (is (= "Fine, be that way." (bob/response-for ""))))

(run-tests)

(ns bob.test (:use clojure.test))
(load-file "bob.clj")

(deftest responds-to-something
  (is (= "Whatever." (bob/response-for "Tom-ay-to, tom-aaaah-to."))))

(deftest responds-to-shouts
  (is (= "Woah, chill out!" (bob/response-for "WATCH OUT!"))))

(deftest responds-to-questions
  (is (= "Sure." (bob/response-for "Does this cryogenic chamber make me look fat?"))))

(deftest responds-to-forceful-talking
  (is (= "Whatever." (bob/response-for "Let's go make out behind the gym!"))))

(deftest responds-to-acronyms
  (is (= "Whatever." (bob/response-for "It's OK if you don't want to go to the DMV."))))

(deftest responds-to-forceful-questions
  (is (= "Woah, chill out!" (bob/response-for "WHAT THE HELL WERE YOU THINKING?"))))

(deftest responds-to-shouting-with-special-characters
  (is (= "Woah, chill out!" (bob/response-for "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!"))))

(deftest responds-to-shouting-numbers
  (is (= "Woah, chill out!" (bob/response-for "1, 2, 3 GO!"))))

(deftest responds-to-shouting-with-no-exclamation-mark
  (is (= "Woah, chill out!" (bob/response-for "I HATE YOU"))))

(deftest responds-to-statement-containing-question-mark
  (is (= "Whatever." (bob/response-for "Ending with ? means a question."))))

(deftest responds-to-silence
  (is (= "Fine, be that way." (bob/response-for ""))))

(run-tests)

Bring tests in line with Ruby tests.

Bring tests in line with Ruby tests.

The Ruby spec for Bob includes a number of tests that clarify certain
points of Bob's behavior.  This commit brings them to the Clojure spec
for Bob.


(ns reports.exporter
  (:require [clojure.java.io :as io])
  (:import java.io.File
           java.util.UUID
           org.waterforpeople.mapping.dataexport.SurveyDataImportExportFactory))

(defn- get-file-extension [t]
  (if (= t "SURVEY_FORM")
    "xls"
    "xlsx"))

(defn- get-file [et id]
  (let [path (str "/var/tmp/akvo/flow/reports/" (UUID/randomUUID))]
    (.mkdirs (io/file path))
    (io/file (format "%s/%s-%s.%s" path et id (get-file-extension et)))))

(defn ^File export-report [type base id options]
  (let [exporter (.getExporter (SurveyDataImportExportFactory.) type)
        file (get-file type id)]
    (.export exporter {"surveyId" id} file base options) file))

(ns reports.exporter
  (:require [clojure.java.io :as io])
  (:import java.io.File
           java.util.UUID
           org.waterforpeople.mapping.dataexport.SurveyDataImportExportFactory))

(defn- get-file-extension [t]
  (if (= t "SURVEY_FORM")
    "xls"
    "xlsx"))

(defn- get-path []
  (format "%s/%s/%s" (System/getProperty "java.io.tmpdir") "akvo/flow/reports" (UUID/randomUUID)))

(defn- get-file [et id]
  (let [path (get-path)]
    (.mkdirs (io/file path))
    (io/file (format "%s/%s-%s.%s" path et id (get-file-extension et)))))

(defn ^File export-report [type base id options]
  (let [exporter (.getExporter (SurveyDataImportExportFactory.) type)
        file (get-file type id)]
    (.export exporter {"surveyId" id} file base options)
    file))

Use java.io.tmpdir for storing the exported files


(ns discuss.cards
  (:require [devcards.core :as dc :refer-macros [defcard defcard-om defcard-om-next dom-node]]
            [sablono.core :as html :refer-macros [html]]
            [om.next :as om :refer-macros [defui]]
            [discuss.parser :as parser]
            [discuss.components.search.statements :refer [SearchQuery]]
            [discuss.utils.common :as lib]
            [discuss.views :as views]))

(enable-console-print!)

(defcard-om discuss
  views/main-view
  lib/app-state)

(defonce test-data {:foo :bar
                    :search/results [:foo :bar :baz]})

(defonce devcard-reconciler
  (om/reconciler {:state test-data
                  :parser (om/parser {:read parser/read :mutate parser/mutate})}))

(defcard search-query-card-no-next
  (dom-node
   (fn [_ node]
     (om/add-root! devcard-reconciler SearchQuery node)))
  {:inspect-data true})

;; -----------------------------------------------------------------------------
;; Start devcards

(defn main []
  ;; conditionally start the app based on whether the #main-app-area
  ;; node is on the page
  (when-let [node (.getElementById js/document "main-app-area")]
    (.render js/ReactDOM (html [:div "This is working"]) node)))
(main)

(ns discuss.cards
  (:require [devcards.core :as dc :refer-macros [defcard defcard-om defcard-om-next dom-node]]
            [sablono.core :as html :refer-macros [html]]
            [om.next :as om :refer-macros [defui]]
            [discuss.parser :as parser]
            [discuss.components.search.statements :refer [SearchQuery Results]]
            [discuss.utils.common :as lib]
            [discuss.views :as views]))

(enable-console-print!)

(defcard-om discuss
  views/main-view
  lib/app-state)

(defonce test-data {:foo :bar
                    :search/results [:foo :bar :baz]})

(defonce devcard-reconciler
  (om/reconciler {:state test-data
                  :parser (om/parser {:read parser/read :mutate parser/mutate})}))

(defcard search-query
  (dom-node
   (fn [_ node]
     (om/add-root! parser/reconciler SearchQuery node)))
  {:inspect-data true})

(defcard search-results
  (dom-node
   (fn [_ node]
     (om/add-root! parser/reconciler Results node)))
  {:inspect-data true})

;; -----------------------------------------------------------------------------
;; Start devcards

(defn main []
  ;; conditionally start the app based on whether the #main-app-area
  ;; node is on the page
  (when-let [node (.getElementById js/document "main-app-area")]
    (.render js/ReactDOM (html [:div "This is working"]) node)))
(main)

Add separate card for search-results

Add separate card for search-results


(ns lcmap.clownfish.configuration
  "Supplies system configuration map"
  (:require [clojure.string :as str]
            [clojure.tools.logging :as log]
            [dire.core :as dire :refer [with-handler!]]
            [lcmap.commons.numbers :refer [numberize]]
            [mount.core :refer [defstate] :as mount]))

(defn- tokenize
  "Split a string on whitespace and returns a vector of the tokens or nil if
   the value was untokenizable"
  [value]
  (vec (remove #(zero? (count %)) (str/split value #" "))))

(with-handler! #'tokenize
  [java.lang.NullPointerException java.lang.ClassCastException]
  (fn [e & args] nil))

(defn config-map
  [env]
  {:http   {:port (numberize (:http-port env))
            :join? false :daemon? true}
   :event  {:host (:event-host env)
            :port (numberize (:event-port env))}
   :db     {:keyspace (:db-keyspace env)
            :cluster {:contact-points (tokenize (:db-url env))
                      :credentials {:user (:db-user env)
                                    :password (:db-pass env)}}}
   :server {:exchange (:exchange env) :queue (:queue env)}
   :chip-specs-url (:chip-specs-url env)})

(defstate config
  :start (log/spy :debug (config-map ((mount/args) :environment))))

(ns lcmap.clownfish.configuration
  "Supplies system configuration map"
  (:require [clojure.string :as str]
            [clojure.tools.logging :as log]
            [dire.core :as dire :refer [with-handler!]]
            [lcmap.commons.numbers :refer [numberize]]
            [mount.core :refer [defstate] :as mount]))

(defn- tokenize
  "Split a string on whitespace and returns a vector of the tokens or nil if
   the value was untokenizable"
  [value]
  (vec (remove #(zero? (count %)) (str/split value #" "))))

(with-handler! #'tokenize
  [java.lang.NullPointerException java.lang.ClassCastException]
  (fn [e & args] nil))

(defn config-map
  [env]
  {:http   {:port (numberize (:http-port env))
            :join? false :daemon? true}
   :event  {:host (:event-host env)
            :port (numberize (:event-port env))}
   :db     {:keyspace (:db-keyspace env)
            :cluster {:contact-points (tokenize (:db-url env))
                      :credentials {:user (:db-user env)
                                    :password (:db-pass env)}
                      :query-options {:consistency :quorum}}}
   :server {:exchange (:exchange env) :queue (:queue env)}
   :chip-specs-url (:chip-specs-url env)})

(defstate config
  :start (log/spy :debug (config-map ((mount/args) :environment))))

Set DB consistency to quorum

Set DB consistency to quorum


(ns reitit.doo-runner
  (:require [doo.runner :refer-macros [doo-tests]]
            reitit.coercion-test
            reitit.core-test
            reitit.impl-test
            reitit.middleware-test
            reitit.ring-test
            #_reitit.spec-test
            reitit.exception-test
            reitit.frontend.core-test
            reitit.frontend.history-test
            reitit.frontend.controllers-test))

(enable-console-print!)

(doo-tests 'reitit.coercion-test
           'reitit.core-test
           'reitit.impl-test
           'reitit.middleware-test
           'reitit.ring-test
           #_'reitit.spec-test
           'reitit.exception-test
           'reitit.frontend.core-test
           'reitit.frontend.history-test
           'reitit.frontend.controllers-test)

(ns reitit.doo-runner
  (:require [doo.runner :refer-macros [doo-tests]]
            reitit.coercion-test
            reitit.core-test
            reitit.impl-test
            reitit.middleware-test
            reitit.ring-test
            reitit.spec-test
            reitit.exception-test
            reitit.frontend.core-test
            reitit.frontend.history-test
            reitit.frontend.controllers-test))

(enable-console-print!)

(doo-tests 'reitit.coercion-test
           'reitit.core-test
           'reitit.impl-test
           'reitit.middleware-test
           'reitit.ring-test
           'reitit.spec-test
           'reitit.exception-test
           'reitit.frontend.core-test
           'reitit.frontend.history-test
           'reitit.frontend.controllers-test)

Return of the spec-tests for cljs

Return of the spec-tests for cljs


; :mode=clojure:

(ns hello
    (:use
        [goog.dom :only [appendChild createDom]]
        [goog.events :only [listen]]
        [goog.events.EventType :only [CLICK]]
        ))

(def pos (atom 0))

(defn ^:export foobar []
    (let [canvas (goog.dom/getElement "my-canvas")
        ctx (.getContext canvas "2d")
        x (swap! pos inc)]
        (do
            (. ctx (save))
            (.clearRect ctx 0 0 (.width canvas) (.height canvas))
            (set! (.fillStyle ctx) "red")
            (.fillRect ctx x 100 100 50)
            (. ctx (restore))
            )))

(defn ^:export main []
    (let [body document.body ;(goog.dom/getElement "my-body")
        f (partial goog.dom/appendChild body)] (do
        (f
            (goog.dom/createDom "h1" {} "Hello!"))
        (f
            (goog.dom/createDom "canvas" (.strobj {
                "id" "my-canvas"
                "width" 600
                "height" 600
                "style" "border: 1px solid #000000"
                }) ""))
        (let [button (goog.dom/createDom "button" {} "Click!")] (do
            (goog.events/listen button goog.events.EventType/CLICK foobar)
            (f button)
            button))
)))

; :mode=clojure:

(ns hello
    (:use
        [goog.dom :only [appendChild createDom]]
        [goog.events :only [listen]]
        [goog.events.EventType :only [CLICK]]
        ))

(def pos (atom 0))

(defn foobar [canvas]
    (let [ctx (.getContext canvas "2d")
        x (swap! pos inc)]
        (do
            (. ctx (save))
            (.clearRect ctx 0 0 (.width canvas) (.height canvas))
            (set! (.fillStyle ctx) "red")
            (.fillRect ctx x 100 100 50)
            (. ctx (restore))
            )))

(defn ^:export main []
    (let [
        canvas (goog.dom/createDom "canvas" (.strobj {
            "width" 600
            "height" 600
            "style" "border: 1px solid #000000"
            }) "")
        button (goog.dom/createDom "button" {} "Click!")]
        (do
            (goog.events/listen button goog.events.EventType/CLICK (partial foobar canvas))
            (dorun (map (partial goog.dom/appendChild document.body)
                [(goog.dom/createDom "h1" {} "Hello!") canvas button])))))

Work in progress - refactoring.

Work in progress - refactoring.


(ns evermind.domain.core-test
  (:require [clojure.test :refer :all]
            [evermind.domain.core :refer :all]
            [clojure.spec.test.alpha :as stest]
            [evermind.test-util :as tu]))

(defn fixture [f]
  (tu/instrument-namespaces)
  (f))

(use-fixtures :once fixture)

(deftest test-create-node
         (is (tu/check 'evermind.domain.core/create-node)))

(deftest test-set-attributes
         (is (tu/check 'evermind.domain.core/set-attributes)))

(deftest test-add-child
         (is (tu/check 'evermind.domain.core/add-child)))

(deftest test-remove-child
  (is (tu/check 'evermind.domain.core/remove-child)))

(deftest test-filter-children
         (is (tu/check 'evermind.domain.core/filter-children)))

(deftest test-create-mindmap
         (is (tu/check 'evermind.domain.core/create-mindmap)))

(ns evermind.domain.core-test
  (:require [clojure.test :refer :all]
            [evermind.domain.core :refer :all]
            [clojure.spec.test.alpha :as stest]
            [evermind.test-util :as tu]))

(defn fixture [f]
  (tu/instrument-namespaces)
  (f))

(use-fixtures :once fixture)

(deftest test-create-node
         (is (tu/check 'evermind.domain.core/create-node)))

(deftest test-set-attributes
         (is (tu/check 'evermind.domain.core/set-attributes)))

(deftest test-add-child
         (is (tu/check 'evermind.domain.core/add-child)))

(deftest test-remove-child
  (is (tu/check 'evermind.domain.core/remove-child)))

(deftest test-filter-children
         (is (tu/check 'evermind.domain.core/filter-children {::clojure.spec.test.check/opts {:num-tests 10}})))

(deftest test-create-mindmap
         (is (tu/check 'evermind.domain.core/create-mindmap)))

Fix number of tests for filter-children.


(ns ^{:doc "A way to keep track of the pertinent context of the current nested fact.
            Currently, that is only the fact's description/doc-string"}
  midje.internal-ideas.fact-context
  (:use [clojure.string :only [join]]))

(def fact-context (atom []))

(defn nested-descriptions []
  @fact-context)

(defn- enter-runtime-context [description]
  (swap! fact-context conj description))

(defn- leave-runtime-context []
  (swap! fact-context #(vec (butlast %))))

(defmacro within-runtime-fact-context [description & body]
  `(try
     (#'enter-runtime-context ~description)
     ~@body
     (finally
       (#'leave-runtime-context))))

(ns ^{:doc "A way to keep track of the pertinent context of the current nested fact.
            Currently, that is only the fact's description/doc-string"}
  midje.internal-ideas.fact-context
  (:use [clojure.string :only [join]]))

(def ^{:dynamic true} *fact-context* [])

(defn nested-descriptions []
  *fact-context*)

(defmacro within-runtime-fact-context [description & body]
  `(binding [*fact-context* (conj *fact-context* ~description)]
     ~@body))

Switch from atom to var

Switch from atom to var


{:user {:dependencies [[slamhound "1.3.1"]
                       [org.clojure/tools.namespace "0.2.4"]
                       [clj-stacktrace "0.2.7"]]
        :plugins [[lein-difftest "2.0.0"]
                  [lein-marginalia "0.7.1"]
                  [lein-pprint "1.1.1"]
                  [lein-swank "1.4.4"]
                  [lein-kibit "0.0.8"]]

        :injections [(let [orig (ns-resolve (doto 'clojure.stacktrace require)
                                            'print-cause-trace)
                           new (ns-resolve (doto 'clj-stacktrace.repl require)
                                           'pst)]
                       (alter-var-root orig (constantly (deref new))))]}}

        :aliases {"slamhound" ["run" "-m" "slam.hound"]}
        :source-paths ["/Users/jcf/.lein/dev"]
        :search-page-size 30}}

{:user {:dependencies [[slamhound "1.3.1"]
                       [org.clojure/tools.namespace "0.2.4"]
                       [clj-stacktrace "0.2.7"]]

        :plugins [[lein-pprint "1.1.1"]
                  [lein-difftest "2.0.0"]
                  [lein-cloverage "1.0.2"]
                  [lein-marginalia "0.7.1"]
                  [lein-swank "1.4.4"]
                  [lein-kibit "0.0.8"]]

        :injections [(let [orig (ns-resolve (doto 'clojure.stacktrace require)
                                            'print-cause-trace)
                           new (ns-resolve (doto 'clj-stacktrace.repl require)
                                           'pst)]
                       (alter-var-root orig (constantly (deref new))))]}}

        :aliases {"slamhound" ["run" "-m" "slam.hound"]}
        :source-paths ["/Users/jcf/.lein/dev"]
        :search-page-size 30}}

Add cloverage to lein plugins

Add cloverage to lein plugins


(defproject onyx-app/lein-template "0.9.10.0-beta1"
  :description "Onyx Leiningen application template"
  :url "https://github.com/onyx-platform/onyx-template"
  :license {:name "MIT License"
            :url "http://choosealicense.com/licenses/mit/#"}
  :repositories {"snapshots" {:url "https://clojars.org/repo"
                              :username :env
                              :password :env
                              :sign-releases false}
                 "releases" {:url "https://clojars.org/repo"
                             :username :env
                             :password :env
                             :sign-releases false}}
  :plugins [[lein-set-version "0.4.1"]]
  :profiles {:dev {:plugins [[lein-set-version "0.4.1"]
                             [lein-update-dependency "0.1.2"]
                             [lein-pprint "1.1.1"]]}}
  :eval-in-leiningen true)

(defproject onyx-app/lein-template "0.9.10.0-SNAPSHOT"
  :description "Onyx Leiningen application template"
  :url "https://github.com/onyx-platform/onyx-template"
  :license {:name "MIT License"
            :url "http://choosealicense.com/licenses/mit/#"}
  :repositories {"snapshots" {:url "https://clojars.org/repo"
                              :username :env
                              :password :env
                              :sign-releases false}
                 "releases" {:url "https://clojars.org/repo"
                             :username :env
                             :password :env
                             :sign-releases false}}
  :plugins [[lein-set-version "0.4.1"]]
  :profiles {:dev {:plugins [[lein-set-version "0.4.1"]
                             [lein-update-dependency "0.1.2"]
                             [lein-pprint "1.1.1"]]}}
  :eval-in-leiningen true)

Prepare for next release cycle.

Prepare for next release cycle.


(ns incise.watcher
  (:require [taoensso.timbre :refer [error]]
            [clojure.stacktrace :refer [print-cause-trace]]
            [watchtower.core :refer [watcher rate file-filter extensions
                                     on-change]]))

(defn log-exceptions [func]
  "Log (i.e. print) exceptions received from the given function."
  (let [out *out*
        err *err*]
    (fn [& args]
      (binding [*out* out
                *err* err]
        (try
          (apply func args)
          (catch Exception e
            (error (with-out-str (print-cause-trace e)))))))))

(defn per-change [change-fn]
  (fn [files]
    (doseq [file files]
      (change-fn file))))

(defn watch
  [change-fn]
  (watcher ["resources/posts/" "resources/pages/"]
           (rate 300)
           (on-change (-> change-fn
                          per-change
                          log-exceptions))))

(def watching nil)

(defn start-watching [& args]
  (alter-var-root #'watching (fn [& _] (apply watch args))))

(defn stop-watching []
  (when watching
    (future-cancel watching)))

(ns incise.watcher
  (:require [taoensso.timbre :refer [error]]
            [clojure.stacktrace :refer [print-cause-trace]]
            [watchtower.core :refer [watcher rate file-filter extensions
                                     on-change]])
  (:import [java.io File]))

(defn log-exceptions [func]
  "Log (i.e. print) exceptions received from the given function."
  (let [out *out*
        err *err*]
    (fn [& args]
      (binding [*out* out
                *err* err]
        (try
          (apply func args)
          (catch Exception e
            (error (with-out-str (print-cause-trace e)))))))))

(defn per-change [change-fn]
  (fn [files]
    (doseq [file files]
      (change-fn file))))

(def gitignore-file? [^File file]
  (= (.getName file) ".gitignore"))

(defn delete-recursively
  "Delete a directory tree."
  [^File root]
  (when (.isDirectory root)
    (doseq [file (remove gitignore-file? (.listFiles root))]
      (delete-recursively file)))
  (.delete root))

(defn watch
  [change-fn]
  (delete-recursively (File. "resources/public/"))
  (watcher ["resources/posts/" "resources/pages/"]
           (rate 300)
           (on-change (-> change-fn
                          per-change
                          log-exceptions))))

(def watching nil)

(defn start-watching [& args]
  (alter-var-root #'watching (fn [& _] (apply watch args))))

(defn stop-watching []
  (when watching
    (future-cancel watching)))

Delete public directory when watching starts.


(ns graphql-clj.box
  (:import [clojure.lang IObj IDeref IPersistentCollection Named]
           [java.io Writer]))

(deftype Box [value meta]

  IObj
  (meta [_] meta)

  IDeref
  (deref [_] (if (instance? Box value) @value value))

  IPersistentCollection
  (equiv [a b] (.equals a b))

  Named
  (getName [this] (if (instance? Box value) (.getName value) (.toString this)))

  Object
  (equals [_ b] (if (instance? Box b) (= value @b) (= value b)))
  (hashCode [_] (.hashCode value))
  (toString [_] (str value)))

(defmethod print-method Box [v ^Writer w]
  (.write w (.toString v)))

(defn kv->box
  "Given a single key value pair in a map, preserve metadata for the value."
  [value]
  (let [m (meta value)
        [[k v]] (vec value)]
    {k (->Box v m)}))

(defn box->val
  "Given a potentially boxed value, strip the box and return the raw value.
   Same as identity if value is already unboxed"
  [v]
  (if (instance? Box v) @v v))

(ns graphql-clj.box
  (:import [clojure.lang IObj IDeref IPersistentCollection Named]
           [java.io Writer]))

(deftype Box [value meta]

  IObj
  (meta [_] meta)

  IDeref
  (deref [_] (if (instance? Box value) @value value))

  IPersistentCollection
  (equiv [a b] (.equals a b))

  Named
  (getName [_] (if (instance? Box value) (.getName value) (str value)))

  Object
  (equals [_ b] (if (instance? Box b) (= value @b) (= value b)))
  (hashCode [_] (.hashCode value))
  (toString [_] (str value)))

(defmethod print-method Box [v ^Writer w]
  (.write w (.toString v)))

(defn kv->box
  "Given a single key value pair in a map, preserve metadata for the value."
  [value]
  (let [m (meta value)
        [[k v]] (vec value)]
    {k (->Box v m)}))

(defn box->val
  "Given a potentially boxed value, strip the box and return the raw value.
   Same as identity if value is already unboxed"
  [v]
  (if (instance? Box v) @v v))

Use str instead of .toString

Use str instead of .toString


(ns tx.listen
  (:use clojure.test)
  (:require [immutant.cache :as ic]
            [immutant.messaging :as imsg]
            [tx.core :as core]))

(imsg/start "/queue/trigger")

(defn listener [m]
  (imsg/publish "/queue/test" "kiwi")
  (imsg/publish "/queue/remote-test" "starfruit" :host "localhost" :port 5445)
  (ic/put core/cache :a 1)
  (if (:throw? m) (throw (Exception. "rollback"))))

(imsg/listen "/queue/trigger" listener)

(defn trigger-listener
  [throw?]
  (imsg/publish "/queue/trigger" {:throw? throw?}))

(use-fixtures :each core/cache-fixture)

(deftest transactional-writes-in-listener-should-work
  (trigger-listener false)
  (is (= "kiwi" (imsg/receive "/queue/test" :timeout 2000)))
  (is (= "starfruit" (imsg/receive "/queue/remote-test")))
  (is (= 1 (:a core/cache))))

(deftest transactional-writes-in-listener-should-fail-on-rollback
  (trigger-listener true)
  (is (nil? (imsg/receive "/queue/test" :timeout 2000)))
  (is (nil? (imsg/receive "/queue/remote-test")))
  (is (nil? (:a core/cache))))

(ns tx.listen
  (:use clojure.test)
  (:require [immutant.cache :as ic]
            [immutant.messaging :as imsg]
            [tx.core :as core]))

(imsg/start "/queue/trigger")

(defn listener [m]
  (imsg/publish "/queue/test" "kiwi")
  (imsg/publish "/queue/remote-test" "starfruit" :host "localhost" :port 5445)
  (ic/put core/cache :a 1)
  (if (:throw? m) (throw (Exception. "rollback"))))

(imsg/listen "/queue/trigger" listener)

(defn trigger-listener
  [throw?]
  (imsg/publish "/queue/trigger" {:throw? throw?}))

(use-fixtures :each core/cache-fixture)

(deftest transactional-writes-in-listener-should-work
  (trigger-listener false)
  (is (= "kiwi" (imsg/receive "/queue/test" :timeout 2000)))
  (is (= "starfruit" (imsg/receive "/queue/remote-test")))
  (is (= 1 (:a core/cache))))

(deftest transactional-writes-in-listener-should-fail-on-rollback
  (trigger-listener true)
  (is (nil? (imsg/receive "/queue/test" :timeout 2000)))
  (is (nil? (imsg/receive "/queue/remote-test" :timeout 2000)))
  (is (nil? (:a core/cache))))

Speed up test a bit

Speed up test a bit


(ns braid.server.bots
  (:require
    [org.httpkit.client :as http]
    [taoensso.timbre :as timbre]
    [braid.server.crypto :as crypto]
    [braid.server.util :refer [->transit]])
  (:import
    java.io.ByteArrayInputStream))

(defn send-message-notification
  [bot message]
  (let [body (->transit message)
        hmac (crypto/hmac-bytes (bot :token) body)]
    (timbre/debugf "sending bot notification")
    (println
      ; TODO: should this be a POST too?
      @(http/put (bot :webhook-url)
                 {:headers {"Content-Type" "application/transit+msgpack"
                            "X-Braid-Signature" hmac}
                  :body (ByteArrayInputStream. body)}))))

(defn send-event-notification
  [bot info]
  (when-let [url (:event-webhook-url bot)]
    (timbre/debugf "Sending event notification %s to %s" info bot)
    (let [body (->transit info)
          hmac (crypto/hmac-bytes (bot :token) body)]
      (timbre/debugf "sending bot event notification")
      (println
        @(http/post url
                    {:headers {"Content-Type" "application/transit+msgpack"
                               "X-Braid-Signature" hmac}
                     :body (ByteArrayInputStream. body)})))))

(ns braid.server.bots
  "Sending notification of messages and events to bots"
  (:require
    [braid.server.crypto :as crypto]
    [braid.server.util :refer [->transit]]
    [org.httpkit.client :as http]
    [taoensso.timbre :as timbre])
  (:import
    (java.io ByteArrayInputStream)))

(defn send-message-notification
  [bot message]
  (let [body (->transit message)
        hmac (crypto/hmac-bytes (bot :token) body)]
    (timbre/debugf "sending bot notification")
    (println
      ; TODO: should this be a POST too?
      @(http/put (bot :webhook-url)
                 {:headers {"Content-Type" "application/transit+msgpack"
                            "X-Braid-Signature" hmac}
                  :body (ByteArrayInputStream. body)}))))

(defn send-event-notification
  [bot info]
  (when-let [url (:event-webhook-url bot)]
    (timbre/debugf "Sending event notification %s to %s" info bot)
    (let [body (->transit info)
          hmac (crypto/hmac-bytes (bot :token) body)]
      (timbre/debugf "sending bot event notification")
      (println
        @(http/post url
                    {:headers {"Content-Type" "application/transit+msgpack"
                               "X-Braid-Signature" hmac}
                     :body (ByteArrayInputStream. body)})))))

Fix ns form, add docstring

Fix ns form, add docstring


(ns puppetlabs.trapperkeeper.utils)

(def ^{:doc "Alias for plumbing.map/map-leaves-and-path, which is named inconsistently
            with Clojure conventions as it doesn't behave like other `map` functions.
            Map functions typically return a `seq`, never a map, and walk functions
            are used to modify a collection in-place without altering the structure."}
  walk-leaves-and-path plumbing.map/map-leaves-and-path)

(defn service-graph?
  "Predicate that tests whether or not the argument is a valid trapperkeeper
  service graph."
  [service-graph]
  (and
    (map? service-graph)
    (every? keyword? (keys service-graph))
    (every? (some-fn ifn? service-graph?) (vals service-graph))))

(defn validate-service-graph!
  "Validates that the argument is a valid trapperkeeper service graph.  Throws
  an IllegalArgumentException if it is not."
  [service-graph]
  (if (service-graph? service-graph)
    service-graph
    (throw (IllegalArgumentException. (str "Invalid service graph; service graphs must "
                                           "be nested maps of keywords to functions.  Found: "
                                           service-graph)))))

(ns puppetlabs.trapperkeeper.utils
  (:require [plumbing.map]))

(def ^{:doc "Alias for plumbing.map/map-leaves-and-path, which is named inconsistently
            with Clojure conventions as it doesn't behave like other `map` functions.
            Map functions typically return a `seq`, never a map, and walk functions
            are used to modify a collection in-place without altering the structure."}
  walk-leaves-and-path plumbing.map/map-leaves-and-path)

(defn service-graph?
  "Predicate that tests whether or not the argument is a valid trapperkeeper
  service graph."
  [service-graph]
  (and
    (map? service-graph)
    (every? keyword? (keys service-graph))
    (every? (some-fn ifn? service-graph?) (vals service-graph))))

(defn validate-service-graph!
  "Validates that the argument is a valid trapperkeeper service graph.  Throws
  an IllegalArgumentException if it is not."
  [service-graph]
  (if (service-graph? service-graph)
    service-graph
    (throw (IllegalArgumentException. (str "Invalid service graph; service graphs must "
                                           "be nested maps of keywords to functions.  Found: "
                                           service-graph)))))

Add missing require for 'plumbing.map'

Add missing require for 'plumbing.map'


(ns rumahsewa141.test.db.core
  (:require [rumahsewa141.db.core :refer [*db*] :as db]
            [luminus-migrations.core :as migrations]
            [clojure.test :refer :all]
            [clojure.java.jdbc :as jdbc]
            [rumahsewa141.config :refer [env]]
            [mount.core :as mount]))

(use-fixtures
  :once
  (fn [f]
    (mount/start
      #'rumahsewa141.config/env
      #'rumahsewa141.db.core/*db*)
    (migrations/migrate ["migrate"] (select-keys env [:database-url]))
    (f)))

(deftest test-users
  (jdbc/with-db-transaction [t-conn *db*]
    (jdbc/db-set-rollback-only! t-conn)
    (is (= 1 (db/create-user!
               t-conn
               {:id         "1"
                :first_name "Sam"
                :last_name  "Smith"
                :email      "sam.smith@example.com"
                :pass       "pass"})))
    (is (= {:id         "1"
            :first_name "Sam"
            :last_name  "Smith"
            :email      "sam.smith@example.com"
            :pass       "pass"
            :admin      nil
            :last_login nil
            :is_active  nil}
           (db/get-user t-conn {:id "1"})))))

(ns rumahsewa141.test.db.core
  (:require [rumahsewa141.db.core :refer [*db*] :as db]
            [luminus-migrations.core :as migrations]
            [clojure.test :refer :all]
            [clojure.java.jdbc :as jdbc]
            [rumahsewa141.config :refer [env]]
            [mount.core :as mount]))

(use-fixtures
  :once
  (fn [f]
    (mount/start
      #'rumahsewa141.config/env
      #'rumahsewa141.db.core/*db*)
    (migrations/migrate ["migrate"] (select-keys env [:database-url]))
    (f)))

(deftest test-users
  (jdbc/with-db-transaction [t-conn *db*]
    (jdbc/db-set-rollback-only! t-conn)
    (is (= 1 (db/create-user!
               t-conn
               {:username "dingdong123"
                :nickname "Ding Dong"
                :phone_no "012-9876543"
                :password "pass"})))
    (is (= {:username "dingdong123"
            :nickname "Ding Dong"
            :phone_no "012-9876543"
            :password "pass"
            :admin    nil}
           (dissoc (db/fetch-user-by-username t-conn {:username "dingdong123"})
                   :id)))))

Update test just to make it works

Update test just to make it works


(ns pericles.routes
  (:require [compojure.core :refer :all]
            [compojure.route :as route]
            [ring.middleware.defaults :refer [wrap-defaults api-defaults]]
            [gpio.core :as gpio]
            [pericles.gpio :refer [port]]
            [pericles.handlers :as handlers]))

(defroutes api-routes
  (GET "/" [] "Hello world!")
  (GET "/readPort" [] (name (gpio/read-value @port)))
  (GET "/writePort" [value] (gpio/write-value! @port value))
  (route/not-found "Not found!"))

(def app (-> #'api-routes
             (wrap-defaults api-defaults)
             handlers/wrap-catch-exceptions
             handlers/wrap-log-request))

(ns pericles.routes
  (:require [compojure.core :refer :all]
            [compojure.route :as route]
            [compojure.coercions :refer [as-int]]
            [ring.middleware.defaults :refer [wrap-defaults api-defaults]]
            [ring.util.http-response :as resp]
            [gpio.core :as gpio]
            [pericles.gpio :refer [port]]
            [pericles.handlers :as handlers]))

(defroutes api-routes
  (GET "/" [] "Hello world!")
  (GET "/readPort" [] (name (gpio/read-value @port)))
  (GET "/writePort" [value :<< as-int]
       (do
         (gpio/write-value! @port value)
         (name (gpio/read-value @port))))
  (GET "/readTemp" [] "27C")
  (route/not-found "Not found!"))

(def app (-> #'api-routes
             (wrap-defaults api-defaults)
             handlers/wrap-catch-exceptions
             handlers/wrap-log-request))

Return new value on write

Return new value on write


(ns pericles.routes
  (:require [compojure.core :refer :all]
            [compojure.route :as route]
            [compojure.coercions :refer [as-int]]
            [ring.middleware.defaults :refer [wrap-defaults api-defaults]]
            [ring.util.http-response :as resp]
            [gpio.core :as gpio]
            [pericles.gpio :refer [port]]
            [pericles.handlers :as handlers]))

(defroutes api-routes
  (GET "/" [] "Hello world!")
  (GET "/readPort" [] (name (gpio/read-value @port)))
  (GET "/writePort" [value :<< as-int]
       (do
         (gpio/write-value! @port value)
         (name (gpio/read-value @port))))
  (GET "/readTemp" [] "27C")
  (route/not-found "Not found!"))

(def app (-> #'api-routes
             (wrap-defaults (assoc api-defaults :static {:resources "public"}))
             handlers/wrap-catch-exceptions
             handlers/wrap-log-request))

(ns pericles.routes
  (:require [compojure.core :refer :all]
            [compojure.route :as route]
            [compojure.coercions :refer [as-int]]
            [ring.middleware.defaults :refer [wrap-defaults api-defaults]]
            [ring.util.http-response :as resp]
            [gpio.core :as gpio]
            [pericles.gpio :refer [port]]
            [pericles.handlers :as handlers]))

(defroutes api-routes
  (GET "/" [] (resp/found "/index.html"))
  (GET "/readPort" [] (name (gpio/read-value @port)))
  (GET "/writePort" [value :<< as-int]
       (do
         (gpio/write-value! @port value)
         (name (gpio/read-value @port))))
  (GET "/readTemp" [] "27C")
  (route/not-found "Not found!"))

(def app (-> #'api-routes
             (wrap-defaults (assoc api-defaults :static {:resources "public"}))
             handlers/wrap-catch-exceptions
             handlers/wrap-log-request))

Read port on load; Redirect / to index.html


(ns whitman.core
  (:require [clojure.data.json :as json])
  (:gen-class))

(defn exit [code msg]
  (binding [*out* *err*]
    (do (println msg)
        (System/exit code))))

(defn -main [& args]
  (if (< (count args) 1)
      (exit 1 "No configuration file specified")
      (println (json/read-str (slurp (nth args 0))))))

(ns whitman.core
  (:require [clojure.data.json :as json])
  (:gen-class))

(defn exit [code msg]
  (binding [*out* *err*]
    (do (println msg)
        (System/exit code))))

(defn -main [& args]
  (if (< (count args) 1)
      (exit 1 "No configuration file specified")
      (-> (nth args 0)
          slurp
          json/read-str
          println)))

Use thread macro to clarify code

Use thread macro to clarify code


(ns comic-reader.core
  (:gen-class)
  (:require [comic-reader.sites :as sites]
            [comic-reader.scrape :as scrape]
            [ring.util.response :as response]
            [ring.middleware.params :refer [wrap-params]]
            [compojure.core  :as c]
            [compojure.route :as route]
            [hiccup.page :as hp]))

(defn edn-response [data & [status]]
  {:status (or status 200)
   :headers {"Content-Type" "application/edn"}
   :body (pr-str data)})

(c/defroutes routes
  (c/GET "/" [] (hp/html5
                 [:input#history_state {:type "hidden"}]
                 (hp/include-js "js/compiled/main.js")))
  (c/GET "/blank" [] "")
  (c/context "/api/v1" []
    (c/GET "/sites" []
      (edn-response (vec (map #(select-keys % [:id :name :url])
                              sites/list))))
    (c/GET "/comics/:site" [site]
      (->> sites/list
           (some (fn [s]
                   (when (= (:id s)
                            site)
                     s)))
           (scrape/fetch-comic-list site)
           edn-response))
    (c/GET "/comic/:name" [name]
      (str "Hello comic" name)))
  (route/resources "/"))

(def app (wrap-params routes))

(ns comic-reader.core
  (:gen-class)
  (:require [comic-reader.sites :as sites]
            [comic-reader.scrape :as scrape]
            [ring.util.response :as response]
            [ring.middleware.params :refer [wrap-params]]
            [compojure.core  :as c]
            [compojure.route :as route]
            [hiccup.page :as hp]))

(defn edn-response [data & [status]]
  {:status (or status 200)
   :headers {"Content-Type" "application/edn"}
   :body (pr-str data)})

(c/defroutes routes
  (c/GET "/" [] (hp/html5
                 [:input#history_state {:type "hidden"}]
                 (hp/include-js "js/compiled/main.js")))
  (c/GET "/blank" [] "")
  (c/context "/api/v1" []
    (c/GET "/sites" []
      (edn-response (vec (map #(select-keys % [:id :name :url])
                              sites/list))))
    (c/GET "/comics/:site" [site]
      (->> sites/list
           (some (fn [s]
                   (when (= (:id s)
                            site)
                     s)))
           scrape/fetch-comic-list
           edn-response))
    (c/GET "/comic/:name" [name]
      (str "Hello comic" name)))
  (route/resources "/"))

(def app (wrap-params routes))

Fix the way I'm calling fetch-comic-list


(ns my-noir-lab.views.welcome
  (:require [my-noir-lab.views.common :as common])
  (:use [noir.core :only [defpage render]]
        [hiccup.core :only [html]]
        [hiccup.form-helpers :only [form-to submit-button]]))

(defpage "/welcome" []
  (common/layout
   [:p "Welcome to my-noir-lab"]))

(defpage "/my-page" []
  (common/site-layout
   "Welcome"
   [:h1 "Hello"]
   [:p#wrapper "Hope you like it!"]))

(defpage "/range" {:as user}
  (common/site-layout
   "Range input"
   [:h1 "range method"]
   (form-to [:post "/range"]
            (common/input-fields-range user)
            (submit-button "submit"))))

(defpage [:post "/range"] {:keys [start end] :as user}
  (common/site-layout
   "Range"
   [:h2 (str "Display range from " start " to " end)]
   [:p#wrapper (map #(str % "<br />")
                    (range (read-string start) (read-string end)))]
   (render "/range" user)))

(ns my-noir-lab.views.welcome
  (:require [my-noir-lab.views.common :as common])
  (:use [noir.core :only [defpage render]]
        [hiccup.core :only [html]]
        [hiccup.form-helpers :only [form-to submit-button]]))

(defpage "/welcome" []
  (common/layout
   [:p "Welcome to my-noir-lab"]))

(defpage "/my-page" []
  (common/site-layout
   "Welcome"
   [:h1 "Hello"]
   [:p#wrapper "Hope you like it!"]))

(defpage "/range" {:as user}
  (common/site-layout
   "Range input"
   [:h1 "range method"]
   (form-to [:post "/range"]
            (common/input-fields-range user)
            (submit-button "submit"))))

(defpage [:post "/range"] {:keys [start end] :as user}
  (common/site-layout
   "Range"
   [:h2 (str "Display range from " start " to " end)]
   [:p#wrapper (map #(str % "<br />")
                    (range (read-string start) (read-string end)))]))

Delete the render method at the moment.

Delete the render method at the moment.


(ns karmanaut.utils
  (:gen-class)
  (:require [clojure.java.io :as io])
  (:import [java.util Date]))

(defn env [key default]
  (get (System/getenv) key default))

(defn version []
  (if (.exists (io/as-file "project.clj"))
    (-> "project.clj" slurp read-string (nth 2))
    (-> (eval 'karmanaut.utils) .getPackage .getImplementationVersion)))

(defn utcnow []
  (Date.))

(defn long-to-date
  "Reddit timestamps are the number of seconds since the
  Unix epoch, in UTC."
  [epoch]
  (Date. (* 1000 (long epoch))))

(ns karmanaut.utils
  (:gen-class)
  (:require [clojure.java.io :as io])
  (:import [java.util Calendar
                      Date
                      GregorianCalendar
                      TimeZone]))

(defn env [key default]
  (get (System/getenv) key default))

(defn version []
  (if (.exists (io/as-file "project.clj"))
    (-> "project.clj" slurp read-string (nth 2))
    (-> (eval 'karmanaut.utils) .getPackage .getImplementationVersion)))

(defn utcnow []
  (Date.))

(defn utcnow-midnight []
  (let [tz (TimeZone/getTimeZone "UTC")
        c (GregorianCalendar. tz)]
    (doto c
      (.set Calendar/HOUR_OF_DAY 0)
      (.set Calendar/MINUTE 0)
      (.set Calendar/SECOND 0)
      (.set Calendar/MILLISECOND 0))
    (.getTime c)))

(defn long-to-date
  "Reddit timestamps are the number of seconds since the
  Unix epoch, in UTC."
  [epoch]
  (Date. (* 1000 (long epoch))))

utcnow-midnight: Return current time, UTC, floored to midnight


(defproject io.aviso/rook "0.1.8-SNAPSHOT"
  :description "Ruby on Rails-style resource mapping for Clojure/Compojure web apps"
  :url "https://github.com/AvisoNovate/rook"
  :license {:name "Apache Sofware License 2.0"
            :url  "http://www.apache.org/licenses/LICENSE-2.0.html"}
  ;; Normally we don't AOT compile; only when tracking down reflection warnings.
  :profiles {:reflection-warnings {:aot         :all
                                   :global-vars {*warn-on-reflection* true}}
             :dev {:dependencies [[ring-mock "0.1.5"]
                                  [io.aviso/pretty "0.1.10"]
                                  [speclj "2.5.0"]
                                  [log4j "1.2.17"]]}}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [org.clojure/core.async "0.1.267.0-0d7780-alpha"]
                 [org.clojure/tools.logging "0.2.6"]
                 [ring-middleware-format "0.3.2"]
                 [prismatic/schema "0.2.1"]
                 [compojure "1.1.6"]]
  :plugins [[test2junit "1.0.1"]
            [speclj "2.5.0"]]
  :test-paths ["spec"])

(defproject io.aviso/rook "0.1.8-SNAPSHOT"
  :description "Ruby on Rails-style resource mapping for Clojure/Compojure web apps"
  :url "https://github.com/AvisoNovate/rook"
  :license {:name "Apache Sofware License 2.0"
            :url  "http://www.apache.org/licenses/LICENSE-2.0.html"}
  ;; Normally we don't AOT compile; only when tracking down reflection warnings.
  :profiles {:reflection-warnings {:aot         :all
                                   :global-vars {*warn-on-reflection* true}}
             :dev {:dependencies [[ring-mock "0.1.5"]
                                  [io.aviso/pretty "0.1.10"]
                                  [speclj "2.9.1"]
                                  [log4j "1.2.17"]]}}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [org.clojure/core.async "0.1.267.0-0d7780-alpha"]
                 [org.clojure/tools.logging "0.2.6"]
                 [ring-middleware-format "0.3.2"]
                 [prismatic/schema "0.2.1"]
                 [compojure "1.1.6"]]
  :plugins [[test2junit "1.0.1"]
            [speclj "2.9.1"]]
  :test-paths ["spec"])

Update dependency to latest usable version


(defproject cli4clj "1.6.1"
;(defproject cli4clj "1.6.2-SNAPSHOT"
  :description "Create simple interactive CLIs for Clojure applications."
  :url "https://github.com/ruedigergad/cli4clj"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.9.0"]
                 [clj-assorted-utils "1.18.2"]
                 [org.clojure/core.async "0.4.474"]
                 [jline/jline "2.14.6"]]
  :global-vars {*warn-on-reflection* true}
  :html5-docs-docs-dir "ghpages/doc"
  :html5-docs-ns-includes #"^cli4clj.*"
  :html5-docs-repository-url "https://github.com/ruedigergad/cli4clj/blob/master"
  :test2junit-output-dir "ghpages/test-results"
  :test2junit-run-ant true
  :main cli4clj.example
  :plugins [[lein-cloverage "1.0.2"] [test2junit "1.3.3"] [lein-html5-docs "3.0.3"]]
  :profiles  {:repl  {:dependencies  [[jonase/eastwood "0.2.7" :exclusions  [org.clojure/clojure]]]}}
)

(defproject cli4clj "1.6.2"
;(defproject cli4clj "1.6.3-SNAPSHOT"
  :description "Create simple interactive CLIs for Clojure applications."
  :url "https://github.com/ruedigergad/cli4clj"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.9.0"]
                 [clj-assorted-utils "1.18.2"]
                 [org.clojure/core.async "0.4.474"]
                 [jline/jline "2.14.6"]]
  :global-vars {*warn-on-reflection* true}
  :html5-docs-docs-dir "ghpages/doc"
  :html5-docs-ns-includes #"^cli4clj.*"
  :html5-docs-repository-url "https://github.com/ruedigergad/cli4clj/blob/master"
  :test2junit-output-dir "ghpages/test-results"
  :test2junit-run-ant true
  :main cli4clj.example
  :plugins [[lein-cloverage "1.0.2"] [test2junit "1.3.3"] [lein-html5-docs "3.0.3"]]
  :profiles  {:repl  {:dependencies  [[jonase/eastwood "0.2.7" :exclusions  [org.clojure/clojure]]]}}
)

Update version info and deploy to clojars.


;(defproject cli4clj "1.3.2"
(defproject cli4clj "1.3.3-SNAPSHOT"
  :description "Create simple interactive CLIs for Clojure applications."
  :url "https://github.com/ruedigergad/cli4clj"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.9.0"]
                 [clj-assorted-utils "1.18.2"]
                 [org.clojure/core.async "0.3.443"]
                 [jline/jline "2.14.2"]]
  :global-vars {*warn-on-reflection* true}
  :html5-docs-docs-dir "ghpages/doc"
  :html5-docs-ns-includes #"^cli4clj.*"
  :html5-docs-repository-url "https://github.com/ruedigergad/cli4clj/blob/master"
  :test2junit-output-dir "ghpages/test-results"
  :test2junit-run-ant true
  :main cli4clj.example
  :plugins [[lein-cloverage "1.0.2"] [test2junit "1.3.3"] [lein-html5-docs "3.0.3"]]
  :profiles  {:repl  {:dependencies  [[jonase/eastwood "0.2.4" :exclusions  [org.clojure/clojure]]]}}
)

;(defproject cli4clj "1.3.2"
(defproject cli4clj "1.3.3-SNAPSHOT"
  :description "Create simple interactive CLIs for Clojure applications."
  :url "https://github.com/ruedigergad/cli4clj"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.9.0"]
                 [clj-assorted-utils "1.18.2"]
                 [org.clojure/core.async "0.3.465"]
                 [jline/jline "2.14.2"]]
  :global-vars {*warn-on-reflection* true}
  :html5-docs-docs-dir "ghpages/doc"
  :html5-docs-ns-includes #"^cli4clj.*"
  :html5-docs-repository-url "https://github.com/ruedigergad/cli4clj/blob/master"
  :test2junit-output-dir "ghpages/test-results"
  :test2junit-run-ant true
  :main cli4clj.example
  :plugins [[lein-cloverage "1.0.2"] [test2junit "1.3.3"] [lein-html5-docs "3.0.3"]]
  :profiles  {:repl  {:dependencies  [[jonase/eastwood "0.2.5" :exclusions  [org.clojure/clojure]]]}}
)

Update eastwood and core.async dependencies.


(defproject uxbox "0.1.0-SNAPSHOT"
  :description "UXBox client"
  :url "http://uxbox.github.io"
  :license {:name "" :url ""}

  :dependencies [[org.clojure/clojure "1.7.0" :scope "provided"]
                 [org.clojure/clojurescript "1.7.228" :scope "provided"]
                 [figwheel-sidecar "0.5.0-2" :scope "test"]

                 ;; runtime
                 [rum "0.6.0" :exclusions [sablono]]
                 [sablono "0.5.3"]
                 [cljsjs/react "0.14.3-0"]
                 [cljsjs/react-dom "0.14.3-1"]
                 [cljsjs/react-dom-server "0.14.3-0"]
                 [cljsjs/moment "2.10.6-0"]
                 [funcool/promesa "0.7.0"]
                 [funcool/beicon "0.5.1"]
                 [funcool/cats "1.2.1"]
                 [funcool/cuerdas "0.7.1"]
                 [funcool/hodgepodge "0.1.4"]
                 [bouncer "1.0.0"]
                 [bidi "1.21.0"]]

  :clean-targets ^{:protect false} ["resources/public/js" "target"]
  )

(defproject uxbox "0.1.0-SNAPSHOT"
  :description "UXBox client"
  :url "http://uxbox.github.io"
  :license {:name "" :url ""}
  :jvm-opts ["-Dclojure.compiler.direct-linking=true"]

  :dependencies [[org.clojure/clojure "1.8.0" :scope "provided"]
                 [org.clojure/clojurescript "1.7.228" :scope "provided"]
                 [figwheel-sidecar "0.5.0-2" :scope "test"]

                 ;; runtime
                 [rum "0.6.0" :exclusions [sablono]]
                 [sablono "0.5.3"]
                 [cljsjs/react "0.14.3-0"]
                 [cljsjs/react-dom "0.14.3-1"]
                 [cljsjs/react-dom-server "0.14.3-0"]
                 [cljsjs/moment "2.10.6-0"]
                 [funcool/promesa "0.7.0"]
                 [funcool/beicon "0.5.1"]
                 [funcool/cats "1.2.1"]
                 [funcool/cuerdas "0.7.1"]
                 [funcool/hodgepodge "0.1.4"]
                 [bouncer "1.0.0"]
                 [bidi "1.21.0"]]

  :clean-targets ^{:protect false} ["resources/public/js" "target"]
  )

Set clojure 1.8.0 as default clojure.

Set clojure 1.8.0 as default clojure.


(defproject com.hypirion/primes "0.2.0"
  :description "Fetch, locate and use prime numbers."
  :url "http://github.com/hyPiRion/primes"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.2.0"]]

  :warn-on-reflection true

  :source-paths ["src/clojure"]
  :java-source-paths ["src/java"]
  :javac-options ["-Xlint:unchecked"]
  :plugins [[codox "0.6.4"]]
  :codox {:output-dir "codox"})

(defproject com.hypirion/primes "0.3.0-SNAPSHOT"
  :description "Fetch, locate and use prime numbers."
  :url "http://github.com/hyPiRion/primes"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.2.0"]]

  :warn-on-reflection true

  :source-paths ["src/clojure"]
  :java-source-paths ["src/java"]
  :javac-options ["-Xlint:unchecked"]
  :plugins [[codox "0.6.4"]]
  :codox {:output-dir "codox"})

Bump to next version snapshot.

Bump to next version snapshot.


(defproject onyx-plugin/lein-template "0.8.2.5"
  :description "A Leiningen 2.0 template for new Onyx plugins"
  :url "http://github.com/MichaelDrogalis/onyx-plugin"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :repositories {"snapshots" {:url "https://clojars.org/repo"
                              :username :env
                              :password :env
                              :sign-releases false}
                 "releases" {:url "https://clojars.org/repo"
                             :username :env
                             :password :env
                             :sign-releases false}}
  :plugins [[lein-set-version "0.4.1"]]
  :profiles {:dev {:plugins [[lein-set-version "0.4.1"]
                             [lein-update-dependency "0.1.2"]
                             [lein-pprint "1.1.1"]]}}
  :eval-in-leiningen true)

(defproject onyx-plugin/lein-template "0.8.2.6-SNAPSHOT"
  :description "A Leiningen 2.0 template for new Onyx plugins"
  :url "http://github.com/MichaelDrogalis/onyx-plugin"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :repositories {"snapshots" {:url "https://clojars.org/repo"
                              :username :env
                              :password :env
                              :sign-releases false}
                 "releases" {:url "https://clojars.org/repo"
                             :username :env
                             :password :env
                             :sign-releases false}}
  :plugins [[lein-set-version "0.4.1"]]
  :profiles {:dev {:plugins [[lein-set-version "0.4.1"]
                             [lein-update-dependency "0.1.2"]
                             [lein-pprint "1.1.1"]]}}
  :eval-in-leiningen true)

Prepare for next release cycle.

Prepare for next release cycle.


(defproject strava-activity-graphs "0.1.0-SNAPSHOT"
  :description "Generate statistical charts for Strava activities"
  :url "https://github.com/nicokosi/strava-activity-graphs"
  :license {:name "Creative Commons Attribution 4.0"
            :url  "https://creativecommons.org/licenses/by/4.0/"}
  :dependencies [[org.clojure/clojure "1.10.2"]
                 [incanter/incanter-core "1.9.3"]
                 [incanter/incanter-charts "1.9.3"]
                 [incanter/incanter-io "1.9.3"]
                 [org.clojure/data.json "1.0.0"]
                 [clj-http "3.11.0"]
                 [slingshot "0.12.2"]]
  :plugins [[lein-cljfmt "0.7.0"]]
  :main ^:skip-aot strava-activity-graphs.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all}})

(defproject strava-activity-graphs "0.1.0-SNAPSHOT"
  :description "Generate statistical charts for Strava activities"
  :url "https://github.com/nicokosi/strava-activity-graphs"
  :license {:name "Creative Commons Attribution 4.0"
            :url  "https://creativecommons.org/licenses/by/4.0/"}
  :dependencies [[org.clojure/clojure "1.10.3"]
                 [incanter/incanter-core "1.9.3"]
                 [incanter/incanter-charts "1.9.3"]
                 [incanter/incanter-io "1.9.3"]
                 [org.clojure/data.json "1.0.0"]
                 [clj-http "3.11.0"]
                 [slingshot "0.12.2"]]
  :plugins [[lein-cljfmt "0.7.0"]]
  :main ^:skip-aot strava-activity-graphs.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all}})

Update dependency org.clojure:clojure to v1.10.3


(set-env!
 :source-paths #{"src"}
 :dependencies '[[org.clojure/clojure  "1.6.0" :scope "provided"]
                 [boot/core            "2.1.0" :scope "provided"]
                 [junit                "4.12"]
                 [org.reflections/reflections "0.9.10"]
                 [org.glassfish/javax.servlet "3.0"]])

(require '[radicalzephyr.boot-junit :refer [junit]])

(def +version+ "0.1.0")

(task-options!
 pom  {:project     'radicalzephyr/boot-junit
       :version     +version+
       :description "Run some jUnit tests in boot!"
       :url         "https://github.com/radicalzephyr/boot-junit"
       :scm         {:url "https://github.com/radicalzephyr/boot-junit"}
       :license     {"Eclipse Public License"
                     "http://www.eclipse.org/legal/epl-v10.html"}}
 junit {:packages '#{radicalzephyr.boot_junit.test}})

(set-env!
 :source-paths #{"src"}
 :dependencies '[[org.clojure/clojure         "1.6.0"  :scope "provided"]
                 [boot/core                   "2.1.0"  :scope "provided"]
                 [junit                       "4.12"   :scope "test"]
                 [org.reflections/reflections "0.9.10" :scope "test"]
                 [org.glassfish/javax.servlet "3.0"    :scope "test"]
                 [radicalzephyr/clansi        "1.2.0"  :scope "test"]])

(require '[radicalzephyr.boot-junit :refer [junit]])

(def +version+ "0.1.0")

(task-options!
 pom  {:project     'radicalzephyr/boot-junit
       :version     +version+
       :description "Run some jUnit tests in boot!"
       :url         "https://github.com/radicalzephyr/boot-junit"
       :scm         {:url "https://github.com/radicalzephyr/boot-junit"}
       :license     {"Eclipse Public License"
                     "http://www.eclipse.org/legal/epl-v10.html"}}
 junit {:packages '#{radicalzephyr.boot_junit.test}})

Add clansi as a dependency

Add clansi as a dependency


{
  :uberjar {
    :aot :all
  }
  :dev {
    :resource-paths ["src/dev/resources"]
    :source-paths ["src/dev/clj"]
    :dependencies [[org.clojure/tools.namespace "0.2.7"]]
    :env {:db-url "plocal:D:/temp/orientdb/dev"
          :db-admin-user nil
          :db-admin-pwd nil
          :bind 8081}
  }
  :test {
    :resource-paths ["src/dev/resources"]
    :dependencies [[clj-http "1.0.1"]]
    :env {:db-url "plocal:D:/temp/orientdb/test"
          :db-admin-user nil
          :db-admin-pwd nil
          :bind 8082}
  }
}

{
  :uberjar {
    :aot :all
  }
  :dev {
    :resource-paths ["src/dev/resources"]
    :source-paths ["src/dev/clj"]
    :dependencies [[org.clojure/tools.namespace "0.2.7"]]
    :env {:db-url "memory:devdb"
          :db-admin-user nil
          :db-admin-pwd nil
          :bind 8081}
  }
  :test {
    :resource-paths ["src/dev/resources"]
    :dependencies [[clj-http "1.0.1"]]
    :env {:db-url "memory:testdb"
          :db-admin-user nil
          :db-admin-pwd nil
          :bind 8082}
  }
}

Switch to in-memory database default for dev/test.


(ns clj-gatling.core
  (:import (org.joda.time LocalDateTime))
  (:require [clojure-csv.core :as csv]
            [clj-gatling.chart :as chart]
            [clj-gatling.report :as report]
            [clj-gatling.simulation :as simulation]))

(def results-dir "target/results")

(defn create-dir [dir]
  (.mkdirs (java.io.File. dir)))

(defn run-simulation [scenario users]
 (let [start-time (LocalDateTime.)
       result (simulation/run-simulation scenario users)
       csv (csv/write-csv (report/create-result-lines start-time result) :delimiter "\t" :end-of-line "\n")]
   (create-dir (str results-dir "/input"))
   (spit (str results-dir "/input/simulation.log") csv)
   (chart/create-chart results-dir)
   (println (str "Open " results-dir "/output/index.html"))))

(ns clj-gatling.core
  (:import (org.joda.time LocalDateTime))
  (:require [clojure-csv.core :as csv]
            [clj-gatling.chart :as chart]
            [clj-gatling.report :as report]
            [clj-gatling.simulation :as simulation]))

(defn create-dir [dir]
  (.mkdirs (java.io.File. dir)))

(defn run-simulation [scenario users & [options]]
 (let [start-time (LocalDateTime.)
       results-dir (if (nil? (:root options))
                      "target/results"
                      (:root options))
       result (simulation/run-simulation scenario users)
       csv (csv/write-csv (report/create-result-lines start-time result) :delimiter "\t" :end-of-line "\n")]
   (create-dir (str results-dir "/input"))
   (spit (str results-dir "/input/simulation.log") csv)
   (chart/create-chart results-dir)
   (println (str "Open " results-dir "/output/index.html"))))

Add possibility to configure root path via :root key


(ns metrics.test.test-utils
  (:import java.util.concurrent.TimeUnit))

(defn abs
  [n]
  (if (> n 0) n (* -1 n)))

(defn maps-within-one
  [a b]
  (when (= (set (keys a)) (set (keys b)))
    (every? identity
            (map #(within-one (a %) (b %))
                 (keys a)))))

(ns metrics.test.test-utils
  (:import java.util.concurrent.TimeUnit))

(defn abs
  [n]
  (if (> n 0) n (* -1 n)))

(defn within-one [a b]
  (<= (abs (- a b))
      1))

(defn within-ten [a b]
  (<= (abs (- a b))
      10))

(defn maps-within-one
  [a b]
  (when (= (set (keys a)) (set (keys b)))
    (every? identity
            (map #(within-one (a %) (b %))
                 (keys a)))))

Bring back some test helpers

Bring back some test helpers


#!/usr/bin/env boot

(set-env!
  :source-paths #{"less" "src"}
  :resource-paths #{"html" "resources"}
  :dependencies '[; Boot setup
                  [adzerk/boot-cljs "1.7.170-1"]
                  [adzerk/boot-reload "0.4.1"]
                  [deraen/boot-less "0.4.2"]
                  [pandeiro/boot-http "0.7.0-SNAPSHOT"]

                  ; App dependencies
                  [org.clojure/clojurescript "1.7.170"]
                  [org.omcljs/om "1.0.0-alpha18-SNAPSHOT"]

                  ; Other dependencies
                  [devcards "0.2.0-8"]])

(task-options!
  pom {:project "om-next-kanban-demo"
       :version "0.1.0-SNAPSHOT"})

(require '[adzerk.boot-cljs :refer [cljs]]
         '[adzerk.boot-reload :refer [reload]]
         '[deraen.boot-less :refer [less]]
         '[pandeiro.boot-http :refer [serve]])

(deftask run
  []
  (comp
    (watch)
    (speak)
    (reload :on-jsload 'kanban.app/run)
    (less)
    (cljs :source-map true
          :optimizations :none
          :compiler-options {:devcards true})
    (serve :dir "target")))

(deftask release
  []
  (comp
    (less :compression true)
    (cljs :optimizations :advanced
          :compiler-options {:devcards true})))

Add a "boot release" task to generate optimized JS/CSS


(ns leiningen.deps
  (:require [lancet])
  (:use [leiningen]
        [clojure.contrib.java-utils :only [file]])
  (:import [org.apache.maven.model Dependency]
           [org.apache.maven.artifact.ant DependenciesTask]
           [org.apache.tools.ant.util FlatFileNameMapper]))

(defn- make-dependency [[group name version]]
  (doto (Dependency.)
    (.setGroupId group)
    (.setArtifactId name)
    (.setVersion version)))

(defn deps
  "Install dependencies in lib/"
  [project & args]
  (let [deps-task (DependenciesTask.)]
    (.setBasedir lancet/ant-project (:root project))
    (.setFilesetId deps-task "dependency.fileset")
    (.setProject deps-task lancet/ant-project)
    (.setPathId deps-task (:name project))
    (doseq [dep (:dependencies project)]
      (.addDependency deps-task (make-dependency dep)))
    (.execute deps-task)
    (.mkdirs (file (:root project) "lib"))
    (lancet/copy {:todir "lib/"}
                 (.getReference lancet/ant-project
                                (.getFilesetId deps-task))
                 (FlatFileNameMapper.))))

(ns leiningen.deps
  (:require [lancet])
  (:use [clojure.contrib.java-utils :only [file]])
  (:import [org.apache.maven.model Dependency]
           [org.apache.maven.artifact.ant DependenciesTask]
           [org.apache.tools.ant.util FlatFileNameMapper]))

(defn- make-dependency [[group name version]]
  (doto (Dependency.)
    (.setGroupId group)
    (.setArtifactId name)
    (.setVersion version)))

(defn deps
  "Install dependencies in lib/"
  [project & args]
  (let [deps-task (DependenciesTask.)]
    (.setBasedir lancet/ant-project (:root project))
    (.setFilesetId deps-task "dependency.fileset")
    (.setProject deps-task lancet/ant-project)
    (.setPathId deps-task (:name project))
    (doseq [dep (:dependencies project)]
      (.addDependency deps-task (make-dependency dep)))
    (.execute deps-task)
    (.mkdirs (file (:root project) "lib"))
    (lancet/copy {:todir (str (:root project) "/lib/")}
                 (.getReference lancet/ant-project
                                (.getFilesetId deps-task))
                 (FlatFileNameMapper.))))

Fix dependency unpacking to use right directory.


(ns leiningen.ring
  (:use [leiningen.help :only (help-for subtask-help-for)]
        [leiningen.ring.server :only (server)]
        [leiningen.ring.server-headless :only (server-headless)]
        [leiningen.ring.war :only (war)]
        [leiningen.ring.uberwar :only (uberwar)]))

(defn ring
  "Manage a Ring-based application."
  {:help-arglists '([server server-headless war uberwar])
   :subtasks [#'server #'server-headless #'war #'uberwar]}
  ([project]
     (println (help-for "ring")))
  ([project subtask & args]
     (case subtask
       "server"          (apply server project args)
       "server-headless" (apply server-headless project args)
       "war"             (apply war project args)
       "uberwar"         (apply uberwar project args)
                         (println "Subtask" (str \" subtask \") "not found."
                                  (subtask-help-for *ns* #'ring)))))

(ns leiningen.ring
  (:use [leiningen.help :only (help-for subtask-help-for)]
        [leiningen.ring.server :only (server)]
        [leiningen.ring.server-headless :only (server-headless)]
        [leiningen.ring.war :only (war)]
        [leiningen.ring.uberwar :only (uberwar)]))

(defn- nary? [v n]
  (some #{n} (map count (:arglists (meta v)))))

(defn ring
  "Manage a Ring-based application."
  {:help-arglists '([server server-headless war uberwar])
   :subtasks [#'server #'server-headless #'war #'uberwar]}
  ([project]
     (println (if (nary? #'help-for 2)
                ;; lein2 help-for
                (help-for project "ring")
                (help-for "ring"))))
  ([project subtask & args]
     (case subtask
       "server"          (apply server project args)
       "server-headless" (apply server-headless project args)
       "war"             (apply war project args)
       "uberwar"         (apply uberwar project args)
                         (println "Subtask" (str \" subtask \") "not found."
                                  (subtask-help-for *ns* #'ring)))))

Fix help task for leiningen 2.0.

Fix help task for leiningen 2.0.


(set-env!
 :source-paths #{"src"}
 :resource-paths #{"src"}
 :dependencies '[[org.clojure/clojure     "1.6.0" :scope "provided"]
                 [boot/core               "2.1.0" :scope "provided"]
                 [junit                   "4.12"  :scope "test"]
                 [radicalzephyr/bootlaces "0.1.12"]])

(require '[radicalzephyr.bootlaces :refer :all]
         '[radicalzephyr.boot-junit :refer [junit]])

(def +version+ "0.2.1-SNAPSHOT")

(bootlaces! +version+)

(task-options!
 pom  {:project     'radicalzephyr/boot-junit
       :version     +version+
       :description "Run some jUnit tests in boot!"
       :url         "https://github.com/radicalzephyr/boot-junit"
       :scm         {:url "https://github.com/radicalzephyr/boot-junit"}
       :license     {"Eclipse Public License"
                     "http://www.eclipse.org/legal/epl-v10.html"}}
 junit {:packages '#{radicalzephyr.boot_junit.test}})

(set-env!
 :source-paths #{"src"}
 :resource-paths #{"src"}
 :dependencies '[[org.clojure/clojure     "1.6.0" :scope "provided"]
                 [boot/core               "2.1.0" :scope "provided"]
                 [junit                   "4.12"  :scope "test"]
                 [radicalzephyr/bootlaces "0.1.15-SNAPSHOT"]])

(require '[radicalzephyr.bootlaces :refer :all]
         '[radicalzephyr.boot-junit :refer [junit]])

(def +version+ "0.2.1-SNAPSHOT")

(bootlaces! +version+)

(task-options!
 pom  {:project     'radicalzephyr/boot-junit
       :version     +version+
       :description "Run some jUnit tests in boot!"
       :url         "https://github.com/radicalzephyr/boot-junit"
       :scm         {:url "https://github.com/radicalzephyr/boot-junit"}
       :license     {"Eclipse Public License"
                     "http://www.eclipse.org/legal/epl-v10.html"}}
 junit {:packages '#{radicalzephyr.boot_junit.test}})

Update to my latest and greatest bootlaces


(ns analyze-data.train-model
  (:require [analyze-data.naive-bayes.train :as naive-bayes]
            [analyze-data.serialize :refer [read-object write-object!]]))

(defmulti train-model
  "Train a model on a dataset.

  model-type: one of [:knn :naive-bayes]
  dataset: a dataset (e.g. produced by corpus-to-dataset)

  Return a model, which is a map with the following keys:
  :type       the type of the model
  :parameters the learned parameters of the model
  :dataset    the dataset the model was trained on"
  (fn [model-type dataset] model-type))

(defn train-model-file
  "Like train-model, but accepts a file name for input and output.

  model-type: type of model to create
  in: path to a dataset file
  out: path where the trained model will be written as a serialized map."
  [model-type in out]
  (let [dataset (read-object in)
        model (train-model model-type dataset)]
    (write-object! out model)))

(defmethod train-model :knn [model-type dataset]
  {:type model-type
   :parameters nil
   :dataset dataset})

(defmethod train-model :naive-bayes [model-type dataset]
  (let [{:keys [X y]} dataset]
    {:type model-type
     :parameters (naive-bayes/train X y)
     :dataset dataset}))

(ns analyze-data.train-model
  (:require [analyze-data.naive-bayes.train :as naive-bayes]
            [analyze-data.serialize :refer [read-object write-object!]]))

(defmulti train-model
  "Train a model on a dataset.

  model-type: one of [:knn :naive-bayes]
  dataset: a dataset (e.g. produced by corpus-to-dataset)

  Return a model, which is a map with the following keys:
  :type       the type of the model
  :parameters the learned parameters of the model
  :dataset    the dataset the model was trained on"
  (fn [model-type dataset] model-type))

(defn train-model-file!
  "Like train-model, but accepts a file name for input and output.

  model-type: type of model to create
  in: path to a dataset file
  out: path where the trained model will be written as a serialized map."
  [model-type in out]
  (let [dataset (read-object in)
        model (train-model model-type dataset)]
    (write-object! out model)))

(defmethod train-model :knn [model-type dataset]
  {:type model-type
   :parameters nil
   :dataset dataset})

(defmethod train-model :naive-bayes [model-type dataset]
  (let [{:keys [X y]} dataset]
    {:type model-type
     :parameters (naive-bayes/train X y)
     :dataset dataset}))

Add exclamation point to train-model-file\!


(ns rest.core
  (:require
    [ring.util.response :as resp]
    [compojure.handler :as handler]
    [compojure.core :refer [routes]]
    ; Auth
    [cemerick.friend :as friend]
    (cemerick.friend [credentials :as credentials]
                     [workflows :as workflows])
    [rest.auth.views :refer [unauthorized]]
    [rest.auth.services :refer [user]]
    ; Routes
    [rest.auth.routes :refer [auth-routes]]
    [rest.tasks.routes :refer [tasks-routes]]
    [rest.base.routes :refer [base-routes]]))

(def app-routes
 (routes auth-routes
         tasks-routes
         base-routes))

(def app
  (handler/site
    (friend/authenticate
      app-routes
      {:allow-anon? true
       :login-url "/login"
       :unauthorized-handler #(-> unauthorized
                                  resp/response
                                  (resp/status 401))
       :credential-fn #(credentials/bcrypt-credential-fn user %)
       :workflows [(workflows/interactive-form)]})))

(ns rest.core
  (:require
    [ring.util.response :as resp]
    [compojure.handler :as handler]
    [compojure.core :refer [routes]]
    ; Auth
    [cemerick.friend :as friend]
    (cemerick.friend [credentials :as credentials]
                     [workflows :as workflows])
    [rest.auth.views :refer [unauthorized]]
    [rest.auth.services :refer [user]]
    ; Routes
    [rest.auth.routes :refer [auth-routes]]
    [rest.tasks.routes :refer [tasks-routes]]
    [rest.base.routes :refer [base-routes]]))

(def app-routes
 (routes auth-routes
         tasks-routes
         base-routes))

(def app
  (handler/site
    (friend/authenticate
      app-routes
      {:allow-anon? true
       :login-url "/login"
       :default-landing-uri "/tasks"
       :unauthorized-handler #(-> unauthorized
                                  resp/response
                                  (resp/status 401))
       :credential-fn #(credentials/bcrypt-credential-fn user %)
       :workflows [(workflows/interactive-form)]})))

Use /tasks as the landing URI after login


(ns org.playasophy.wonderdome.input.gamepad-test
  (:require
    [clojure.core.async :as async :refer [<!]]
    [clojure.test :refer :all]
    [com.stuartsierra.component :as component]
    [org.playasophy.wonderdome.input.gamepad :as gamepad]))

(defn gamepad-test
  "Creates and starts a gamepad input component attached to a channel and reader
  which will print events received to the console."
  []
  (let [channel (async/chan (async/dropping-buffer 5))
        input (gamepad/snes channel)]
    (async/go-loop []
      (prn (<! channel))
      (recur))
    (component/start input)))

(ns org.playasophy.wonderdome.input.gamepad-test
  (:require
    [clojure.core.async :as async :refer [<!]]
    [clojure.test :refer :all]
    [com.stuartsierra.component :as component]
    [org.playasophy.wonderdome.input.gamepad :as gamepad]))

(defn gamepad-harness
  "Creates and starts a gamepad input component attached to a channel and reader
  which will print events received to the console."
  []
  (let [channel (async/chan (async/dropping-buffer 5))
        input (gamepad/snes channel)]
    (async/go-loop []
      (prn (<! channel))
      (recur))
    (component/start input)))

Change gamepad test function to specify 'harness'.


(defproject robb1e "0.1.0-SNAPSHOT"
  :description "Personal website for robb1e"
  :url "https://github.com/robb1e/robb1e.clj"
  :min-lein-version "2.0.0"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [ring/ring-jetty-adapter "1.2.1"]
                 [hiccup "1.0.4"]
                 [compojure "1.1.6"]
                 [org.clojure/java.jdbc "0.3.2"]
                 [postgresql "9.1-901.jdbc4"]
                 [clj-time "0.6.0"]]
  :plugins [[lein-haml-sass "0.2.7-SNAPSHOT"]]
  :sass {:src "resources/sass"
         :output-directory "resources/public/stylesheets"
         :output-extension "css"
         ;; Other options (provided are default values)
         ;; :auto-compile-delay 250
         ;; :delete-output-dir true ;; -> when running lein clean it will delete the output directory if it does not contain any file
         ;; :ignore-hooks [:clean :compile :deps] ;; -> if you use the hooks, this option allows you to remove some hooks that you don't want to run
         ;; :gem-version "3.2.1"
         }
  )

(defproject robb1e "0.1.0-SNAPSHOT"
  :description "Personal website for robb1e"
  :url "https://github.com/robb1e/robb1e.clj"
  :min-lein-version "2.0.0"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [ring/ring-jetty-adapter "1.2.1"]
                 [hiccup "1.0.4"]
                 [compojure "1.1.6"]
                 [org.clojure/java.jdbc "0.3.2"]
                 [postgresql "9.1-901.jdbc4"]
                 [clj-time "0.6.0"]]
  :main robb1e.web
  :plugins [[lein-haml-sass "0.2.7-SNAPSHOT"]]
  :sass {:src "resources/sass"
         :output-directory "resources/public/stylesheets"
         :output-extension "css"
         ;; Other options (provided are default values)
         ;; :auto-compile-delay 250
         ;; :delete-output-dir true ;; -> when running lein clean it will delete the output directory if it does not contain any file
         ;; :ignore-hooks [:clean :compile :deps] ;; -> if you use the hooks, this option allows you to remove some hooks that you don't want to run
         ;; :gem-version "3.2.1"
         }
  )

Set main namespace (for `lein run`)

Set main namespace (for `lein run`)


(defproject foreclojure "0.1.0-SNAPSHOT"
  :description "4clojure - a website for lisp beginners"
  :dependencies [[org.clojure/clojure "1.2.1"]
                 [org.clojure/clojure-contrib "1.2.0"]
                 [compojure "0.6.2"]
                 [hiccup "0.2.4"]
                 [clojail "0.4.0-SNAPSHOT"]
                 [sandbar "0.4.0-SNAPSHOT"]
                 [congomongo "0.1.3-SNAPSHOT"]
                 [org.jasypt/jasypt "1.7"]
                 [amalloy/utils "[0.3.7,)"]
                 [clj-github "1.0.0-SNAPSHOT"]]
  :dev-dependencies [[lein-ring "0.4.0"]
                     [swank-clojure "1.2.1"]]
  :main foreclojure.core
  :ring {:handler foreclojure.core/app})

(defproject foreclojure "0.0.2"
  :description "4clojure - a website for lisp beginners"
  :dependencies [[org.clojure/clojure "1.2.1"]
                 [org.clojure/clojure-contrib "1.2.0"]
                 [compojure "0.6.2"]
                 [hiccup "0.2.4"]
                 [clojail "0.4.0-SNAPSHOT"]
                 [sandbar "0.4.0-SNAPSHOT"]
                 [congomongo "0.1.3-SNAPSHOT"]
                 [org.jasypt/jasypt "1.7"]
                 [amalloy/utils "[0.3.7,)"]
                 [clj-github "1.0.0-SNAPSHOT"]]
  :dev-dependencies [[lein-ring "0.4.0"]
                     [swank-clojure "1.2.1"]]
  :main foreclojure.core
  :ring {:handler foreclojure.core/app})

Set version number for release

Set version number for release


(defproject java-s3-tests/java-s3-tests "0.0.1"
  :dependencies [[org.clojure/clojure "1.4.0"]
                 [com.amazonaws/aws-java-sdk "1.3.11"]
                 [com.reiddraper/clj-aws-s3 "0.4.0"]
                 [commons-codec/commons-codec "1.6"]
                 [clj-http "0.4.3"]
                 [cheshire "4.0.0"]]
  :profiles {:dev {:dependencies [[midje "1.4.0"]]}}
  :min-lein-version "2.0.0"
  :plugins [[lein-midje "2.0.1"]]
  :description "integration tests for Riak CS using the offical Java SDK")

(defproject java-s3-tests/java-s3-tests "0.0.1"
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [com.reiddraper/clj-aws-s3 "0.4.0"]
                 [clj-http "0.7.1"]
                 [cheshire "5.1.0"]]
  :profiles {:dev {:dependencies [[midje "1.5.1"]]}}
  :min-lein-version "2.0.0"
  :plugins [[lein-midje "3.0.1"]]
  :description "integration tests for Riak CS using the offical Java SDK")

Update dependencies to latest versions

Update dependencies to latest versions


(ns circle.workers.test-github
  (:use circle.backend.build.test-utils)
  (:require [circle.model.build :as build])
  (:use [circle.util.mongo])
  (:require [somnium.congomongo :as mongo])
  (:use midje.sweet)
  (:use circle.workers.github))

(test-ns-setup)

(fact "start-build-from-hook works with dummy project"
  (let [json circle-dummy-project-json-str
        id (object-id)
        _   (mongo/insert! :builds {:_id id})
        build (start-build-from-hook nil nil nil json (str id))]
    (-> @build :vcs_url) => truthy
    (-> build (build/successful?)) => true
    (-> @build :build_num) => integer?
    (-> @build :_id) => id))

(fact "authorization-url works"
  (-> "http://localhost:3000/hooks/repos" authorization-url) =>
  "https://github.com/login/oauth/authorize?client_id=586bf699b48f69a09d8c&scope=repo&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fhooks%2Frepos")

(ns circle.workers.test-github
  (:use circle.backend.build.test-utils)
  (:require [circle.model.build :as build])
  (:use [circle.util.mongo])
  (:require [somnium.congomongo :as mongo])
  (:use midje.sweet)
  (:use circle.workers.github))

(test-ns-setup)

(fact "start-build-from-hook works with dummy project"
  (let [json circle-dummy-project-json-str
        id (object-id)
        _   (mongo/insert! :builds {:_id id})
        build (start-build-from-hook nil nil nil json (str id))]
    (-> @build :vcs_url) => truthy
    (-> build (build/successful?)) => true
    (-> @build :build_num) => integer?
    (-> @build :_id) => id))

(fact "authorization-url works"
  (-> "http://localhost:3000/hooks/repos" authorization-url) =>
  "https://github.com/login/oauth/authorize?client_id=586bf699b48f69a09d8c&scope=repo&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fhooks%2Frepos"
  (provided (circle.env/env) => :test))

Fix the test to not depend on the current process's env