line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OrePAN2::Repository; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
40388
|
use strict; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
57
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
46
|
|
5
|
2
|
|
|
2
|
|
671
|
use utf8; |
|
2
|
|
|
|
|
16
|
|
|
2
|
|
|
|
|
10
|
|
6
|
2
|
|
|
2
|
|
80
|
use 5.008_001; |
|
2
|
|
|
|
|
6
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
9
|
use Carp; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
157
|
|
9
|
|
|
|
|
|
|
use Class::Accessor::Lite 0.05 ( |
10
|
2
|
|
|
|
|
15
|
rw => [qw(directory cache compress_index)], |
11
|
2
|
|
|
2
|
|
1018
|
); |
|
2
|
|
|
|
|
2582
|
|
12
|
2
|
|
|
2
|
|
194
|
use File::Find; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
129
|
|
13
|
2
|
|
|
2
|
|
13
|
use File::Spec; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
53
|
|
14
|
2
|
|
|
2
|
|
970
|
use File::pushd; |
|
2
|
|
|
|
|
21373
|
|
|
2
|
|
|
|
|
114
|
|
15
|
2
|
|
|
2
|
|
912
|
use OrePAN2::Indexer; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
87
|
|
16
|
2
|
|
|
2
|
|
1179
|
use OrePAN2::Injector; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
77
|
|
17
|
2
|
|
|
2
|
|
1050
|
use OrePAN2::Repository::Cache; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
1367
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
2
|
|
|
2
|
0
|
3490
|
my $class = shift; |
21
|
2
|
50
|
|
|
|
24
|
my %args = @_ == 1 ? %{ $_[0] } : @_; |
|
0
|
|
|
|
|
0
|
|
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
11
|
for my $key (qw(directory)) { |
24
|
2
|
50
|
|
|
|
15
|
unless ( exists $args{$key} ) { |
25
|
0
|
|
|
|
|
0
|
Carp::croak("Missing mandatory parameter: $key"); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
2
|
|
|
|
|
18
|
my $self = bless { |
29
|
|
|
|
|
|
|
compress_index => 1, |
30
|
|
|
|
|
|
|
%args, |
31
|
|
|
|
|
|
|
}, $class; |
32
|
|
|
|
|
|
|
$self->{cache} |
33
|
2
|
|
|
|
|
36
|
= OrePAN2::Repository::Cache->new( directory => $self->{directory} ); |
34
|
|
|
|
|
|
|
|
35
|
2
|
|
|
|
|
7
|
return $self; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub injector { |
39
|
2
|
|
|
2
|
0
|
4
|
my $self = shift; |
40
|
2
|
|
33
|
|
|
26
|
$self->{injector} ||= OrePAN2::Injector->new( |
41
|
|
|
|
|
|
|
directory => $self->directory, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub indexer { |
46
|
2
|
|
|
2
|
0
|
6
|
my $self = shift; |
47
|
|
|
|
|
|
|
$self->{indexer} ||= OrePAN2::Indexer->new( |
48
|
|
|
|
|
|
|
directory => $self->directory, |
49
|
|
|
|
|
|
|
simple => $self->{simple}, |
50
|
2
|
|
33
|
|
|
15
|
); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub has_cache { |
54
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $stuff ) = @_; |
55
|
0
|
|
|
|
|
0
|
$self->cache->is_hit($stuff); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub make_index { |
59
|
2
|
|
|
2
|
0
|
29
|
my $self = shift; |
60
|
2
|
|
|
|
|
10
|
$self->indexer->make_index( no_compress => !$self->compress_index ); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub inject { |
64
|
2
|
|
|
2
|
0
|
22
|
my ( $self, $stuff, $opts ) = @_; |
65
|
|
|
|
|
|
|
|
66
|
2
|
|
|
|
|
10
|
my $tarpath = $self->injector->inject( $stuff, $opts ); |
67
|
2
|
|
|
|
|
13
|
$self->cache->set( $stuff, $tarpath ); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub index_file { |
71
|
4
|
|
|
4
|
0
|
19
|
my $self = shift; |
72
|
4
|
50
|
|
|
|
38
|
return File::Spec->catfile( |
73
|
|
|
|
|
|
|
$self->directory, 'modules', |
74
|
|
|
|
|
|
|
'02packages.details.txt' . ( $self->compress_index ? '.gz' : '' ) |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub save_cache { |
79
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
80
|
0
|
|
|
|
|
0
|
$self->cache->save; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub load_index { |
84
|
2
|
|
|
2
|
0
|
7
|
my $self = shift; |
85
|
|
|
|
|
|
|
|
86
|
2
|
|
|
|
|
39
|
my $index = OrePAN2::Index->new(); |
87
|
2
|
|
|
|
|
8
|
$index->load( $self->index_file ); |
88
|
2
|
|
|
|
|
2243
|
$index; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# Remove files that are not referenced by the index file. |
92
|
|
|
|
|
|
|
sub gc { |
93
|
2
|
|
|
2
|
0
|
6095
|
my ( $self, $callback ) = @_; |
94
|
|
|
|
|
|
|
|
95
|
2
|
50
|
|
|
|
13
|
return unless -f $self->index_file; |
96
|
|
|
|
|
|
|
|
97
|
2
|
|
|
|
|
148
|
my $index = $self->load_index; |
98
|
2
|
|
|
|
|
12
|
my %registered; |
99
|
2
|
|
|
|
|
14
|
for my $package ( $index->packages ) { |
100
|
2
|
|
|
|
|
22
|
my ( $version, $path ) = $index->lookup($package); |
101
|
2
|
|
|
|
|
12
|
$registered{$path}++; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
2
|
|
|
|
|
16
|
my $pushd = File::pushd::pushd( |
105
|
|
|
|
|
|
|
File::Spec->catdir( $self->directory, 'authors', 'id' ) ); |
106
|
|
|
|
|
|
|
File::Find::find( |
107
|
|
|
|
|
|
|
{ |
108
|
|
|
|
|
|
|
no_chdir => 1, |
109
|
|
|
|
|
|
|
wanted => sub { |
110
|
12
|
100
|
|
12
|
|
906
|
return unless -f $_; |
111
|
4
|
|
|
|
|
35
|
$_ = File::Spec->canonpath($_); |
112
|
4
|
100
|
|
|
|
17
|
unless ( $registered{$_} ) { |
113
|
2
|
100
|
|
|
|
108
|
$callback ? $callback->($_) : unlink $_; |
114
|
|
|
|
|
|
|
} |
115
|
4
|
|
|
|
|
1293
|
1; |
116
|
|
|
|
|
|
|
}, |
117
|
|
|
|
|
|
|
}, |
118
|
2
|
|
|
|
|
912
|
'.' |
119
|
|
|
|
|
|
|
); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |
123
|
|
|
|
|
|
|
|