File tree Expand file tree Collapse file tree 3 files changed +16
-10
lines changed
Expand file tree Collapse file tree 3 files changed +16
-10
lines changed Original file line number Diff line number Diff line change 1111 [duct.core.resource :as resource]
1212 [integrant.core :as ig]
1313 [medley.core :as m]
14- [clojure.walk :as walk]))
14+ [clojure.walk :as walk])
15+ (:import [java.util.regex Pattern]))
1516
1617(def target-path
1718 " A path to place generated files in. Typically used by compilers. Can be set
110111 (merge
111112 {'duct/env env/env
112113 'duct/include (make-include readers)
113- 'duct/resource resource}
114+ 'duct/resource resource
115+ 'duct/regex #(Pattern/compile %)}
114116 readers))
115117
116118(defn read-config
119121
120122 #duct/env
121123 : an environment variable, see [[duct.core.env/env]]
122-
124+
123125 #duct/include
124126 : substitute for a configuration on the classpath
125127
Original file line number Diff line number Diff line change 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))
Original file line number Diff line number Diff line change 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" }
You can’t perform that action at this time.
0 commit comments