cryogen-core/src/cryogen_core/plugins.clj

19 lines
668 B
Clojure
Raw Normal View History

2015-01-15 01:49:51 +00:00
(ns cryogen-core.plugins
(:require [cryogen-core.compiler :refer [compile-assets-timed]]
[clojure.edn :as edn]
[clojure.string :as s]
2015-01-15 01:49:51 +00:00
[text-decoration.core :refer :all]))
(defn load-plugin [url]
(let [{:keys [description init]} (edn/read-string (slurp url))]
(println (green (str "loading module: " description)))
(-> init str (s/split #"/") first symbol require)
((resolve init))))
2015-01-15 01:49:51 +00:00
(defn load-plugins []
(let [plugins (.getResources (ClassLoader/getSystemClassLoader) "plugin.edn")]
(loop []
(load-plugin (.. plugins nextElement openStream))
(when (.hasMoreElements plugins)
(recur)))))