Skip to content

Commit 6ccb1ac

Browse files
committed
Add :duct/regex reader tag
1 parent c5fb68a commit 6ccb1ac

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

src/duct/core.clj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@
110110
(merge
111111
{'duct/env env/env
112112
'duct/include (make-include readers)
113-
'duct/resource resource}
113+
'duct/resource resource
114+
'duct/regex re-pattern}
114115
readers))
115116

116117
(defn read-config
@@ -119,7 +120,7 @@
119120
120121
#duct/env
121122
: an environment variable, see [[duct.core.env/env]]
122-
123+
123124
#duct/include
124125
: substitute for a configuration on the classpath
125126

test/duct/core_test.clj

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,15 @@
4848
{::a {:x 1}} {::a (ig/refset ::b)} {::a (ig/refset ::b)}))
4949

5050
(deftest test-read-config
51-
(is (= (core/read-config (io/resource "duct/readers.edn") {'custom/bar (fn [x] {:x x})})
52-
{:foo/a {:x "bar"}
53-
:foo/b {:bar/a {:x 1}, :bar/b (ig/ref :bar/a) :bar/c {:baz/a {:x 1}}}
54-
:foo/c (core/resource "duct/config.edn")
55-
:foo/d (ig/ref :foo/a)
56-
:foo/e (ig/refset :foo/b)})))
51+
(let [config (core/read-config (io/resource "duct/readers.edn") {'custom/bar (fn [x] {:x x})})]
52+
(is (= (dissoc config :foo/f)
53+
{:foo/a {:x "bar"}
54+
:foo/b {:bar/a {:x 1}, :bar/b (ig/ref :bar/a) :bar/c {:baz/a {:x 1}}}
55+
:foo/c (core/resource "duct/config.edn")
56+
:foo/d (ig/ref :foo/a)
57+
:foo/e (ig/refset :foo/b)}))
58+
(is (= (.pattern (:foo/f config))
59+
"baz"))))
5760

5861
(defmethod ig/init-key ::foo [_ {:keys [x]}]
5962
#(update % ::x (fnil conj []) x))

test/duct/readers.edn

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
:foo/b #duct/include "duct/config.edn"
33
:foo/c #duct/resource "duct/config.edn"
44
:foo/d #ig/ref :foo/a
5-
:foo/e #ig/refset :foo/b}
5+
:foo/e #ig/refset :foo/b
6+
:foo/f #duct/regex "baz"}

0 commit comments

Comments
 (0)