PurePerl/Pack/WithIndex.pm

filter: Statementstmt 96.8% 31 / 32 Branchbran 66.6% 4 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 82.0% 41 / 50 SCAR 16.2
CC
5
Cov
88%
BUILD
4.1
get_object
2.0
BEGIN
1.0
CRAP 5.0
« PurePerl/Object/Tag.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 sub BUILD {
14 2 ▶ my $self = shift;
Subroutine BUILD: called CC=4 SCAR=14.1
Pod undocumented
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($!);
Condition33%1/3
'IO::File'->new($index_filename) || confess($!)
l!l&&r!l&&!r
200
MC/DC0%0/2
'IO::File'->new($index_filename) || confess($!)
'IO::File'->new($index_filename) confess($!)
Truth table33%1/3
A || B
A= 'IO::File'->new($index_filename)B= confess($!)
ABresult
1X1
011
000
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 sub get_object {
46 48 ▶ my ( $self, $want_sha1 ) = @_;
Subroutine get_object: called CC=2 SCAR=7.0
Pod undocumented
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/Object/Tag.pm ↑ Summary PurePerl/PackIndex.pm »