removing tools.macro dependency
This commit is contained in:
parent
fd4d846c3f
commit
ef735d7ccb
3 changed files with 31 additions and 3 deletions
|
|
@ -6,8 +6,7 @@
|
||||||
|
|
||||||
:source-paths ["src"]
|
:source-paths ["src"]
|
||||||
|
|
||||||
:dependencies [[org.clojure/clojure "1.7.0"]
|
:dependencies [[org.clojure/clojure "1.7.0"]]
|
||||||
[org.clojure/tools.macro "0.1.2"]]
|
|
||||||
|
|
||||||
:profiles {:dev {:source-paths ["dev" "test/app"]
|
:profiles {:dev {:source-paths ["dev" "test/app"]
|
||||||
:dependencies [[yesql "0.5.1"]
|
:dependencies [[yesql "0.5.1"]
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
(ns mount.core
|
(ns mount.core
|
||||||
(:require [clojure.tools.macro :as macro]))
|
(:require [mount.tools.macro :as macro]))
|
||||||
|
|
||||||
(defonce ^:private mount-state 42)
|
(defonce ^:private mount-state 42)
|
||||||
(defonce ^:private -args (atom :no-args)) ;; mostly for command line args and external files
|
(defonce ^:private -args (atom :no-args)) ;; mostly for command line args and external files
|
||||||
|
|
|
||||||
29
src/mount/tools/macro.clj
Normal file
29
src/mount/tools/macro.clj
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
(ns mount.tools.macro)
|
||||||
|
|
||||||
|
;; this is a one to one copy from https://github.com/clojure/tools.macro
|
||||||
|
;; to avoid a lib dependency for a single function
|
||||||
|
|
||||||
|
(defn name-with-attributes
|
||||||
|
"To be used in macro definitions.
|
||||||
|
Handles optional docstrings and attribute maps for a name to be defined
|
||||||
|
in a list of macro arguments. If the first macro argument is a string,
|
||||||
|
it is added as a docstring to name and removed from the macro argument
|
||||||
|
list. If afterwards the first macro argument is a map, its entries are
|
||||||
|
added to the name's metadata map and the map is removed from the
|
||||||
|
macro argument list. The return value is a vector containing the name
|
||||||
|
with its extended metadata map and the list of unprocessed macro
|
||||||
|
arguments."
|
||||||
|
[name macro-args]
|
||||||
|
(let [[docstring macro-args] (if (string? (first macro-args))
|
||||||
|
[(first macro-args) (next macro-args)]
|
||||||
|
[nil macro-args])
|
||||||
|
[attr macro-args] (if (map? (first macro-args))
|
||||||
|
[(first macro-args) (next macro-args)]
|
||||||
|
[{} macro-args])
|
||||||
|
attr (if docstring
|
||||||
|
(assoc attr :doc docstring)
|
||||||
|
attr)
|
||||||
|
attr (if (meta name)
|
||||||
|
(conj (meta name) attr)
|
||||||
|
attr)]
|
||||||
|
[(with-meta name attr) macro-args]))
|
||||||
Loading…
Reference in a new issue