config secured configuration

Author: Chris Zheng  (z@caudate.me)
Date: 27 November 2018
Repository: https://github.com/zcaudate/hara
Version: 3.0.2

1    Introduction

hara.config allows flexible construction of configuration files.

1.1    Installation

Add to project.clj dependencies:

[hara/config "3.0.2"]

All functions are in the hara.config namespace.

 (use (quote hara.config))

2    API



global ^

returns the entire global map

v 3.0
(defn global
  ([]
   (global :all))
  ([k]
   (global k {:cached false}))
  ([k {:keys [cached]}]
   (if-let [prop (and cached
                      (get @+cache k))]
     prop
     (let [prop ((get +global+ k))]
       (swap! +cache assoc k prop)
       prop))))
link
(global :all)

load ^

helper function for file resolvers

v 3.0
(defn load
  ([]
   (load +config+))
  ([file]
   (resolve (read-string (slurp file)))))
link
(load "dev/test/hara.config/config.edn") => map?

resolve ^

helper function for resolve

v 3.0
(defn resolve
  ([form]
   (prewalk (fn [form]
              (if (directive? form)
                (resolve-directive form)
                form))
            form)))
link
(resolve 1) => 1 (resolve [:str ["hello" " " "there"]]) => "hello there"