2015-01-15 01:49:51 +00:00
|
|
|
(ns cryogen-core.plugins
|
2017-01-16 07:37:19 +00:00
|
|
|
(:require [clojure.edn :as edn]
|
2015-01-15 03:07:51 +00:00
|
|
|
[clojure.string :as s]
|
2015-01-15 01:49:51 +00:00
|
|
|
[text-decoration.core :refer :all]))
|
|
|
|
|
2015-09-14 10:06:35 +00:00
|
|
|
(defn load-plugin [^java.net.URL url]
|
2015-01-15 03:07:51 +00:00
|
|
|
(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")]
|
2015-09-20 20:52:51 +00:00
|
|
|
(doseq [plugin (enumeration-seq plugins)]
|
|
|
|
(load-plugin (. ^java.net.URL plugin openStream)))))
|