mob
parent
d270dfcbd0
commit
86b6e890cf
@ -1,17 +1,21 @@
|
||||
(ns dda.c4k-common.yaml
|
||||
(:require
|
||||
["js-yaml" :as yaml]
|
||||
[clojure.string :as st]))
|
||||
[clojure.string :as st]
|
||||
[orchestra.core :refer-macros [defn-spec]]
|
||||
[dda.c4k-common.predicate :as cp]))
|
||||
|
||||
(defn from-string [input]
|
||||
(defn-spec from-string cp/map-or-seq?
|
||||
[input string?]
|
||||
(js->clj (yaml/load input)
|
||||
:keywordize-keys true))
|
||||
|
||||
(defn to-string [edn]
|
||||
(defn-spec to-string string?
|
||||
[edn cp/map-or-seq?]
|
||||
(yaml/dump (clj->js edn)))
|
||||
|
||||
(defn dispatch-by-resource-name
|
||||
[resource]
|
||||
(defn-spec dispatch-by-resource-name keyword?
|
||||
[resource string?]
|
||||
(keyword (first (st/split resource #"/"))))
|
||||
|
||||
(defmulti load-resource dispatch-by-resource-name)
|
||||
|
Loading…
Reference in New Issue