Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/duct/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -119,7 +120,7 @@

#duct/env
: an environment variable, see [[duct.core.env/env]]

#duct/include
: substitute for a configuration on the classpath

Expand Down
15 changes: 9 additions & 6 deletions test/duct/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 2 additions & 1 deletion test/duct/readers.edn
Original file line number Diff line number Diff line change
Expand Up @@ -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"}