blib/lib/App/RecordStream/Site.pm

filter: Statementstmt 86.1% 31 / 36 Branchbran 92.8% 13 / 14 Conditioncond 30.0% 3 / 10 MC/DCmcdc 33.3% 2 / 6 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 2 totaltotal 72.9% 54 / 74 CC 14 SCAR 23.8
CC
14
Cov
78%
register_site
20.0
bootstrap
11.0
BEGIN
1.0
CRAP 10.8
« blib/lib/App/RecordStream/Operation/tognuplot.pm ↑ Summary blib/lib/App/RecordStream/Operation/fromps.pm »
1 package App::RecordStream::Site;
2  
3 118 our $VERSION = "4.0.23";
4  
5 118 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 118 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 118 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 {
11 118 my $bootstrapped;
12 118 my %registry;
13  
14 sub bootstrap
15 {
16 143 ▶ if($bootstrapped)
Subroutine bootstrap: called CC=11 SCAR=24.0
Branch: 1 branch
BranchTrueFalseTotal
if ($bootstrapped) 87 56 143
17 {
18 87 return;
19 }
20  
21 my @site_libs = (
22 (defined $ENV{RECS_SITELIB} ? $ENV{RECS_SITELIB} : ()),
23 (defined $ENV{HOME} ? "$ENV{HOME}/.recs/site" : ()),
24 56 ▶ map { "$_/Recs/Site" } @INC
Branch: 2 branches
BranchTrueFalseTotal
defined $ENV{'RECS_SITELIB'} ? : 5 51 56
defined $ENV{'HOME'} ? : 56 0 56
25 );
26  
27 # First we find all conceivable sites by looking for module files
28 56 my %sites;
29 56 for my $dir (@site_libs)
30 {
31 524 ▶ if(opendir(DIR, $dir))
Branch: 1 branch
BranchTrueFalseTotal
if (opendir DIR, $dir) 6 518 524
32 {
33 6 ▶ while(my $site_module = readdir(DIR))
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $site_module = readdir DIR)) 20 6 26
34 {
35 20 ▶ next if($site_module eq "." || $site_module eq "..");
Branch: 1 branch
BranchTrueFalseTotal
if $site_module eq "." or $site_module eq ".." 12 8 20
Condition100%3/3
$site_module eq "." or $site_module eq ".."
l!l&&r!l&&!r
668
MC/DC100%2/2
$site_module eq "." or $site_module eq ".."
$site_module eq "." $site_module eq ".."
Truth table100%3/3
A or B
A= $site_module eq "."B= $site_module eq ".."
ABresult
1X1
011
000
36  
37 8 ▶ if($site_module =~ /^(.*)\.pm$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($site_module =~ /^(.*)\.pm$/) 6 2 8
38 {
39 6 $sites{$1} = "$dir/$site_module";
40 }
41 }
42 6 closedir(DIR);
43 }
44 }
45  
46 56 delete $sites{'Bootstrap'};
47  
48 # Then we try loading each of them (they register themselves)
49 56 for my $site (sort(keys(%sites)))
50 {
51 6 require $sites{$site};
52 }
53  
54 56 $bootstrapped = 1;
55 }
56  
57 sub register_site
58 {
59 0 ▶ my ($class, %args) = @_;
Subroutine register_site: not called CC=4 SCAR=30.0
Pod undocumented
60  
61 0 ▶ my $name = delete($args{'name'}) || croak "No name given in registration?!\n";
Condition0%0/3
delete $args{'name'} || croak("No name given in registration?!\n")
l!l&&r!l&&!r
000
MC/DC0%0/2
delete $args{'name'} || croak("No name given in registration?!\n")
delete $args{'name'} croak("No name given in registration?!\n")
Truth table0%0/3
A || B
A= delete $args{'name'}B= croak("No name given in registration?!\n")
ABresult
1X1
011
000
62 0 ▶ my $priority = delete($args{'priority'}) || 0;
Condition0%0/2
delete $args{'priority'} || 0
l!l
00
MC/DC0%0/1
delete $args{'priority'} || 0
delete $args{'priority'}
Truth table0%0/2
A
A= delete $args{'priority'}
Aresult
11
00
63 0 ▶ my $path = delete($args{'path'}) || "App::RecordStream::Site::$name";
Condition0%0/2
delete $args{'path'} || "App::RecordStream::Site::$name"
l!l
00
MC/DC0%0/1
delete $args{'path'} || "App::RecordStream::Site::$name"
delete $args{'path'}
Truth table0%0/2
A
A= delete $args{'path'}
Aresult
11
00
64  
65 0 $registry{$name} =
66 {
67 'name' => $name,
68 'path' => $path,
69 'priority' => $priority,
70 };
71 }
72  
73 sub list_sites
74 {
75 138 ▶ return values(%registry);
Subroutine list_sites: called CC=1 SCAR=0.0
Pod undocumented
76 }
77 }
78  
79 118 1;
« blib/lib/App/RecordStream/Operation/tognuplot.pm ↑ Summary blib/lib/App/RecordStream/Operation/fromps.pm »