Cogit/PackIndex.pm

filter: Statementstmt 100% 47 / 47 Branchbran 50.0% 1 / 2 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 1 totaltotal 93.4% 57 / 61 CC 4 SCAR 7.4
CC
4
Cov
96%
BUILD
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.1
« Cogit/Pack/WithIndex.pm ↑ Summary Cogit/Loose.pm »
1 package Cogit::PackIndex;
2 4 $Cogit::PackIndex::VERSION = '0.001001';
3 4 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Path::Class 'file';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use Check::ISA;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use MooX::Types::MooseLike::Base qw( InstanceOf ArrayRef Str Int );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 has filename => (
11 is => 'ro',
12 isa => InstanceOf['Path::Class::File'],
13 2 ▶ coerce => sub { file($_[0]) },
Subroutine __ANON__: called CC=1 SCAR=0.0
14 4 required => 1,
15 );
16  
17 4 has fh => (
18 is => 'rw',
19 isa => InstanceOf['IO::File'],
20 );
21  
22 4 has offsets => (
23 is => 'rw',
24 isa => ArrayRef[Int],
25 );
26  
27 4 has size => (
28 is => 'rw',
29 isa => Int,
30 );
31  
32 4 my $FanOutCount = 256;
33 4 my $SHA1Size = 20;
34 4 my $IdxOffsetSize = 4;
35 4 my $OffsetSize = 4;
36 4 my $CrcSize = 4;
37 4 my $OffsetStart = $FanOutCount * $IdxOffsetSize;
38 4 my $SHA1Start = $OffsetStart + $OffsetSize;
39 4 my $EntrySize = $OffsetSize + $SHA1Size;
40 4 my $EntrySizeV2 = $SHA1Size + $CrcSize + $OffsetSize;
41  
42 2 ▶sub BUILD {
Subroutine BUILD: called CC=4 SCAR=13.9
Pod undocumented
43 2 my $self = shift;
44 2 my $filename = $self->filename;
45  
46 2 ▶ my $fh = IO::File->new($filename) || confess($!);
Condition50%1/2
'IO::File'->new($filename) || confess($!)
l!l
20
MC/DC0%0/1
'IO::File'->new($filename) || confess($!)
'IO::File'->new($filename)
Truth table50%1/2
A
A= 'IO::File'->new($filename)
Aresult
11
00
47 2 $self->fh($fh);
48  
49 2 my @offsets = (0);
50 2 $fh->seek( $self->global_offset, 0 );
51 2 for my $i ( 0 .. $FanOutCount - 1 ) {
52 512 $fh->read( my $data, $IdxOffsetSize );
53 512 my $offset = unpack( 'N', $data );
54 512 ▶ confess("pack has discontinuous index") if $offset < $offsets[-1];
Branch: 1 branch
BranchTrueFalseTotal
if $offset < $offsets[-1] 0 512 512
55 512 push @offsets, $offset;
56 }
57 2 $self->offsets( \@offsets );
58 2 $self->size( $offsets[-1] );
59 }
60  
61 4 1;
62  
63 __END__
« Cogit/Pack/WithIndex.pm ↑ Summary Cogit/Loose.pm »