line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Iterates through distribution prerequisites |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Pinto::PrerequisiteWalker; |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
63119
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use MooseX::StrictConstructor; |
7
|
|
|
|
|
|
|
use MooseX::Types::Moose qw(CodeRef ArrayRef HashRef Bool); |
8
|
|
|
|
|
|
|
use MooseX::MarkAsMethods ( autoclean => 1 ); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.09995'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has start => ( |
17
|
|
|
|
|
|
|
is => 'ro', |
18
|
|
|
|
|
|
|
isa => 'Pinto::Schema::Result::Distribution', |
19
|
|
|
|
|
|
|
required => 1, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has callback => ( |
23
|
|
|
|
|
|
|
is => 'ro', |
24
|
|
|
|
|
|
|
isa => CodeRef, |
25
|
|
|
|
|
|
|
required => 1, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has filters => ( |
29
|
|
|
|
|
|
|
is => 'ro', |
30
|
|
|
|
|
|
|
isa => ArrayRef [CodeRef], |
31
|
|
|
|
|
|
|
predicate => 'has_filters', |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has queue => ( |
35
|
|
|
|
|
|
|
isa => ArrayRef ['Pinto::Schema::Result::Prerequisite'], |
36
|
|
|
|
|
|
|
traits => [qw(Array)], |
37
|
|
|
|
|
|
|
handles => { enqueue => 'push', dequeue => 'shift' }, |
38
|
|
|
|
|
|
|
default => sub { return [ $_[0]->apply_filters( $_[0]->start->prerequisites ) ] }, |
39
|
|
|
|
|
|
|
init_arg => undef, |
40
|
|
|
|
|
|
|
lazy => 1, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has seen => ( |
44
|
|
|
|
|
|
|
is => 'ro', |
45
|
|
|
|
|
|
|
isa => HashRef, |
46
|
|
|
|
|
|
|
default => sub { return { $_[0]->start->path => 1 } }, |
47
|
|
|
|
|
|
|
init_arg => undef, |
48
|
|
|
|
|
|
|
lazy => 1, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub next { |
54
|
|
|
|
|
|
|
my ($self) = @_; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my $prereq = $self->dequeue or return; |
57
|
|
|
|
|
|
|
my $dist = $self->callback->($prereq); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
if ( defined $dist ) { |
60
|
|
|
|
|
|
|
my $path = $dist->path; |
61
|
|
|
|
|
|
|
my @prereqs = $self->apply_filters( $dist->prerequisites ); |
62
|
|
|
|
|
|
|
$self->enqueue(@prereqs) unless $self->seen->{$path}; |
63
|
|
|
|
|
|
|
$self->seen->{$path} = 1; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
return $prereq; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub apply_filters { |
72
|
|
|
|
|
|
|
my ( $self, @prereqs ) = @_; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
return @prereqs if not $self->has_filters; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
for my $filter ( @{ $self->filters } ) { |
77
|
|
|
|
|
|
|
@prereqs = grep { !$filter->($_) } @prereqs; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
return @prereqs; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
88
|
|
|
|
|
|
|
1; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
__END__ |