   (:require [circle.ruby :as ruby])
   (:use [clojure.tools.logging :only (info)])
   (:use [circle.util.straight-jacket])
+  (:use [circle.util.predicates :only (ref?)])
   (:require [clipchat.rooms])
   (:require [circle.model.build :as build])
   (:require [circle.model.project :as project])

  (let [build (ruby/->instance :Build @build)
        class (ruby/get-class :SimpleMailer)]
    (assert build)
    (ruby/send class :post_build_email_hook build)))

(defn build-message [build]
  (ruby/send (ruby/->instance :Build build) :as_email_subject))

(defn github-project-name [project]
  (ruby/send (ruby/->instance :Project project) :github_project_name))


(defn send-hipchat-build-notification [build]
  (let [project (build/get-project build)
        message (build-message build)
        url (build-url build)
        message (format "<a href='%s'>%s</a>" url message)
        success? (-> @build :failed not)
        color (if success? :green :red)]
