"Fossies" - the Fresh Open Source Software Archive

Member "install-tl-20200916/tlpkg/tlperl/lib/TAP/Parser/Iterator/Stream.pm" (10 Mar 2019, 1925 Bytes) of package /windows/misc/install-tl.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 package TAP::Parser::Iterator::Stream;
    2 
    3 use strict;
    4 use warnings;
    5 
    6 use base 'TAP::Parser::Iterator';
    7 
    8 =head1 NAME
    9 
   10 TAP::Parser::Iterator::Stream - Iterator for filehandle-based TAP sources
   11 
   12 =head1 VERSION
   13 
   14 Version 3.42
   15 
   16 =cut
   17 
   18 our $VERSION = '3.42';
   19 
   20 =head1 SYNOPSIS
   21 
   22   use TAP::Parser::Iterator::Stream;
   23   open( TEST, 'test.tap' );
   24   my $it   = TAP::Parser::Iterator::Stream->new(\*TEST);
   25   my $line = $it->next;
   26 
   27 =head1 DESCRIPTION
   28 
   29 This is a simple iterator wrapper for reading from filehandles, used by
   30 L<TAP::Parser>.  Unless you're writing a plugin or subclassing, you probably
   31 won't need to use this module directly.
   32 
   33 =head1 METHODS
   34 
   35 =head2 Class Methods
   36 
   37 =head3 C<new>
   38 
   39 Create an iterator.  Expects one argument containing a filehandle.
   40 
   41 =cut
   42 
   43 # new() implementation supplied by TAP::Object
   44 
   45 sub _initialize {
   46     my ( $self, $thing ) = @_;
   47     $self->{fh} = $thing;
   48     return $self;
   49 }
   50 
   51 =head2 Instance Methods
   52 
   53 =head3 C<next>
   54 
   55 Iterate through it, of course.
   56 
   57 =head3 C<next_raw>
   58 
   59 Iterate raw input without applying any fixes for quirky input syntax.
   60 
   61 =head3 C<wait>
   62 
   63 Get the wait status for this iterator. Always returns zero.
   64 
   65 =head3 C<exit>
   66 
   67 Get the exit status for this iterator. Always returns zero.
   68 
   69 =cut
   70 
   71 sub wait { shift->exit }
   72 sub exit { shift->{fh} ? () : 0 }
   73 
   74 sub next_raw {
   75     my $self = shift;
   76     my $fh   = $self->{fh};
   77 
   78     if ( defined( my $line = <$fh> ) ) {
   79         chomp $line;
   80         return $line;
   81     }
   82     else {
   83         $self->_finish;
   84         return;
   85     }
   86 }
   87 
   88 sub _finish {
   89     my $self = shift;
   90     close delete $self->{fh};
   91 }
   92 
   93 sub get_select_handles {
   94     my $self = shift;
   95 
   96     # return our handle in case it's a socket or pipe (select()-able)
   97     return ( $self->{fh}, )
   98         if (-S $self->{fh} || -p $self->{fh});
   99 
  100     return;
  101 }
  102 
  103 1;
  104 
  105 =head1 ATTRIBUTION
  106 
  107 Originally ripped off from L<Test::Harness>.
  108 
  109 =head1 SEE ALSO
  110 
  111 L<TAP::Object>,
  112 L<TAP::Parser>,
  113 L<TAP::Parser::Iterator>,
  114 
  115 =cut
  116