1 package TAP::Parser::SourceHandler::Handle;
6 use TAP::Parser::IteratorFactory ();
7 use TAP::Parser::Iterator::Stream ();
9 use base 'TAP::Parser::SourceHandler';
11 TAP::Parser::IteratorFactory->register_handler(__PACKAGE__);
15 TAP::Parser::SourceHandler::Handle - Stream TAP from an IO::Handle or a GLOB.
23 our $VERSION = '3.31';
27 use TAP::Parser::Source;
28 use TAP::Parser::SourceHandler::Executable;
30 my $source = TAP::Parser::Source->new->raw( \*TAP_FILE );
31 $source->assemble_meta;
33 my $class = 'TAP::Parser::SourceHandler::Handle';
34 my $vote = $class->can_handle( $source );
35 my $iter = $class->make_iterator( $source );
39 This is a I<raw TAP stored in an IO Handle> L<TAP::Parser::SourceHandler> class. It
42 1. Figure out if the L<TAP::Parser::Source> it's given is an L<IO::Handle> or
43 GLOB containing raw TAP output (L</can_handle>).
45 2. Creates an iterator for IO::Handle's & globs (L</make_iterator>).
47 Unless you're writing a plugin or subclassing L<TAP::Parser>, you probably
48 won't need to use this module directly.
56 my $vote = $class->can_handle( $source );
58 Casts the following votes:
60 0.9 if $source is an IO::Handle
61 0.8 if $source is a glob
66 my ( $class, $src ) = @_;
67 my $meta = $src->meta;
71 && UNIVERSAL::isa( $src->raw, 'IO::Handle' );
73 return 0.8 if $meta->{is_glob};
78 =head3 C<make_iterator>
80 my $iterator = $class->make_iterator( $source );
82 Returns a new L<TAP::Parser::Iterator::Stream> for the source.
87 my ( $class, $source ) = @_;
89 $class->_croak('$source->raw must be a glob ref or an IO::Handle')
90 unless $source->meta->{is_glob}
91 || UNIVERSAL::isa( $source->raw, 'IO::Handle' );
93 return $class->iterator_class->new( $source->raw );
96 =head3 C<iterator_class>
98 The class of iterator to use, override if you're sub-classing. Defaults
99 to L<TAP::Parser::Iterator::Stream>.
103 use constant iterator_class => 'TAP::Parser::Iterator::Stream';
109 Please see L<TAP::Parser/SUBCLASSING> for a subclassing overview.
115 L<TAP::Parser::Iterator>,
116 L<TAP::Parser::Iterator::Stream>,
117 L<TAP::Parser::IteratorFactory>,
118 L<TAP::Parser::SourceHandler>,
119 L<TAP::Parser::SourceHandler::Executable>,
120 L<TAP::Parser::SourceHandler::Perl>,
121 L<TAP::Parser::SourceHandler::File>,
122 L<TAP::Parser::SourceHandler::RawTAP>