1 package TAP::Parser::Iterator;
6 use TAP::Parser::Iterator::Array ();
7 use TAP::Parser::Iterator::Stream ();
8 use TAP::Parser::Iterator::Process ();
12 TAP::Parser::Iterator - Internal TAP::Parser Iterator
24 use TAP::Parser::Iterator;
25 my $it = TAP::Parser::Iterator->new(\*TEST);
26 my $it = TAP::Parser::Iterator->new(\@array);
30 Originally ripped off from L<Test::Harness>.
34 B<FOR INTERNAL USE ONLY!>
36 This is a simple iterator wrapper for arrays and filehandles.
42 my $iter = TAP::Parser::Iterator->new( $array_reference );
43 my $iter = TAP::Parser::Iterator->new( $filehandle );
47 =head2 Instance Methods
51 while ( my $item = $iter->next ) { ... }
53 Iterate through it, of course.
57 while ( my $item = $iter->next_raw ) { ... }
59 Iterate raw input without applying any fixes for quirky input syntax.
64 my ( $proto, $thing ) = @_;
67 if ( $ref eq 'GLOB' || $ref eq 'IO::Handle' ) {
68 return TAP::Parser::Iterator::Stream->new($thing);
70 elsif ( $ref eq 'ARRAY' ) {
71 return TAP::Parser::Iterator::Array->new($thing);
73 elsif ( $ref eq 'HASH' ) {
74 return TAP::Parser::Iterator::Process->new($thing);
77 die "Can't iterate with a $ref";
83 my $line = $self->next_raw;
85 # vms nit: When encountering 'not ok', vms often has the 'not' on a line
89 if ( defined($line) and $line =~ /^\s*not\s*$/ ) {
90 $line .= ( $self->next_raw || '' );
96 =head3 C<handle_unicode>
98 If necessary switch the input stream to handle unicode. This only has
99 any effect for I/O handle based streams.
103 sub handle_unicode { }
105 =head3 C<get_select_handles>
107 Return a list of filehandles that may be used upstream in a select()
108 call to signal that this Iterator is ready. Iterators that are not
109 handle based should return an empty list.
113 sub get_select_handles {return}