| 1 | package TAP::Parser::Iterator::Stream; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 33 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 33 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 33 | ▶ | use base 'TAP::Parser::Iterator'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | =head1 NAME | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | TAP::Parser::Iterator::Stream - Iterator for filehandle-based TAP sources | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | =head1 VERSION | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | Version 3.52 | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | =cut | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 33 | our $VERSION = '3.52'; | |||||||||||||||||||||||||||
| 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 | 13 | ▶ | sub _initialize { | ||||||||||||||||||||||||||
|
Subroutine
_initialize: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 46 | 13 | my ( $self, $thing ) = @_; | |||||||||||||||||||||||||||
| 47 | 13 | $self->{fh} = $thing; | |||||||||||||||||||||||||||
| 48 | 13 | 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 | 8 | ▶ | sub wait { shift->exit } | ||||||||||||||||||||||||||
|
Subroutine
wait: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 72 | 17 | ▶ | sub exit { shift->{fh} ? () : 0 } | ||||||||||||||||||||||||||
|
Subroutine
exit: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 49 | ▶ | sub next_raw { | ||||||||||||||||||||||||||
|
Subroutine
next_raw: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 75 | 49 | my $self = shift; | |||||||||||||||||||||||||||
| 76 | 49 | my $fh = $self->{fh}; | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 49 | ▶ | if ( defined( my $line = <$fh> ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 38 | chomp $line; | |||||||||||||||||||||||||||
| 80 | 38 | return $line; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | else { | ||||||||||||||||||||||||||||
| 83 | 11 | $self->_finish; | |||||||||||||||||||||||||||
| 84 | 11 | return; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 11 | ▶ | sub _finish { | ||||||||||||||||||||||||||
|
Subroutine
_finish: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 89 | 11 | my $self = shift; | |||||||||||||||||||||||||||
| 90 | 11 | close delete $self->{fh}; | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 0 | ▶ | sub get_select_handles { | ||||||||||||||||||||||||||
|
Subroutine
get_select_handles: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 94 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | # return our handle in case it's a socket or pipe (select()-able) | ||||||||||||||||||||||||||||
| 97 | return ( $self->{fh}, ) | ||||||||||||||||||||||||||||
| 98 | 0 | ▶ | if (-S $self->{fh} || -p $self->{fh}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-S $self->{"fh"} or -p $self->{"fh"}
MC/DC0%0/2
-S $self->{"fh"} or -p $self->{"fh"}
-S $self->{"fh"}
-p $self->{"fh"}
Truth table0%0/3
A or B
A= -S $self->{"fh"}B= -p $self->{"fh"}
| |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 0 | return; | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 33 | 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 | |||||||||||||||||||||||||||||