-
Notifications
You must be signed in to change notification settings - Fork 11
The Dojo
sritchie edited this page Nov 28, 2011
·
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