Class Picnic::Conf
In: lib/picnic/conf.rb
Parent: Object

Provides an interface for accessing your Picnic app‘s configuration file.

Usage example:

  # Load the configuration from /etc/foo/config.yml
  Conf.load('foo')

  # The contents of config.yml is now available as follows:
  puts Conf[:server]
  puts Conf[:authentication][:username]
  # ... etc.

Methods

Classes and Modules

Class Picnic::Conf::Error

Public Class methods

Public Instance methods

Read a configuration option.

For example:

  puts conf[:server]

Set a configuration option.

For example:

  conf[:server] = 'mongrel'

Copies the example config file into the appropriate configuration directory.

app_name:The name of your application. For example: foo
app_root:The path to your application‘s root directory. For example: /srv/www/camping/foo/
+dest_conf_file:The path where the example conf file should be copied to. For example: /etc/foo/config.yml

Business logic for deriving the current config file name.

Returns the path to your application‘s example config file.

The example config file should be in the root directory of your application‘s distribution package and should be called config.example.yml. This file is used as a template for your app‘s configuration, to be customized by the end user.

Loads the configuration from the YAML file for the given app.

app_name should be the name of your app; for example: foo

app_root should be the path to your application‘s root directory; for example:/srv/www/camping/foo/
config_file
can be the path to an alternate location for the config file to load

By default, the configuration will be loaded from /etc/<app_name>/config.yml.

Another way of reading or writing a configuration option.

The following statements are equivalent:

  puts conf[:server]
  puts conf.server

These are also equivalent:

  conf[:server] = 'mongrel'
  conf.server = 'mongrel'

Needs to be defined when we have a custom method_missing().

[Validate]