Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

The Dojo

sritchie edited this page · 1 revision

By default, koans are executed in a bare namespace with clojure.core, the meditations macro, and the __ and ___ symbols. Most koan projects will need to customize this namespace to make APIs and custom functions available.

To do this, simply add code forms to resources/dojo.clj. Each of these forms will be evaluated before every koan. Here's the dojo for the Cascalog-Koans:

;; in resources/dojo.clj
(use 'cascalog.api
     '[cascalog.testing :only (test?-)]
     '[cascalog.util :only (defalias)])

(defalias ?= test?-)

This dojo makes the cascalog API available, along with a custom equality operator that doesn't exist in the API but made koans very concise. Now koans of this form will run just fine:

"Some queries transform nothing."
(?= __ (<- [?x] ([["tuple."]] ?x))

You can customize the :dojo-resource sub-path and name inside of resources by tweaking its entry in project.clj, as discussed above:

:koan {:dojo-resource "helpers/dojo_file.clj"} ;; dojo located at resources/helpers/dojo_file.clj
Something went wrong with that request. Please try again.