| 1 | # ABSTRACT: Iterates through revision history | ||||||||||
| 2 | |||||||||||
| 3 | package Pinto::RevisionWalker; | ||||||||||
| 4 | |||||||||||
| 5 | 3 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 3 | ▶ | use MooseX::StrictConstructor; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 3 | ▶ | use MooseX::Types::Moose qw(ArrayRef); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 3 | ▶ | use MooseX::MarkAsMethods ( autoclean => 1 ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | #------------------------------------------------------------------------------ | ||||||||||
| 11 | |||||||||||
| 12 | 3 | our $VERSION = '0.14'; # VERSION | |||||||||
| 13 | |||||||||||
| 14 | #------------------------------------------------------------------------------ | ||||||||||
| 15 | # TODO: Rethink this API. Do we need start? Can we just use queue? What | ||||||||||
| 16 | # about filtering, or walking forward? Sort chronological or topological? | ||||||||||
| 17 | |||||||||||
| 18 | 3 | has start => ( | |||||||||
| 19 | is => 'ro', | ||||||||||
| 20 | isa => 'Pinto::Schema::Result::Revision', | ||||||||||
| 21 | required => 1, | ||||||||||
| 22 | ); | ||||||||||
| 23 | |||||||||||
| 24 | has queue => ( | ||||||||||
| 25 | isa => ArrayRef, | ||||||||||
| 26 | traits => [qw(Array)], | ||||||||||
| 27 | handles => { enqueue => 'push', dequeue => 'shift' }, | ||||||||||
| 28 | 2 | ▶ | default => sub { [ $_[0]->start ] }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 29 | 3 | lazy => 1, | |||||||||
| 30 | ); | ||||||||||
| 31 | |||||||||||
| 32 | #------------------------------------------------------------------------------ | ||||||||||
| 33 | |||||||||||
| 34 | 5 | ▶ | sub next { | ||||||||
|
Subroutine
next: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 35 | 5 | my ($self) = @_; | |||||||||
| 36 | |||||||||||
| 37 | 5 | my $next = $self->dequeue; | |||||||||
| 38 | |||||||||||
| 39 | 5 | ▶ | return if not $next; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 5 | ▶ | return if $next->is_root; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | |||||||||||
| 42 | 3 | $self->enqueue( $next->parents ); | |||||||||
| 43 | |||||||||||
| 44 | 3 | return $next; | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | #------------------------------------------------------------------------------ | ||||||||||
| 48 | |||||||||||
| 49 | 3 | __PACKAGE__->meta->make_immutable; | |||||||||
| 50 | |||||||||||
| 51 | #------------------------------------------------------------------------------- | ||||||||||
| 52 | 3 | 1; | |||||||||
| 53 | |||||||||||
| 54 | __END__ | ||||||||||