line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OPM::Repository; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: parse OPM repositories' framework.xml files to search for add ons |
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
312782
|
use strict; |
|
4
|
|
|
|
|
35
|
|
|
4
|
|
|
|
|
90
|
|
6
|
4
|
|
|
4
|
|
16
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
133
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.0.0'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
1583
|
use Moo; |
|
4
|
|
|
|
|
34093
|
|
|
4
|
|
|
|
|
15
|
|
11
|
4
|
|
|
4
|
|
4400
|
use List::Util qw(all); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
178
|
|
12
|
4
|
|
|
4
|
|
19
|
use Scalar::Util qw(blessed); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
160
|
|
13
|
4
|
|
|
4
|
|
1576
|
use Regexp::Common qw(URI); |
|
4
|
|
|
|
|
14545
|
|
|
4
|
|
|
|
|
10
|
|
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
4
|
|
74503
|
use OPM::Repository::Source; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
2250
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $ALLOWED_SCHEME = [ 'HTTP', 'file' ]; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has sources => ( is => 'ro', required => 1, isa => sub { |
20
|
|
|
|
|
|
|
die "no valid URIs" unless |
21
|
|
|
|
|
|
|
ref $_[0] eq 'ARRAY' |
22
|
|
|
|
|
|
|
and |
23
|
|
|
|
|
|
|
all { _check_uri( $_ ) } @{ $_[0] } |
24
|
|
|
|
|
|
|
}); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has _objects => ( is => 'ro', isa => sub { |
27
|
|
|
|
|
|
|
die "no valid objects" unless |
28
|
|
|
|
|
|
|
ref $_[0] eq 'ARRAY' |
29
|
|
|
|
|
|
|
and |
30
|
|
|
|
|
|
|
all { blessed $_ and $_->isa( 'OPM::Repository::Source' ) } @{ $_[0] } |
31
|
|
|
|
|
|
|
}); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub find { |
34
|
9
|
|
|
9
|
1
|
3185
|
my ($self, %params) = @_; |
35
|
|
|
|
|
|
|
|
36
|
9
|
|
|
|
|
15
|
my @found; |
37
|
9
|
50
|
|
|
|
13
|
for my $source ( @{ $self->_objects || [] } ) { |
|
9
|
|
|
|
|
39
|
|
38
|
12
|
|
|
|
|
46
|
my $found = $source->find( %params ); |
39
|
12
|
100
|
|
|
|
32
|
push @found, $found if $found; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
9
|
|
|
|
|
58
|
return @found; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub list { |
46
|
4
|
|
|
4
|
1
|
3913
|
my ($self, %params) = @_; |
47
|
|
|
|
|
|
|
|
48
|
4
|
|
|
|
|
7
|
my %found_packages; |
49
|
|
|
|
|
|
|
my @detailed_list; |
50
|
4
|
50
|
|
|
|
5
|
for my $source ( @{ $self->_objects || [] } ) { |
|
4
|
|
|
|
|
21
|
|
51
|
4
|
|
|
|
|
15
|
my @found = $source->list( %params ); |
52
|
4
|
|
|
|
|
95
|
@found_packages{@found} = (1) x @found; |
53
|
4
|
|
|
|
|
23
|
push @detailed_list, @found; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
4
|
|
|
|
|
6
|
my @packages; |
57
|
4
|
100
|
|
|
|
9
|
if ( $params{details} ) { |
58
|
2
|
50
|
|
|
|
7
|
@packages = sort { $a->{name} cmp $b->{name} || $a->{version} cmp $b->{version} }@detailed_list; |
|
127
|
|
|
|
|
162
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
else { |
61
|
2
|
|
|
|
|
32
|
@packages = sort keys %found_packages; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
4
|
|
|
|
|
46
|
return @packages; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub BUILDARGS { |
68
|
4
|
|
|
4
|
1
|
6674
|
my ($class, @args) = @_; |
69
|
|
|
|
|
|
|
|
70
|
4
|
50
|
|
|
|
21
|
unshift @args, 'sources' if @args % 2; |
71
|
|
|
|
|
|
|
|
72
|
4
|
|
|
|
|
12
|
my %param = @args; |
73
|
|
|
|
|
|
|
|
74
|
4
|
50
|
|
|
|
8
|
for my $url ( @{ $param{sources} || [] } ) { |
|
4
|
|
|
|
|
17
|
|
75
|
5
|
|
|
|
|
18
|
push @{ $param{_objects} }, OPM::Repository::Source->new( url => $url ); |
|
5
|
|
|
|
|
48
|
|
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
4
|
|
|
|
|
83
|
return \%param; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub _check_uri { |
82
|
5
|
50
|
|
5
|
|
15
|
my @allowed_schemes = ref $ALLOWED_SCHEME ? @{ $ALLOWED_SCHEME } : $ALLOWED_SCHEME; |
|
5
|
|
|
|
|
14
|
|
83
|
|
|
|
|
|
|
|
84
|
5
|
|
|
|
|
9
|
my $matches; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
SCHEME: |
87
|
5
|
|
|
|
|
12
|
for my $scheme ( @allowed_schemes ) { |
88
|
|
|
|
|
|
|
my $regex = ( lc $scheme eq 'http' ) ? |
89
|
|
|
|
|
|
|
$RE{URI}{HTTP}{-scheme => qr/https?/} : |
90
|
10
|
100
|
|
|
|
952
|
$RE{URI}{$scheme}; |
91
|
|
|
|
|
|
|
|
92
|
10
|
100
|
|
|
|
332
|
if ( $_[0] =~ m{\A$regex\z} ) { |
93
|
5
|
|
|
|
|
652
|
$matches++; |
94
|
5
|
|
|
|
|
20
|
last SCHEME; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
5
|
50
|
|
|
|
27
|
die "No valid URI" unless $matches; |
99
|
5
|
|
|
|
|
125
|
return 1; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__END__ |