line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TAP::Parser::SourceHandler::RawTAP; |
2
|
|
|
|
|
|
|
|
3
|
33
|
|
|
33
|
|
20622
|
use strict; |
|
33
|
|
|
|
|
99
|
|
|
33
|
|
|
|
|
1175
|
|
4
|
33
|
|
|
33
|
|
223
|
use warnings; |
|
33
|
|
|
|
|
91
|
|
|
33
|
|
|
|
|
1038
|
|
5
|
|
|
|
|
|
|
|
6
|
33
|
|
|
33
|
|
223
|
use TAP::Parser::IteratorFactory (); |
|
33
|
|
|
|
|
91
|
|
|
33
|
|
|
|
|
725
|
|
7
|
33
|
|
|
33
|
|
16020
|
use TAP::Parser::Iterator::Array (); |
|
33
|
|
|
|
|
130
|
|
|
33
|
|
|
|
|
856
|
|
8
|
|
|
|
|
|
|
|
9
|
33
|
|
|
33
|
|
241
|
use base 'TAP::Parser::SourceHandler'; |
|
33
|
|
|
|
|
89
|
|
|
33
|
|
|
|
|
13255
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
TAP::Parser::IteratorFactory->register_handler(__PACKAGE__); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
TAP::Parser::SourceHandler::RawTAP - Stream output from raw TAP in a scalar/array ref. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 VERSION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Version 3.40_01 |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '3.40_01'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 SYNOPSIS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use TAP::Parser::Source; |
28
|
|
|
|
|
|
|
use TAP::Parser::SourceHandler::RawTAP; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $source = TAP::Parser::Source->new->raw( \"1..1\nok 1\n" ); |
31
|
|
|
|
|
|
|
$source->assemble_meta; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $class = 'TAP::Parser::SourceHandler::RawTAP'; |
34
|
|
|
|
|
|
|
my $vote = $class->can_handle( $source ); |
35
|
|
|
|
|
|
|
my $iter = $class->make_iterator( $source ); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 DESCRIPTION |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
This is a I L - it has 2 jobs: |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1. Figure out if the L it's given is raw TAP output |
42
|
|
|
|
|
|
|
(L). |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
2. Creates an iterator for raw TAP output (L). |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Unless you're writing a plugin or subclassing L, you probably |
47
|
|
|
|
|
|
|
won't need to use this module directly. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 METHODS |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 Class Methods |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head3 C |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $vote = $class->can_handle( $source ); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Only votes if $source is an array, or a scalar with newlines. Casts the |
58
|
|
|
|
|
|
|
following votes: |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
0.9 if it's a scalar with '..' in it |
61
|
|
|
|
|
|
|
0.7 if it's a scalar with 'ok' in it |
62
|
|
|
|
|
|
|
0.3 if it's just a scalar with newlines |
63
|
|
|
|
|
|
|
0.5 if it's an array |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub can_handle { |
68
|
310
|
|
|
310
|
1
|
1272
|
my ( $class, $src ) = @_; |
69
|
310
|
|
|
|
|
1689
|
my $meta = $src->meta; |
70
|
|
|
|
|
|
|
|
71
|
310
|
100
|
|
|
|
1598
|
return 0 if $meta->{file}; |
72
|
89
|
100
|
|
|
|
353
|
if ( $meta->{is_scalar} ) { |
|
|
100
|
|
|
|
|
|
73
|
66
|
100
|
|
|
|
267
|
return 0 unless $meta->{has_newlines}; |
74
|
65
|
100
|
|
|
|
148
|
return 0.9 if ${ $src->raw } =~ /\d\.\.\d/; |
|
65
|
|
|
|
|
201
|
|
75
|
4
|
100
|
|
|
|
11
|
return 0.7 if ${ $src->raw } =~ /ok/; |
|
4
|
|
|
|
|
15
|
|
76
|
2
|
|
|
|
|
10
|
return 0.3; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
elsif ( $meta->{is_array} ) { |
79
|
4
|
|
|
|
|
28
|
return 0.5; |
80
|
|
|
|
|
|
|
} |
81
|
19
|
|
|
|
|
73
|
return 0; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head3 C |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $iterator = $class->make_iterator( $source ); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Returns a new L for the source. |
89
|
|
|
|
|
|
|
C<$source-Eraw> must be an array ref, or a scalar ref. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Cs on error. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub make_iterator { |
96
|
66
|
|
|
66
|
1
|
228
|
my ( $class, $src ) = @_; |
97
|
66
|
|
|
|
|
251
|
my $meta = $src->meta; |
98
|
|
|
|
|
|
|
|
99
|
66
|
|
|
|
|
153
|
my $tap_array; |
100
|
66
|
100
|
|
|
|
269
|
if ( $meta->{is_scalar} ) { |
|
|
50
|
|
|
|
|
|
101
|
63
|
|
|
|
|
152
|
$tap_array = [ split "\n" => ${ $src->raw } ]; |
|
63
|
|
|
|
|
222
|
|
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
elsif ( $meta->{is_array} ) { |
104
|
3
|
|
|
|
|
15
|
$tap_array = $src->raw; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
66
|
50
|
|
|
|
328
|
$class->_croak('No raw TAP found in $source->raw') |
108
|
|
|
|
|
|
|
unless scalar $tap_array; |
109
|
|
|
|
|
|
|
|
110
|
66
|
|
|
|
|
438
|
return TAP::Parser::Iterator::Array->new($tap_array); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 SUBCLASSING |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Please see L for a subclassing overview. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 SEE ALSO |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
L, |
122
|
|
|
|
|
|
|
L, |
123
|
|
|
|
|
|
|
L, |
124
|
|
|
|
|
|
|
L, |
125
|
|
|
|
|
|
|
L, |
126
|
|
|
|
|
|
|
L, |
127
|
|
|
|
|
|
|
L, |
128
|
|
|
|
|
|
|
L |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |