diff --git a/project.clj b/project.clj index 5d8bf0a..e514733 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject functional-koans "0.1.0" +(defproject functional-koans "0.2.0" :description "The functional koans" :dependencies [[org.clojure/clojure "1.3.0-alpha3"] [jline "0.9.94"]]) diff --git a/src/path_to_enlightenment.clj b/src/path_to_enlightenment.clj index 13408d3..a65f9ed 100644 --- a/src/path_to_enlightenment.clj +++ b/src/path_to_enlightenment.clj @@ -1,6 +1,7 @@ (ns path-to-enlightenment (:use [clojure.test]) - (:require [clojure.set])) + (:require [clojure.set] + [clojure.string])) (def __ nil) (def ___ (fn [& args] nil)) @@ -37,7 +38,20 @@ (throw (Exception. (str "Clojure version " required-major "." required-minor " or higher required.")))))) +(defn parse-required-version [] + (let [rdr (clojure.lang.LineNumberingPushbackReader. + (java.io.FileReader. (java.io.File. "project.clj"))) + project-form (read rdr) + version-string (->> project-form + (drop 3) + (apply hash-map) + :dependencies + (into {}) + ('org.clojure/clojure))] + (map read-string + (take 3 (clojure.string/split version-string #"[\.\-]"))))) + (defn run [] - (require-version [1 3]) + (require-version (parse-required-version)) (apply load (doall (map (partial str "koans/") ordered-koans))) (println "You have achieved clojure enlightenment. Namaste."))