Refactor configuration loading.

This commit is contained in:
Andrey Antukh 2017-01-22 15:50:00 +01:00
parent 3092884525
commit 5a641e4629
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95
12 changed files with 125 additions and 89 deletions

View file

@ -5,6 +5,7 @@
;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz>
(ns uxbox.main
(:refer-clojure :exclude [test])
(:require [clojure.tools.namespace.repl :as repl]
[clojure.walk :refer [macroexpand-all]]
[clojure.pprint :refer [pprint]]
@ -27,6 +28,10 @@
[]
(mount/start))
(defn- stop
[]
(mount/stop))
(defn- start-minimal
[]
(-> (mount/only #{#'uxbox.config/config
@ -34,56 +39,25 @@
#'uxbox.migrations/migrations})
(mount/start)))
(defn- stop
[]
(mount/stop))
(defn- refresh
[]
(stop)
(repl/refresh))
(defn- refresh-all
[]
(stop)
(repl/refresh-all))
(defn- go
"starts all states defined by defstate"
[]
(start)
:ready)
(defn- reset
[]
(stop)
(repl/refresh :after 'uxbox.main/start))
(defn make-secret
(defn- make-secret
[]
(-> (nonce/random-bytes 64)
(b64/encode true)
(codecs/bytes->str)))
;; --- Entry point (only for uberjar)
(defn- test
([] (test #"^uxbox.tests.*"))
([o]
(repl/refresh)
(cond
(instance? java.util.regex.Pattern o)
(test/run-all-tests o)
(defn test-vars
[& vars]
(repl/refresh)
(test/test-vars
(map (fn [sym]
(require (symbol (namespace sym)))
(resolve sym))
vars)))
(defn test-ns
[ns]
(repl/refresh)
(test/test-ns ns))
(defn test-all
([] (test/run-all-tests #"^uxbox.tests.*"))
([re] (test/run-all-tests re)))
(symbol? o)
(if-let [sns (namespace o)]
(do (require (symbol sns))
(test/test-vars [(resolve o)]))
(test/test-ns o)))))
;; --- Entry point (only for uberjar)