| 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($!)
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($!)
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 27 | 1 | ▶ | if ( $version == 2 ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 49 | 48 | return $self->unpack_object($offset); | |||||||||||||||||||
| 50 | } | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||
| 53 | |||||||||||||||||||||