blib/lib/Devel/StatProfiler/Metadata.pm

filter: Statementstmt 91.4% 43 / 47 Branchbran 75.0% 3 / 4 Conditioncond 42.8% 3 / 7 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 88.2% 15 / 17 Podpod 0.0% 0 / 12 totaltotal 71.4% 65 / 91 CC 8 SCAR 8.0
CC
8
Cov
84%
get_at_inc
6.0
_save
4.2
new
2.0
CRAP 2.2
« blib/lib/Devel/StatProfiler/NameMap.pm ↑ Summary blib/lib/Devel/StatProfiler/SectionChangeReader.pm »
1 package Devel::StatProfiler::Metadata;
2  
3 24 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 24 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 24 ▶use Devel::StatProfiler::Utils qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
7 check_serializer
8 read_data
9 state_dir
10 write_data_any
11 24 );
12 24 ▶use File::Path;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 14093 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod undocumented
15 14093 my ($class, %opts) = @_;
16 my $self = bless {
17 metadata => {},
18 serializer => $opts{serializer} || 'storable',
19 root_dir => $opts{root_directory},
20 shard => $opts{shard},
21 14093 ▶ }, $class;
Condition100%2/2
$opts{'serializer'} || 'storable'
l!l
101303963
MC/DC100%1/1
$opts{'serializer'} || 'storable'
$opts{'serializer'}
Truth table100%2/2
A
A= $opts{'serializer'}
Aresult
11
00
22  
23 14093 check_serializer($self->{serializer});
24  
25 14093 return $self;
26 }
27  
28 8709 ▶sub add_entries {
Subroutine add_entries: called CC=2 SCAR=6.9
Pod undocumented
29 8709 my ($self, $entries) = @_;
30  
31 8709 $self->{metadata}{$_} = $entries->{$_} for keys %$entries;
32 }
33  
34 459 ▶sub add_entry {
Subroutine add_entry: called CC=1 SCAR=0.0
Pod undocumented
35 459 my ($self, $key, $value) = @_;
36  
37 459 $self->{metadata}{$key} = $value;
38 }
39  
40 0 ▶sub set_at_inc {
Subroutine set_at_inc: not called CC=1 SCAR=6.9
Pod undocumented
41 0 my ($self, $value) = @_;
42  
43 0 $self->add_entry("\x00at_inc", [split /\x00/, $value]);
44 }
45  
46 5295 ▶sub _save {
Subroutine _save: called CC=4 SCAR=14.2
47 5295 my ($self, $dir, $is_part) = @_;
48  
49 5295 ▶ return unless %{$self->{metadata}};
Branch: 1 branch
BranchTrueFalseTotal
unless %{$self->{"metadata"};} 4453 842 5295
50  
51 842 ▶ $dir //= state_dir($self, $is_part);
Condition33%1/3
$dir //= state_dir($self, $is_part)
l!l&&r!l&&!r
84200
MC/DC0%0/2
$dir //= state_dir($self, $is_part)
$dir state_dir($self, $is_part)
Truth table33%1/3
A //= B
A= $dirB= state_dir($self, $is_part)
ABresult
1X1
011
000
52 842 File::Path::mkpath([$dir]);
53  
54 write_data_any($is_part, $self, $dir, 'metadata', $self->{metadata})
55 842 ▶ if %{$self->{metadata}};
Branch: 1 branch
BranchTrueFalseTotal
if %{$self->{"metadata"};} 842 0 842
56 }
57  
58 1859 ▶sub save_report_part { $_[0]->_save($_[1], 1) }
Subroutine save_report_part: called CC=1 SCAR=0.0
Pod undocumented
59 1491 ▶sub save_report_merged { $_[0]->_save($_[1], 0) }
Subroutine save_report_merged: called CC=1 SCAR=0.0
Pod undocumented
60 1942 ▶sub save_part { $_[0]->_save($_[1], 1) }
Subroutine save_part: called CC=1 SCAR=0.0
Pod undocumented
61 3 ▶sub save_merged { $_[0]->_save($_[1], 0) }
Subroutine save_merged: called CC=1 SCAR=0.0
Pod undocumented
62  
63 387 ▶sub load_and_merge {
Subroutine load_and_merge: called CC=2 SCAR=6.9
Pod undocumented
64 387 my ($self, @files) = @_;
65  
66 $self->{metadata} = {
67 835 %{$self->{metadata}},
68 835 %{read_data($self->{serializer}, $_)},
69 387 } for @files;
70 }
71  
72 8781 ▶sub merge {
Subroutine merge: called CC=1 SCAR=0.0
Pod undocumented
73 8781 my ($self, $report) = @_;
74  
75 $self->{metadata} = {
76 8781 %{$self->{metadata}},
77 8781 %{$report->{metadata}},
78 };
79 }
80  
81 21 ▶sub get {
Subroutine get: called CC=1 SCAR=0.0
Pod undocumented
82 21 my ($self) = @_;
83  
84 21 return { %{$self->{metadata}} };
85 }
86  
87 0 ▶sub get_at_inc {
Subroutine get_at_inc: not called CC=2 SCAR=17.9
Pod undocumented
88 0 my ($self, $value) = @_;
89  
90 0 ▶ $self->{metadata}{"\x00at_inc"} // [];
Condition0%0/2
$self->{"metadata"}{"\0at_inc"} // []
l!l
00
MC/DC0%0/1
$self->{"metadata"}{"\0at_inc"} // []
$self->{"metadata"}{"\0at_inc"}
Truth table0%0/2
A
A= $self->{"metadata"}{"\0at_inc"}
Aresult
11
00
91 }
92  
93 24 1;
94  
95 __END__
« blib/lib/Devel/StatProfiler/NameMap.pm ↑ Summary blib/lib/Devel/StatProfiler/SectionChangeReader.pm »