| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
## no critic (RequireUseStrict) |
|
2
|
|
|
|
|
|
|
package Tapper::Reports::DPath::TT; |
|
3
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TAPPER'; |
|
4
|
|
|
|
|
|
|
# ABSTRACT: Mix DPath into Template-Toolkit templates |
|
5
|
|
|
|
|
|
|
$Tapper::Reports::DPath::TT::VERSION = '5.0.4'; |
|
6
|
5
|
|
|
5
|
|
294478
|
use 5.010; |
|
|
5
|
|
|
|
|
46
|
|
|
7
|
5
|
|
|
5
|
|
1572
|
use Moose; |
|
|
5
|
|
|
|
|
1315409
|
|
|
|
5
|
|
|
|
|
49
|
|
|
8
|
5
|
|
|
5
|
|
40742
|
use Template; |
|
|
5
|
|
|
|
|
95821
|
|
|
|
5
|
|
|
|
|
171
|
|
|
9
|
5
|
|
|
5
|
|
37
|
use Cwd 'cwd'; |
|
|
5
|
|
|
|
|
16
|
|
|
|
5
|
|
|
|
|
235
|
|
|
10
|
5
|
|
|
5
|
|
1786
|
use Data::Dumper; |
|
|
5
|
|
|
|
|
17464
|
|
|
|
5
|
|
|
|
|
270
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
5
|
|
|
5
|
|
2719
|
use Template::Stash; |
|
|
5
|
|
|
|
|
64570
|
|
|
|
5
|
|
|
|
|
210
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# modules needed inside the TT template for vmethods |
|
15
|
5
|
|
|
5
|
|
1684
|
use Tapper::Reports::DPath 'reportdata', 'testrundata', 'testplandata'; |
|
|
5
|
|
|
|
|
18
|
|
|
|
5
|
|
|
|
|
63
|
|
|
16
|
5
|
|
|
5
|
|
2249
|
use Tapper::Model 'model'; |
|
|
5
|
|
|
|
|
12
|
|
|
|
5
|
|
|
|
|
285
|
|
|
17
|
5
|
|
|
5
|
|
33
|
use Data::Dumper; |
|
|
5
|
|
|
|
|
11
|
|
|
|
5
|
|
|
|
|
228
|
|
|
18
|
5
|
|
|
5
|
|
3907
|
use Data::DPath 'dpath'; |
|
|
5
|
|
|
|
|
5807
|
|
|
|
5
|
|
|
|
|
35
|
|
|
19
|
5
|
|
|
5
|
|
1179
|
use DateTime; |
|
|
5
|
|
|
|
|
12
|
|
|
|
5
|
|
|
|
|
139
|
|
|
20
|
5
|
|
|
5
|
|
3177
|
use JSON; |
|
|
5
|
|
|
|
|
37949
|
|
|
|
5
|
|
|
|
|
27
|
|
|
21
|
5
|
|
|
5
|
|
2754
|
use YAML::XS; |
|
|
5
|
|
|
|
|
12231
|
|
|
|
5
|
|
|
|
|
305
|
|
|
22
|
5
|
|
|
5
|
|
2398
|
use Data::Structure::Util 'unbless'; |
|
|
5
|
|
|
|
|
7352
|
|
|
|
5
|
|
|
|
|
4034
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has debug => ( is => 'rw'); |
|
25
|
|
|
|
|
|
|
has puresqlabstract => ( is => 'rw', default => 0); |
|
26
|
|
|
|
|
|
|
has include_path => ( is => 'rw', default => ""); |
|
27
|
|
|
|
|
|
|
has substitutes => ( is => 'rw', default => undef); |
|
28
|
|
|
|
|
|
|
has eval_perl => ( is => 'rw', default => 0); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub get_template |
|
31
|
|
|
|
|
|
|
{ |
|
32
|
12
|
|
|
12
|
1
|
32
|
my ($self) = @_; |
|
33
|
|
|
|
|
|
|
|
|
34
|
12
|
50
|
|
|
|
507
|
my $tt = Template->new({EVAL_PERL => $self->eval_perl, |
|
35
|
|
|
|
|
|
|
$self->include_path ? (INCLUDE_PATH => $self->include_path) : (), |
|
36
|
|
|
|
|
|
|
}); |
|
37
|
12
|
|
|
1
|
|
33436
|
$Template::Stash::SCALAR_OPS->{reportdata} = sub { reportdata($_[0]) }; |
|
|
1
|
|
|
|
|
4567
|
|
|
38
|
12
|
|
|
1
|
|
87
|
$Template::Stash::SCALAR_OPS->{testrundata} = sub { testrundata($_[0]) }; |
|
|
1
|
|
|
|
|
28598
|
|
|
39
|
12
|
|
|
2
|
|
57
|
$Template::Stash::SCALAR_OPS->{testrundata_nohost} = sub { testrundata($_[0], 1) }; # nohost=1 |
|
|
2
|
|
|
|
|
11656
|
|
|
40
|
12
|
|
|
0
|
|
59
|
$Template::Stash::SCALAR_OPS->{testplandata} = sub { testplandata($_[0]) }; |
|
|
0
|
|
|
|
|
0
|
|
|
41
|
12
|
|
|
1
|
|
72
|
$Template::Stash::SCALAR_OPS->{dpath_match}= sub { my ($path, $data) = @_; dpath($path)->match($data); }; |
|
|
1
|
|
|
|
|
8355
|
|
|
|
1
|
|
|
|
|
8
|
|
|
42
|
12
|
|
|
1
|
|
75
|
$Template::Stash::LIST_OPS->{to_json} = sub { JSON->new->pretty->encode(unbless $_[0]) }; |
|
|
1
|
|
|
|
|
4382
|
|
|
43
|
12
|
|
|
1
|
|
201
|
$Template::Stash::LIST_OPS->{to_yaml} = sub { YAML::XS::Dump(unbless $_[0]) }; |
|
|
1
|
|
|
|
|
4413
|
|
|
44
|
12
|
|
|
1
|
|
61
|
$Template::Stash::LIST_OPS->{Dumper} = sub { $Data::Dumper::Sortkeys = 1; Dumper @_ }; |
|
|
1
|
|
|
|
|
31620
|
|
|
|
1
|
|
|
|
|
9
|
|
|
45
|
12
|
|
|
|
|
31
|
return $tt; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub testrundb_hostnames { |
|
49
|
0
|
|
|
0
|
1
|
0
|
my $host_iter = model('TestrunDB')->resultset("Host")->search({ }); |
|
50
|
0
|
|
|
|
|
0
|
my %hosts = (); |
|
51
|
0
|
|
|
|
|
0
|
while (my $h = $host_iter->next) { |
|
52
|
0
|
|
|
|
|
0
|
$hosts{$h->name} = { id => $h->id, |
|
53
|
|
|
|
|
|
|
name => $h->name, |
|
54
|
|
|
|
|
|
|
free => $h->free, |
|
55
|
|
|
|
|
|
|
active => $h->active, |
|
56
|
|
|
|
|
|
|
comment => $h->comment, |
|
57
|
|
|
|
|
|
|
is_deleted => $h->is_deleted, |
|
58
|
|
|
|
|
|
|
}; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
0
|
|
|
|
|
0
|
return \%hosts; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub render { |
|
64
|
12
|
|
|
12
|
1
|
3381307
|
my ($self, %args) = @_; |
|
65
|
|
|
|
|
|
|
|
|
66
|
12
|
|
|
|
|
33
|
my $file = $args{file}; |
|
67
|
12
|
|
|
|
|
30
|
my $template = $args{template}; |
|
68
|
|
|
|
|
|
|
|
|
69
|
12
|
100
|
|
|
|
52
|
return $self->render_file ($file) if $file; |
|
70
|
11
|
50
|
|
|
|
59
|
return $self->render_template ($template) if $template; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub render_template { |
|
74
|
11
|
|
|
11
|
1
|
35
|
my ($self, $template) = @_; |
|
75
|
|
|
|
|
|
|
|
|
76
|
11
|
|
|
|
|
22
|
my $outbuf; |
|
77
|
11
|
|
|
|
|
43
|
my $tt = $self->get_template(); |
|
78
|
|
|
|
|
|
|
|
|
79
|
11
|
|
|
|
|
452
|
local $Tapper::Reports::DPath::puresqlabstract = $self->puresqlabstract; |
|
80
|
11
|
50
|
|
|
|
369
|
if(not $tt->process(\$template, {reportdata => \&reportdata, |
|
|
|
50
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
testrundata => \&testrundata, |
|
82
|
|
|
|
|
|
|
testplandata => \&testplandata, |
|
83
|
|
|
|
|
|
|
testrundb_hostnames => \&testrundb_hostnames, |
|
84
|
0
|
|
|
|
|
0
|
defined $self->substitutes ? ( %{$self->substitutes} ) : (), |
|
85
|
|
|
|
|
|
|
}, \$outbuf)) { |
|
86
|
0
|
|
|
|
|
0
|
die $tt->error; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
11
|
|
|
|
|
14093
|
return $outbuf; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub render_file { |
|
92
|
1
|
|
|
1
|
1
|
4
|
my ($self, $file) = @_; |
|
93
|
|
|
|
|
|
|
|
|
94
|
1
|
|
|
|
|
4
|
my $outbuf; |
|
95
|
1
|
|
|
|
|
5
|
my $tt = $self->get_template(); |
|
96
|
|
|
|
|
|
|
|
|
97
|
1
|
50
|
|
|
|
7
|
if(not $tt->process($file, {}, \$outbuf)) { |
|
98
|
0
|
|
|
|
|
0
|
die Template->error(); |
|
99
|
|
|
|
|
|
|
} |
|
100
|
1
|
|
|
|
|
40300
|
return $outbuf; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
__END__ |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=pod |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=encoding UTF-8 |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 NAME |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Tapper::Reports::DPath::TT - Mix DPath into Template-Toolkit templates |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
use Tapper::Reports::DPath::Mason 'render'; |
|
119
|
|
|
|
|
|
|
$result = render file => $filename; |
|
120
|
|
|
|
|
|
|
$result = render template => $string; |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 METHODS |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 get_template |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Render template processor with complete Tapper prelude set. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 render |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Render file or template. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 render_file |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Render file. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 render_template |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Render template. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 testrundb_hostnames |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Provide list of hosts from Tapper TestrunDB to be accessible in |
|
143
|
|
|
|
|
|
|
templates. |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 AUTHORS |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=over 4 |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item * |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
AMD OSRC Tapper Team <tapper@amd64.org> |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item * |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Tapper Team <tapper-ops@amazon.com> |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=back |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by Advanced Micro Devices, Inc.. |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
This is free software, licensed under: |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
The (two-clause) FreeBSD License |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |