Perl: Update "prove" and add its dependencies so it actually works (again)
[msysgit.git] / lib / perl5 / 5.8.8 / TAP / Parser / SourceHandler / Handle.pm
blobfc2e65461caface19f4515aa6c22fb1198436903
1 package TAP::Parser::SourceHandler::Handle;
3 use strict;
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__);
14 =head1 NAME
16 TAP::Parser::SourceHandler::Handle - Stream TAP from an IO::Handle or a GLOB.
18 =head1 VERSION
20 Version 3.23
22 =cut
24 $VERSION = '3.23';
26 =head1 SYNOPSIS
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 );
38 =head1 DESCRIPTION
40 This is a I<raw TAP stored in an IO Handle> L<TAP::Parser::SourceHandler> class. It
41 has 2 jobs:
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.
51 =head1 METHODS
53 =head2 Class Methods
55 =head3 C<can_handle>
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
64 =cut
66 sub can_handle {
67 my ( $class, $src ) = @_;
68 my $meta = $src->meta;
70 return 0.9
71 if $meta->{is_object}
72 && UNIVERSAL::isa( $src->raw, 'IO::Handle' );
74 return 0.8 if $meta->{is_glob};
76 return 0;
79 =head3 C<make_iterator>
81 my $iterator = $class->make_iterator( $source );
83 Returns a new L<TAP::Parser::Iterator::Stream> for the source.
85 =cut
87 sub make_iterator {
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>.
102 =cut
104 use constant iterator_class => 'TAP::Parser::Iterator::Stream';
108 =head1 SUBCLASSING
110 Please see L<TAP::Parser/SUBCLASSING> for a subclassing overview.
112 =head1 SEE ALSO
114 L<TAP::Object>,
115 L<TAP::Parser>,
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>
125 =cut