line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::Any::TT2; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
15263
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
78
|
|
4
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
70
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
44
|
use base 'Config::Any::Base'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
2078
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.12'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Config::Any::TT2 - Config::Any plugin for Config::TT2 files |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use Config::Any; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $cfg_file = 'cfg.tt2'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $configs = Config::Any->load_files( |
21
|
|
|
|
|
|
|
{ |
22
|
|
|
|
|
|
|
files => [$cfg_file], |
23
|
|
|
|
|
|
|
flatten_to_hash => 1, |
24
|
|
|
|
|
|
|
use_ext => 1, |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $cfg = $configs->{$cfg_file}; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Loads Config::TT2 files. Example: |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
[% # tt2 directive start-tag |
35
|
|
|
|
|
|
|
scalar = 'string' |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
array = [ 10 20 30 ] # commas are optional |
38
|
|
|
|
|
|
|
rev = array.reverse # powerful virtual methods |
39
|
|
|
|
|
|
|
item = array.0 # interpolate previous value |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
hash = { foo = 'bar' # hashes to any depth |
42
|
|
|
|
|
|
|
moo = array # points to above arrayref |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
%] # tt2 directive end-tag |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 METHODS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 extensions( ) |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
return an array of valid extensions (C, C). |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub extensions { |
55
|
5
|
|
|
5
|
1
|
63673
|
return qw( tt2 tt ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 load( $file ) |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Attempts to load C<$file> via Config::TT2. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub load { |
65
|
5
|
|
|
5
|
1
|
29879
|
my $class = shift; |
66
|
5
|
|
|
|
|
11
|
my $file = shift; |
67
|
5
|
|
50
|
|
|
22
|
my $args = shift || {}; |
68
|
|
|
|
|
|
|
|
69
|
5
|
|
|
|
|
37
|
require Config::TT2; |
70
|
5
|
|
|
|
|
41
|
my $cfg = Config::TT2->new( $args )->process( $file ); |
71
|
|
|
|
|
|
|
|
72
|
2
|
|
|
|
|
88390
|
return $cfg; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# maybe we need instead a shallow, unblessed copy for Config::Any |
75
|
|
|
|
|
|
|
# return { %$cfg }; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 requires_all_of( ) |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Specifies that this module requires L in order to work. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
|
84
|
5
|
|
|
5
|
1
|
1071
|
sub requires_all_of { [ 'Config::TT2' ] } |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 AUTHOR |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Karl Gaissmaier Egaissmai@cpan.orgE |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Copyright 2012 by Karl Gaissmaier |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
95
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 SEE ALSO |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=over 4 |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item * L |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item * L |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=back |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |