blib/lib/TAP/Parser/SourceHandler.pm

filter: Statementstmt 69.2% 18 / 26 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 6 / 8 Podpod 100% 4 / 4 totaltotal 73.6% 28 / 38 CC 1 SCAR 1.4
CC
1
Cov
69%
can_handle
1.3
can_handle
1.3
make_iterator
1.3
CRAP 1.1
« blib/lib/TAP/Parser/Iterator.pm ↑ Summary blib/lib/TAP/Formatter/File.pm »
1 package TAP::Parser::SourceHandler;
2  
3 37 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 37 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 37 ▶use TAP::Parser::Iterator ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 37 ▶use base 'TAP::Object';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 =head1 NAME
10  
11 TAP::Parser::SourceHandler - Base class for different TAP source handlers
12  
13 =head1 VERSION
14  
15 Version 3.52
16  
17 =cut
18  
19 37 our $VERSION = '3.52';
20  
21 =head1 SYNOPSIS
22  
23 # abstract class - don't use directly!
24 # see TAP::Parser::IteratorFactory for general usage
25  
26 # must be sub-classed for use
27 package MySourceHandler;
28 use base 'TAP::Parser::SourceHandler';
29 sub can_handle { return $confidence_level }
30 sub make_iterator { return $iterator }
31  
32 # see example below for more details
33  
34 =head1 DESCRIPTION
35  
36 This is an abstract base class for L<TAP::Parser::Source> handlers / handlers.
37  
38 A C<TAP::Parser::SourceHandler> does whatever is necessary to produce & capture
39 a stream of TAP from the I<raw> source, and package it up in a
40 L<TAP::Parser::Iterator> for the parser to consume.
41  
42 C<SourceHandlers> must implement the I<source detection & handling> interface
43 used by L<TAP::Parser::IteratorFactory>. At 2 methods, the interface is pretty
44 simple: L</can_handle> and L</make_source>.
45  
46 Unless you're writing a new L<TAP::Parser::SourceHandler>, a plugin, or
47 subclassing L<TAP::Parser>, you probably won't need to use this module directly.
48  
49 =head1 METHODS
50  
51 =head2 Class Methods
52  
53 =head3 C<can_handle>
54  
55 I<Abstract method>.
56  
57 my $vote = $class->can_handle( $source );
58  
59 C<$source> is a L<TAP::Parser::Source>.
60  
61 Returns a number between C<0> & C<1> reflecting how confidently the raw source
62 can be handled. For example, C<0> means the source cannot handle it, C<0.5>
63 means it may be able to, and C<1> means it definitely can. See
64 L<TAP::Parser::IteratorFactory/detect_source> for details on how this is used.
65  
66 =cut
67  
68 1 ▶sub can_handle {
Subroutine can_handle: called CC=1 SCAR=2.6
Pod documented
69 0 ▶ my ( $class, $args ) = @_;
Subroutine can_handle: not called CC=1 SCAR=2.6
Pod documented
70 0 $class->_croak(
71 "Abstract method 'can_handle' not implemented for $class!");
72 0 return;
73 }
74  
75 =head3 C<make_iterator>
76  
77 I<Abstract method>.
78  
79 my $iterator = $class->make_iterator( $source );
80  
81 C<$source> is a L<TAP::Parser::Source>.
82  
83 Returns a new L<TAP::Parser::Iterator> object for use by the L<TAP::Parser>.
84 C<croak>s on error.
85  
86 =cut
87  
88 1 ▶sub make_iterator {
Subroutine make_iterator: called CC=1 SCAR=2.6
Pod documented
89 0 ▶ my ( $class, $args ) = @_;
Subroutine make_iterator: not called CC=1 SCAR=2.6
Pod documented
90 0 $class->_croak(
91 "Abstract method 'make_iterator' not implemented for $class!");
92 0 return;
93 }
94 37 1;
95  
96 __END__
« blib/lib/TAP/Parser/Iterator.pm ↑ Summary blib/lib/TAP/Formatter/File.pm »