1TAP::Parser::Source(3)User Contributed Perl DocumentationTAP::Parser::Source(3)
2
3
4
6 TAP::Parser::Source - a TAP source & meta data about it
7
9 Version 3.42
10
12 use TAP::Parser::Source;
13 my $source = TAP::Parser::Source->new;
14 $source->raw( \'reference to raw TAP source' )
15 ->config( \%config )
16 ->merge( $boolean )
17 ->switches( \@switches )
18 ->test_args( \@args )
19 ->assemble_meta;
20
21 do { ... } if $source->meta->{is_file};
22 # see assemble_meta for a full list of data available
23
25 A TAP source is something that produces a stream of TAP for the parser
26 to consume, such as an executable file, a text file, an archive, an IO
27 handle, a database, etc. "TAP::Parser::Source"s encapsulate these raw
28 sources, and provide some useful meta data about them. They are used
29 by TAP::Parser::SourceHandlers, which do whatever is required to
30 produce & capture a stream of TAP from the raw source, and package it
31 up in a TAP::Parser::Iterator for the parser to consume.
32
33 Unless you're writing a new TAP::Parser::SourceHandler, a plugin or
34 subclassing TAP::Parser, you probably won't need to use this module
35 directly.
36
38 Class Methods
39 "new"
40
41 my $source = TAP::Parser::Source->new;
42
43 Returns a new "TAP::Parser::Source" object.
44
45 Instance Methods
46 "raw"
47
48 my $raw = $source->raw;
49 $source->raw( $some_value );
50
51 Chaining getter/setter for the raw TAP source. This is a reference, as
52 it may contain large amounts of data (eg: raw TAP).
53
54 "meta"
55
56 my $meta = $source->meta;
57 $source->meta({ %some_value });
58
59 Chaining getter/setter for meta data about the source. This defaults
60 to an empty hashref. See "assemble_meta" for more info.
61
62 "has_meta"
63
64 True if the source has meta data.
65
66 "config"
67
68 my $config = $source->config;
69 $source->config({ %some_value });
70
71 Chaining getter/setter for the source's configuration, if any has been
72 provided by the user. How it's used is up to you. This defaults to an
73 empty hashref. See "config_for" for more info.
74
75 "merge"
76
77 my $merge = $source->merge;
78 $source->config( $bool );
79
80 Chaining getter/setter for the flag that dictates whether STDOUT and
81 STDERR should be merged (where appropriate). Defaults to undef.
82
83 "switches"
84
85 my $switches = $source->switches;
86 $source->config([ @switches ]);
87
88 Chaining getter/setter for the list of command-line switches that
89 should be passed to the source (where appropriate). Defaults to undef.
90
91 "test_args"
92
93 my $test_args = $source->test_args;
94 $source->config([ @test_args ]);
95
96 Chaining getter/setter for the list of command-line arguments that
97 should be passed to the source (where appropriate). Defaults to undef.
98
99 "assemble_meta"
100
101 my $meta = $source->assemble_meta;
102
103 Gathers meta data about the "raw" source, stashes it in "meta" and
104 returns it as a hashref. This is done so that the
105 TAP::Parser::SourceHandlers don't have to repeat common checks.
106 Currently this includes:
107
108 is_scalar => $bool,
109 is_hash => $bool,
110 is_array => $bool,
111
112 # for scalars:
113 length => $n
114 has_newlines => $bool
115
116 # only done if the scalar looks like a filename
117 is_file => $bool,
118 is_dir => $bool,
119 is_symlink => $bool,
120 file => {
121 # only done if the scalar looks like a filename
122 basename => $string, # including ext
123 dir => $string,
124 ext => $string,
125 lc_ext => $string,
126 # system checks
127 exists => $bool,
128 stat => [ ... ], # perldoc -f stat
129 empty => $bool,
130 size => $n,
131 text => $bool,
132 binary => $bool,
133 read => $bool,
134 write => $bool,
135 execute => $bool,
136 setuid => $bool,
137 setgid => $bool,
138 sticky => $bool,
139 is_file => $bool,
140 is_dir => $bool,
141 is_symlink => $bool,
142 # only done if the file's a symlink
143 lstat => [ ... ], # perldoc -f lstat
144 # only done if the file's a readable text file
145 shebang => $first_line,
146 }
147
148 # for arrays:
149 size => $n,
150
151 "shebang"
152
153 Get the shebang line for a script file.
154
155 my $shebang = TAP::Parser::Source->shebang( $some_script );
156
157 May be called as a class method
158
159 "config_for"
160
161 my $config = $source->config_for( $class );
162
163 Returns "config" for the $class given. Class names may be fully
164 qualified or abbreviated, eg:
165
166 # these are equivalent
167 $source->config_for( 'Perl' );
168 $source->config_for( 'TAP::Parser::SourceHandler::Perl' );
169
170 If a fully qualified $class is given, its abbreviated version is
171 checked first.
172
174 Steve Purkis.
175
177 TAP::Object, TAP::Parser, TAP::Parser::IteratorFactory,
178 TAP::Parser::SourceHandler
179
180
181
182perl v5.30.1 2020-01-30 TAP::Parser::Source(3)