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.2'; |
6
|
3
|
|
|
3
|
|
57718
|
use 5.010; |
|
3
|
|
|
|
|
9
|
|
7
|
3
|
|
|
3
|
|
480
|
use Moose; |
|
3
|
|
|
|
|
304173
|
|
|
3
|
|
|
|
|
27
|
|
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
15410
|
use HTML::Mason; |
|
3
|
|
|
|
|
168382
|
|
|
3
|
|
|
|
|
135
|
|
10
|
3
|
|
|
3
|
|
35
|
use Cwd 'cwd'; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
193
|
|
11
|
3
|
|
|
3
|
|
643
|
use Data::Dumper; |
|
3
|
|
|
|
|
4458
|
|
|
3
|
|
|
|
|
152
|
|
12
|
3
|
|
|
3
|
|
432
|
use File::ShareDir 'module_dir'; |
|
3
|
|
|
|
|
4511
|
|
|
3
|
|
|
|
|
1134
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has debug => ( is => 'rw'); |
15
|
|
|
|
|
|
|
has puresqlabstract => ( is => 'rw', default => 0); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub render { |
18
|
5
|
|
|
5
|
1
|
702345
|
my ($self, %args) = @_; |
19
|
|
|
|
|
|
|
|
20
|
5
|
|
|
|
|
10
|
my $file = $args{file}; |
21
|
5
|
|
|
|
|
8
|
my $template = $args{template}; |
22
|
|
|
|
|
|
|
|
23
|
5
|
100
|
|
|
|
14
|
return $self->render_file ($file) if $file; |
24
|
4
|
50
|
|
|
|
16
|
return $self->render_template ($template) if $template; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub render_template { |
28
|
4
|
|
|
4
|
1
|
6
|
my ($self, $template) = @_; |
29
|
|
|
|
|
|
|
|
30
|
4
|
|
|
|
|
6
|
my $outbuf; |
31
|
4
|
|
|
|
|
16
|
my $comp_root = module_dir('Tapper::Reports::DPath::Mason'); |
32
|
|
|
|
|
|
|
|
33
|
4
|
|
|
|
|
1310
|
local $Tapper::Reports::DPath::puresqlabstract = $self->puresqlabstract; |
34
|
4
|
|
|
|
|
29
|
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
|
|
|
|
|
554
|
my $anon_comp = eval { |
42
|
4
|
|
|
|
|
14
|
$interp->make_component |
43
|
|
|
|
|
|
|
( |
44
|
|
|
|
|
|
|
comp_source => $template, |
45
|
|
|
|
|
|
|
name => '/virtual/tapper_reports_dpath_mason', |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
}; |
48
|
4
|
50
|
|
|
|
3919
|
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
|
|
|
|
|
4
|
eval { |
55
|
4
|
|
|
|
|
14
|
$interp->exec($anon_comp); |
56
|
|
|
|
|
|
|
}; |
57
|
4
|
50
|
|
|
|
1589
|
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
|
|
|
|
|
147
|
return $outbuf; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub render_file { |
67
|
1
|
|
|
1
|
1
|
3
|
my ($self, $file) = @_; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# must be absolute to mason, although meant relative in real world |
70
|
1
|
50
|
|
|
|
6
|
$file = "/$file" unless $file =~ m(^/); |
71
|
|
|
|
|
|
|
|
72
|
1
|
|
|
|
|
1
|
my $outbuf; |
73
|
|
|
|
|
|
|
my $interp; |
74
|
1
|
|
|
|
|
1
|
eval { |
75
|
1
|
|
|
|
|
5397
|
$interp = new HTML::Mason::Interp( |
76
|
|
|
|
|
|
|
use_object_files => 1, |
77
|
|
|
|
|
|
|
comp_root => cwd(), |
78
|
|
|
|
|
|
|
out_method => \$outbuf, |
79
|
|
|
|
|
|
|
); |
80
|
|
|
|
|
|
|
}; |
81
|
1
|
50
|
|
|
|
18330
|
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
|
|
|
|
|
2
|
eval { $interp->exec($file) }; |
|
1
|
|
|
|
|
4
|
|
88
|
1
|
50
|
|
|
|
2025
|
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
|
|
|
|
|
43
|
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) 2016 by Advanced Micro Devices, Inc.. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
This is free software, licensed under: |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
The (two-clause) FreeBSD License |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |