* add crispin to lib tests and projects.md * add a missing line in crispin example
This commit is contained in:
parent
4c0578c56c
commit
b53be25b94
6 changed files with 59 additions and 1 deletions
3
deps.edn
3
deps.edn
|
|
@ -81,7 +81,8 @@
|
|||
rm-hull/jasentaa {:mvn/version "0.2.5"}
|
||||
slingshot/slingshot {:mvn/version "0.12.2"}
|
||||
io.replikativ/hasch {:mvn/version "0.3.7"}
|
||||
com.grammarly/omniconf {:mvn/version "0.4.3"}}
|
||||
com.grammarly/omniconf {:mvn/version "0.4.3"}
|
||||
crispin/crispin {:mvn/version "0.3.8"}}
|
||||
:classpath-overrides {org.clojure/clojure nil
|
||||
org.clojure/spec.alpha nil
|
||||
org.clojure/core.specs.alpha nil}}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,9 @@ The following libraries and projects are known to work with babashka.
|
|||
- [rewrite-edn](#rewrite-edn)
|
||||
- [expound](#expound)
|
||||
- [omniconf](#omniconf)
|
||||
- [slingshot](#slingshot)
|
||||
- [hasch](#hasch)
|
||||
- [crispin](#crispin)
|
||||
- [Pods](#pods)
|
||||
- [Projects](#projects-1)
|
||||
- [babashka-test-action](#babashka-test-action)
|
||||
|
|
@ -598,6 +601,33 @@ NOTE: hasch's tests pass with babashka except the test around hashing
|
|||
records. This is due to a difference in how records are implemented in
|
||||
babashka. This may be fixed later if this turns out to be really useful.
|
||||
|
||||
### [crispin](https://github.com/dunaj-project/crispin)
|
||||
|
||||
Populate a configuration map from multiple sources (environment variables,
|
||||
system variables, config files, etc.)
|
||||
|
||||
Example:
|
||||
|
||||
script.clj
|
||||
``` clojure
|
||||
#!/usr/bin/env bb
|
||||
|
||||
(ns script
|
||||
(:require [babashka.deps :as deps]))
|
||||
|
||||
(deps/add-deps
|
||||
'{:deps {crispin/crispin {:mvn/version "0.3.8"}}})
|
||||
|
||||
(require '[crispin.core :as crispin])
|
||||
(def app-cfg (crispin/cfg))
|
||||
(app-cfg :foo)
|
||||
```
|
||||
|
||||
``` text
|
||||
FOO=1 script.clj
|
||||
"1"
|
||||
```
|
||||
|
||||
## Pods
|
||||
|
||||
[Babashka pods](https://github.com/babashka/babashka.pods) are programs that can
|
||||
|
|
|
|||
|
|
@ -223,6 +223,8 @@
|
|||
|
||||
(test-namespaces 'omniconf.core-test)
|
||||
|
||||
(test-namespaces 'crispin.core-test)
|
||||
|
||||
;;;; final exit code
|
||||
|
||||
(let [{:keys [:test :fail :error] :as m} @status]
|
||||
|
|
|
|||
22
test-resources/lib_tests/crispin/core_test.clj
Normal file
22
test-resources/lib_tests/crispin/core_test.clj
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
(ns crispin.core-test
|
||||
(:require [clojure.test :refer [deftest is testing]]
|
||||
[crispin.core :as cfg]))
|
||||
|
||||
(deftest crispin.core-test
|
||||
(testing "config from multiple sources"
|
||||
(do
|
||||
(cfg/load-custom-cfg! "test-resources/lib_tests/crispin" "crispin-test-custom-cfg.edn")
|
||||
(System/setProperty "crispintest.value" "yes")
|
||||
(System/setProperty "crispin" "test-resources/lib_tests/crispin/crispin-test-cfg.edn")
|
||||
(let [c (cfg/cfg)]
|
||||
; something from the environment
|
||||
(is (not-empty (cfg/sget c :path)))
|
||||
; things from the resource named by the :crispin property
|
||||
(is (= "pina colada" (cfg/sget-in c [:likes 0])))
|
||||
(is (= 3.14 (cfg/nget-in c [:crispintest :pi])))
|
||||
; something from system properties
|
||||
(is (true? (cfg/bget-in c [:crispintest :value])))
|
||||
; something from load-custom-cfg! file
|
||||
(is (= :bar (:foo c))))
|
||||
(System/clearProperty "crispintest.value")
|
||||
(System/clearProperty "crispin"))))
|
||||
2
test-resources/lib_tests/crispin/crispin-test-cfg.edn
Normal file
2
test-resources/lib_tests/crispin/crispin-test-cfg.edn
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
{:crispintest {:pi 3.14}
|
||||
:likes ["pina colada" "getting caught in the rain"]}
|
||||
|
|
@ -0,0 +1 @@
|
|||
{:foo :bar}
|
||||
Loading…
Reference in a new issue