line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OurCal::Config; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1649
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
4
|
1
|
|
|
1
|
|
907
|
use Config::INI::Reader; |
|
1
|
|
|
|
|
59800
|
|
|
1
|
|
|
|
|
17
|
|
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 |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Must be given a file param which gives a path to an C<.ini> type file. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub new { |
59
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
60
|
0
|
|
|
|
|
|
my %what = @_; |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
die "You must pass in a 'file' option\n" unless defined $what{file}; |
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
|
|
|
|
|
|
|
sub config { |
75
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
76
|
0
|
|
0
|
|
|
|
my $section = shift || "_"; |
77
|
0
|
|
|
|
|
|
return $self->{_config}->{$section}; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |