lib/Acme/CPANAuthors/Utils/CPANIndex.pm

filter: Statementstmt 98.2% 56 / 57 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.8% 13 / 14 Podpod 100% 1 / 1 totaltotal 96.2% 77 / 80 SCAR 20.8
CC
8
Cov
97%
_handle
4.0
new
3.0
_install_methods
3.0
CRAP 8.0
« blib/lib/Acme/CPANAuthors/Utils/CPANIndex.pm ↑ Summary lib/Acme/CPANAuthors/Utils/Kwalitee.pm »
1 package Acme::CPANAuthors::Utils::CPANIndex;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 sub new {
8 7 ▶ my $class = shift;
Subroutine new: called CC=3 SCAR=11.0
Pod documented
9 7 my $self = bless { preambles => {} }, $class;
10  
11 7 $self->_install_methods;
12 7 $self->{$_} = {} for keys %{ $self->_mappings };
13  
14 7 ▶ $self->_parse(@_) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 7 0 7
15  
16 5 $self;
17 }
18  
19 0 ▶sub _mappings {+{}}
Subroutine _mappings: not called CC=1 SCAR=6.9
20 ▶sub _preambles {}
Subroutine _preambles: called CC=1 SCAR=0.0
21  
22 sub _install_methods {
23 7 ▶ my $self = shift;
Subroutine _install_methods: called CC=3 SCAR=11.0
24 7 my $class = ref $self;
25  
26 4 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
27 4 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
28 7 for my $method ($self->_preambles) {
29 16 *{"$class\::$method"} = sub {
30 8 ▶ my $self = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
31 8 $self->{preambles}{$method};
32 }
33 16 }
34  
35 7 for my $method (keys %{ $self->_mappings }) {
36 11 my $key = $self->_mappings->{$method};
37 11 *{"$class\::$method"} = sub {
38 13 ▶ my ($self, $name) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
39 13 $self->{$key}{$name};
40 11 };
41 11 *{"$class\::${method}s"} = sub {
42 5 ▶ my $self = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
43 5 values %{ $self->{$key} };
44 11 };
45 11 *{"$class\::${method}_count"} = sub {
46 3 ▶ my $self = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
47 3 scalar values %{ $self->{$key} };
48 11 };
49 }
50 }
51  
52 sub _handle {
53 7 ▶ my ($self, $file) = @_;
Subroutine _handle: called CC=4 SCAR=13.9
54  
55 7 my $handle;
56 7 ▶ if ($file =~ /\.gz$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file =~ /\.gz$/) { } 4 3 7
57 4 require IO::Uncompress::Gunzip;
58 4 ▶ $handle = IO::Uncompress::Gunzip->new($file) or croak "Failed to read $file";
Branch: 1 branch
BranchTrueFalseTotal
$handle = "IO::Uncompress::Gunzip"->new($file) or croak("Failed to read $file") 1 3 4
59 }
60 else {
61 3 require IO::File;
62 3 ▶ $handle = IO::File->new($file, 'r') or croak "Failed to read $file";
Branch: 1 branch
BranchTrueFalseTotal
$handle = "IO::File"->new($file, "r") or croak("Failed to read $file") 1 2 3
63 2 binmode $handle;
64 }
65 5 $handle;
66 }
67  
68 4 1;
69  
70 __END__
« blib/lib/Acme/CPANAuthors/Utils/CPANIndex.pm ↑ Summary lib/Acme/CPANAuthors/Utils/Kwalitee.pm »