line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TAP::Parser::SourceHandler::File; |
2
|
|
|
|
|
|
|
|
3
|
33
|
|
|
33
|
|
2831
|
use strict; |
|
33
|
|
|
|
|
95
|
|
|
33
|
|
|
|
|
1084
|
|
4
|
33
|
|
|
33
|
|
217
|
use warnings; |
|
33
|
|
|
|
|
89
|
|
|
33
|
|
|
|
|
1082
|
|
5
|
|
|
|
|
|
|
|
6
|
33
|
|
|
33
|
|
222
|
use TAP::Parser::IteratorFactory (); |
|
33
|
|
|
|
|
92
|
|
|
33
|
|
|
|
|
563
|
|
7
|
33
|
|
|
33
|
|
15157
|
use TAP::Parser::Iterator::Stream (); |
|
33
|
|
|
|
|
110
|
|
|
33
|
|
|
|
|
937
|
|
8
|
|
|
|
|
|
|
|
9
|
33
|
|
|
33
|
|
249
|
use base 'TAP::Parser::SourceHandler'; |
|
33
|
|
|
|
|
116
|
|
|
33
|
|
|
|
|
12636
|
|
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.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::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
|
310
|
|
|
310
|
1
|
1204
|
my ( $class, $src ) = @_; |
66
|
310
|
|
|
|
|
1242
|
my $meta = $src->meta; |
67
|
310
|
|
|
|
|
1457
|
my $config = $src->config_for($class); |
68
|
|
|
|
|
|
|
|
69
|
310
|
100
|
|
|
|
1400
|
return 0 unless $meta->{is_file}; |
70
|
225
|
|
|
|
|
612
|
my $file = $meta->{file}; |
71
|
225
|
100
|
|
|
|
906
|
return 0.9 if $file->{lc_ext} eq '.tap'; |
72
|
|
|
|
|
|
|
|
73
|
222
|
100
|
|
|
|
1001
|
if ( my $exts = $config->{extensions} ) { |
74
|
4
|
50
|
|
|
|
33
|
my @exts = ref $exts eq 'ARRAY' ? @$exts : $exts; |
75
|
4
|
50
|
|
|
|
18
|
return 0.9 if grep { lc($_) eq $file->{lc_ext} } @exts; |
|
4
|
|
|
|
|
158
|
|
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
218
|
|
|
|
|
1153
|
return 0; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head3 C |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my $iterator = $class->make_iterator( $source ); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Returns a new L for the source. Cs |
86
|
|
|
|
|
|
|
on error. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub make_iterator { |
91
|
5
|
|
|
5
|
1
|
53
|
my ( $class, $source ) = @_; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
$class->_croak('$source->raw must be a scalar ref') |
94
|
5
|
50
|
|
|
|
22
|
unless $source->meta->{is_scalar}; |
95
|
|
|
|
|
|
|
|
96
|
5
|
|
|
|
|
15
|
my $file = ${ $source->raw }; |
|
5
|
|
|
|
|
21
|
|
97
|
5
|
|
|
|
|
81
|
my $fh; |
98
|
5
|
50
|
|
|
|
179
|
open( $fh, '<', $file ) |
99
|
|
|
|
|
|
|
or $class->_croak("error opening TAP source file '$file': $!"); |
100
|
5
|
|
|
|
|
110
|
return $class->iterator_class->new($fh); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head3 C |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
The class of iterator to use, override if you're sub-classing. Defaults |
106
|
|
|
|
|
|
|
to L. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
|
110
|
33
|
|
|
33
|
|
360
|
use constant iterator_class => 'TAP::Parser::Iterator::Stream'; |
|
33
|
|
|
|
|
97
|
|
|
33
|
|
|
|
|
2822
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
__END__ |