blib/lib/Data/Polipo.pm

filter: Statementstmt 100% 54 / 54 Branchbran 71.4% 10 / 14 Conditioncond 25.0% 1 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 12 / 12 Podpod 75.0% 3 / 4 totaltotal 88.8% 80 / 90 CC 9 SCAR 13.8
CC
9
Cov
90%
new
8.2
__ANON__
2.0
BEGIN
1.0
CRAP 4.0
↑ Summary
1 package Data::Polipo;
2  
3 1 ▶use 5.008009;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 require Exporter;
10  
11 1 our @ISA = qw(Exporter);
12  
13 # Items to export into callers namespace by default. Note: do not export
14 # names by default without a very good reason. Use EXPORT_OK instead.
15 # Do not simply export all your public functions/methods/constants.
16  
17 # This allows declaration use Data::Polipo ':all';
18 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
19 # will save memory.
20 1 our %EXPORT_TAGS = ( 'all' => [ qw(
21
22 ) ] );
23  
24 1 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
25  
26 1 our @EXPORT = qw(
27
28 );
29  
30 1 our $VERSION = '0.02';
31  
32  
33 # Preloaded methods go here.
34  
35 1 our $count = 0;
36  
37 1 ▶sub new {
Subroutine new: called CC=8 SCAR=21.0
Pod documented
38 1 my ($class, $file) = @_;
39 1 my $h = {};
40  
41 1 ▶ my $fh = new IO::File $file, "r" or die "$file: $!";
Branch: 1 branch
BranchTrueFalseTotal
my $fh = "IO::File"->new($file, "r") or die "${file}: $!" 1 0 1
42 1 $fh->binmode;
43 1 local $/ = "\r\n";
44 1 my $res = <$fh>;
45 1 chomp $res;
46  
47 1 my $ns = $class . "::" . $count ++;
48  
49 1 ▶ while (my $line = <$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $fh)) 15 0 15
50 15 chomp $line;
51 15 ▶ last if ($line =~ /^$/);
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /^$/ 1 14 15
52  
53 14 my ($k, $v) = $line =~ /([^:]+):\s*(.*)/;
54 14 ▶ warn $line and next unless ($k);
Branch: 1 branch
BranchTrueFalseTotal
unless $k 0 14 14
Condition25%1/4
$k || warn($line) && (next)
l!l
140
warn $line and next
!ll
00
MC/DC0%0/2
$k || warn($line) && (next)
$k warn $line
Truth table33%1/3
A || B
A= $kB= warn $line
ABresult
1X1
011
000
55 14 $k =~ s/-/_/g;
56 14 $k =~ s/^(.+)$/\L$1\E/;
57 14 ▶ if (! defined $h->{$k}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $h->{$k}) 12 2 14
58 12 $h->{$k} = $v;
59 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
60 12 ▶ *{$ns . "::" . $k} = (sub {my $v=shift; sub {$v}})->($v);
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
61 }
62 }
63  
64 1 ▶ if (my $offset = $h->{x_polipo_body_offset}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $offset = $h->{"x_polipo_body_offset"}) 1 0 1
65 1 $fh->seek ($offset, SEEK_SET);
66 }
67  
68 1 my $d = bless {} => $ns;
69 1 ▶ my $obj = sub {wantarray ? ($fh, $res) : $d};
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 2 5 7
70 1 bless $obj => $class;
71 }
72  
73 1 ▶sub open {
Subroutine open: called CC=1 SCAR=0.0
Pod documented
74 1 return ($_[0]->())[0];
75 }
76  
77 1 ▶sub status {
Subroutine status: called CC=1 SCAR=0.0
Pod documented
78 1 return ($_[0]->())[1];
79 }
80  
81 5 ▶sub header {
Subroutine header: called CC=1 SCAR=0.0
Pod undocumented
82 5 return $_[0]->();
83 }
84  
85 1 1;
86 __END__
↑ Summary