line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::RecordStream::Site; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = "4.0.23"; |
4
|
|
|
|
|
|
|
|
5
|
70
|
|
|
70
|
|
788
|
use strict; |
|
70
|
|
|
|
|
882
|
|
|
70
|
|
|
|
|
1672
|
|
6
|
70
|
|
|
70
|
|
327
|
use warnings; |
|
70
|
|
|
|
|
134
|
|
|
70
|
|
|
|
|
1785
|
|
7
|
|
|
|
|
|
|
|
8
|
70
|
|
|
70
|
|
356
|
use Carp qw(croak); |
|
70
|
|
|
|
|
140
|
|
|
70
|
|
|
|
|
24034
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
{ |
11
|
|
|
|
|
|
|
my $bootstrapped; |
12
|
|
|
|
|
|
|
my %registry; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub bootstrap |
15
|
|
|
|
|
|
|
{ |
16
|
66
|
100
|
|
66
|
|
219
|
if($bootstrapped) |
17
|
|
|
|
|
|
|
{ |
18
|
59
|
|
|
|
|
146
|
return; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my @site_libs = ( |
22
|
|
|
|
|
|
|
(defined $ENV{RECS_SITELIB} ? $ENV{RECS_SITELIB} : ()), |
23
|
|
|
|
|
|
|
(defined $ENV{HOME} ? "$ENV{HOME}/.recs/site" : ()), |
24
|
7
|
50
|
|
|
|
56
|
map { "$_/Recs/Site" } @INC |
|
91
|
50
|
|
|
|
204
|
|
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# First we find all conceivable sites by looking for module files |
28
|
7
|
|
|
|
|
18
|
my %sites; |
29
|
7
|
|
|
|
|
20
|
for my $dir (@site_libs) |
30
|
|
|
|
|
|
|
{ |
31
|
98
|
50
|
|
|
|
1000
|
if(opendir(DIR, $dir)) |
32
|
|
|
|
|
|
|
{ |
33
|
0
|
|
|
|
|
0
|
while(my $site_module = readdir(DIR)) |
34
|
|
|
|
|
|
|
{ |
35
|
0
|
0
|
0
|
|
|
0
|
next if($site_module eq "." || $site_module eq ".."); |
36
|
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
0
|
if($site_module =~ /^(.*)\.pm$/) |
38
|
|
|
|
|
|
|
{ |
39
|
0
|
|
|
|
|
0
|
$sites{$1} = "$dir/$site_module"; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
0
|
|
|
|
|
0
|
closedir(DIR); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
7
|
|
|
|
|
22
|
delete $sites{'Bootstrap'}; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Then we try loading each of them (they register themselves) |
49
|
7
|
|
|
|
|
32
|
for my $site (sort(keys(%sites))) |
50
|
|
|
|
|
|
|
{ |
51
|
0
|
|
|
|
|
0
|
require $sites{$site}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
7
|
|
|
|
|
39
|
$bootstrapped = 1; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub register_site |
58
|
|
|
|
|
|
|
{ |
59
|
0
|
|
|
0
|
0
|
0
|
my ($class, %args) = @_; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
0
|
|
|
0
|
my $name = delete($args{'name'}) || croak "No name given in registration?!\n"; |
62
|
0
|
|
0
|
|
|
0
|
my $priority = delete($args{'priority'}) || 0; |
63
|
0
|
|
0
|
|
|
0
|
my $path = delete($args{'path'}) || "App::RecordStream::Site::$name"; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
0
|
$registry{$name} = |
66
|
|
|
|
|
|
|
{ |
67
|
|
|
|
|
|
|
'name' => $name, |
68
|
|
|
|
|
|
|
'path' => $path, |
69
|
|
|
|
|
|
|
'priority' => $priority, |
70
|
|
|
|
|
|
|
}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub list_sites |
74
|
|
|
|
|
|
|
{ |
75
|
66
|
|
|
66
|
0
|
273
|
return values(%registry); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |