1 package TAP
::Parser
::SourceHandler
::Handle
;
4 use vars
qw($VERSION @ISA);
6 use TAP::Parser::SourceHandler ();
7 use TAP::Parser::IteratorFactory ();
8 use TAP::Parser::Iterator::Stream ();
10 @ISA = qw(TAP::Parser::SourceHandler);
12 TAP
::Parser
::IteratorFactory
->register_handler(__PACKAGE__
);
16 TAP::Parser::SourceHandler::Handle - Stream TAP from an IO::Handle or a GLOB.
28 use TAP::Parser::Source;
29 use TAP::Parser::SourceHandler::Executable;
31 my $source = TAP::Parser::Source->new->raw( \*TAP_FILE );
32 $source->assemble_meta;
34 my $class = 'TAP::Parser::SourceHandler::Handle';
35 my $vote = $class->can_handle( $source );
36 my $iter = $class->make_iterator( $source );
40 This is a I<raw TAP stored in an IO Handle> L<TAP::Parser::SourceHandler> class. It
43 1. Figure out if the L<TAP::Parser::Source> it's given is an L<IO::Handle> or
44 GLOB containing raw TAP output (L</can_handle>).
46 2. Creates an iterator for IO::Handle's & globs (L</make_iterator>).
48 Unless you're writing a plugin or subclassing L<TAP::Parser>, you probably
49 won't need to use this module directly.
57 my $vote = $class->can_handle( $source );
59 Casts the following votes:
61 0.9 if $source is an IO::Handle
62 0.8 if $source is a glob
67 my ( $class, $src ) = @_;
68 my $meta = $src->meta;
72 && UNIVERSAL
::isa
( $src->raw, 'IO::Handle' );
74 return 0.8 if $meta->{is_glob
};
79 =head3 C<make_iterator>
81 my $iterator = $class->make_iterator( $source );
83 Returns a new L<TAP::Parser::Iterator::Stream> for the source.
88 my ( $class, $source ) = @_;
90 $class->_croak('$source->raw must be a glob ref or an IO::Handle')
91 unless $source->meta->{is_glob
}
92 || UNIVERSAL
::isa
( $source->raw, 'IO::Handle' );
94 return $class->iterator_class->new( $source->raw );
97 =head3 C<iterator_class>
99 The class of iterator to use, override if you're sub-classing. Defaults
100 to L<TAP::Parser::Iterator::Stream>.
104 use constant iterator_class
=> 'TAP::Parser::Iterator::Stream';
110 Please see L<TAP::Parser/SUBCLASSING> for a subclassing overview.
116 L<TAP::Parser::Iterator>,
117 L<TAP::Parser::Iterator::Stream>,
118 L<TAP::Parser::IteratorFactory>,
119 L<TAP::Parser::SourceHandler>,
120 L<TAP::Parser::SourceHandler::Executable>,
121 L<TAP::Parser::SourceHandler::Perl>,
122 L<TAP::Parser::SourceHandler::File>,
123 L<TAP::Parser::SourceHandler::RawTAP>