line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Cogit::Object::Tree; |
2
|
|
|
|
|
|
|
$Cogit::Object::Tree::VERSION = '0.001001'; |
3
|
4
|
|
|
4
|
|
17
|
use Moo; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
23
|
|
4
|
4
|
|
|
4
|
|
9003
|
use Cogit::DirectoryEntry; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
114
|
|
5
|
4
|
|
|
4
|
|
20
|
use MooX::Types::MooseLike::Base 'ArrayRef', 'InstanceOf'; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
185
|
|
6
|
4
|
|
|
4
|
|
19
|
use namespace::clean; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
16
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
extends 'Cogit::Object'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has '+kind' => ( default => sub { 'tree' } ); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has directory_entries => ( |
13
|
|
|
|
|
|
|
is => 'rw', |
14
|
|
|
|
|
|
|
isa => ArrayRef[InstanceOf['Cogit::DirectoryEntry']], |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _build_content { |
18
|
4
|
|
|
4
|
|
30
|
my $self = shift; |
19
|
4
|
|
|
|
|
8
|
my $content; |
20
|
4
|
|
|
|
|
5
|
for my $de ( @{$self->directory_entries} ) { |
|
4
|
|
|
|
|
67
|
|
21
|
8
|
|
|
|
|
89
|
$content |
22
|
|
|
|
|
|
|
.= $de->mode . ' ' |
23
|
|
|
|
|
|
|
. $de->filename . "\0" |
24
|
|
|
|
|
|
|
. pack( 'H*', $de->sha1 ); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
|
|
14
|
return $content; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub BUILD { |
31
|
35
|
|
|
35
|
0
|
2197
|
my $self = shift; |
32
|
35
|
|
|
|
|
618
|
my $content = $self->content; |
33
|
35
|
50
|
|
|
|
210
|
return unless $content; |
34
|
35
|
|
|
|
|
45
|
my @directory_entries; |
35
|
35
|
|
|
|
|
75
|
while ($content) { |
36
|
49
|
|
|
|
|
2472
|
my $space_index = index( $content, ' ' ); |
37
|
49
|
|
|
|
|
100
|
my $mode = substr( $content, 0, $space_index ); |
38
|
49
|
|
|
|
|
81
|
$content = substr( $content, $space_index + 1 ); |
39
|
49
|
|
|
|
|
59
|
my $null_index = index( $content, "\0" ); |
40
|
49
|
|
|
|
|
63
|
my $filename = substr( $content, 0, $null_index ); |
41
|
49
|
|
|
|
|
83
|
$content = substr( $content, $null_index + 1 ); |
42
|
49
|
|
|
|
|
186
|
my $sha1 = unpack( 'H*', substr( $content, 0, 20 ) ); |
43
|
49
|
|
|
|
|
83
|
$content = substr( $content, 20 ); |
44
|
49
|
100
|
|
|
|
891
|
push @directory_entries, |
45
|
|
|
|
|
|
|
Cogit::DirectoryEntry->new( |
46
|
|
|
|
|
|
|
mode => $mode, |
47
|
|
|
|
|
|
|
filename => $filename, |
48
|
|
|
|
|
|
|
sha1 => $sha1, |
49
|
|
|
|
|
|
|
( |
50
|
|
|
|
|
|
|
$self->git |
51
|
|
|
|
|
|
|
? (git => $self->git) |
52
|
|
|
|
|
|
|
: () |
53
|
|
|
|
|
|
|
), |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
} |
56
|
35
|
|
|
|
|
7427
|
$self->directory_entries( \@directory_entries ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=pod |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=encoding UTF-8 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 NAME |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Cogit::Object::Tree |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 VERSION |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
version 0.001001 |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 AUTHOR |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Arthur Axel "fREW" Schmidt <cogit@afoolishmanifesto.com> |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Arthur Axel "fREW" Schmidt. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
84
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |