OurCal::Config - a default config reader


OurCal documentation Contained in the OurCal distribution.

Index


Code Index:

NAME

Top

OurCal::Config - a default config reader

SYNOPSIS

Top

    image_url     = images
    template_path = templates

    [providers]
    providers = default birthday dopplr

    [default]
    dsn  = dbi:SQLite:ourcal
    type = dbi

    [birthday]
    file = ics/birthdays.ics
    type = icalendar

    [dopplr_cache]
    type  = cache
    dir   = .cache
    child = dopplr

    [dopplr]
    file  = http://www.dopplr.com/traveller/ical/user/d34dbeefd34dbeefd34dbeefd34dbeefd34dbeef.ics
    type  = icalendar




FORMAT

Top

Generic Config

Then generic configuration contain key value pairs for non specific config values.

Provider Specific Config

Each provider can have specific config options in a named section.

METHODS

Top

new <param[s]>

Must be given a file param which gives a path to an .ini type file.

config [name]

Returns a hashref containin the config for a give section or the generic config if no name is given.


OurCal documentation Contained in the OurCal distribution.
package OurCal::Config;

use strict;
use Config::INI::Reader;

sub new {
    my $class = shift;
    my %what = @_;
    
    die "You must pass in a 'file' option\n" unless defined $what{file};
    $what{_config} = Config::INI::Reader->read_file($what{file});
    return bless \%what, $class;
}

sub config {
    my $self    = shift;
    my $section = shift || "_";
    return $self->{_config}->{$section}; 
}

1;