line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Test::TAP::HTMLMatrix; |
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
46744
|
use strict; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
254
|
|
6
|
5
|
|
|
5
|
|
28
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
158
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
2434
|
use Test::TAP::Model::Visual; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
145
|
|
9
|
5
|
|
|
5
|
|
5364
|
use Test::TAP::Model::Consolidated; |
|
5
|
|
|
|
|
12196
|
|
|
5
|
|
|
|
|
166
|
|
10
|
5
|
|
|
5
|
|
5473
|
use Petal; |
|
5
|
|
|
|
|
441931
|
|
|
5
|
|
|
|
|
205
|
|
11
|
5
|
|
|
5
|
|
5854
|
use Petal::Utils qw/:logic/; |
|
5
|
|
|
|
|
5843
|
|
|
5
|
|
|
|
|
40
|
|
12
|
5
|
|
|
5
|
|
60973
|
use Carp qw/croak/; |
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
320
|
|
13
|
5
|
|
|
5
|
|
29
|
use File::Spec; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
130
|
|
14
|
5
|
|
|
5
|
|
28
|
use File::Path; |
|
5
|
|
|
|
|
85
|
|
|
5
|
|
|
|
|
281
|
|
15
|
5
|
|
|
5
|
|
28
|
use URI::file; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
130
|
|
16
|
|
|
|
|
|
|
|
17
|
5
|
|
|
5
|
|
24
|
use overload '""' => "html"; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
43
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = "0.09"; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new { |
22
|
4
|
|
|
4
|
1
|
5221
|
my ( $pkg, @models ) = @_; |
23
|
|
|
|
|
|
|
|
24
|
4
|
100
|
|
|
|
11
|
my $ext = pop @models unless eval { $models[-1]->isa("Test::TAP::Model") }; |
|
4
|
|
|
|
|
58
|
|
25
|
|
|
|
|
|
|
|
26
|
4
|
50
|
|
|
|
19
|
@models || croak "must supply a model to graph"; |
27
|
|
|
|
|
|
|
|
28
|
4
|
|
|
|
|
15
|
my $self = bless {}, $pkg; |
29
|
|
|
|
|
|
|
|
30
|
4
|
|
|
|
|
41
|
$self->model(@models); |
31
|
4
|
|
|
|
|
24
|
$self->extra($ext); |
32
|
|
|
|
|
|
|
|
33
|
4
|
|
|
|
|
33
|
$self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
7
|
|
|
7
|
1
|
381538
|
sub title { "TAP Matrix - " . gmtime() . " GMT" } |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub tests { |
39
|
7
|
|
|
7
|
1
|
1355
|
my $self = shift; |
40
|
7
|
|
|
|
|
21
|
[ sort { $a->name cmp $b->name } $self->model->test_files ]; |
|
0
|
|
|
|
|
0
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub model { |
44
|
43
|
|
|
43
|
1
|
6166
|
my $self = shift; |
45
|
43
|
100
|
|
|
|
134
|
if (@_) { |
46
|
4
|
50
|
|
|
|
85
|
$self->{model} = $_[0]->isa("Test::TAP::Model::Consolidated") |
47
|
|
|
|
|
|
|
? shift |
48
|
|
|
|
|
|
|
: Test::TAP::Model::Consolidated->new(@_); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
43
|
|
|
|
|
333
|
$self->{model}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub extra { |
55
|
11
|
|
|
11
|
1
|
1022
|
my $self = shift; |
56
|
11
|
100
|
|
|
|
45
|
$self->{extra} = shift if @_; |
57
|
11
|
|
|
|
|
49
|
$self->{extra}; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub petal { |
61
|
7
|
|
|
7
|
1
|
13
|
my $self = shift; |
62
|
7
|
|
|
|
|
15
|
my $file = shift; |
63
|
|
|
|
|
|
|
|
64
|
7
|
|
|
|
|
973
|
Petal->new( |
65
|
|
|
|
|
|
|
file => File::Spec->abs2rel($file), # damn petal requires rel path |
66
|
|
|
|
|
|
|
input => "XHTML", |
67
|
|
|
|
|
|
|
output => "XHTML", |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
encode_charset => "utf8", |
70
|
|
|
|
|
|
|
decode_charset => "utf8", |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub html { |
75
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
76
|
0
|
|
|
|
|
0
|
$self->detail_html; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub detail_html { |
80
|
5
|
|
|
5
|
1
|
20
|
my $self = shift; |
81
|
5
|
|
|
|
|
22
|
$self->template_to_html($self->detail_template); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub summary_html { |
85
|
2
|
|
|
2
|
1
|
14698
|
my $self = shift; |
86
|
2
|
|
|
|
|
10
|
$self->template_to_html($self->summary_template); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub output_dir { |
90
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
91
|
0
|
|
0
|
|
|
0
|
my $dir = shift || die "You need to specify a directory"; |
92
|
|
|
|
|
|
|
|
93
|
0
|
0
|
0
|
|
|
0
|
mkpath $dir or die "can't create directory '$dir': $!" unless -e $dir; |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
0
|
local $self->{_css_uri} = "htmlmatrix.css"; |
96
|
|
|
|
|
|
|
|
97
|
0
|
0
|
|
|
|
0
|
my %outputs = ( |
98
|
|
|
|
|
|
|
"summary.html" => $self->summary_html, |
99
|
|
|
|
|
|
|
"detail.html" => $self->detail_html, |
100
|
|
|
|
|
|
|
( $self->has_inline_css ? () : "htmlmatrix.css" => $self->_slurp_css ), |
101
|
|
|
|
|
|
|
); |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
0
|
foreach my $file ( keys %outputs ) { |
104
|
0
|
0
|
|
|
|
0
|
open my $fh, ">", File::Spec->catfile( $dir, $file ) or die "can't open '$file' for writing: $!"; |
105
|
0
|
|
|
|
|
0
|
print $fh $outputs{$file}; |
106
|
0
|
0
|
|
|
|
0
|
close $fh or die "can't close '$file'"; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub template_to_html { |
111
|
7
|
|
|
7
|
1
|
15
|
my $self = shift; |
112
|
7
|
|
|
|
|
12
|
my $path = shift; |
113
|
7
|
|
|
|
|
37
|
$self->process_petal($self->petal($path)); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub process_petal { |
117
|
7
|
|
|
7
|
1
|
233
|
my $self = shift; |
118
|
7
|
|
|
|
|
12
|
my $petal = shift; |
119
|
7
|
|
|
|
|
34
|
$petal->process(page => $self); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub _find_in_INC { |
123
|
17
|
|
|
17
|
|
28
|
my $self = shift; |
124
|
17
|
|
|
|
|
30
|
my $file = shift; |
125
|
|
|
|
|
|
|
|
126
|
17
|
|
|
|
|
43
|
foreach my $str (grep { not ref } @INC){ |
|
187
|
|
|
|
|
322
|
|
127
|
34
|
|
|
|
|
290
|
my $target = File::Spec->catfile($str, $file); |
128
|
34
|
100
|
|
|
|
1551
|
return $target if -e $target; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
0
|
die "couldn't find $file in \@INC"; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub _find_in_my_INC { |
135
|
17
|
|
|
17
|
|
31
|
my $self = shift; |
136
|
17
|
|
|
|
|
328
|
$self->_find_in_INC(File::Spec->catfile(split("::", __PACKAGE__), shift)); |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub detail_template { |
140
|
6
|
|
|
6
|
1
|
21
|
my $self = shift; |
141
|
6
|
|
|
|
|
37
|
$self->_find_in_my_INC("detailed_view.html"); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub summary_template { |
145
|
3
|
|
|
3
|
1
|
1530
|
my $self = shift; |
146
|
3
|
|
|
|
|
10
|
$self->_find_in_my_INC("summary_view.html"); |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub css_file { |
150
|
8
|
|
|
8
|
1
|
1337
|
my $self = shift; |
151
|
8
|
|
|
|
|
32
|
$self->_find_in_my_INC("htmlmatrix.css"); |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub css_uri { |
155
|
6
|
|
|
6
|
1
|
935
|
my $self = shift; |
156
|
6
|
50
|
|
|
|
50
|
$self->{_css_uri} || URI::file->new($self->css_file); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub has_inline_css { |
160
|
16
|
|
|
16
|
1
|
13027
|
my $self = shift; |
161
|
16
|
100
|
|
|
|
58
|
$self->{has_inline_css} = shift if @_; |
162
|
16
|
|
|
|
|
54
|
$self->{has_inline_css}; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub no_javascript { |
166
|
32
|
|
|
32
|
1
|
1385
|
my $self = shift; |
167
|
32
|
100
|
|
|
|
87
|
$self->{no_javascript} = shift if @_; |
168
|
32
|
|
|
|
|
133
|
$self->{no_javascript}; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub has_javascript { |
172
|
30
|
|
|
30
|
1
|
14490
|
my $self = shift; |
173
|
30
|
|
|
|
|
90
|
!$self->no_javascript; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub _slurp_css { |
177
|
1
|
|
|
1
|
|
3
|
my $self = shift; |
178
|
1
|
|
|
|
|
4
|
local $/; |
179
|
1
|
50
|
|
|
|
13
|
open my $fh, $self->css_file or die "open: " . $self->css_file. ": $!"; |
180
|
1
|
|
|
|
|
89499
|
<$fh>; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub inline_css { |
184
|
1
|
|
|
1
|
1
|
93
|
my $self = shift; |
185
|
1
|
|
|
|
|
4
|
"\n/\n"; |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
__PACKAGE__ |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
__END__ |