Panda Config
Panda Config helps you manage config files.
Configuration = require "panda-config"configuration = Configuratorcreate name: "settings" extension: "yml" format: "yaml"options = yield Configurationload configurationassert optionsmessageswelcome == "Hello, World!"
Suppose you want a dot-file in your users' home directory:
Configuration = require "panda-config"configuration = Configurationcreate name: "foo" prefix: "." paths: processenvHOME format: "yaml"options = yield load configuration
You can update configurations, too, making it easy to write command-line tools that update a configuration.
options.email = "johndoe@acme.org"
save configuration, options
Status
This is an alpha release, meaning it is not recommended for production use.
API
Configuration
create(options)
Create a new configurator object. Valid options:
-
paths
: the list of paths to search when loading a configuration. Defaults to["."]
. -
prefix
: a prefix to use when generating the filename. Defaults to an empty string.
This is useful for creating application-specific prefixes when writing to a directory shared by other applications. It's also useful for create hidden dot-files.
-
extension
: a file-type extension, such as.yaml
. Defaults to an empty string. -
format
: the desired file-format. The two currently supported formats arejson
andyaml
.
load(configuration)
Attempts to load and parse the configuration from a file.
save(configuration)
Attempts to save a configuration.