line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## no critic (RequireUseStrict) |
2
|
|
|
|
|
|
|
package Tapper::Reports::DPath::Mason; |
3
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TAPPER'; |
4
|
|
|
|
|
|
|
# ABSTRACT: Mix DPath into Mason templates |
5
|
|
|
|
|
|
|
$Tapper::Reports::DPath::Mason::VERSION = '5.0.4'; |
6
|
3
|
|
|
3
|
|
104585
|
use 5.010; |
|
3
|
|
|
|
|
22
|
|
7
|
3
|
|
|
3
|
|
560
|
use Moose; |
|
3
|
|
|
|
|
464459
|
|
|
3
|
|
|
|
|
1452
|
|
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
23608
|
use HTML::Mason; |
|
3
|
|
|
|
|
211314
|
|
|
3
|
|
|
|
|
308
|
|
10
|
3
|
|
|
3
|
|
57
|
use Cwd 'cwd'; |
|
3
|
|
|
|
|
15
|
|
|
3
|
|
|
|
|
398
|
|
11
|
3
|
|
|
3
|
|
965
|
use Data::Dumper; |
|
3
|
|
|
|
|
6771
|
|
|
3
|
|
|
|
|
294
|
|
12
|
3
|
|
|
3
|
|
580
|
use File::ShareDir 'module_dir'; |
|
3
|
|
|
|
|
21476
|
|
|
3
|
|
|
|
|
1754
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has debug => ( is => 'rw'); |
15
|
|
|
|
|
|
|
has puresqlabstract => ( is => 'rw', default => 0); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub render { |
18
|
5
|
|
|
5
|
1
|
1204850
|
my ($self, %args) = @_; |
19
|
|
|
|
|
|
|
|
20
|
5
|
|
|
|
|
16
|
my $file = $args{file}; |
21
|
5
|
|
|
|
|
12
|
my $template = $args{template}; |
22
|
|
|
|
|
|
|
|
23
|
5
|
100
|
|
|
|
28
|
return $self->render_file ($file) if $file; |
24
|
4
|
50
|
|
|
|
20
|
return $self->render_template ($template) if $template; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub render_template { |
28
|
4
|
|
|
4
|
1
|
16
|
my ($self, $template) = @_; |
29
|
|
|
|
|
|
|
|
30
|
4
|
|
|
|
|
10
|
my $outbuf; |
31
|
4
|
|
|
|
|
28
|
my $comp_root = module_dir('Tapper::Reports::DPath::Mason'); |
32
|
|
|
|
|
|
|
|
33
|
4
|
|
|
|
|
2069
|
local $Tapper::Reports::DPath::puresqlabstract = $self->puresqlabstract; |
34
|
4
|
|
|
|
|
43
|
my $interp = new HTML::Mason::Interp |
35
|
|
|
|
|
|
|
( |
36
|
|
|
|
|
|
|
use_object_files => 1, |
37
|
|
|
|
|
|
|
comp_root => $comp_root, |
38
|
|
|
|
|
|
|
out_method => \$outbuf, |
39
|
|
|
|
|
|
|
preloads => [ '/mason_include.pl' ], |
40
|
|
|
|
|
|
|
); |
41
|
4
|
|
|
|
|
772
|
my $anon_comp = eval { |
42
|
4
|
|
|
|
|
18
|
$interp->make_component |
43
|
|
|
|
|
|
|
( |
44
|
|
|
|
|
|
|
comp_source => $template, |
45
|
|
|
|
|
|
|
name => '/virtual/tapper_reports_dpath_mason', |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
}; |
48
|
4
|
50
|
|
|
|
6158
|
if ($@) { |
49
|
0
|
|
|
|
|
0
|
my $msg = "Tapper::Reports::DPath::Mason::render_template::make_component: ".$@; |
50
|
0
|
|
|
|
|
0
|
print STDERR $msg; |
51
|
0
|
0
|
|
|
|
0
|
return $msg if $self->debug; |
52
|
0
|
|
|
|
|
0
|
return ''; |
53
|
|
|
|
|
|
|
} |
54
|
4
|
|
|
|
|
9
|
eval { |
55
|
4
|
|
|
|
|
16
|
$interp->exec($anon_comp); |
56
|
|
|
|
|
|
|
}; |
57
|
4
|
50
|
|
|
|
2403
|
if ($@) { |
58
|
0
|
|
|
|
|
0
|
my $msg = "Tapper::Reports::DPath::Mason::render_template::exec(anon_comp): ".$@; |
59
|
0
|
|
|
|
|
0
|
print STDERR $msg; |
60
|
0
|
0
|
|
|
|
0
|
return $msg if $self->debug; |
61
|
0
|
|
|
|
|
0
|
return ''; |
62
|
|
|
|
|
|
|
} |
63
|
4
|
|
|
|
|
180
|
return $outbuf; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub render_file { |
67
|
1
|
|
|
1
|
1
|
4
|
my ($self, $file) = @_; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# must be absolute to mason, although meant relative in real world |
70
|
1
|
50
|
|
|
|
7
|
$file = "/$file" unless $file =~ m(^/); |
71
|
|
|
|
|
|
|
|
72
|
1
|
|
|
|
|
3
|
my $outbuf; |
73
|
|
|
|
|
|
|
my $interp; |
74
|
1
|
|
|
|
|
3
|
eval { |
75
|
1
|
|
|
|
|
7508
|
$interp = new HTML::Mason::Interp( |
76
|
|
|
|
|
|
|
use_object_files => 1, |
77
|
|
|
|
|
|
|
comp_root => cwd(), |
78
|
|
|
|
|
|
|
out_method => \$outbuf, |
79
|
|
|
|
|
|
|
); |
80
|
|
|
|
|
|
|
}; |
81
|
1
|
50
|
|
|
|
29225
|
if ($@) { |
82
|
0
|
|
|
|
|
0
|
my $msg = "Tapper::Reports::DPath::Mason::render_file::new_Interp: ".$@; |
83
|
0
|
|
|
|
|
0
|
print STDERR $msg; |
84
|
0
|
0
|
|
|
|
0
|
return $msg if $self->debug; |
85
|
0
|
|
|
|
|
0
|
return ''; |
86
|
|
|
|
|
|
|
} |
87
|
1
|
|
|
|
|
56
|
eval { $interp->exec($file) }; |
|
1
|
|
|
|
|
13
|
|
88
|
1
|
50
|
|
|
|
4040
|
if ($@) { |
89
|
0
|
|
|
|
|
0
|
my $msg = "Tapper::Reports::DPath::Mason::render_file::exec(file): ".$@; |
90
|
0
|
|
|
|
|
0
|
print STDERR $msg; |
91
|
0
|
0
|
|
|
|
0
|
return $msg if $self->debug; |
92
|
0
|
|
|
|
|
0
|
return ''; |
93
|
|
|
|
|
|
|
} |
94
|
1
|
|
|
|
|
79
|
return $outbuf; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__END__ |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=pod |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=encoding UTF-8 |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 NAME |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Tapper::Reports::DPath::Mason - Mix DPath into Mason templates |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 SYNOPSIS |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
use Tapper::Reports::DPath::Mason 'render'; |
112
|
|
|
|
|
|
|
$result = render file => $filename; |
113
|
|
|
|
|
|
|
$result = render template => $string; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 METHODS |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 render |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Render file or template. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 render_file |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Render file. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 render_template |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Render template. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 AUTHORS |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=over 4 |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item * |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
AMD OSRC Tapper Team <tapper@amd64.org> |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item * |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Tapper Team <tapper-ops@amazon.com> |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=back |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by Advanced Micro Devices, Inc.. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
This is free software, licensed under: |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
The (two-clause) FreeBSD License |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |