line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Git::PurePerl::Loose; |
2
|
4
|
|
|
4
|
|
16
|
use Moose; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
26
|
|
3
|
4
|
|
|
4
|
|
19472
|
use MooseX::StrictConstructor; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
36
|
|
4
|
4
|
|
|
4
|
|
8714
|
use MooseX::Types::Path::Class; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
43
|
|
5
|
4
|
|
|
4
|
|
2800
|
use Compress::Zlib qw(compress uncompress); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
256
|
|
6
|
4
|
|
|
4
|
|
16
|
use Path::Class; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
198
|
|
7
|
4
|
|
|
4
|
|
18
|
use namespace::autoclean; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
33
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'directory' => ( |
10
|
|
|
|
|
|
|
is => 'ro', |
11
|
|
|
|
|
|
|
isa => 'Path::Class::Dir', |
12
|
|
|
|
|
|
|
required => 1, |
13
|
|
|
|
|
|
|
coerce => 1 |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub get_object { |
17
|
68
|
|
|
68
|
0
|
128
|
my ( $self, $sha1 ) = @_; |
18
|
|
|
|
|
|
|
|
19
|
68
|
|
|
|
|
1955
|
my $filename |
20
|
|
|
|
|
|
|
= file( $self->directory, substr( $sha1, 0, 2 ), substr( $sha1, 2 ) ); |
21
|
68
|
50
|
|
|
|
6260
|
return unless -f $filename; |
22
|
|
|
|
|
|
|
|
23
|
68
|
|
|
|
|
3507
|
my $compressed = $filename->slurp( iomode => '<:raw' ); |
24
|
68
|
|
|
|
|
11749
|
my $data = uncompress($compressed); |
25
|
68
|
|
|
|
|
3772
|
my ( $kind, $size, $content ) = $data =~ /^(\w+) (\d+)\0(.*)$/s; |
26
|
68
|
|
|
|
|
461
|
return ( $kind, $size, $content ); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub put_object { |
30
|
14
|
|
|
14
|
0
|
19
|
my ( $self, $object ) = @_; |
31
|
|
|
|
|
|
|
|
32
|
14
|
|
|
|
|
413
|
my $filename = file( |
33
|
|
|
|
|
|
|
$self->directory, |
34
|
|
|
|
|
|
|
substr( $object->sha1, 0, 2 ), |
35
|
|
|
|
|
|
|
substr( $object->sha1, 2 ) |
36
|
|
|
|
|
|
|
); |
37
|
14
|
|
|
|
|
1316
|
$filename->parent->mkpath; |
38
|
14
|
|
|
|
|
2323
|
my $compressed = compress( $object->raw ); |
39
|
14
|
|
|
|
|
4118
|
my $fh = $filename->openw; |
40
|
14
|
|
|
|
|
2560
|
binmode($fh); #important for Win32 |
41
|
14
|
50
|
|
|
|
69
|
$fh->print($compressed) || die "Error writing to $filename: $!"; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub all_sha1s { |
45
|
20
|
|
|
20
|
0
|
31
|
my $self = shift; |
46
|
20
|
|
|
|
|
556
|
my $files = Data::Stream::Bulk::Path::Class->new( |
47
|
|
|
|
|
|
|
dir => $self->directory, |
48
|
|
|
|
|
|
|
only_files => 1, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
return Data::Stream::Bulk::Filter->new( |
51
|
|
|
|
|
|
|
filter => sub { |
52
|
62
|
|
|
|
|
275
|
[ map { m{([a-z0-9]{2})[/\\]([a-z0-9]{38})}; $1 . $2 } |
|
62
|
|
|
|
|
1544
|
|
|
78
|
|
|
|
|
1343
|
|
53
|
16
|
|
|
16
|
|
46832
|
grep {m{[/\\][a-z0-9]{2}[/\\]}} @$_ |
54
|
|
|
|
|
|
|
]; |
55
|
|
|
|
|
|
|
}, |
56
|
20
|
|
|
|
|
2829
|
stream => $files, |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
61
|
|
|
|
|
|
|
|