| 1 | package OurCal::Config; | ||||||||||||
| 2 | |||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 2 | ▶ | use Config::INI::Reader; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | =head1 NAME | ||||||||||||
| 7 | |||||||||||||
| 8 | OurCal::Config - a default config reader | ||||||||||||
| 9 | |||||||||||||
| 10 | =head1 SYNOPSIS | ||||||||||||
| 11 | |||||||||||||
| 12 | image_url = images | ||||||||||||
| 13 | template_path = templates | ||||||||||||
| 14 | |||||||||||||
| 15 | [providers] | ||||||||||||
| 16 | providers = default birthday dopplr | ||||||||||||
| 17 | |||||||||||||
| 18 | [default] | ||||||||||||
| 19 | dsn = dbi:SQLite:ourcal | ||||||||||||
| 20 | type = dbi | ||||||||||||
| 21 | |||||||||||||
| 22 | [birthday] | ||||||||||||
| 23 | file = ics/birthdays.ics | ||||||||||||
| 24 | type = icalendar | ||||||||||||
| 25 | |||||||||||||
| 26 | [dopplr_cache] | ||||||||||||
| 27 | type = cache | ||||||||||||
| 28 | dir = .cache | ||||||||||||
| 29 | child = dopplr | ||||||||||||
| 30 | |||||||||||||
| 31 | [dopplr] | ||||||||||||
| 32 | file = http://www.dopplr.com/traveller/ical/user/d34dbeefd34dbeefd34dbeefd34dbeefd34dbeef.ics | ||||||||||||
| 33 | type = icalendar | ||||||||||||
| 34 | |||||||||||||
| 35 | |||||||||||||
| 36 | =head1 FORMAT | ||||||||||||
| 37 | |||||||||||||
| 38 | =head2 Generic Config | ||||||||||||
| 39 | |||||||||||||
| 40 | Then generic configuration contain key value pairs for non specific config values. | ||||||||||||
| 41 | |||||||||||||
| 42 | =head2 Provider Specific Config | ||||||||||||
| 43 | |||||||||||||
| 44 | Each provider can have specific config options in a named section. | ||||||||||||
| 45 | |||||||||||||
| 46 | =cut | ||||||||||||
| 47 | |||||||||||||
| 48 | =head1 METHODS | ||||||||||||
| 49 | |||||||||||||
| 50 | =cut | ||||||||||||
| 51 | |||||||||||||
| 52 | =head2 new <param[s]> | ||||||||||||
| 53 | |||||||||||||
| 54 | Must be given a file param which gives a path to an C<.ini> type file. | ||||||||||||
| 55 | |||||||||||||
| 56 | =cut | ||||||||||||
| 57 | |||||||||||||
| 58 | 0 | ▶ | sub new { | ||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 59 | 0 | my $class = shift; | |||||||||||
| 60 | 0 | my %what = @_; | |||||||||||
| 61 | |||||||||||||
| 62 | 0 | ▶ | die "You must pass in a 'file' option\n" unless defined $what{file}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 63 | 0 | $what{_config} = Config::INI::Reader->read_file($what{file}); | |||||||||||
| 64 | 0 | return bless \%what, $class; | |||||||||||
| 65 | } | ||||||||||||
| 66 | |||||||||||||
| 67 | =head2 config [name] | ||||||||||||
| 68 | |||||||||||||
| 69 | Returns a hashref containin the config for a give section or the generic config | ||||||||||||
| 70 | if no name is given. | ||||||||||||
| 71 | |||||||||||||
| 72 | =cut | ||||||||||||
| 73 | |||||||||||||
| 74 | 0 | ▶ | sub config { | ||||||||||
|
Subroutine
config: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 75 | 0 | my $self = shift; | |||||||||||
| 76 | 0 | ▶ | my $section = shift || "_"; | ||||||||||
|
Condition0%0/2
shift() || '_'
MC/DC0%0/1
shift() || '_'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||
| 77 | 0 | return $self->{_config}->{$section}; | |||||||||||
| 78 | } | ||||||||||||
| 79 | |||||||||||||
| 80 | 2 | 1; | |||||||||||