Skip to content

Commit

Permalink
Change #ref tag to #ig/ref (fixes #12)
Browse files Browse the repository at this point in the history
  • Loading branch information
weavejester committed Apr 21, 2017
1 parent 804f546 commit 70bb134
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ For example:
Alternatively, you can specify your configuration as pure edn:

```edn
{:adapter/jetty {:port 8080, :handler #ref :handler/greet}
{:adapter/jetty {:port 8080, :handler #ig/ref :handler/greet}
:handler/greet {:name "Alice"}}
```

Expand Down Expand Up @@ -274,8 +274,8 @@ parent:
You could then write a configuration like:

```edn
{:example/web-1 {:port 8080, :handler #ref :handler/greet}
:example/web-2 {:port 8081, :handler #ref :handler/greet}
{:example/web-1 {:port 8080, :handler #ig/ref :handler/greet}
:example/web-2 {:port 8081, :handler #ig/ref :handler/greet}
:handler/greet {:name "Alice"}}
```

Expand All @@ -286,8 +286,8 @@ treats it as being derived from all the keywords inside it.
So your could also write:

```edn
{[:adapter/jetty :example/web-1] {:port 8080, :handler #ref :handler/greet}
[:adapter/jetty :example/web-2] {:port 8081, :handler #ref :handler/greet}
{[:adapter/jetty :example/web-1] {:port 8080, :handler #ig/ref :handler/greet}
[:adapter/jetty :example/web-2] {:port 8081, :handler #ig/ref :handler/greet}
:handler/greet {:name "Alice"}}
```

Expand Down
4 changes: 2 additions & 2 deletions src/integrant/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@
#?(:clj
(defn read-string
"Read a config from a string of edn. Refs may be denotied by tagging keywords
with #ref."
with #ig/ref."
([s]
(read-string {:eof nil} s))
([opts s]
(let [readers (merge {'ref ref} (:readers opts {}))]
(let [readers (merge {'ig/ref ref} (:readers opts {}))]
(edn/read-string (assoc opts :readers readers) s)))))

#?(:clj
Expand Down
5 changes: 3 additions & 2 deletions test/integrant/core_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@

#?(:clj
(deftest read-string-test
(is (= (ig/read-string "{:foo/a #ref :foo/b, :foo/b 1}")
(is (= (ig/read-string "{:foo/a #ig/ref :foo/b, :foo/b 1}")
{:foo/a (ig/ref :foo/b), :foo/b 1}))
(is (= (ig/read-string {:readers {'var find-var}} "{:foo/a #var clojure.core/+}")
(is (= (ig/read-string {:readers {'test/var find-var}}
"{:foo/a #test/var clojure.core/+}")
{:foo/a #'+}))))

#?(:clj
Expand Down

0 comments on commit 70bb134

Please sign in to comment.