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