line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TAP::Parser::SourceHandler::File; |
2
|
|
|
|
|
|
|
|
3
|
33
|
|
|
33
|
|
1985
|
use strict; |
|
33
|
|
|
|
|
43
|
|
|
33
|
|
|
|
|
815
|
|
4
|
33
|
|
|
33
|
|
109
|
use warnings; |
|
33
|
|
|
|
|
45
|
|
|
33
|
|
|
|
|
762
|
|
5
|
|
|
|
|
|
|
|
6
|
33
|
|
|
33
|
|
138
|
use TAP::Parser::IteratorFactory (); |
|
33
|
|
|
|
|
583
|
|
|
33
|
|
|
|
|
438
|
|
7
|
33
|
|
|
33
|
|
12216
|
use TAP::Parser::Iterator::Stream (); |
|
33
|
|
|
|
|
60
|
|
|
33
|
|
|
|
|
569
|
|
8
|
|
|
|
|
|
|
|
9
|
33
|
|
|
33
|
|
142
|
use base 'TAP::Parser::SourceHandler'; |
|
33
|
|
|
|
|
36
|
|
|
33
|
|
|
|
|
8537
|
|
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.39 |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '3.39'; |
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
|
500
|
my ( $class, $src ) = @_; |
66
|
307
|
|
|
|
|
726
|
my $meta = $src->meta; |
67
|
307
|
|
|
|
|
867
|
my $config = $src->config_for($class); |
68
|
|
|
|
|
|
|
|
69
|
307
|
100
|
|
|
|
905
|
return 0 unless $meta->{is_file}; |
70
|
222
|
|
|
|
|
319
|
my $file = $meta->{file}; |
71
|
222
|
100
|
|
|
|
643
|
return 0.9 if $file->{lc_ext} eq '.tap'; |
72
|
|
|
|
|
|
|
|
73
|
220
|
100
|
|
|
|
643
|
if ( my $exts = $config->{extensions} ) { |
74
|
4
|
50
|
|
|
|
10
|
return 0.9 if grep { lc($_) eq $file->{lc_ext} } @$exts; |
|
4
|
|
|
|
|
27
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
216
|
|
|
|
|
505
|
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
|
43
|
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
|
|
|
|
|
15
|
|
96
|
5
|
|
|
|
|
55
|
my $fh; |
97
|
5
|
50
|
|
|
|
144
|
open( $fh, '<', $file ) |
98
|
|
|
|
|
|
|
or $class->_croak("error opening TAP source file '$file': $!"); |
99
|
5
|
|
|
|
|
120
|
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
|
|
216
|
use constant iterator_class => 'TAP::Parser::Iterator::Stream'; |
|
33
|
|
|
|
|
61
|
|
|
33
|
|
|
|
|
2011
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
__END__ |