| 1 | package Net::FreeDB2::Entry; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | # Copyright 2002, Vincenzo Zocca. | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | # See LICENSE section for usage and distribution rights. | ||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | require 5.005_62; | |||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Error qw (:try); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use AutoLoader qw(AUTOLOAD); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | # Items to export into callers namespace by default. Note: do not export | ||||||||||||||||||||||||||||||||||||||||||
| 18 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||||||||||||||||||||||||||||||||||
| 19 | # Do not simply export all your public functions/methods/constants. | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | # This allows declaration use Net::FreeDB2::Entry ':all'; | ||||||||||||||||||||||||||||||||||||||||||
| 22 | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | ||||||||||||||||||||||||||||||||||||||||||
| 23 | # will save memory. | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | our %EXPORT_TAGS = ( 'all' => [ qw( | |||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | ) ] ); | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | our @EXPORT = qw( | |||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | our ( $VERSION ) = '$Revision: 0.8.2.3 $ ' =~ /\$Revision:\s+([^\s]+)/; | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | my $DB_LINE_LEN_DEF = 256; | |||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | my $XMCD_RX = '^\s*#\s*xmcd'; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | my $XMCD_ERR = '# xmcd'; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | my $TFO_RX = '^\s*#\s*Track\s+frame\s+offsets\s*:\s*$'; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | my $TFO_ERR = '# Track frame offsets:'; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | my $FO_RX = '^\s*#\s*(\d+)\s*$'; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | my $FO_ERR = '# <number>'; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | my $DL_RX = '^\s*#\s*Disc\s+length\s*:\s*(\d+)\s+seconds\s*$'; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | my $DL_ERR = '# Disc length: <length> seconds'; | |||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | my $REV_RX = '^\s*#\s*Revision\s*:\s*(\d+)\s*'; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | my $REV_ERR = '# Revision: <revision>'; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | my $SUB_RX = '^\s*#\s*Submitted\s+via\s*:\s*(\S+)\s+(\S+)\s*(.*)\s*$'; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | my $SUB_ERR = '# Submitted via: <client_name> <client_version> <optional_comments>'; | |||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | my $DID_RX = '^\s*DISCID\s*=\s*(\S+)\s*$'; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | my $DID_ERR = 'DISCID=<disc ID>'; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | my $DTITLE_RX = '^\s*DTITLE\s*=(.*)$'; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | my $DYEAR_RX = '^\s*DYEAR\s*=(.*)$'; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | my $DGENRE_RX = '^\s*DGENRE\s*=(.*)$'; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 1 | my $TTITLEN_RX = '^\s*TTITLE(\d+)\s*=(.*)$'; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 1 | my $EXTD_RX = '^\s*EXTD\s*=(.*)$'; | |||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | my $EXTTN_RX = '^\s*EXTT(\d+)\s*=(.*)$'; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | my $CDPARA_TRACK_RX = '^\s*(\d+)\.\s*(\d+)\s*\[\d+[:.]\d+[:.]\d+\]\s*(\d+)\s*\[\d+[:.]\d+[:.]\d+\]'; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | my $CDPARA_TOTAL_RX = '^\s*TOTAL\s+(\d+)'; | |||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my $self = {}; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | bless ($self, (ref($class) || $class)); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table0%0/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | return ($self->_initialize (@_)); | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub _initialize { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_initialize: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | my $opt = shift || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | (defined ($opt->{fh}) or defined ($opt->{fn}) or defined ($opt->{array_ref})) and $self->read ($opt); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $opt->{"fh"} or defined $opt->{"fn"} or defined $opt->{"array_ref"}
defined $opt->{"fh"} or defined $opt->{"fn"}
MC/DC0%0/3
defined $opt->{"fh"} or defined $opt->{"fn"} or defined $opt->{"array_ref"}
defined $opt->{"fh"}
defined $opt->{"fn"}
defined $opt->{"array_ref"}
Truth table0%0/4
A or B or C
A= defined $opt->{"fh"}B= defined $opt->{"fn"}C= defined $opt->{"array_ref"}
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | defined ($opt->{dev}) and $self->readDev ($opt); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | return ($self); | |||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | sub read { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read: not called CC=37 SCAR=72.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | my $opt = shift || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | # Make an array reference out of $opt->{fh}, $opt->{fn} or | ||||||||||||||||||||||||||||||||||||||||||
| 82 | # $opt->{array_ref}. | ||||||||||||||||||||||||||||||||||||||||||
| 83 | # From http://www.freedb.org/src/latest/DBFORMAT : | ||||||||||||||||||||||||||||||||||||||||||
| 84 | # The beginning of the first line in a database entry should consist of | ||||||||||||||||||||||||||||||||||||||||||
| 85 | # the string "# xmcd". This string identifies the file as an xmcd format | ||||||||||||||||||||||||||||||||||||||||||
| 86 | # CD database file. More text can appear after the "xmcd", but is | ||||||||||||||||||||||||||||||||||||||||||
| 87 | # unnecessary. | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | my $array_ref; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | my $lineNr = 1;; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | if (exists ($opt->{fh})|| exists ($opt->{fn})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
exists $opt->{"fh"} or exists $opt->{"fn"}
MC/DC0%0/2
exists $opt->{"fh"} or exists $opt->{"fn"}
exists $opt->{"fh"}
exists $opt->{"fn"}
Truth table0%0/3
A or B
A= exists $opt->{"fh"}B= exists $opt->{"fn"}
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | my $fh; | |||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | if (exists ($opt->{fh})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $fh = $opt->{fh}; | |||||||||||||||||||||||||||||||||||||||||
| 94 | } elsif (exists ($opt->{fn})) { | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | ▶ | use IO::File; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | $fh = IO::File->new ("< $opt->{fn}"); | |||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | defined ($fh) || throw Error::Simple ('ERROR: Net::FreeDB2::Entry::read, Failed to make file handle out of provided options.'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my $line = $fh->getline (); | |||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | chomp ($line); | |||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | $line =~ /$XMCD_RX/ || throw Error::Simple ("ERROR: Net::FreeDB2::Entry::read, Expected '$XMCD_ERR' in line " . $lineNr . ' but encountered: ' . $line); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my @array = (); | |||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | while ($line = $fh->getline ()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | chomp ($line); | |||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | push (@array, $line); | |||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $array_ref = \@array; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } elsif (exists ($opt->{array_ref})) { | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $array_ref = $opt->{array_ref}; | |||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my $line = shift (@{$array_ref}); | |||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | $line =~ /$XMCD_RX/ || throw Error::Simple ("ERROR: Net::FreeDB2::Entry::read, Expected '$XMCD_ERR' in line " . $lineNr . ' but encountered: ' . $line); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | throw Error::Simple ("ERROR: Net::FreeDB2::Entry::read, missing option 'fh', 'fn' or 'array_ref'"); | |||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | # Tollerate '#.*' until '# Track frame offsets:' | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | my $line; | |||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | while ($line = shift (@{$array_ref})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $lineNr++; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | ($line =~ /$TFO_RX/i) && last; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | ($line =~ /^\s*#/) && next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | throw Error::Simple ("ERROR: Net::FreeDB2::Entry::read, Expected '$TFO_ERR' in line " . $lineNr . ' but encountered: ' . $line); | |||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | # Read frame offsets | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my $track = 1; | |||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | while ($line = shift (@{$array_ref})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $lineNr++; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | my ($off) = $line =~ /$FO_RX/; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | defined ($off) || last; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $self->setFrameOffset ($track++, $off); | |||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | $track > 1 || throw Error::Simple ("ERROR: Net::FreeDB2::Entry::read, Expected '$FO_ERR' in line " . $lineNr . ' but encountered: ' . $line); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | # Read '# Disc length', '"# Revision', "# Submitted via' until 'DID' | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | while ($line = shift (@{$array_ref})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $lineNr++; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my ($len) = $line =~ /$DL_RX/i; | |||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | if (defined ($len)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | $self->setDiscLength ($len); | |||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | my ($rev) = $line =~ /$REV_RX/i; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | if (defined ($rev)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $self->setRevision ($rev); | |||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my ($name, $vers, $comm) = $line =~ /$SUB_RX/i; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | if (defined ($name)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $self->setClientName ($name); | |||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $self->setClientVersion ($vers); | |||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | $self->setClientComment ($comm); | |||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my ($discid) = $line =~ /$DID_RX/i; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | if (defined ($discid)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | $self->setDiscID ($discid); | |||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | ($line =~ /^\s*#/) && next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | $self->getDiscLength () || throw Error::Simple ("ERROR: Net::FreeDB2::Entry::read, Expected '$DL_ERR' in line " . $lineNr . ' but encountered: ' . $line); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | defined ($self->getRevision ()) || throw Error::Simple ("ERROR: Net::FreeDB2::Entry::read, Expected '$REV_ERR' in line " . $lineNr . ' but encountered: ' . $line); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | $self->getClientName () || throw Error::Simple ("ERROR: Net::FreeDB2::Entry::read, Expected '$SUB_ERR' in line " . $lineNr . ' but encountered: ' . $line); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | $self->getDiscID () || throw Error::Simple ("ERROR: Net::FreeDB2::Entry::read, Expected '$DID_ERR' in line " . $lineNr . ' but encountered: ' . $line); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | # Read DTITLE, DYEAR, DGENRE, TTITLEN, EXTD, EXTTN | ||||||||||||||||||||||||||||||||||||||||||
| 172 | # Indeed, this code is a bit forgiving | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | my $DTITLE = ''; | |||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | my $DYEAR = ''; | |||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my $DGENRE = ''; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my @TTITLEN = ''; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my $EXTD = ''; | |||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my @EXTTN = ''; | |||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | while ($line = shift (@{$array_ref})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $lineNr++; | |||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | my $str; | |||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ($str) = $line =~ /$DTITLE_RX/; | |||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | if (defined ($str)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $DTITLE .= $str; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ($str) = $line =~ /$DYEAR_RX/; | |||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | if (defined ($str)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | $DYEAR .= $str; | |||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ($str) = $line =~ /$DGENRE_RX/; | |||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | if (defined ($str)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | $DGENRE .= $str; | |||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my $nr; | |||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ($nr, $str) = $line =~ /$TTITLEN_RX/; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | if (defined ($nr)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | $TTITLEN[$nr] .= $str; | |||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ($str) = $line =~ /$EXTD_RX/; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | if (defined ($str)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | $EXTD .= $str; | |||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ($nr, $str) = $line =~ /$EXTTN_RX/; | |||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | if (defined ($nr)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | $EXTTN[$nr] .= $str; | |||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||
| 214 | # Set artist and title | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my ($artist, $title) = split (/\s*\/\s*/, $DTITLE, 2); | |||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | $title = '' if (!$title); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $artist =~ s/\\n/\n/gm; | |||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | $title =~ s/\\n/\n/gm; | |||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $self->setArtist ($artist); | |||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $self->setTitle ($title); | |||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | # DYEAR | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $DYEAR =~ s/\\n/\n/gm; | |||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | $self->setDyear ($DYEAR); | |||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | # DGENRE | ||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | $DGENRE =~ s/\\n/\n/gm; | |||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | $self->setDgenre ($DGENRE); | |||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | # TTITLEN | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | for (my $i = 0; $i < scalar (@TTITLEN); $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | $TTITLEN[$i] =~ s/\\n/\n/gm; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | $self->setTtitlen ($i+1, $TTITLEN[$i]); | |||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | # EXTD | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | $EXTD =~ s/\\n/\n/gm; | |||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | $self->setExtd ($EXTD); | |||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | # EXTTN | ||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | for (my $i = 0; $i < scalar (@EXTTN); $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | $EXTTN[$i] =~ s/\\n/\n/gm; | |||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $self->setExttn ($i+1, $EXTTN[$i]); | |||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | sub readDev { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readDev: not called CC=8 SCAR=40.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | my $opt = shift || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | # Setup the cdparanoia command | ||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | my $cmd = 'cdparanoia -Q'; | |||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | $cmd .= " -d '$opt->{dev}'" if (exists $opt->{dev}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | # Run the cdparanoia command | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 1 | ▶ | use IO::File; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | my $fh = IO::File->new ("$cmd 2>&1 |"); | |||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | defined ($fh) || throw Error::Simple ("ERROR: Net::FreeDB2::Entry::readDev, Failed to open pipe from command '$cmd'."); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | # Parse cdparanoia's output | ||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | my $frameOffset = 150; | |||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | while (my $line = $fh->getline ()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | my ($track, $framelength, $frameBegin) = $line =~ /$CDPARA_TRACK_RX/; | |||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | if (defined ($track)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | $self->setFrameOffset ($track, $frameOffset); | |||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | $frameOffset += $framelength; | |||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | my ($frameTotal) = $line =~ /$CDPARA_TOTAL_RX/; | |||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | if (defined ($frameTotal)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | $self->setDiscLength (int ($frameTotal / 75) + 2); | |||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | # Check if anything is read | ||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | ($frameOffset == 150) && throw Error::Simple ("ERROR: Net::FreeDB2::Entry::readDev, Command '$cmd' did not produce any usable output."); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | # Make discid | ||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | $self->mkDiscID (); | |||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | sub write { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write: not called CC=19 SCAR=58.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | my $opt = shift || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | # Make an empty array | ||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | my @array = (); | |||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | # xmcd | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | push (@array, "# xmcd"); | |||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | push (@array, "#"); | |||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | # Make maximum tracks | ||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my $max = scalar ($self->getFrameOffset ()); | |||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | # Track frame offsets: | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | push (@array, "# Track frame offsets:"); | |||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | for (my $i = 1; $i <= $max; $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | push (@array, "#\t" . $self->getFrameOffset ($i)); | |||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | push (@array, "#"); | |||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | # Disc length: N seconds | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | push (@array, "# Disc length: " . $self->getDiscLength () . " seconds"); | |||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | push (@array, "#"); | |||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | # Revision: N | ||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | push (@array, "# Revision: " . ($self->getRevision () || '0')); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->getRevision || '0'
MC/DC0%0/1
$self->getRevision || '0'
$self->getRevision
Truth table0%0/2
A
A= $self->getRevision
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | push (@array, "#"); | |||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | # Submitted via: client_name client_version optional_comments | ||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | my $str = ($self->getClientName () || 'none') . ' '; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->getClientName || 'none'
MC/DC0%0/1
$self->getClientName || 'none'
$self->getClientName
Truth table0%0/2
A
A= $self->getClientName
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | $str .= ($self->getClientVersion () || '0'); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->getClientVersion || '0'
MC/DC0%0/1
$self->getClientVersion || '0'
$self->getClientVersion
Truth table0%0/2
A
A= $self->getClientVersion
| |||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | $str .= ' ' . $self->getClientComment () if ($self->getClientComment ()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | push (@array, sprintf ("%.79s", "# Submitted via: " . $str)); | |||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | push (@array, "#"); | |||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | # DISCID | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | push (@array, "DISCID=" . ($self->getDiscID () || '')); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->getDiscID || ''
MC/DC0%0/1
$self->getDiscID || ''
$self->getDiscID
Truth table0%0/2
A
A= $self->getDiscID
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | # DTITLE (Artist / Title) | ||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | $self->print_db_length (\@array, 'DTITLE=', | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$self->getArtist || ''
$self->getTitle || ''
MC/DC0%0/1
$self->getArtist || ''
$self->getArtist
MC/DC0%0/1
$self->getTitle || ''
$self->getTitle
Truth table0%0/2
A
A= $self->getArtist
Truth table0%0/2
A
A= $self->getTitle
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | ($self->getArtist () || '') . ' / ' . ($self->getTitle () || '')); | ||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | # DYEAR | ||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | $self->print_db_length (\@array, 'DYEAR=', $self->getDyear ()); | |||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | # DGENRE | ||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | $self->print_db_length (\@array, 'DGENRE=', $self->getDgenre ()); | |||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | # TTITLEN | ||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | for (my $i = 1; $i <= $max; $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | my $str; | |||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | $str = $self->getTtitlen ($i); | |||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | } catch Error::Simple with { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | $self->print_db_length (\@array, "TTITLE" . int ($i-1) . "=", $str); | |||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | # EXTD | ||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | $self->print_db_length (\@array, 'EXTD=', $self->getExtd ()); | |||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | # EXTTN | ||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | for (my $i = 1; $i <= $max; $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | my $str; | |||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | $str = $self->getExttn ($i); | |||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | } catch Error::Simple with { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | $self->print_db_length (\@array, "EXTT" . int ($i-1) . "=", $str); | |||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||
| 356 | # PLAYORDER | ||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | push (@array, "PLAYORDER="); | |||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | if (exists ($opt->{fh})|| exists ($opt->{fn})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
exists $opt->{"fh"} or exists $opt->{"fn"}
MC/DC0%0/2
exists $opt->{"fh"} or exists $opt->{"fn"}
exists $opt->{"fh"}
exists $opt->{"fn"}
Truth table0%0/3
A or B
A= exists $opt->{"fh"}B= exists $opt->{"fn"}
| |||||||||||||||||||||||||||||||||||||||||||
| 360 | # Make a file handle out of $opt->{fh} or $opt->{fn} | ||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my $fh; | |||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | if (exists ($opt->{fh})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | $fh = $opt->{fh}; | |||||||||||||||||||||||||||||||||||||||||
| 364 | } elsif (exists ($opt->{fn})) { | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 1 | ▶ | use IO::File; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | $fh = IO::File->new ("> $opt->{fn}"); | |||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | defined ($fh) || throw Error::Simple ('ERROR: Net::FreeDB2::Entry::write, Failed to make file handle out of provided options.'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | foreach my $line (@array) { | |||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | $fh->print ($line, "\n"); | |||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||
| 372 | } elsif (exists ($opt->{array_ref})) { | ||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | @{$opt->{array_ref}} = @array; | |||||||||||||||||||||||||||||||||||||||||
| 374 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | throw Error::Simple ("ERROR: Net::FreeDB2::Entry::write, missing option 'fh', 'fn' or 'array_ref'"); | |||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | sub setFrameOffset { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setFrameOffset: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | my $track = int (shift); | |||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | my $off = int (shift); | |||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | # Check for a positive track number | ||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | $track > 0 || throw Error::Simple ("ERROR: setFrameOffset, track must be a positive integer."); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | # Check for a positive offset | ||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | $off > 0 || throw Error::Simple ("ERROR: setFrameOffset, offset must be a positive integer."); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | # Set the offset | ||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | $self->{Net_FreeDB2_Entry}{track}{$track}{off} = $off; | |||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | sub getFrameOffset { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getFrameOffset: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | my $track = int (shift || 0); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | # Check for a positive or 0 track number | ||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | $track > -1 || throw Error::Simple ("ERROR: getFrameOffset, track must be a positive or 0 integer."); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | # Handle a specified track number | ||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | if ($track) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | # Check for an existing track number | ||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | (exists ($self->{Net_FreeDB2_Entry}{track}{$track}) && exists ($self->{Net_FreeDB2_Entry}{track}{$track}{off})) || throw Error::Simple ("ERROR: getFrameOffset, no track with number '$track'."); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $self->{"Net_FreeDB2_Entry"}{"track"}{$track} and exists $self->{"Net_FreeDB2_Entry"}{"track"}{$track}{"off"}
MC/DC0%0/2
exists $self->{"Net_FreeDB2_Entry"}{"track"}{$track} and exists $self->{"Net_FreeDB2_Entry"}{"track"}{$track}{"off"}
exists $self->{"Net_FreeDB2_Entry"}{"track"}{$track}
exists $self->{"Net_FreeDB2_Entry"}{"track"}{$track}{"off"}
Truth table0%0/3
A and B
A= exists $self->{"Net_FreeDB2_Entry"}{"track"}{$track}B= exists $self->{"Net_FreeDB2_Entry"}{"track"}{$track}{"off"}
| |||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | # Return the offset | ||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | return ($self->{Net_FreeDB2_Entry}{track}{$track}{off}); | |||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | # Return all offsets if track == 0; | ||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | my @ret = (); | |||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | foreach my $track (sort {$a <=> $b} (keys (%{$self->{Net_FreeDB2_Entry}{track}}))) { | |||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | exists ($self->{Net_FreeDB2_Entry}{track}{$track}{off}) || next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | push (@ret, $self->{Net_FreeDB2_Entry}{track}{$track}{off}); | |||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | return (@ret); | |||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | ▶ | sub setDiscLength { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setDiscLength: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | my $length = int (shift); | |||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | $length || throw Error::Simple ("ERROR: setDiscLength, length must be a positive integer."); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | $self->{Net_FreeDB2_Entry}{length} = $length; | |||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | sub getDiscLength { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getDiscLength: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | return ($self->{Net_FreeDB2_Entry}{length}); | |||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | ▶ | sub setRevision { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setRevision: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | my $revision = shift; | |||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | $self->{Net_FreeDB2_Entry}{revision} = $revision; | |||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | sub getRevision { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getRevision: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | return ($self->{Net_FreeDB2_Entry}{revision}); | |||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | sub setClientName { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setClientName: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | my $client_name = shift; | |||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | $self->{Net_FreeDB2_Entry}{client_name} = $client_name; | |||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | sub getClientName { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getClientName: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | return ($self->{Net_FreeDB2_Entry}{client_name}); | |||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | sub setClientVersion { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setClientVersion: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | my $client_version = shift; | |||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | $self->{Net_FreeDB2_Entry}{client_version} = $client_version; | |||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | sub getClientVersion { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getClientVersion: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | return ($self->{Net_FreeDB2_Entry}{client_version}); | |||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | sub setClientComment { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setClientComment: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | my $client_comment = shift; | |||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | $self->{Net_FreeDB2_Entry}{client_comment} = $client_comment; | |||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | sub getClientComment { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getClientComment: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | return ($self->{Net_FreeDB2_Entry}{client_comment}); | |||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | sub setDiscID { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setDiscID: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | my $disc_id = shift; | |||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | $self->{Net_FreeDB2_Entry}{disc_id} = $disc_id; | |||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | ▶ | sub getDiscID { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getDiscID: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | return ($self->{Net_FreeDB2_Entry}{disc_id}); | |||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | ▶ | sub mkDiscID { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mkDiscID: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||
| 501 | # Make sum | ||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | my $sum = 0; | |||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | for (my $i = 1; $i <= scalar ($self->getFrameOffset ()); $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | $sum += &digitSum ($self->getFrameOffset ($i)/75); | |||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||
| 507 | # Make ID out of sum, getDiscLength () -2 and the number of tracks. | ||||||||||||||||||||||||||||||||||||||||||
| 508 | # And call setDiscID. | ||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | $self->setDiscID (sprintf ("%8x", ($sum % 0xff) << 24 | | |||||||||||||||||||||||||||||||||||||||||
| 510 | int( $self->getDiscLength () - 2) << 8 | | ||||||||||||||||||||||||||||||||||||||||||
| 511 | scalar ($self->getFrameOffset ()))); | ||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | sub mkQuery { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mkQuery: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||
| 517 | # Make a 'fresh' disc ID | ||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | $self->mkDiscID (); | |||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||
| 520 | # Return query: disc ID, number of tracks, frame offsets and disc lenght | ||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | return (sprintf ("%s %d %s %d", | |||||||||||||||||||||||||||||||||||||||||
| 522 | $self->getDiscID (), | ||||||||||||||||||||||||||||||||||||||||||
| 523 | scalar ($self->getFrameOffset ()), | ||||||||||||||||||||||||||||||||||||||||||
| 524 | join (' ', $self->getFrameOffset ()), | ||||||||||||||||||||||||||||||||||||||||||
| 525 | $self->getDiscLength () | ||||||||||||||||||||||||||||||||||||||||||
| 526 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | sub setArtist { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setArtist: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | my $artist = shift; | |||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | $self->{Net_FreeDB2_Entry}{artist} = $artist; | |||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | sub getArtist { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getArtist: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | return ($self->{Net_FreeDB2_Entry}{artist}); | |||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | ▶ | sub setTitle { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setTitle: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | my $title = shift; | |||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | $self->{Net_FreeDB2_Entry}{title} = $title; | |||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | ▶ | sub getTitle { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getTitle: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | return ($self->{Net_FreeDB2_Entry}{title}); | |||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | ▶ | sub setDyear { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setDyear: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | my $year = shift; | |||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | $self->{Net_FreeDB2_Entry}{year} = $year; | |||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | ▶ | sub getDyear { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getDyear: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | return ($self->{Net_FreeDB2_Entry}{year}); | |||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | ▶ | sub setDgenre { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setDgenre: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | my $genre = shift; | |||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | $self->{Net_FreeDB2_Entry}{genre} = $genre; | |||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | ▶ | sub getDgenre { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getDgenre: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | return ($self->{Net_FreeDB2_Entry}{genre}); | |||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | ▶ | sub setTtitlen { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setTtitlen: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | my $track = int (shift); | |||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | my $title = shift; | |||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||
| 586 | # Check for a positive track number | ||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | ▶ | $track > 0 || throw Error::Simple ("ERROR: setTtitlen, track must be a positive integer."); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||
| 589 | # Set the title | ||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | $self->{Net_FreeDB2_Entry}{track}{$track}{title} = $title; | |||||||||||||||||||||||||||||||||||||||||
| 591 | } | ||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | ▶ | sub getTtitlen { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getTtitlen: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | my $track = int (shift); | |||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||
| 597 | # Check for a positive or 0 track number | ||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | ▶ | $track > -1 || throw Error::Simple ("ERROR: getTtitlen, track must be a positive or 0 integer."); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||
| 600 | # Handle a specified track number | ||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | ▶ | if ($track) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 602 | # Check for an existing track number | ||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | (exists ($self->{Net_FreeDB2_Entry}{track}{$track}) && exists ($self->{Net_FreeDB2_Entry}{track}{$track}{title})) || throw Error::Simple ("ERROR: getFrameOffset, no track with number '$track'."); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $self->{"Net_FreeDB2_Entry"}{"track"}{$track} and exists $self->{"Net_FreeDB2_Entry"}{"track"}{$track}{"title"}
MC/DC0%0/2
exists $self->{"Net_FreeDB2_Entry"}{"track"}{$track} and exists $self->{"Net_FreeDB2_Entry"}{"track"}{$track}{"title"}
exists $self->{"Net_FreeDB2_Entry"}{"track"}{$track}
exists $self->{"Net_FreeDB2_Entry"}{"track"}{$track}{"title"}
Truth table0%0/3
A and B
A= exists $self->{"Net_FreeDB2_Entry"}{"track"}{$track}B= exists $self->{"Net_FreeDB2_Entry"}{"track"}{$track}{"title"}
| |||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||
| 605 | # Return the title | ||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | return ($self->{Net_FreeDB2_Entry}{track}{$track}{title}); | |||||||||||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||
| 609 | # Return all title if track == 0; | ||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | my @ret = (); | |||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | foreach my $track (sort {$a <=> $b} (keys (%{$self->{Net_FreeDB2_Entry}{track}}))) { | |||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | ▶ | exists ($self->{Net_FreeDB2_Entry}{track}{$track}{title}) || next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | push (@ret, $self->{Net_FreeDB2_Entry}{track}{$track}{title}); | |||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | return (@ret); | |||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | ▶ | sub setExtd { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setExtd: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | my $ext = shift; | |||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | $self->{Net_FreeDB2_Entry}{ext} = $ext; | |||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | sub getExtd { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getExtd: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | return ($self->{Net_FreeDB2_Entry}{ext}); | |||||||||||||||||||||||||||||||||||||||||
| 629 | } | ||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | ▶ | sub setExttn { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setExttn: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | my $track = int (shift); | |||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | my $ext = shift; | |||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||
| 636 | # Check for a positive track number | ||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | ▶ | $track > 0 || throw Error::Simple ("ERROR: setExttn, track must be a positive integer."); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||
| 639 | # Set the ext | ||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | $self->{Net_FreeDB2_Entry}{track}{$track}{ext} = $ext; | |||||||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | ▶ | sub getExttn { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getExttn: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | my $track = int (shift); | |||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||
| 647 | # Check for a positive or 0 track number | ||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | ▶ | $track > -1 || throw Error::Simple ("ERROR: setExttn, track must be a positive or 0 integer."); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||
| 650 | # Handle a specified track number | ||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | if ($track) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 652 | # Check for an existing track number | ||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | ▶ | (exists ($self->{Net_FreeDB2_Entry}{track}{$track}) && exists ($self->{Net_FreeDB2_Entry}{track}{$track}{ext})) || throw Error::Simple ("ERROR: getFrameOffset, no track with number '$track'."); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $self->{"Net_FreeDB2_Entry"}{"track"}{$track} and exists $self->{"Net_FreeDB2_Entry"}{"track"}{$track}{"ext"}
MC/DC0%0/2
exists $self->{"Net_FreeDB2_Entry"}{"track"}{$track} and exists $self->{"Net_FreeDB2_Entry"}{"track"}{$track}{"ext"}
exists $self->{"Net_FreeDB2_Entry"}{"track"}{$track}
exists $self->{"Net_FreeDB2_Entry"}{"track"}{$track}{"ext"}
Truth table0%0/3
A and B
A= exists $self->{"Net_FreeDB2_Entry"}{"track"}{$track}B= exists $self->{"Net_FreeDB2_Entry"}{"track"}{$track}{"ext"}
| |||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||
| 655 | # Return the ext | ||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | return ($self->{Net_FreeDB2_Entry}{track}{$track}{ext}); | |||||||||||||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||
| 659 | # Return all ext if track == 0; | ||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | my @ret = (); | |||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | foreach my $track (sort {$a <=> $b} (keys (%{$self->{Net_FreeDB2_Entry}{track}}))) { | |||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | ▶ | exists ($self->{Net_FreeDB2_Entry}{track}{$track}{ext}) || next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | push (@ret, $self->{Net_FreeDB2_Entry}{track}{$track}{ext}); | |||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | return (@ret); | |||||||||||||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | ▶ | sub setDbLineLen { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setDbLineLen: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | my $length = int (shift); | |||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | ▶ | $length > 10 || throw Error::Simple ('ERROR: Net::FreeDB2::Entry::setDbLineLen, length must be greater than 10.'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | $self->{Net_FreeDB2_Entry}{db_line_len} = $length; | |||||||||||||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | ▶ | sub getDbLineLen { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getDbLineLen: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | ▶ | return ($self->{Net_FreeDB2_Entry}{db_line_len} || $DB_LINE_LEN_DEF); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{'Net_FreeDB2_Entry'}{'db_line_len'} || $DB_LINE_LEN_DEF
MC/DC0%0/2
$self->{'Net_FreeDB2_Entry'}{'db_line_len'} || $DB_LINE_LEN_DEF
$self->{'Net_FreeDB2_Entry'}{'db_line_len'}
$DB_LINE_LEN_DEF
Truth table0%0/3
A || B
A= $self->{'Net_FreeDB2_Entry'}{'db_line_len'}B= $DB_LINE_LEN_DEF
| |||||||||||||||||||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | ▶ | sub print_db_length { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_db_length: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | my $array_ref = shift; | |||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | my $pre = shift; | |||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | ▶ | my $str = shift || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | $str =~ s/\n/\\n/gm; | |||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | my $first = 1; | |||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | ▶ | while ($first || $str) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$first or $str
MC/DC0%0/2
$first or $str
$first
$str
Truth table0%0/3
A or B
A= $firstB= $str
| |||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | push (@{$array_ref}, $pre . substr ($str, 0, $self->getDbLineLen () - 1 - length ($pre), '')); | |||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | $first = 0; | |||||||||||||||||||||||||||||||||||||||||
| 694 | } | ||||||||||||||||||||||||||||||||||||||||||
| 695 | } | ||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | ▶ | sub digitSum { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
digitSum: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | my $int = int (shift); | |||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | my $sum = 0; | |||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | ▶ | while ($int) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | $sum += $int % 10; | |||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | $int = int ($int / 10); | |||||||||||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | return ($sum); | |||||||||||||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||
| 709 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 710 | __END__ | ||||||||||||||||||||||||||||||||||||||||||