The envy Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The envy Reference Manual

This is the envy Reference Manual, version 0.1, generated automatically by Declt version 2.4 "Will Decker" on Wed Jun 20 11:44:17 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

Envy

Configuration switcher by an environment variable inspired by Perl's Config::ENV.

Usage

(defpackage :myapp.config
  (:use :cl
        :envy))
(in-package :myapp.config)

(setf (config-env-var) "APP_ENV")

(defconfig :common
  `(:application-root ,(asdf:component-pathname (asdf:find-system :myapp))))

(defconfig |development|
  '(:debug T
    :database-type :sqlite3
    :database-connection-spec (:database-name "sqlite3.db")))

(defconfig |production|
  '(:database-type :mysql
    :database-connection-spec (:database-name "test"
                               :usename "whoami"
                               :password "1234")))

(defconfig |staging|
  `(:debug T
    ,@|production|))
(defpackage :myapp
  (:use :cl)
  (:import-from :envy
                :config)
(in-package :myapp)

(getf (config :myapp.config) :database-type)

Description

Envy is a configuration manager for various applications.

Envy uses an environment variable to determine a configuration to use. I'm not sure this is ideal even for Common Lisp applications, but this can separate configuration system from an implementation.

Configurations

Normal configurations

ENVY:DEFCONFIG is a macro for defining a named configuration.

Don't forget to set (ENVY:CONFIG-ENV-VAR) which is a name of environment variable to determine a configuration.

(setf (config-env-var) "APP_ENV")

;; Use SQLite3 for development
(defconfig |development|
  '(:server :hunchentoot
    :database-type :sqlite3
    :database-connection-spec (:database-name "sqlite3.db")))

;; Use MySQL in production environment
(defconfig |production|
  '(:server :fcgi
    :database-type :mysql
    :database-connection-spec (:database-name "test"
                               :usename "whoami"
                               :password "1234")))

Merging

Each configurations are represented as property lists. It means you can merge them by the default way of merging lists -- cons, append or/and splicing unquote.

(defconfig |staging|
  `(:server :hunchentoot
    ,@|production|))

Common configurations

You can also define a common configuration which will be merged into every configurations.

(defconfig :common
  `(:application-root ,(asdf:component-pathname (asdf:find-system :myapp))))

Accessing to configuration

ENVY:CONFIG is an accessor to get the current configuration.

(config :<configuration-package-name>)

(config :myapp.config)
;=> '(:server :hunchentoot
      :database-type :sqlite3
      :database-connection-spec (:database-name "sqlite3.db")
      :application-root #P"/path/to/application/")

(getf (config :myapp.config) :database-type)
;=> :sqlite3

Tips

(defpackage myapp.config
  (:use :cl
        :envy)
  (:shadow :envy
           :config)
  (:export :config))
(in-package :myapp.config)

(defconfig :common
  ...)

;;
;; ... Configurations ...
;;

(defun config ()
  (envy:config #.(package-name *package*)))

See Also

Thank cho45 for the great product. I feel envy to you :)

Author

Copyright

Copyright (c) 2013 Eitarow Fukamachi (e.arrows@gmail.com)

License

Licensed under the BSD 2-Clause License.


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 envy

Author

Eitarow Fukamachi

License

BSD 2-Clause

Description

Configuration switcher by an environment variable.

Long Description

# Envy

Configuration switcher by an environment variable inspired by Perl’s [Config::ENV](http://search.cpan.org/~satoh/Config-ENV/lib/Config/ENV.pm).

## Usage

“‘common-lisp
(defpackage :myapp.config
(:use :cl
:envy))
(in-package :myapp.config)

(setf (config-env-var) "APP_ENV")

(defconfig :common
‘(:application-root ,(asdf:component-pathname (asdf:find-system :myapp))))

(defconfig |development|
’(:debug T
:database-type :sqlite3
:database-connection-spec (:database-name "sqlite3.db")))

(defconfig |production|
’(:database-type :mysql
:database-connection-spec (:database-name "test"
:usename "whoami"
:password "1234")))

(defconfig |staging|
‘(:debug T
,@|production|))
“‘

“‘common-lisp
(defpackage :myapp
(:use :cl)
(:import-from :envy
:config)
(in-package :myapp)

(getf (config :myapp.config) :database-type)
“‘

## Description

Envy is a configuration manager for various applications.

Envy uses an environment variable to determine a configuration to use. I’m not sure this is ideal even for Common Lisp applications, but this can separate configuration system from an implementation.

## Configurations

### Normal configurations

‘ENVY:DEFCONFIG‘ is a macro for defining a named configuration.

Don’t forget to set ‘(ENVY:CONFIG-ENV-VAR)‘ which is a name of environment variable to determine a configuration.

“‘common-lisp
(setf (config-env-var) "APP_ENV")

;; Use SQLite3 for development
(defconfig |development|
’(:server :hunchentoot
:database-type :sqlite3
:database-connection-spec (:database-name "sqlite3.db")))

;; Use MySQL in production environment
(defconfig |production|
’(:server :fcgi
:database-type :mysql
:database-connection-spec (:database-name "test"
:usename "whoami"
:password "1234")))
“‘

### Merging

Each configurations are represented as property lists. It means you can merge them by the default way of merging lists – cons, append or/and splicing unquote.

“‘common-lisp
(defconfig |staging|
‘(:server :hunchentoot
,@|production|))
“‘

### Common configurations

You can also define a common configuration which will be merged into every configurations.

“‘common-lisp
(defconfig :common
‘(:application-root ,(asdf:component-pathname (asdf:find-system :myapp))))
“‘

### Accessing to configuration

‘ENVY:CONFIG‘ is an accessor to get the current configuration.

“‘common-lisp
(config :<configuration-package-name>)

(config :myapp.config)
;=> ’(:server :hunchentoot
:database-type :sqlite3
:database-connection-spec (:database-name "sqlite3.db")
:application-root #P"/path/to/application/")

(getf (config :myapp.config) :database-type)
;=> :sqlite3
“‘

## Tips

“‘common-lisp
(defpackage myapp.config
(:use :cl
:envy)
(:shadow :envy
:config)
(:export :config))
(in-package :myapp.config)

(defconfig :common
...)

;;
;; ... Configurations ...
;;

(defun config ()
(envy:config #.(package-name *package*)))
“‘

## See Also

Thank cho45 for the great product. I feel envy to you :)

- [Config::ENV](http://search.cpan.org/~satoh/Config-ENV/lib/Config/ENV.pm)

## Author

* Eitarow Fukamachi (e.arrows@gmail.com)

## Copyright

Copyright (c) 2013 Eitarow Fukamachi (e.arrows@gmail.com)

# License

Licensed under the BSD 2-Clause License.

Version

0.1

Source

envy.asd (file)

Component

src (module)


Next: , Previous: , Up: Top   [Contents][Index]

3 Modules

Modules are listed depth-first from the system components tree.


Previous: , Up: Modules   [Contents][Index]

3.1 envy/src

Parent

envy (system)

Location

src/

Component

envy.lisp (file)


Next: , Previous: , Up: Top   [Contents][Index]

4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

4.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.1 envy.asd

Location

envy.asd

Systems

envy (system)

Packages

envy-asd


Previous: , Up: Lisp files   [Contents][Index]

4.1.2 envy/src/envy.lisp

Parent

src (module)

Location

src/envy.lisp

Packages

envy

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

5.1 envy-asd

Source

envy.asd

Use List

Previous: , Up: Packages   [Contents][Index]

5.2 envy

Source

envy.lisp (file)

Use List

common-lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

6.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.1 Macros

Macro: defconfig NAME CONFIGURATIONS
Package

envy

Source

envy.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

6.1.2 Functions

Function: config PACKAGE-NAME &optional KEY
Package

envy

Source

envy.lisp (file)

Function: config-env-var &optional PACKAGE-NAME
Function: (setf config-env-var) VAL &optional PACKAGE-NAME
Package

envy

Source

envy.lisp (file)


Previous: , Up: Definitions   [Contents][Index]

6.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.1 Special variables

Special Variable: *config-env-map*
Package

envy

Source

envy.lisp (file)

Special Variable: *package-common-configurations*
Package

envy

Source

envy.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

6.2.2 Functions

Function: config* &optional KEY
Package

envy

Source

envy.lisp (file)

Function: package-config PACKAGE-NAME
Package

envy

Source

envy.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   E   F   L   M  
Index Entry  Section

E
envy.asd: The envy<dot>asd file
envy/src: The envy/src module
envy/src/envy.lisp: The envy/src/envy<dot>lisp file

F
File, Lisp, envy.asd: The envy<dot>asd file
File, Lisp, envy/src/envy.lisp: The envy/src/envy<dot>lisp file

L
Lisp File, envy.asd: The envy<dot>asd file
Lisp File, envy/src/envy.lisp: The envy/src/envy<dot>lisp file

M
Module, envy/src: The envy/src module

Jump to:   E   F   L   M  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   (  
C   D   F   M   P  
Index Entry  Section

(
(setf config-env-var): Exported functions

C
config: Exported functions
config*: Internal functions
config-env-var: Exported functions

D
defconfig: Exported macros

F
Function, (setf config-env-var): Exported functions
Function, config: Exported functions
Function, config*: Internal functions
Function, config-env-var: Exported functions
Function, package-config: Internal functions

M
Macro, defconfig: Exported macros

P
package-config: Internal functions

Jump to:   (  
C   D   F   M   P  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *  
S  
Index Entry  Section

*
*config-env-map*: Internal special variables
*package-common-configurations*: Internal special variables

S
Special Variable, *config-env-map*: Internal special variables
Special Variable, *package-common-configurations*: Internal special variables

Jump to:   *  
S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   E   P   S  
Index Entry  Section

E
envy: The envy system
envy: The envy package
envy-asd: The envy-asd package

P
Package, envy: The envy package
Package, envy-asd: The envy-asd package

S
System, envy: The envy system

Jump to:   E   P   S