File Coverage

blib/lib/TAP/Parser/Iterator/Stream.pm
Criterion Covered Total %
statement 23 26 88.4
branch 4 6 66.6
condition 0 3 0.0
subroutine 8 9 88.8
pod 4 4 100.0
total 39 48 81.2


line stmt bran cond sub pod time code
1             package TAP::Parser::Iterator::Stream;
2              
3 33     33   257 use strict;
  33         695  
  33         1100  
4 33     33   375 use warnings;
  33         117  
  33         1078  
5              
6 33     33   233 use base 'TAP::Parser::Iterator';
  33         87  
  33         11465  
7              
8             =head1 NAME
9              
10             TAP::Parser::Iterator::Stream - Iterator for filehandle-based TAP sources
11              
12             =head1 VERSION
13              
14             Version 3.40_01
15              
16             =cut
17              
18             our $VERSION = '3.40_01';
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. 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
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 13     13   50 my ( $self, $thing ) = @_;
47 13         90 $self->{fh} = $thing;
48 13         62 return $self;
49             }
50              
51             =head2 Instance Methods
52              
53             =head3 C
54              
55             Iterate through it, of course.
56              
57             =head3 C
58              
59             Iterate raw input without applying any fixes for quirky input syntax.
60              
61             =head3 C
62              
63             Get the wait status for this iterator. Always returns zero.
64              
65             =head3 C
66              
67             Get the exit status for this iterator. Always returns zero.
68              
69             =cut
70              
71 8     8 1 43 sub wait { shift->exit }
72 17 100   17 1 2279 sub exit { shift->{fh} ? () : 0 }
73              
74             sub next_raw {
75 49     49 1 110 my $self = shift;
76 49         105 my $fh = $self->{fh};
77              
78 49 100       1016 if ( defined( my $line = <$fh> ) ) {
79 38         112 chomp $line;
80 38         161 return $line;
81             }
82             else {
83 11         61 $self->_finish;
84 11         61 return;
85             }
86             }
87              
88             sub _finish {
89 11     11   35 my $self = shift;
90 11         137 close delete $self->{fh};
91             }
92              
93             sub get_select_handles {
94 0     0 1   my $self = shift;
95              
96             # return our handle in case it's a socket or pipe (select()-able)
97             return ( $self->{fh}, )
98 0 0 0       if (-S $self->{fh} || -p $self->{fh});
99              
100 0           return;
101             }
102              
103             1;
104              
105             =head1 ATTRIBUTION
106              
107             Originally ripped off from L.
108              
109             =head1 SEE ALSO
110              
111             L,
112             L,
113             L,
114              
115             =cut
116