Miner/Ext.pm

filter: Statementstmt 95.6% 22 / 23 Branchbran 83.3% 5 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 4 / 4 Podpod 100% 2 / 2 totaltotal 90.0% 36 / 40 CC 5 SCAR 10.2
CC
5
Cov
91%
mine
4.0
new
2.0
BEGIN
1.0
CRAP 2.8
« Miner/Stat.pm ↑ Summary Miner/HTML.pm »
1 package FileMetadata::Miner::Ext;
2
3 1 our $VERSION = '0.1';
4
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use XML::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 1 ▶sub new {
Subroutine new: called CC=2 SCAR=7.1
Pod documented
9
10 1 my $self = {};
11 1 bless $self, shift;
12
13 1 my $config = shift;
14
15 # Obtain the file suffix to look for from the config
16
17 1 ▶ if (exists $config->{'suffix'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $config->{'suffix'}) { } 0 1 1
18 0 $self->{'ext'} = $config->{'suffix'};
19 } else {
20 1 $self->{'ext'} = '.ext';
21 }
22
23 1 return $self;
24
25 }
26
27 2 ▶sub mine {
Subroutine mine: called CC=4 SCAR=13.9
Pod documented
28
29 2 my ($self, $path, $meta) = @_;
30
31 # Get the file path for the XML file to examine
32
33 2 $path = $path . $self->{'ext'};
34
35 2 ▶ if (-f $path && -r $path) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $path and -r $path) 1 1 2
Condition66%2/3
-f $path and -r $path
!ll&&!rl&&r
101
MC/DC50%1/2
-f $path and -r $path
-f $path -r $path
Truth table66%2/3
A and B
A= -f $pathB= -r $path
ABresult
0X0
100
111
36
37 1 my $ext = XMLin ($path);
38
39 1 ▶ while (my ($key, $value) = each (%{$ext})) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$ext;}) 3 1 4
40
41 3 $meta->{ref ($self) . "::$key"} = $value;
42
43 }
44 }
45
46 # If file cannot be opened, we still return true
47
48 2 return 1;
49 }
50
51 1 1;
52
53 __END__
« Miner/Stat.pm ↑ Summary Miner/HTML.pm »