blib/lib/Devel/Cover/Report/Json.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 34 CC 1 SCAR 6.9
CC
1
Cov
0%
add_runs
2.0
report
2.0
BEGIN
2.0
CRAP 2.0
1 # Copyright 2014-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::Report::Json;
9  
10 use strict;
11 use warnings;
12  
13 our $VERSION = '1.52'; # VERSION
14  
15 use Devel::Cover::DB::IO::JSON;
16 # use Devel::Cover::Dumper; # For debugging
17  
18 sub add_runs {
19 my ($db) = @_;
20 my @runs;
21 for my $r (sort { $a->{start} <=> $b->{start} } $db->runs) {
22 push @runs,
23 { map { $_ => $r->$_ }
24 qw( run perl OS dir name version abstract start finish ) };
25 }
26 \@runs
27 }
28  
29 sub report {
30 my ($pkg, $db, $options) = @_;
31  
32 my %options = map { $_ => 1 } grep !/path|time/, $db->all_criteria, "force";
33 $db->calculate_summary(%options);
34  
35 my $json = { runs => add_runs($db), summary => $db->{summary} };
36 # print "JSON: ", Dumper $json;
37 print "JSON sent to $options->{outputdir}/cover.json\n";
38  
39 my $io = Devel::Cover::DB::IO::JSON->new(options => "pretty");
40 $io->write($json, "$options->{outputdir}/cover.json");
41 }
42  
43 1
44  
45 __END__