<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package TAP::Parser::Iterator::Stream;

use strict;
use warnings;

use base 'TAP::Parser::Iterator';

=head1 NAME

TAP::Parser::Iterator::Stream - Iterator for filehandle-based TAP sources

=head1 VERSION

Version 3.44

=cut

our $VERSION = '3.44';

=head1 SYNOPSIS

  use TAP::Parser::Iterator::Stream;
  open( TEST, 'test.tap' );
  my $it   = TAP::Parser::Iterator::Stream-&gt;new(\*TEST);
  my $line = $it-&gt;next;

=head1 DESCRIPTION

This is a simple iterator wrapper for reading from filehandles, used by
L&lt;TAP::Parser&gt;.  Unless you're writing a plugin or subclassing, you probably
won't need to use this module directly.

=head1 METHODS

=head2 Class Methods

=head3 C&lt;new&gt;

Create an iterator.  Expects one argument containing a filehandle.

=cut

# new() implementation supplied by TAP::Object

sub _initialize {
    my ( $self, $thing ) = @_;
    $self-&gt;{fh} = $thing;
    return $self;
}

=head2 Instance Methods

=head3 C&lt;next&gt;

Iterate through it, of course.

=head3 C&lt;next_raw&gt;

Iterate raw input without applying any fixes for quirky input syntax.

=head3 C&lt;wait&gt;

Get the wait status for this iterator. Always returns zero.

=head3 C&lt;exit&gt;

Get the exit status for this iterator. Always returns zero.

=cut

sub wait { shift-&gt;exit }
sub exit { shift-&gt;{fh} ? () : 0 }

sub next_raw {
    my $self = shift;
    my $fh   = $self-&gt;{fh};

    if ( defined( my $line = &lt;$fh&gt; ) ) {
        chomp $line;
        return $line;
    }
    else {
        $self-&gt;_finish;
        return;
    }
}

sub _finish {
    my $self = shift;
    close delete $self-&gt;{fh};
}

sub get_select_handles {
    my $self = shift;

    # return our handle in case it's a socket or pipe (select()-able)
    return ( $self-&gt;{fh}, )
        if (-S $self-&gt;{fh} || -p $self-&gt;{fh});

    return;
}

1;

=head1 ATTRIBUTION

Originally ripped off from L&lt;Test::Harness&gt;.

=head1 SEE ALSO

L&lt;TAP::Object&gt;,
L&lt;TAP::Parser&gt;,
L&lt;TAP::Parser::Iterator&gt;,

=cut

</pre></body></html>