line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Orze::Sources; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
60
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
546
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Orze::Sources - Superclass of all Orze::Sources:: |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
package Orze::Sources::Foo; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use strict; |
17
|
|
|
|
|
|
|
use warnings; |
18
|
|
|
|
|
|
|
use base qw( Orze::Sources ); |
19
|
|
|
|
|
|
|
use Text::Foo; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub process { |
22
|
|
|
|
|
|
|
# do some cool stuff |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 METHODS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 new |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Create the source object, using the C<$page> tree and the C<$variables> |
32
|
|
|
|
|
|
|
hash. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub new { |
37
|
0
|
|
|
0
|
1
|
|
my ($name, $page, $var) = @_; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $self = {}; |
40
|
0
|
|
|
|
|
|
bless $self, $name; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
$self->{name} = $name; |
43
|
0
|
|
|
|
|
|
$self->{page} = $page; |
44
|
0
|
|
|
|
|
|
$self->{var} = $var; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
return $self; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 evaluate |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Do the evaluation. You need to subclass it ! |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub evaluate { |
56
|
0
|
|
|
0
|
1
|
|
croak "You really should subclass this package !!!!"; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 cleanpath |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Delete C<..> and add C prefix to paths used in driver modules. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
It's not really intended to be safe, only to help to enforce to only use data in C. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub cleanpath { |
68
|
0
|
|
|
0
|
1
|
|
my ($self, $file) = @_; |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my $outputdir = $self->{page}->att('outputdir'); |
71
|
0
|
|
|
|
|
|
my $path = $self->{page}->att('path'); |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
$file =~ s!\.\./!!g; |
74
|
0
|
|
|
|
|
|
$file =~ s!^/!!; |
75
|
0
|
|
|
|
|
|
$file = "data/" . $outputdir . $path . $file; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
return $file; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 warning |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Display a warning message during the processing, giving information on |
83
|
|
|
|
|
|
|
the current page, the current source and the current variable. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub warning { |
88
|
0
|
|
|
0
|
1
|
|
my ($self, @message) = @_; |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
my $name = $self->{name}; |
91
|
0
|
|
|
|
|
|
my $path = $self->{page}->att('path'); |
92
|
0
|
|
|
|
|
|
my $page_name = $self->{page}->att('name'); |
93
|
0
|
|
|
|
|
|
my $var_name = $self->{var}->att('name'); |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
warn |
96
|
|
|
|
|
|
|
$name . " warning for " . |
97
|
|
|
|
|
|
|
$path . $page_name . "->" . $var_name . ": ", |
98
|
|
|
|
|
|
|
@message, "\n"; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 file |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
If there an attribute C in the variable, use it. Otherwise, use the name of page. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
If there is an argument, use it as a suffix. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub file { |
110
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
111
|
0
|
|
|
|
|
|
my $suffix = shift; |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
my $page = $self->{page}; |
114
|
0
|
|
|
|
|
|
my $var = $self->{var}; |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
my $file; |
117
|
0
|
0
|
|
|
|
|
if (defined($var->att('file'))) { |
118
|
0
|
|
|
|
|
|
$file = $self->cleanpath($var->att('file')); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
else { |
121
|
0
|
0
|
|
|
|
|
if (defined($page->att('name'))) { |
122
|
0
|
|
|
|
|
|
$file = $self->cleanpath($page->att('name')); |
123
|
0
|
0
|
|
|
|
|
if (defined($suffix)) { |
124
|
0
|
|
|
|
|
|
$file = $file . "." . $suffix; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
} |
128
|
0
|
|
|
|
|
|
return $file; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; |