blib/lib/Devel/Cover/Base/Editor.pm untested

filter: Statementstmt 0.0% 0 / 58 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 16 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 89 CC 4 SCAR 13.9
CC
4
Cov
0%
report
12.0
fetch
6.0
template_name
2.0
CRAP 4.0
1 # Copyright 2026, Paul Johnson (paul@pjcj.net)
2  
3 # This software is free. It is licensed under the same terms as Perl itself.
4  
5 # The latest version of this software should be available from my homepage:
6 # https://pjcj.net
7  
8 package Devel::Cover::Base::Editor;
9  
10 use 5.20.0;
11 use warnings;
12 use feature "signatures";
13 no warnings "experimental::signatures";
14  
15 our $VERSION = '1.52'; # VERSION
16  
17 use Template 2.00 ();
18  
19 sub report ($pkg, $db, $options) {
20 my $template = Template->new({
21 LOAD_TEMPLATES => [
22 Devel::Cover::Base::Editor::Template::Provider->new({
23 editor_class => $pkg, })
24 ]
25 });
26  
27 my $vars = {
28 runs => [
29 map {
30 run => $_->run,
31 perl => $_->perl,
32 OS => $_->OS,
33 start => scalar gmtime $_->start,
34 finish => scalar gmtime $_->finish,
35 },
36 sort { $a->start <=> $b->start } $db->runs,
37 ],
38 cov_time => do {
39 my $time = 0;
40 for ($db->runs) {
41 $time = $_->finish if $_->finish > $time;
42 }
43 int $time
44 },
45 version => $pkg->VERSION,
46 files => $options->{file},
47 cover => $db->cover,
48 types => [ grep $_ ne "time", keys $options->{show}->%* ],
49 };
50  
51 my $out = "$options->{outputdir}/$options->{outputfile}";
52 $template->process($pkg->template_name, $vars, $out) or die $template->error;
53  
54 print $pkg->output_message($out) . "\n" unless $options->{silent};
55 }
56  
57 sub template_name { die "Subclass must implement template_name" }
58 sub templates { die "Subclass must implement templates" }
59 sub output_message { die "Subclass must implement output_message" }
60  
61 1;
62  
63 package Devel::Cover::Base::Editor::Template::Provider;
64  
65 use 5.20.0;
66 use warnings;
67 use feature "signatures";
68 no warnings "experimental::signatures";
69  
70 our $VERSION = '1.52'; # VERSION
71  
72 use parent "Template::Provider";
73  
74 sub new ($class, $params) {
75 my $self = $class->SUPER::new($params);
76 $self->{_editor_class} = $params->{editor_class};
77 $self
78 }
79  
80 sub fetch ($self, $name) {
81 my $templates = $self->{_editor_class}->templates;
82 $self->SUPER::fetch(exists $templates->{$name} ? \$templates->{$name} : $name)
83 }
84  
85 1
86  
87 __END__