.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Path::IsDev::Result 3" .TH Path::IsDev::Result 3 2023-07-26 "perl v5.38.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Path::IsDev::Result \- Result container .SH VERSION .IX Header "VERSION" version 1.001003 .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use Path::IsDev::Result; \& \& my $result = Path::IsDev::Result\->new( path => \*(Aq/some/path/that/exists\*(Aq ): \& \& if ( $heuristcset\->matches( $result ) ) { \& print Dumper($result); \& } .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" This is a reasonably new internal component for Path::IsDev. .PP Its purpose is to communicate state between internal things, and give some sort of introspectable context for why things happened in various places without resorting to spamming debug everywhere. .PP Now instead of turning on debug, as long as you can get a result, you can inspect and dump that result at the point you need it. .SH METHODS .IX Header "METHODS" .ie n .SS """BUILD""" .el .SS \f(CWBUILD\fP .IX Subsection "BUILD" .ie n .SS """add_reason""" .el .SS \f(CWadd_reason\fP .IX Subsection "add_reason" Call this method from a heuristic to record checking of the heuristic and the relevant meta-data. .PP .Vb 1 \& $result\->add_reason( $heuristic, $matchvalue, $reason_summary, \e%contextinfo ); .Ve .PP For example: .PP .Vb 10 \& sub Foo::matches { \& my ( $self , $result_object ) = @_; \& if ( $result_object\->path\->child(\*(Aqbar\*(Aq)\->exists ) { \& $result_object\->add_reason( $self, 1, "child \*(Aqbar\*(Aq exists" , { \& child => \*(Aqbar\*(Aq, \& \*(Aqexists?\*(Aq => 1, \& child_path => $result_object\->path\->child(\*(Aqbar\*(Aq) \& }); \& $result_object\->result(1); \& return 1; \& } \& return; \& } .Ve .PP Note that here, \f(CW$matchvalue\fR should be the result of the relevant matching logic, not the global impact. .PP For instance, \f(CW\*(C`excludes\*(C'\fR compositions should still add reasons of \f(CW\*(C`$matchvalue == 1\*(C'\fR, but they should not set \f(CW\*(C`$result_object\->result(1)\*(C'\fR. ( In fact, setting \f(CW\*(C`result\*(C'\fR is the job of the individual heuristic, not the matches that are folded into it ) .SH ATTRIBUTES .IX Header "ATTRIBUTES" .ie n .SS """path""" .el .SS \f(CWpath\fP .IX Subsection "path" .ie n .SS """result""" .el .SS \f(CWresult\fP .IX Subsection "result" .ie n .SS """reasons""" .el .SS \f(CWreasons\fP .IX Subsection "reasons" .SH AUTHOR .IX Header "AUTHOR" Kent Fredric .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2017 by Kent Fredric . .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.