<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package TAP::Parser::SourceHandler::Handle;

use strict;
use warnings;

use TAP::Parser::IteratorFactory  ();
use TAP::Parser::Iterator::Stream ();

use base 'TAP::Parser::SourceHandler';

TAP::Parser::IteratorFactory-&gt;register_handler(__PACKAGE__);

=head1 NAME

TAP::Parser::SourceHandler::Handle - Stream TAP from an IO::Handle or a GLOB.

=head1 VERSION

Version 3.42

=cut

our $VERSION = '3.42';

=head1 SYNOPSIS

  use TAP::Parser::Source;
  use TAP::Parser::SourceHandler::Executable;

  my $source = TAP::Parser::Source-&gt;new-&gt;raw( \*TAP_FILE );
  $source-&gt;assemble_meta;

  my $class = 'TAP::Parser::SourceHandler::Handle';
  my $vote  = $class-&gt;can_handle( $source );
  my $iter  = $class-&gt;make_iterator( $source );

=head1 DESCRIPTION

This is a I&lt;raw TAP stored in an IO Handle&gt; L&lt;TAP::Parser::SourceHandler&gt; class.  It
has 2 jobs:

1. Figure out if the L&lt;TAP::Parser::Source&gt; it's given is an L&lt;IO::Handle&gt; or
GLOB containing raw TAP output (L&lt;/can_handle&gt;).

2. Creates an iterator for IO::Handle's &amp; globs (L&lt;/make_iterator&gt;).

Unless you're writing a plugin or subclassing L&lt;TAP::Parser&gt;, you probably
won't need to use this module directly.

=head1 METHODS

=head2 Class Methods

=head3 C&lt;can_handle&gt;

  my $vote = $class-&gt;can_handle( $source );

Casts the following votes:

  0.9 if $source is an IO::Handle
  0.8 if $source is a glob

=cut

sub can_handle {
    my ( $class, $src ) = @_;
    my $meta = $src-&gt;meta;

    return 0.9
      if $meta-&gt;{is_object}
          &amp;&amp; UNIVERSAL::isa( $src-&gt;raw, 'IO::Handle' );

    return 0.8 if $meta-&gt;{is_glob};

    return 0;
}

=head3 C&lt;make_iterator&gt;

  my $iterator = $class-&gt;make_iterator( $source );

Returns a new L&lt;TAP::Parser::Iterator::Stream&gt; for the source.

=cut

sub make_iterator {
    my ( $class, $source ) = @_;

    $class-&gt;_croak('$source-&gt;raw must be a glob ref or an IO::Handle')
      unless $source-&gt;meta-&gt;{is_glob}
          || UNIVERSAL::isa( $source-&gt;raw, 'IO::Handle' );

    return $class-&gt;iterator_class-&gt;new( $source-&gt;raw );
}

=head3 C&lt;iterator_class&gt;

The class of iterator to use, override if you're sub-classing.  Defaults
to L&lt;TAP::Parser::Iterator::Stream&gt;.

=cut

use constant iterator_class =&gt; 'TAP::Parser::Iterator::Stream';

1;

=head1 SUBCLASSING

Please see L&lt;TAP::Parser/SUBCLASSING&gt; for a subclassing overview.

=head1 SEE ALSO

L&lt;TAP::Object&gt;,
L&lt;TAP::Parser&gt;,
L&lt;TAP::Parser::Iterator&gt;,
L&lt;TAP::Parser::Iterator::Stream&gt;,
L&lt;TAP::Parser::IteratorFactory&gt;,
L&lt;TAP::Parser::SourceHandler&gt;,
L&lt;TAP::Parser::SourceHandler::Executable&gt;,
L&lt;TAP::Parser::SourceHandler::Perl&gt;,
L&lt;TAP::Parser::SourceHandler::File&gt;,
L&lt;TAP::Parser::SourceHandler::RawTAP&gt;

=cut
</pre></body></html>