NAME

Haver::Config - Configuration Manager.

SYNOPSIS

  use Haver::Config;
  my $ch = new Haver::Config (
      load  => "$ENV{HOME}/.myconfigfile",
      merge => {
          name => $ENV{USER},
          stuff => [1,2,3],
      },
  );
  my $config = $ch->config;
  $config->{name} eq $ENV{USER}; # true.
  $ch->save;

DESCRIPTION

This is a simple class to allow the loading and saving of config files written in YAML format.

In the future it might provide a way of finding config files in a cross-platform way or even storing the config data in the Registry on Win32 platforms.

INHERITENCE

Haver::Config extends Haver::Base.

METHODS

This class uses Spiffy indirectly, and thus methods and parameters to the constructor new() are the same thing. Thus you may write:

$ch = new Haver::Config ( load => 'foobar' );

Instead of:

$ch = new Haver::Config;
$ch->load('foobar');

The following methods are public:

load($file)

Load the file $file into memory. This overwrites whatever config data is already loaded.

save()

Save the config data to the most recently loaded file.

reload()

Reload the most recently loaded file.

file()

Return the name of the most recently loaded file.

merge($hash)

Recursively merge $hash with the loaded config data. This should be called after load(). Already loaded data has precedence over $hash.

config()

Return the currently loaded config data.

get($key)

This is shorthand for $self->config->{$key}, except it is marginally faster and perhaps safer to use.

set($key => $value)

Like get(), this is shorthand for $self->config->{$key} = $value.

del($key)

Finally, this is shorthand for delete $self->config->{$key}.

BUGS

None known. Bug reports are welcome. Please use our bug tracker at http://gna.org/bugs/?func=additem&group=haver.

AUTHOR

Dylan William Hardison, <dylan@haverdev.org> Bryan Donlan, <bdonlan@haverdev.org>.

SEE ALSO

http://www.haverdev.org/.

COPYRIGHT and LICENSE

Copyright 2005 by Dylan William Hardison. All Rights Reserved. Copyright 2005 by Bryan Donlan. All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This module is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this module; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA