1package TAP::Parser::Iterator::Array; 2 3use strict; 4use warnings; 5 6use base 'TAP::Parser::Iterator'; 7 8=head1 NAME 9 10TAP::Parser::Iterator::Array - Iterator for array-based TAP sources 11 12=head1 VERSION 13 14Version 3.44 15 16=cut 17 18our $VERSION = '3.44'; 19 20=head1 SYNOPSIS 21 22 use TAP::Parser::Iterator::Array; 23 my @data = ('foo', 'bar', baz'); 24 my $it = TAP::Parser::Iterator::Array->new(\@data); 25 my $line = $it->next; 26 27=head1 DESCRIPTION 28 29This is a simple iterator wrapper for arrays of scalar content, used by 30L<TAP::Parser>. Unless you're writing a plugin or subclassing, you probably 31won't need to use this module directly. 32 33=head1 METHODS 34 35=head2 Class Methods 36 37=head3 C<new> 38 39Create an iterator. Takes one argument: an C<$array_ref> 40 41=head2 Instance Methods 42 43=head3 C<next> 44 45Iterate through it, of course. 46 47=head3 C<next_raw> 48 49Iterate raw input without applying any fixes for quirky input syntax. 50 51=head3 C<wait> 52 53Get the wait status for this iterator. For an array iterator this will always 54be zero. 55 56=head3 C<exit> 57 58Get the exit status for this iterator. For an array iterator this will always 59be zero. 60 61=cut 62 63# new() implementation supplied by TAP::Object 64 65sub _initialize { 66 my ( $self, $thing ) = @_; 67 chomp @$thing; 68 $self->{idx} = 0; 69 $self->{array} = $thing; 70 $self->{exit} = undef; 71 return $self; 72} 73 74sub wait { shift->exit } 75 76sub exit { 77 my $self = shift; 78 return 0 if $self->{idx} >= @{ $self->{array} }; 79 return; 80} 81 82sub next_raw { 83 my $self = shift; 84 return $self->{array}->[ $self->{idx}++ ]; 85} 86 871; 88 89=head1 ATTRIBUTION 90 91Originally ripped off from L<Test::Harness>. 92 93=head1 SEE ALSO 94 95L<TAP::Object>, 96L<TAP::Parser>, 97L<TAP::Parser::Iterator>, 98 99=cut 100 101