lib/File/Information/VerifyBase.pm

filter: Statementstmt 32.0% 16 / 50 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 22 MC/DCmcdc 0.0% 0 / 14 Subroutinesub 27.7% 5 / 18 Podpod 100% 12 / 12 totaltotal 26.1% 33 / 126 CC 14 SCAR 36.3
CC
14
Cov
20%
_new
110.0
base_from
6.0
base_to
6.0
CRAP 37.7
« blib/lib/File/Information/Chunk.pm ↑ Summary blib/lib/File/Information/VerifyTestResult.pm »
1 # Copyright (c) 2024-2025 Philipp Schafft <lion@cpan.org>
2  
3 # licensed under Artistic License 2.0 (see LICENSE file)
4  
5 # ABSTRACT: generic module for extracting information from filesystems
6  
7  
8 package File::Information::VerifyBase;
9  
10 1 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 our $VERSION = v0.16;
17  
18 use constant {
19 1 STATUS_ERROR => 'error',
20 STATUS_PASSED => 'passed',
21 STATUS_FAILED => 'failed',
22 STATUS_NO_DATA => 'no_data',
23 STATUS_INSUFFICIENT_DATA => 'insufficient_data',
24 1 ▶};
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26  
27 sub status {
28 0 ▶ my ($self) = @_;
Subroutine status: not called CC=1 SCAR=6.9
Pod documented
29 0 return $self->{status};
30 }
31  
32  
33 sub has_error {
34 0 ▶ my ($self) = @_;
Subroutine has_error: not called CC=1 SCAR=6.9
Pod documented
35 0 return $self->{status} eq STATUS_ERROR;
36 }
37  
38  
39 sub has_passed {
40 0 ▶ my ($self) = @_;
Subroutine has_passed: not called CC=1 SCAR=6.9
Pod documented
41 0 return $self->{status} eq STATUS_PASSED;
42 }
43  
44  
45 sub has_failed {
46 0 ▶ my ($self) = @_;
Subroutine has_failed: not called CC=1 SCAR=6.9
Pod documented
47 0 return $self->{status} eq STATUS_FAILED;
48 }
49  
50  
51 sub has_no_data {
52 0 ▶ my ($self) = @_;
Subroutine has_no_data: not called CC=1 SCAR=6.9
Pod documented
53 0 return $self->{status} eq STATUS_NO_DATA;
54 }
55  
56  
57 sub has_insufficient_data {
58 0 ▶ my ($self) = @_;
Subroutine has_insufficient_data: not called CC=1 SCAR=6.9
Pod documented
59 0 return $self->{status} eq STATUS_INSUFFICIENT_DATA;
60 }
61  
62  
63 #@returns File::Information::Base
64 sub base {
65 0 ▶ my ($self) = @_;
Subroutine base: not called CC=1 SCAR=6.9
Pod documented
66 0 return $self->{base};
67 }
68  
69  
70 #@returns File::Information::Base
71 sub base_from {
72 0 ▶ my ($self) = @_;
Subroutine base_from: not called CC=2 SCAR=17.9
Pod documented
73 0 ▶ return $self->{base_from} // $self->{base};
Condition0%0/3
$self->{"base_from"} // $self->{"base"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"base_from"} // $self->{"base"}
$self->{"base_from"} $self->{"base"}
Truth table0%0/3
A // B
A= $self->{"base_from"}B= $self->{"base"}
ABresult
1X1
011
000
74 }
75  
76  
77 #@returns File::Information::Base
78 sub base_to {
79 0 ▶ my ($self) = @_;
Subroutine base_to: not called CC=2 SCAR=17.9
Pod documented
80 0 ▶ return $self->{base_to} // $self->{base};
Condition0%0/3
$self->{"base_to"} // $self->{"base"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"base_to"} // $self->{"base"}
$self->{"base_to"} $self->{"base"}
Truth table0%0/3
A // B
A= $self->{"base_to"}B= $self->{"base"}
ABresult
1X1
011
000
81 }
82  
83  
84 #@returns File::Information
85 sub instance {
86 0 ▶ my ($self) = @_;
Subroutine instance: not called CC=1 SCAR=6.9
Pod documented
87 0 return $self->{instance};
88 }
89  
90  
91 #@returns Data::URIID
92 sub extractor {
93 0 ▶ my ($self, @args) = @_;
Subroutine extractor: not called CC=2 SCAR=17.9
Pod documented
94 0 ▶ return $self->{extractor} //= $self->instance->extractor(@args);
Condition0%0/3
$self->{"extractor"} //= $self->instance->extractor(@args)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"extractor"} //= $self->instance->extractor(@args)
$self->{"extractor"} $self->instance->extractor(@args)
Truth table0%0/3
A //= B
A= $self->{"extractor"}B= $self->instance->extractor(@args)
ABresult
1X1
011
000
95 }
96  
97 #@returns Data::TagDB
98 sub db {
99 0 ▶ my ($self, @args) = @_;
Subroutine db: not called CC=2 SCAR=17.9
Pod documented
100 0 ▶ return $self->{db} //= $self->instance->db(@args);
Condition0%0/3
$self->{"db"} //= $self->instance->db(@args)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"db"} //= $self->instance->db(@args)
$self->{"db"} $self->instance->db(@args)
Truth table0%0/3
A //= B
A= $self->{"db"}B= $self->instance->db(@args)
ABresult
1X1
011
000
101 }
102  
103 # ----------------
104  
105 sub _new {
106 0 ▶ my ($pkg, %opts) = @_;
Subroutine _new: not called CC=10 SCAR=47.0
107 0 my $self = bless(\%opts, $pkg);
108  
109 0 ▶ $self->{lifecycle_from} //= 'current';
Condition0%0/2
$self->{"lifecycle_from"} //= "current"
l!l
00
MC/DC0%0/1
$self->{"lifecycle_from"} //= "current"
$self->{"lifecycle_from"}
Truth table0%0/2
A
A= $self->{"lifecycle_from"}
Aresult
11
00
110 0 ▶ $self->{lifecycle_to} //= 'final';
Condition0%0/2
$self->{"lifecycle_to"} //= "final"
l!l
00
MC/DC0%0/1
$self->{"lifecycle_to"} //= "final"
$self->{"lifecycle_to"}
Truth table0%0/2
A
A= $self->{"lifecycle_to"}
Aresult
11
00
111  
112 0 ▶ croak 'No instance is given' unless defined $self->{instance};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"instance"} 0 0 0
113 0 ▶ croak 'No base_from is given' unless defined($self->{base_from}) || defined($self->{base});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"base_from"} or defined $self->{"base"} 0 0 0
Condition0%0/3
defined $self->{"base_from"} or defined $self->{"base"}
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $self->{"base_from"} or defined $self->{"base"}
defined $self->{"base_from"} defined $self->{"base"}
Truth table0%0/3
A or B
A= defined $self->{"base_from"}B= defined $self->{"base"}
ABresult
1X1
011
000
114 0 ▶ croak 'No base_to is given' unless defined($self->{base_to}) || defined($self->{base});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"base_to"} or defined $self->{"base"} 0 0 0
Condition0%0/3
defined $self->{"base_to"} or defined $self->{"base"}
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $self->{"base_to"} or defined $self->{"base"}
defined $self->{"base_to"} defined $self->{"base"}
Truth table0%0/3
A or B
A= defined $self->{"base_to"}B= defined $self->{"base"}
ABresult
1X1
011
000
115 0 ▶ croak 'No lifecycle_from is given' unless defined $self->{lifecycle_from};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"lifecycle_from"} 0 0 0
116 0 ▶ croak 'No lifecycle_to is given' unless defined $self->{lifecycle_to};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"lifecycle_to"} 0 0 0
117  
118 0 return $self;
119 }
120  
121 1 1;
122  
123 __END__
124  
125 =pod
126  
127 =encoding UTF-8
128  
129 =head1 NAME
130  
131 File::Information::VerifyBase - generic module for extracting information from filesystems
132  
133 =head1 VERSION
134  
135 version v0.16
136  
137 =head1 SYNOPSIS
138  
139 use File::Information;
140  
141 my File::Information::VerifyBase $base = ...;
142  
143 my $passed = $base->is_passed;
144  
145 This package contains the basic methods for verify results.
146 See also L<File::Information::Base/verify>.
147  
148 =head1 METHODS
149  
150 =head2 status
151  
152 my $status = $obj->status;
153  
154 Returns the status of the test.
155 Most commonly one want to check for the passed state using L</has_passed>.
156  
157 =head2 has_error
158  
159 my $has_error = $obj->has_error;
160  
161 Returns if the status is the error status. That is the test was not performed
162 (likely due to an internal error or an operating system error).
163  
164 B<Note:>
165 This is B<not> the opposite of L</has_passed>.
166  
167 =head2 has_passed
168  
169 my $has_passed = $obj->has_passed;
170  
171 This will return if the test was successfully passed.
172 That is the data is available and matched the expected value.
173  
174 B<Note:>
175 This is B<not> the opposite of L</has_failed> or L</has_error>.
176  
177 =head2 has_failed
178  
179 my $has_failed = $obj->has_failed;
180  
181 Returns if the status is the failed status.
182 That is the test was successfully performed but the data did not match.
183  
184 B<Note:>
185 This is B<not> the opposite of L</has_passed>.
186  
187 =head2 has_no_data
188  
189 my $has_no_data = $obj->has_no_data;
190  
191 Returns true if the test was not performed due to missing data.
192  
193 =head2 has_insufficient_data
194  
195 my $has_insufficient_data = $obj->has_insufficient_data;
196  
197 Returnes true if the test was performed but there is data missing for it to pass.
198 The parts that have been performed did not fail.
199  
200 =head2 base
201  
202 my File::Information::Base $base = $obj->base;
203  
204 Returns the base that was used to create this object.
205  
206 B<Note:>
207 This method is deprecated and will be removed in future versions.
208  
209 See also
210 L</base_from>,
211 L</base_to>.
212  
213 =head2 base_from
214  
215 my File::Information::Base $base = $obj->base_from;
216  
217 Returns the base object used for the I<from> side of the verify.
218  
219 See also
220 L</base_to>.
221  
222 =head2 base_to
223  
224 my File::Information::Base $base = $obj->base_from;
225  
226 Returns the base object used for the I<to> side of the verify.
227  
228 See also
229 L</base_from>.
230  
231 =head2 instance
232  
233 my File::Information $instance = $obj->instance;
234  
235 Returns the instance that was used to create this object.
236  
237 =head2 extractor, db
238  
239 my Data::URIID $extractor = $obj->extractor;
240 my Data::TagDB $db = $obj->db;
241 my ... = $obj->digest_info;
242  
243 These methods provide access to the same data as the methods of L<File::Information>.
244 Arguments will be passed to said functions. However the object my cache the result.
245 Therefore it is only allowed to pass arguments that are compatible with caching (if any exist).
246  
247 See L<File::Information/extractor>, and L<File::Information/db> for details.
248  
249 =head1 AUTHOR
250  
251 Philipp Schafft <lion@cpan.org>
252  
253 =head1 COPYRIGHT AND LICENSE
254  
255 This software is Copyright (c) 2024-2025 by Philipp Schafft <lion@cpan.org>.
256  
257 This is free software, licensed under:
258  
259 The Artistic License 2.0 (GPL Compatible)
260  
261 =cut
« blib/lib/File/Information/Chunk.pm ↑ Summary blib/lib/File/Information/VerifyTestResult.pm »