line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Orze::Drivers; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
53
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use File::Path; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
52
|
|
7
|
1
|
|
|
1
|
|
5
|
use File::Basename; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
141
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
7
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
798
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Orze::Drivers - Superclass of all Orze::Drivers:: |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
package Orze::Drivers::Foo; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use strict; |
20
|
|
|
|
|
|
|
use warnings; |
21
|
|
|
|
|
|
|
use base qw( Orze::Drivers ); |
22
|
|
|
|
|
|
|
use Text::Foo; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub process { |
25
|
|
|
|
|
|
|
# do some cool stuff |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 new |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Create the driver object, using the C<$page> tree and the C<$variables> |
33
|
|
|
|
|
|
|
hash. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub new { |
38
|
0
|
|
|
0
|
1
|
|
my ($name, $page, $variables) = @_; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $self = {}; |
41
|
0
|
|
|
|
|
|
bless $self, $name; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
$self->{name} = $name; |
44
|
0
|
|
|
|
|
|
$self->{page} = $page; |
45
|
0
|
|
|
|
|
|
$self->{variables} = $variables; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
return $self; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 process |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
You need to overload this method in order to do the real processing of |
53
|
|
|
|
|
|
|
the page data. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub process { |
56
|
|
|
|
|
|
|
croak "You really should subclass this package !!!!"; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 input |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Get the full path of a file in the C folder, according the |
62
|
|
|
|
|
|
|
current C value. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub input { |
67
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
68
|
0
|
|
|
|
|
|
my $path = $self->cleanpath("data/", @_); |
69
|
0
|
|
|
|
|
|
return $path; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 output |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Get the full path of a file in the C folder, according the |
75
|
|
|
|
|
|
|
current C value. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub output { |
80
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
81
|
0
|
|
|
|
|
|
my $path = $self->cleanpath("www/", @_); |
82
|
0
|
|
|
|
|
|
return $path; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 paths |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Give the tuple C<(input($file), output($file))>. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub paths { |
92
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
93
|
0
|
|
|
|
|
|
return ($self->input(@_), $self->output(@_)); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 cache |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Build the name of a file in the cache directory. The path depends on the |
99
|
|
|
|
|
|
|
current driver and on the page's name. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# ' |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub cache { |
106
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
107
|
0
|
|
|
|
|
|
my $name = $self->{name}; |
108
|
0
|
|
|
|
|
|
$name =~ s/::/-/g; |
109
|
0
|
|
|
|
|
|
my $path = $self->cleanpath("cache/" . $name . "/", @_); |
110
|
0
|
|
|
|
|
|
my ($file, $base, $ext) = fileparse($path); |
111
|
0
|
|
|
|
|
|
mkpath($base); |
112
|
0
|
|
|
|
|
|
return $path; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 cleanpath($base, $file, $extension) |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Given a base name and a filename, returns a cleaned path by removing |
118
|
|
|
|
|
|
|
".." and leading "/". Take care of the outputir. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub cleanpath { |
123
|
0
|
|
|
0
|
1
|
|
my ($self, $base, @name) = @_; |
124
|
0
|
|
|
|
|
|
my $name = join(".", grep {$_} @name); |
|
0
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
my $path = $self->{page}->att('path'); |
126
|
0
|
|
|
|
|
|
my $outputdir = $self->{page}->att('outputdir'); |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
$name =~ s!\.\./!!g; |
129
|
0
|
|
|
|
|
|
$name =~ s!^/!!; |
130
|
0
|
|
|
|
|
|
$name = $base . $outputdir . $path . $name; |
131
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
return $name; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 warning |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Display a warning message during the processing, giving information on |
138
|
|
|
|
|
|
|
the current page and the current driver. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub warning { |
143
|
0
|
|
|
0
|
1
|
|
my ($self, @message) = @_; |
144
|
|
|
|
|
|
|
|
145
|
0
|
|
|
|
|
|
my $name = $self->{name}; |
146
|
0
|
|
|
|
|
|
my $path = $self->{page}->att('path'); |
147
|
0
|
|
|
|
|
|
my $page_name = $self->{page}->att('name'); |
148
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
|
warn |
150
|
|
|
|
|
|
|
$name . " warning for " . |
151
|
|
|
|
|
|
|
$path . $page_name . ": ", |
152
|
|
|
|
|
|
|
@message, "\n"; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head2 root |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Give the relative path needed to reach the root of the website from the |
158
|
|
|
|
|
|
|
current page. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub root { |
163
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
164
|
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
my $path = $self->{page}->att('path'); |
166
|
0
|
|
|
|
|
|
my $deep = $path; |
167
|
0
|
|
|
|
|
|
$deep =~ s![^/]!!g; |
168
|
0
|
|
|
|
|
|
$deep = length $deep; |
169
|
|
|
|
|
|
|
|
170
|
0
|
|
|
|
|
|
my $root = "../" x $deep; |
171
|
|
|
|
|
|
|
|
172
|
0
|
|
|
|
|
|
return $root; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
1; |
176
|
|
|
|
|
|
|
|