OurCal/View.pm

filter: Statementstmt 35.7% 10 / 28 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 50.0% 3 / 6 Podpod 100% 3 / 3 totaltotal 34.7% 16 / 46 CC 5 SCAR 20.4
CC
5
Cov
29%
views
12.0
load_view
12.0
new
2.0
CRAP 7.7
« OurCal.pm ↑ Summary OurCal/Provider/Multi.pm »
1 package OurCal::View;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use UNIVERSAL::require;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Module::Pluggable sub_name => '_views',
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 search_path => 'OurCal::View';
7  
8  
9 =head2 NAME
10  
11 OurCal::View - base class for all OourCal views
12  
13 =head1 METHODS
14  
15 =cut
16  
17 =head2 new <param[s]>
18  
19 =cut
20  
21 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
22 0 my $class = shift;
23 0 my %what = @_;
24 0 return bless \%what, $class;
25 }
26  
27  
28 =head2 views
29  
30 Returns a has with key-value pairs representing the shortname and
31 equivalent class for all views installed.
32  
33 =cut
34  
35 0 ▶sub views {
Subroutine views: not called CC=3 SCAR=24.8
Pod documented
36 0 my $self = shift;
37 0 ▶ my $class = (ref $self)? ref($self) : $self;
Branch: 1 branch
BranchTrueFalseTotal
ref $self ? : 0 0 0
38  
39 0 my %views;
40 0 foreach my $view ($self->_views) {
41 0 my $name = $view;
42 0 $name =~ s!^${class}::!!;
43 0 $views{lc($name)} = $view;
44 }
45 0 return %views;
46 }
47  
48 =head2 load_view <name>
49  
50 Returns an object representing a view of the same name of a type,
51 defined in the config and found in C<views>. Authomatically passes in
52 the correct config.
53  
54 =cut
55  
56 0 ▶sub load_view {
Subroutine load_view: not called CC=3 SCAR=24.8
Pod documented
57 0 my $self = shift;
58 0 my $name = shift;
59 0 my %opts = @_;
60 0 my %views = $self->views;
61 0 ▶ my $class = $views{lc($name)} || die "Couldn't get a class for view of type $name\n";
Condition0%0/3
$views{lc $name} || die("Couldn't get a class for view of type $name\n")
l!l&&r!l&&!r
000
MC/DC0%0/2
$views{lc $name} || die("Couldn't get a class for view of type $name\n")
$views{lc $name} die("Couldn't get a class for view of type $name\n")
Truth table0%0/3
A || B
A= $views{lc $name}B= die("Couldn't get a class for view of type $name\n")
ABresult
1X1
011
000
62 0 ▶ $class->require || die "Couldn't require class $class: $@\n";
Branch: 1 branch
BranchTrueFalseTotal
$class->require or die("Couldn't require class ${class}: $@\n") 0 0 0
63 0 return $class->new(%opts);
64 }
65  
66 2 1;
67  
« OurCal.pm ↑ Summary OurCal/Provider/Multi.pm »