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