File Coverage

lib/File/Information/VerifyResult.pm
Criterion Covered Total %
statement 17 35 48.5
branch 0 10 0.0
condition 0 9 0.0
subroutine 6 7 85.7
pod n/a
total 23 61 37.7


line stmt bran cond sub pod time code
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::VerifyResult;
9              
10 1     1   3105 use v5.10;
  1         5  
11 1     1   6 use strict;
  1         3  
  1         31  
12 1     1   4 use warnings;
  1         2  
  1         114  
13              
14 1     1   8 use parent 'File::Information::VerifyBase';
  1         3  
  1         10  
15              
16 1     1   107 use Carp;
  1         2  
  1         88  
17              
18 1     1   9160 use File::Information::VerifyTestResult;
  1         4  
  1         346  
19              
20             our $VERSION = v0.16;
21              
22             # ----------------
23              
24             sub _new {
25 0     0     my ($pkg, %opts) = @_;
26 0           my $self = $pkg->SUPER::_new(%opts);
27 0           my %tests;
28             my $failed;
29 0           my %passed_by_class;
30              
31 0           $self->{tests} = \%tests;
32              
33 0           foreach my $name (File::Information::VerifyTestResult->_supported_tests) {
34 0           my $res = File::Information::VerifyTestResult->_new(test => $name, %opts{'instance', 'base', 'base_from', 'base_to', 'extractor', 'db', 'lifecycle_from', 'lifecycle_to'});
35 0 0         my $class = $res->can('_class') ? $res->_class : $res->isa(__PACKAGE__) ? File::Information::VerifyTestResult->CLASS_STRONG : File::Information::VerifyTestResult->CLASS_WEAK;
    0          
36 0           $tests{$name} = $res;
37              
38 0   0       $failed ||= $res->has_failed;
39 0   0       $passed_by_class{$class} ||= $res->has_passed;
40             }
41              
42 0 0 0       if ($failed) {
    0          
    0          
43 0           $self->{status} = $pkg->STATUS_FAILED;
44             } elsif ($passed_by_class{File::Information::VerifyTestResult->CLASS_METADATA} && $passed_by_class{File::Information::VerifyTestResult->CLASS_STRONG}) {
45 0           $self->{status} = $pkg->STATUS_PASSED;
46 0           } elsif (scalar grep {$_} values %passed_by_class) {
47 0           $self->{status} = $pkg->STATUS_INSUFFICIENT_DATA;
48             } else {
49 0           $self->{status} = $pkg->STATUS_NO_DATA;
50             }
51              
52 0           return $self;
53             }
54              
55             1;
56              
57             __END__
58              
59             =pod
60              
61             =encoding UTF-8
62              
63             =head1 NAME
64              
65             File::Information::VerifyResult - generic module for extracting information from filesystems
66              
67             =head1 VERSION
68              
69             version v0.16
70              
71             =head1 SYNOPSIS
72              
73             use File::Information;
74              
75             my File::Information::Inode $inode = ...;
76              
77             my File::Information::VerifyResult $result = $inode->verify;
78              
79             my $passed = $base->has_passed;
80              
81             This package inherits from L<File::Information::VerifyBase>.
82              
83             =head1 METHODS
84              
85             =head1 AUTHOR
86              
87             Philipp Schafft <lion@cpan.org>
88              
89             =head1 COPYRIGHT AND LICENSE
90              
91             This software is Copyright (c) 2024-2025 by Philipp Schafft <lion@cpan.org>.
92              
93             This is free software, licensed under:
94              
95             The Artistic License 2.0 (GPL Compatible)
96              
97             =cut