blib/lib/TAP/Parser/SourceHandler/Handle.pm

filter: Statementstmt 100% 29 / 29 Branchbran 83.3% 5 / 6 Conditioncond 66.6% 4 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 89.0% 49 / 55 CC 6 SCAR 8.8
CC
6
Cov
93%
can_handle
4.0
make_iterator
3.1
BEGIN
1.0
CRAP 2.4
« blib/lib/TAP/Parser/Grammar.pm ↑ Summary blib/lib/TAP/Formatter/Console.pm »
1 package TAP::Parser::SourceHandler::Handle;
2  
3 33 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 33 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 33 ▶use TAP::Parser::IteratorFactory ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 33 ▶use TAP::Parser::Iterator::Stream ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 33 ▶use base 'TAP::Parser::SourceHandler';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 33 TAP::Parser::IteratorFactory->register_handler(__PACKAGE__);
12  
13 =head1 NAME
14  
15 TAP::Parser::SourceHandler::Handle - Stream TAP from an IO::Handle or a GLOB.
16  
17 =head1 VERSION
18  
19 Version 3.52
20  
21 =cut
22  
23 33 our $VERSION = '3.52';
24  
25 =head1 SYNOPSIS
26  
27 use TAP::Parser::Source;
28 use TAP::Parser::SourceHandler::Executable;
29  
30 my $source = TAP::Parser::Source->new->raw( \*TAP_FILE );
31 $source->assemble_meta;
32  
33 my $class = 'TAP::Parser::SourceHandler::Handle';
34 my $vote = $class->can_handle( $source );
35 my $iter = $class->make_iterator( $source );
36  
37 =head1 DESCRIPTION
38  
39 This is a I<raw TAP stored in an IO Handle> L<TAP::Parser::SourceHandler> class. It
40 has 2 jobs:
41  
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>).
44  
45 2. Creates an iterator for IO::Handle's & globs (L</make_iterator>).
46  
47 Unless you're writing a plugin or subclassing L<TAP::Parser>, you probably
48 won't need to use this module directly.
49  
50 =head1 METHODS
51  
52 =head2 Class Methods
53  
54 =head3 C<can_handle>
55  
56 my $vote = $class->can_handle( $source );
57  
58 Casts the following votes:
59  
60 0.9 if $source is an IO::Handle
61 0.8 if $source is a glob
62  
63 =cut
64  
65 363 ▶sub can_handle {
Subroutine can_handle: called CC=4 SCAR=13.9
Pod documented
66 363 my ( $class, $src ) = @_;
67 363 my $meta = $src->meta;
68  
69 return 0.9
70 if $meta->{is_object}
71 363 ▶ && UNIVERSAL::isa( $src->raw, 'IO::Handle' );
Branch: 1 branch
BranchTrueFalseTotal
if $meta->{"is_object"} and UNIVERSAL::isa($src->raw, "IO::Handle") 2 361 363
Condition66%2/3
$meta->{"is_object"} and UNIVERSAL::isa($src->raw, "IO::Handle")
!ll&&!rl&&r
36102
MC/DC50%1/2
$meta->{"is_object"} and UNIVERSAL::isa($src->raw, "IO::Handle")
$meta->{"is_object"} UNIVERSAL::isa($src->raw, "IO::Handle")
Truth table66%2/3
A and B
A= $meta->{"is_object"}B= UNIVERSAL::isa($src->raw, "IO::Handle")
ABresult
0X0
100
111
72  
73 361 ▶ return 0.8 if $meta->{is_glob};
Branch: 1 branch
BranchTrueFalseTotal
if $meta->{"is_glob"} 6 355 361
74  
75 355 return 0;
76 }
77  
78 =head3 C<make_iterator>
79  
80 my $iterator = $class->make_iterator( $source );
81  
82 Returns a new L<TAP::Parser::Iterator::Stream> for the source.
83  
84 =cut
85  
86 5 ▶sub make_iterator {
Subroutine make_iterator: called CC=3 SCAR=11.4
Pod documented
87 5 my ( $class, $source ) = @_;
88  
89 $class->_croak('$source->raw must be a glob ref or an IO::Handle')
90 unless $source->meta->{is_glob}
91 5 ▶ || UNIVERSAL::isa( $source->raw, 'IO::Handle' );
Branch: 1 branch
BranchTrueFalseTotal
unless $source->meta->{"is_glob"} or UNIVERSAL::isa($source->raw, "IO::Handle") 0 5 5
Condition66%2/3
$source->meta->{"is_glob"} or UNIVERSAL::isa($source->raw, "IO::Handle")
l!l&&r!l&&!r
410
MC/DC0%0/2
$source->meta->{"is_glob"} or UNIVERSAL::isa($source->raw, "IO::Handle")
$source->meta->{"is_glob"} UNIVERSAL::isa($source->raw, "IO::Handle")
Truth table66%2/3
A or B
A= $source->meta->{"is_glob"}B= UNIVERSAL::isa($source->raw, "IO::Handle")
ABresult
1X1
011
000
92  
93 5 return $class->iterator_class->new( $source->raw );
94 }
95  
96 =head3 C<iterator_class>
97  
98 The class of iterator to use, override if you're sub-classing. Defaults
99 to L<TAP::Parser::Iterator::Stream>.
100  
101 =cut
102  
103 33 ▶use constant iterator_class => 'TAP::Parser::Iterator::Stream';
Subroutine BEGIN: called CC=1 SCAR=0.0
104  
105 33 1;
106  
107 =head1 SUBCLASSING
108  
109 Please see L<TAP::Parser/SUBCLASSING> for a subclassing overview.
110  
111 =head1 SEE ALSO
112  
113 L<TAP::Object>,
114 L<TAP::Parser>,
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>
123  
124 =cut
« blib/lib/TAP/Parser/Grammar.pm ↑ Summary blib/lib/TAP/Formatter/Console.pm »