Permalink
Browse files

Use :common configuration if config-env-var isn't set or no configura…

…tion available.
  • Loading branch information...
fukamachi committed Mar 31, 2014
1 parent f02f639 commit 3643dbf4367ac0328ece2629777575205daf22ce
Showing with 18 additions and 8 deletions.
  1. +7 −7 src/envy.lisp
  2. +11 −1 t/envy.lisp
View
@@ -40,13 +40,13 @@
(let ((env (asdf::getenv env-var)))
(if env
(let ((symbol (find-symbol env package)))
(if (and symbol
(get symbol 'configurationp)
(boundp symbol))
(append (symbol-value symbol)
(gethash package-name *package-common-configurations* nil))
nil))
nil))))
(append (if (and symbol
(get symbol 'configurationp)
(boundp symbol))
(symbol-value symbol)
nil)
(gethash package-name *package-common-configurations* nil)))
(gethash package-name *package-common-configurations* nil)))))
(defun config (package-name &optional key)
(if key
View
@@ -39,13 +39,18 @@
:makunbound-environment-variable))
(in-package :envy-test)
(plan 9)
(plan 13)
(defparameter *env-var* "APP_ENV")
(defparameter *env-backup*
(environment-variable *env-var*))
(diag "unbound")
(osicat:makunbound-environment-variable *env-var*)
(is (getf (config :envy.myapp.config) :application-root) #P"/path/to/application/")
(is (getf (config :envy.myapp.config) :a) nil)
(diag "development")
(setf (environment-variable *env-var*) "development")
@@ -75,6 +80,11 @@
#P"/path/to/application/"
"Has a common configuration")
(diag "other environment variable")
(setf (environment-variable *env-var*) "test")
(is (getf (config :envy.myapp.config) :application-root) #P"/path/to/application/")
(is (getf (config :envy.myapp.config) :a) nil)
(finalize)
(if *env-backup*

0 comments on commit 3643dbf

Please sign in to comment.