line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
### Text::PORE::Group.pm
|
2
|
|
|
|
|
|
|
### Contains a group of Templates or TemplateGroups
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Text::PORE::Group;
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
7
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
7
|
1
|
|
|
1
|
|
6
|
use Text::PORE::Volatile;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
8
|
1
|
|
|
1
|
|
7
|
use Text::PORE;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
528
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
@Text::PORE::Group::ISA = qw(Volatile);
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $templates_root = "./new_templates";
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new {
|
15
|
0
|
|
|
0
|
0
|
|
my ($class, $root, %attrs) = @_;
|
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
my ($self) = new Volatile(%attrs);
|
18
|
|
|
|
|
|
|
|
19
|
0
|
0
|
|
|
|
|
if (! $root) { $root = $templates_root; }
|
|
0
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
$self->LoadAttributes('root' => $root, 'initialized' => 0);
|
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
bless $self, $class;
|
23
|
0
|
|
|
|
|
|
return $self;
|
24
|
|
|
|
|
|
|
}
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub GetAttribute {
|
27
|
0
|
|
|
0
|
0
|
|
my ($self, $attr) = @_;
|
28
|
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
|
if (! $self->SUPER::GetAttribute('initialized')) {
|
30
|
0
|
|
|
|
|
|
$self->Initialize();
|
31
|
|
|
|
|
|
|
}
|
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
return $self->SUPER::GetAttribute($attr);
|
34
|
|
|
|
|
|
|
}
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub Initialize {
|
37
|
0
|
|
|
0
|
0
|
|
my ($self) = @_;
|
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $root = $self->{'root'}; # Don't use GetAttribute before we init
|
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
opendir(DIR, $root);
|
42
|
0
|
|
|
|
|
|
my @list = readdir(DIR);
|
43
|
0
|
0
|
|
|
|
|
my @templates = grep { /\.tpl$/ && -f "$root/$_" } @list;
|
|
0
|
|
|
|
|
|
|
44
|
0
|
0
|
|
|
|
|
my @dirs = grep { /^[^\.]/ && -d "$root/$_" } @list;
|
|
0
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
closedir(DIR);
|
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my $dir;
|
48
|
0
|
|
|
|
|
|
foreach $dir (@dirs) {
|
49
|
0
|
|
|
|
|
|
my $new = new Text::PORE::Group("$root/$dir");
|
50
|
0
|
|
|
|
|
|
$self->LoadAttributes($dir => $new);
|
51
|
|
|
|
|
|
|
}
|
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my $tpl;
|
54
|
0
|
|
|
|
|
|
foreach $tpl (@templates) {
|
55
|
0
|
|
|
|
|
|
my $new = new Text::PORE::Template("$root/$tpl", "file");
|
56
|
0
|
|
|
|
|
|
$tpl =~ s/\.tpl$//;
|
57
|
0
|
|
|
|
|
|
$self->LoadAttributes($tpl => $new);
|
58
|
|
|
|
|
|
|
}
|
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
$self->LoadAttributes('initialized' => 1);
|
61
|
0
|
|
|
|
|
|
return $self;
|
62
|
|
|
|
|
|
|
}
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1;
|