blib/lib/Ham/ADIF.pm

filter: Statementstmt 94.1% 32 / 34 Branchbran 50.0% 3 / 6 Conditioncond 66.6% 4 / 6 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 9 / 9 Podpod 100% 4 / 4 totaltotal 85.4% 53 / 62 CC 6 SCAR 10.2
CC
6
Cov
85%
parse_file
5.5
new
2.1
BEGIN
1.0
CRAP 2.8
« blib/lib/Ham/ADIF/ADI.pm ↑ Summary _build/lib/Module/Build/HamADIF.pm »
1 # -*- mode: cperl; tab-width: 8; indent-tabs-mode: nil; basic-offset: 2 -*-
2 # vim:ts=8:sw=2:et:sta:sts=2
3 #########
4 # Author: rmp
5 #
6 package Ham::ADIF;
7 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Ham::ADIF::ADX;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Ham::ADIF::ADI;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 our $VERSION = q[2018.03.31];
14  
15 sub new {
16 10 ▶ my ($class, $ref) = @_;
Subroutine new: called CC=2 SCAR=7.4
Pod documented
17 10 ▶ my $self = { $ref ? %{$ref} : () };
Branch: 1 branch
BranchTrueFalseTotal
$ref ? : 0 10 10
18  
19 10 bless $self, $class;
20  
21 10 return $self;
22 }
23  
24 sub parse_adi {
25 4 ▶ my ($self, $filename, $schema) = @_;
Subroutine parse_adi: called CC=1 SCAR=0.0
Pod documented
26 4 return Ham::ADIF::ADI->new->parse_file($filename);
27 }
28  
29 sub parse_adx {
30 1 ▶ my ($self, $filename, $schema) = @_;
Subroutine parse_adx: called CC=1 SCAR=0.0
Pod documented
31 1 return Ham::ADIF::ADX->new->parse_file($filename, $schema);
32 }
33  
34 sub parse_file {
35 5 ▶ my ($self, $filename, $schema) = @_;
Subroutine parse_file: called CC=5 SCAR=17.1
Pod documented
36  
37 5 ▶ if($schema ||
Branch: 1 branch
BranchTrueFalseTotal
if ($schema or $filename =~ /xml$/imsx or $filename =~ /adx$/imsx) 0 4 4
Condition66%4/6
$schema or $filename =~ /xml$/imsx or $filename =~ /adx$/imsx
l!l&&r!l&&!r
104
$schema or $filename =~ /xml$/imsx
l!l&&r!l&&!r
104
MC/DC33%1/3
$schema or $filename =~ /xml$/imsx or $filename =~ /adx$/imsx
$schema $filename =~ /xml$/imsx $filename =~ /adx$/imsx
Truth table50%2/4
A or B or C
A= $schemaB= $filename =~ /xml$/imsxC= $filename =~ /adx$/imsx
ABCresult
1XX1
01X1
0011
0000
38 $filename =~ /xml$/smix ||
39 $filename =~ /adx$/smix) {
40 1 return $self->parse_adx($filename, $schema);
41 }
42  
43 #########
44 # determine if we have ADI or ADX
45 #
46 4 my $io = IO::File->new($filename, q[r]);
47 4 my $firstline = <$io>;
48 4 ▶ if($firstline =~ m{<[?]xml}smix) {
Branch: 1 branch
BranchTrueFalseTotal
if ($firstline =~ /<[?]xml/imsx) 0 4 4
49 0 return $self->parse_adx($filename, $schema);
50 }
51  
52 4 return $self->parse_adi($filename);
53 }
54  
55 2 1;
56 __END__
« blib/lib/Ham/ADIF/ADI.pm ↑ Summary _build/lib/Module/Build/HamADIF.pm »