line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Git::PurePerl::Loose; |
2
|
4
|
|
|
4
|
|
14
|
use Moose; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
22
|
|
3
|
4
|
|
|
4
|
|
16064
|
use MooseX::StrictConstructor; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
26
|
|
4
|
4
|
|
|
4
|
|
7338
|
use MooseX::Types::Path::Class; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
57
|
|
5
|
4
|
|
|
4
|
|
2371
|
use Compress::Zlib qw(compress uncompress); |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
236
|
|
6
|
4
|
|
|
4
|
|
17
|
use Path::Class; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
166
|
|
7
|
4
|
|
|
4
|
|
13
|
use namespace::autoclean; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
29
|
|
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
|
84
|
my ( $self, $sha1 ) = @_; |
18
|
|
|
|
|
|
|
|
19
|
68
|
|
|
|
|
1508
|
my $filename |
20
|
|
|
|
|
|
|
= file( $self->directory, substr( $sha1, 0, 2 ), substr( $sha1, 2 ) ); |
21
|
68
|
50
|
|
|
|
4085
|
return unless -f $filename; |
22
|
|
|
|
|
|
|
|
23
|
68
|
|
|
|
|
2634
|
my $compressed = $filename->slurp( iomode => '<:raw' ); |
24
|
68
|
|
|
|
|
8608
|
my $data = uncompress($compressed); |
25
|
68
|
|
|
|
|
2717
|
my ( $kind, $size, $content ) = $data =~ /^(\w+) (\d+)\0(.*)$/s; |
26
|
68
|
|
|
|
|
335
|
return ( $kind, $size, $content ); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub put_object { |
30
|
14
|
|
|
14
|
0
|
19
|
my ( $self, $object ) = @_; |
31
|
|
|
|
|
|
|
|
32
|
14
|
|
|
|
|
336
|
my $filename = file( |
33
|
|
|
|
|
|
|
$self->directory, |
34
|
|
|
|
|
|
|
substr( $object->sha1, 0, 2 ), |
35
|
|
|
|
|
|
|
substr( $object->sha1, 2 ) |
36
|
|
|
|
|
|
|
); |
37
|
14
|
|
|
|
|
858
|
$filename->parent->mkpath; |
38
|
14
|
|
|
|
|
1779
|
my $compressed = compress( $object->raw ); |
39
|
14
|
|
|
|
|
2489
|
my $fh = $filename->openw; |
40
|
14
|
|
|
|
|
2100
|
binmode($fh); #important for Win32 |
41
|
14
|
50
|
|
|
|
38
|
$fh->print($compressed) || die "Error writing to $filename: $!"; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub all_sha1s { |
45
|
20
|
|
|
20
|
0
|
30
|
my $self = shift; |
46
|
20
|
|
|
|
|
453
|
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
|
|
|
|
|
231
|
[ map { m{([a-z0-9]{2})[/\\]([a-z0-9]{38})}; $1 . $2 } |
|
62
|
|
|
|
|
1169
|
|
53
|
16
|
|
|
16
|
|
34124
|
grep {m{[/\\][a-z0-9]{2}[/\\]}} @$_ |
|
78
|
|
|
|
|
1179
|
|
54
|
|
|
|
|
|
|
]; |
55
|
|
|
|
|
|
|
}, |
56
|
20
|
|
|
|
|
2103
|
stream => $files, |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
61
|
|
|
|
|
|
|
|