PurePerl/Pack/WithIndex.pm

filter: Statementstmt 96.8% 31 / 32 Branchbran 66.6% 4 / 6 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 85.4% 41 / 48 CC 5 SCAR 9.5
CC
5
Cov
90%
BUILD
4.0
get_object
2.0
BEGIN
1.0
CRAP 2.6
« PurePerl/Protocol/Git.pm ↑ Summary PurePerl/PackIndex.pm »
1 package Git::PurePerl::Pack::WithIndex;
2 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 extends 'Git::PurePerl::Pack';
7  
8 4 has 'index_filename' =>
9 ( is => 'rw', isa => 'Path::Class::File', required => 0, coerce => 1 );
10 4 has 'index' =>
11 ( is => 'rw', isa => 'Git::PurePerl::PackIndex', required => 0 );
12  
13 2 ▶sub BUILD {
Subroutine BUILD: called CC=4 SCAR=14.0
Pod undocumented
14 2 my $self = shift;
15 2 my $index_filename = $self->filename;
16 2 $index_filename =~ s/\.pack/.idx/;
17 2 $self->index_filename($index_filename);
18  
19 2 ▶ my $index_fh = IO::File->new($index_filename) || confess($!);
Condition50%1/2
'IO::File'->new($index_filename) || confess($!)
l!l
20
MC/DC0%0/1
'IO::File'->new($index_filename) || confess($!)
'IO::File'->new($index_filename)
Truth table50%1/2
A
A= 'IO::File'->new($index_filename)
Aresult
11
00
20 2 $index_fh->binmode();
21 2 $index_fh->read( my $signature, 4 );
22 2 $index_fh->read( my $version, 4 );
23 2 $version = unpack( 'N', $version );
24 2 $index_fh->close;
25  
26 2 ▶ if ( $signature eq "\377tOc" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($signature eq "\377tOc") { } 1 1 2
27 1 ▶ if ( $version == 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version == 2) { } 1 0 1
28 1 $self->index(
29 Git::PurePerl::PackIndex::Version2->new(
30 filename => $index_filename
31 )
32 );
33 } else {
34 0 confess("Unknown version");
35 }
36 } else {
37 1 $self->index(
38 Git::PurePerl::PackIndex::Version1->new(
39 filename => $index_filename
40 )
41 );
42 }
43 }
44  
45 48 ▶sub get_object {
Subroutine get_object: called CC=2 SCAR=7.0
Pod undocumented
46 48 my ( $self, $want_sha1 ) = @_;
47 48 my $offset = $self->index->get_object_offset($want_sha1);
48 48 ▶ return unless $offset;
Branch: 1 branch
BranchTrueFalseTotal
unless $offset 0 48 48
49 48 return $self->unpack_object($offset);
50 }
51  
52 4 __PACKAGE__->meta->make_immutable;
53  
« PurePerl/Protocol/Git.pm ↑ Summary PurePerl/PackIndex.pm »