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