Debian Codegraph @

upstream/mageia-cauldron/man3pm/TAP::Parser::ResultFactory.3pm

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\"
56 .\" Required to disable full justification in groff 1.23.0.
57 .if n .ds AD l
58 .\" ========================================================================
59 .\"
60 .IX Title "TAP::Parser::ResultFactory 3pm"
61 .TH TAP::Parser::ResultFactory 3pm 2025-06-24 "perl v5.42.0" "Perl Programmers Reference Guide"
62 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
63 .\" way too many mistakes in technical documents.
64 .if n .ad l
65 .nh
66 .SH NAME
67 TAP::Parser::ResultFactory \- Factory for creating TAP::Parser output objects
68 .SH SYNOPSIS
69 .IX Header "SYNOPSIS"
70 .Vb 4
71 \& use TAP::Parser::ResultFactory;
72 \& my $token = {...};
73 \& my $factory = TAP::Parser::ResultFactory\->new;
74 \& my $result = $factory\->make_result( $token );
75 .Ve
76 .SH VERSION
77 .IX Header "VERSION"
78 Version 3.50
79 .SS DESCRIPTION
80 .IX Subsection "DESCRIPTION"
81 This is a simple factory class which returns a TAP::Parser::Result subclass
82 representing the current bit of test data from TAP (usually a single line).
83 It is used primarily by TAP::Parser::Grammar. Unless you\*(Aqre subclassing,
84 you probably won\*(Aqt need to use this module directly.
85 .SS METHODS
86 .IX Subsection "METHODS"
87 .SS "Class Methods"
88 .IX Subsection "Class Methods"
89 \fR\f(CI\*(C`new\*(C'\fR\fI\fR
90 .IX Subsection "new"
91 .PP
92 Creates a new factory class.
93 \&\fINote:\fR You currently don\*(Aqt need to instantiate a factory in order to use it.
94 .PP
95 \fR\f(CI\*(C`make_result\*(C'\fR\fI\fR
96 .IX Subsection "make_result"
97 .PP
98 Returns an instance the appropriate class for the test token passed in.
99 .PP
100 .Vb 1
101 \& my $result = TAP::Parser::ResultFactory\->make_result($token);
102 .Ve
103 .PP
104 Can also be called as an instance method.
105 .PP
106 \fR\f(CI\*(C`class_for\*(C'\fR\fI\fR
107 .IX Subsection "class_for"
108 .PP
109 Takes one argument: \f(CW$type\fR. Returns the class for this \f(CW$type\fR, or \f(CW\*(C`croak\*(C'\fRs
110 with an error.
111 .PP
112 \fR\f(CI\*(C`register_type\*(C'\fR\fI\fR
113 .IX Subsection "register_type"
114 .PP
115 Takes two arguments: \f(CW$type\fR, \f(CW$class\fR
116 .PP
117 This lets you override an existing type with your own custom type, or register
118 a completely new type, eg:
119 .PP
120 .Vb 4
121 \& # create a custom result type:
122 \& package MyResult;
123 \& use strict;
124 \& use base \*(AqTAP::Parser::Result\*(Aq;
125 \&
126 \& # register with the factory:
127 \& TAP::Parser::ResultFactory\->register_type( \*(Aqmy_type\*(Aq => _\|_PACKAGE_\|_ );
128 \&
129 \& # use it:
130 \& my $r = TAP::Parser::ResultFactory\->( { type => \*(Aqmy_type\*(Aq } );
131 .Ve
132 .PP
133 Your custom type should then be picked up automatically by the TAP::Parser.
134 .SH SUBCLASSING
135 .IX Header "SUBCLASSING"
136 Please see "SUBCLASSING" in TAP::Parser for a subclassing overview.
137 .PP
138 There are a few things to bear in mind when creating your own
139 \&\f(CW\*(C`ResultFactory\*(C'\fR:
140 .IP 1. 4
141 The factory itself is never instantiated (this \fImay\fR change in the future).
142 This means that \f(CW\*(C`_initialize\*(C'\fR is never called.
143 .IP 2. 4
144 \&\f(CW\*(C`TAP::Parser::Result\->new\*(C'\fR is never called, \f(CW$tokens\fR are reblessed.
145 This \fIwill\fR change in a future version!
146 .IP 3. 4
147 TAP::Parser::Result subclasses will register themselves with
148 TAP::Parser::ResultFactory directly:
149 .Sp
150 .Vb 2
151 \& package MyFooResult;
152 \& TAP::Parser::ResultFactory\->register_type( foo => _\|_PACKAGE_\|_ );
153 .Ve
154 .Sp
155 Of course, it\*(Aqs up to you to decide whether or not to ignore them.
156 .SS Example
157 .IX Subsection "Example"
158 .Vb 1
159 \& package MyResultFactory;
160 \&
161 \& use strict;
162 \&
163 \& use MyResult;
164 \&
165 \& use base \*(AqTAP::Parser::ResultFactory\*(Aq;
166 \&
167 \& # force all results to be \*(AqMyResult\*(Aq
168 \& sub class_for {
169 \& return \*(AqMyResult\*(Aq;
170 \& }
171 \&
172 \& 1;
173 .Ve
174 .SH "SEE ALSO"
175 .IX Header "SEE ALSO"
176 TAP::Parser,
177 TAP::Parser::Result,
178 TAP::Parser::Grammar