mob4
This commit is contained in:
parent
c4e1539958
commit
370eb687c7
1 changed files with 16 additions and 7 deletions
|
@ -1,6 +1,9 @@
|
||||||
(ns dda.c4k-common.common
|
(ns dda.c4k-common.common
|
||||||
(:require
|
(:require
|
||||||
[clojure.walk]))
|
[clojure.walk]
|
||||||
|
[orchestra.core :refer [defn-spec]]
|
||||||
|
[dda.c4k-common.predicate :as cp]))
|
||||||
|
|
||||||
|
|
||||||
;; deprecated functions were moved to dda.c4k-common.predicate
|
;; deprecated functions were moved to dda.c4k-common.predicate
|
||||||
(defn ^{:deprecated "0.1"} bash-env-string?
|
(defn ^{:deprecated "0.1"} bash-env-string?
|
||||||
|
@ -17,24 +20,30 @@
|
||||||
[input]
|
[input]
|
||||||
(contains? #{:prod :staging} input))
|
(contains? #{:prod :staging} input))
|
||||||
|
|
||||||
(defn replace-named-value
|
(defn-spec replace-named-value cp/map-or-seq?
|
||||||
[coll name value]
|
[coll cp/map-or-seq?
|
||||||
|
name string?
|
||||||
|
value string?]
|
||||||
(clojure.walk/postwalk #(if (and (map? %)
|
(clojure.walk/postwalk #(if (and (map? %)
|
||||||
(= name (:name %)))
|
(= name (:name %)))
|
||||||
{:name name :value value}
|
{:name name :value value}
|
||||||
%)
|
%)
|
||||||
coll))
|
coll))
|
||||||
|
|
||||||
(defn replace-key-value
|
(defn-spec replace-key-value cp/map-or-seq?
|
||||||
[coll key value]
|
[coll cp/map-or-seq?
|
||||||
|
key keyword?
|
||||||
|
value string?]
|
||||||
(clojure.walk/postwalk #(if (and (map? %)
|
(clojure.walk/postwalk #(if (and (map? %)
|
||||||
(contains? % key))
|
(contains? % key))
|
||||||
(assoc % key value)
|
(assoc % key value)
|
||||||
%)
|
%)
|
||||||
coll))
|
coll))
|
||||||
|
|
||||||
(defn replace-all-matching-values-by-new-value
|
(defn-spec replace-all-matching-values-by-new-value cp/map-or-seq?
|
||||||
[coll value-to-match value-to-replace]
|
[coll string?
|
||||||
|
value-to-match string?
|
||||||
|
value-to-replace string?]
|
||||||
(clojure.walk/postwalk #(if (and (= (type value-to-match) (type %))
|
(clojure.walk/postwalk #(if (and (= (type value-to-match) (type %))
|
||||||
(= value-to-match %))
|
(= value-to-match %))
|
||||||
value-to-replace
|
value-to-replace
|
||||||
|
|
Loading…
Reference in a new issue