| 1 | package Git::PurePerl::Object::Tree; | ||||||||||
| 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 Moose::Util::TypeConstraints; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 4 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 4 | extends 'Git::PurePerl::Object'; | |||||||||
| 8 | |||||||||||
| 9 | 4 | has 'kind' => | |||||||||
| 10 | ( is => 'ro', isa => 'ObjectKind', required => 1, default => 'tree' ); | ||||||||||
| 11 | 4 | has 'directory_entries' => ( | |||||||||
| 12 | is => 'rw', | ||||||||||
| 13 | isa => 'ArrayRef[Git::PurePerl::DirectoryEntry]', | ||||||||||
| 14 | required => 0, | ||||||||||
| 15 | auto_deref => 1, | ||||||||||
| 16 | ); | ||||||||||
| 17 | |||||||||||
| 18 | 30 | ▶ | sub BUILD { | ||||||||
|
Subroutine
BUILD: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 19 | 30 | my $self = shift; | |||||||||
| 20 | 30 | my $content = $self->content; | |||||||||
| 21 | 30 | ▶ | return unless $content; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | 30 | my @directory_entries; | |||||||||
| 23 | 30 | ▶ | while ($content) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 39 | my $space_index = index( $content, ' ' ); | |||||||||
| 25 | 39 | my $mode = substr( $content, 0, $space_index ); | |||||||||
| 26 | 39 | $content = substr( $content, $space_index + 1 ); | |||||||||
| 27 | 39 | my $null_index = index( $content, "\0" ); | |||||||||
| 28 | 39 | my $filename = substr( $content, 0, $null_index ); | |||||||||
| 29 | 39 | $content = substr( $content, $null_index + 1 ); | |||||||||
| 30 | 39 | my $sha1 = unpack( 'H*', substr( $content, 0, 20 ) ); | |||||||||
| 31 | 39 | $content = substr( $content, 20 ); | |||||||||
| 32 | 39 | push @directory_entries, | |||||||||
| 33 | Git::PurePerl::DirectoryEntry->new( | ||||||||||
| 34 | mode => $mode, | ||||||||||
| 35 | filename => $filename, | ||||||||||
| 36 | sha1 => $sha1, | ||||||||||
| 37 | git => $self->git, | ||||||||||
| 38 | ); | ||||||||||
| 39 | } | ||||||||||
| 40 | 30 | $self->directory_entries( \@directory_entries ); | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||
| 44 | |||||||||||