Brackup/Metafile.pm

filter: Statementstmt 90.7% 39 / 43 Branchbran 68.7% 11 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 3 totaltotal 82.3% 56 / 68 CC 9 SCAR 14.2
CC
9
Cov
85%
readline
6.1
open
4.4
BEGIN
1.0
CRAP 4.2
« Brackup/StoredChunk.pm ↑ Summary Brackup/Dict/SQLite.pm »
1 package Brackup::Metafile;
2 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 13 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 9 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
7 9 my ($class) = @_;
8 9 return bless {}, $class;
9 }
10  
11 9 ▶sub open {
Subroutine open: called CC=4 SCAR=14.8
Pod undocumented
12 9 my ($class, $file) = @_;
13 9 ▶ unless (-e $file) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $file) 0 9 9
14 0 die "Unable to open metafile $file\n";
15 }
16 9 my $self = __PACKAGE__->new;
17 9 $self->{filename} = $file;
18 9 ▶ if (eval { require IO::Uncompress::AnyUncompress }) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { require IO::Uncompress::AnyUncompress } }) { } 9 0 9
19 9 ▶ $self->{fh} = IO::Uncompress::AnyUncompress->new($file)
Branch: 1 branch
BranchTrueFalseTotal
$self->{"fh"} = "IO::Uncompress::AnyUncompress"->new($file) or die "Failed to open file ${file}: $IO::Uncompress::AnyUncompress::AnyUncompressError" 9 0 9
20 or die "Failed to open file $file: $IO::Uncompress::AnyUncompress::AnyUncompressError";
21 }
22 else {
23 0 open $self->{fh}, "<", $file;
24 }
25 9 $self->{linenum} = 0;
26 9 return $self;
27 }
28  
29 148 ▶sub readline {
Subroutine readline: called CC=6 SCAR=18.1
Pod undocumented
30 148 my $self = shift;
31 148 my $ret = {};
32 148 my $line; #
33 148 my $fh = $self->{fh};
34 148 ▶ while (defined ($line = <$fh>)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = CORE::readline $fh)) 1021 9 1030
35 1021 $self->{linenum}++;
36 1021 ▶ if ($line =~ /^([\w\-]+):\s*(.+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^([\w\-]+):\s*(.+)/) 856 165 1021
37 856 $ret->{$1} = $2;
38 856 $self->{last} = \$ret->{$1};
39 856 next;
40 }
41 165 ▶ if ($line eq "\n") {
Branch: 1 branch
BranchTrueFalseTotal
if ($line eq "\n") 139 26 165
42 139 return $ret;
43 }
44 26 ▶ if ($line =~ /^\s+(.+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^\s+(.+)/) 26 0 26
45 26 ▶ die "Can't continue line without start" unless $self->{last};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"last"} 0 26 26
46 26 ${ $self->{last} } .= " $1";
47 26 next;
48 }
49  
50 0 $line =~ s/[^[:print:]]/?/g;
51 0 die "Unexpected line in metafile $self->{filename}, line $self->{linenum}: $line";
52 }
53 9 return undef;
54 }
55  
56 13 1;
« Brackup/StoredChunk.pm ↑ Summary Brackup/Dict/SQLite.pm »