diff --git a/src/duct/core.clj b/src/duct/core.clj index 8f2f153..3bc6a4e 100644 --- a/src/duct/core.clj +++ b/src/duct/core.clj @@ -110,7 +110,8 @@ (merge {'duct/env env/env 'duct/include (make-include readers) - 'duct/resource resource} + 'duct/resource resource + 'duct/regex re-pattern} readers)) (defn read-config @@ -119,7 +120,7 @@ #duct/env : an environment variable, see [[duct.core.env/env]] - + #duct/include : substitute for a configuration on the classpath diff --git a/test/duct/core_test.clj b/test/duct/core_test.clj index 5d58b14..fa8b130 100644 --- a/test/duct/core_test.clj +++ b/test/duct/core_test.clj @@ -48,12 +48,15 @@ {::a {:x 1}} {::a (ig/refset ::b)} {::a (ig/refset ::b)})) (deftest test-read-config - (is (= (core/read-config (io/resource "duct/readers.edn") {'custom/bar (fn [x] {:x x})}) - {:foo/a {:x "bar"} - :foo/b {:bar/a {:x 1}, :bar/b (ig/ref :bar/a) :bar/c {:baz/a {:x 1}}} - :foo/c (core/resource "duct/config.edn") - :foo/d (ig/ref :foo/a) - :foo/e (ig/refset :foo/b)}))) + (let [config (core/read-config (io/resource "duct/readers.edn") {'custom/bar (fn [x] {:x x})})] + (is (= (dissoc config :foo/f) + {:foo/a {:x "bar"} + :foo/b {:bar/a {:x 1}, :bar/b (ig/ref :bar/a) :bar/c {:baz/a {:x 1}}} + :foo/c (core/resource "duct/config.edn") + :foo/d (ig/ref :foo/a) + :foo/e (ig/refset :foo/b)})) + (is (= (.pattern (:foo/f config)) + "baz")))) (defmethod ig/init-key ::foo [_ {:keys [x]}] #(update % ::x (fnil conj []) x)) diff --git a/test/duct/readers.edn b/test/duct/readers.edn index c93fcfb..dc691ee 100644 --- a/test/duct/readers.edn +++ b/test/duct/readers.edn @@ -2,4 +2,5 @@ :foo/b #duct/include "duct/config.edn" :foo/c #duct/resource "duct/config.edn" :foo/d #ig/ref :foo/a - :foo/e #ig/refset :foo/b} + :foo/e #ig/refset :foo/b + :foo/f #duct/regex "baz"}