line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TAP::Parser::SourceHandler::File; |
2
|
|
|
|
|
|
|
|
3
|
33
|
|
|
33
|
|
2038
|
use strict; |
|
33
|
|
|
|
|
46
|
|
|
33
|
|
|
|
|
842
|
|
4
|
33
|
|
|
33
|
|
117
|
use warnings; |
|
33
|
|
|
|
|
38
|
|
|
33
|
|
|
|
|
725
|
|
5
|
|
|
|
|
|
|
|
6
|
33
|
|
|
33
|
|
120
|
use TAP::Parser::IteratorFactory (); |
|
33
|
|
|
|
|
494
|
|
|
33
|
|
|
|
|
405
|
|
7
|
33
|
|
|
33
|
|
12193
|
use TAP::Parser::Iterator::Stream (); |
|
33
|
|
|
|
|
56
|
|
|
33
|
|
|
|
|
565
|
|
8
|
|
|
|
|
|
|
|
9
|
33
|
|
|
33
|
|
134
|
use base 'TAP::Parser::SourceHandler'; |
|
33
|
|
|
|
|
33
|
|
|
33
|
|
|
|
|
8256
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
TAP::Parser::IteratorFactory->register_handler(__PACKAGE__); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
TAP::Parser::SourceHandler::File - Stream TAP from a text file. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 VERSION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Version 3.38 |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '3.38'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 SYNOPSIS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use TAP::Parser::Source; |
28
|
|
|
|
|
|
|
use TAP::Parser::SourceHandler::File; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $source = TAP::Parser::Source->new->raw( \'file.tap' ); |
31
|
|
|
|
|
|
|
$source->assemble_meta; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $class = 'TAP::Parser::SourceHandler::File'; |
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 I source it's given is a file containing raw TAP |
42
|
|
|
|
|
|
|
output. See L for more details. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
2. Takes raw TAP from the text file given, and converts into an iterator. |
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 looks like a regular file. Casts the following votes: |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
0.9 if it's a .tap file |
60
|
|
|
|
|
|
|
0.9 if it has an extension matching any given in user config. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub can_handle { |
65
|
307
|
|
|
307
|
1
|
551
|
my ( $class, $src ) = @_; |
66
|
307
|
|
|
|
|
683
|
my $meta = $src->meta; |
67
|
307
|
|
|
|
|
990
|
my $config = $src->config_for($class); |
68
|
|
|
|
|
|
|
|
69
|
307
|
100
|
|
|
|
811
|
return 0 unless $meta->{is_file}; |
70
|
222
|
|
|
|
|
332
|
my $file = $meta->{file}; |
71
|
222
|
100
|
|
|
|
616
|
return 0.9 if $file->{lc_ext} eq '.tap'; |
72
|
|
|
|
|
|
|
|
73
|
220
|
100
|
|
|
|
623
|
if ( my $exts = $config->{extensions} ) { |
74
|
4
|
50
|
|
|
|
7
|
return 0.9 if grep { lc($_) eq $file->{lc_ext} } @$exts; |
|
4
|
|
|
|
|
27
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
216
|
|
|
|
|
603
|
return 0; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head3 C |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $iterator = $class->make_iterator( $source ); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Returns a new L for the source. Cs |
85
|
|
|
|
|
|
|
on error. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub make_iterator { |
90
|
5
|
|
|
5
|
1
|
33
|
my ( $class, $source ) = @_; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
$class->_croak('$source->raw must be a scalar ref') |
93
|
5
|
50
|
|
|
|
15
|
unless $source->meta->{is_scalar}; |
94
|
|
|
|
|
|
|
|
95
|
5
|
|
|
|
|
8
|
my $file = ${ $source->raw }; |
|
5
|
|
|
|
|
16
|
|
96
|
5
|
|
|
|
|
8
|
my $fh; |
97
|
5
|
50
|
|
|
|
140
|
open( $fh, '<', $file ) |
98
|
|
|
|
|
|
|
or $class->_croak("error opening TAP source file '$file': $!"); |
99
|
5
|
|
|
|
|
89
|
return $class->iterator_class->new($fh); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head3 C |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
The class of iterator to use, override if you're sub-classing. Defaults |
105
|
|
|
|
|
|
|
to L. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
108
|
|
|
|
|
|
|
|
109
|
33
|
|
|
33
|
|
234
|
use constant iterator_class => 'TAP::Parser::Iterator::Stream'; |
|
33
|
|
|
|
|
50
|
|
|
33
|
|
|
|
|
1952
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
__END__ |