line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Morpheus::Bootstrap; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Morpheus::Bootstrap::VERSION = '0.46'; |
4
|
|
|
|
|
|
|
} |
5
|
4
|
|
|
4
|
|
22
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
156
|
|
6
|
4
|
|
|
4
|
|
22
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
128
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ABSTRACT: initial morpheus plugin which loads all other plugins |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
|
2648
|
use Morpheus::Plugin::Simple; |
|
4
|
|
|
|
|
86
|
|
|
4
|
|
|
|
|
2451
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $BOOTSTRAP_PATH; |
14
|
|
|
|
|
|
|
$BOOTSTRAP_PATH = [@INC]; |
15
|
|
|
|
|
|
|
@$BOOTSTRAP_PATH = split /[\s:]+/, $ENV{MORPHEUS_BOOTSTRAP_PATH} if defined $ENV{MORPHEUS_BOOTSTRAP_PATH}; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub import { |
18
|
4
|
|
|
4
|
|
10
|
my $class = shift; |
19
|
4
|
|
|
|
|
109
|
while (@_) { |
20
|
0
|
|
|
|
|
0
|
my $cmd = shift; |
21
|
0
|
0
|
|
|
|
0
|
if ($cmd eq '-path') { |
22
|
0
|
|
|
|
|
0
|
push @$BOOTSTRAP_PATH, @{(shift)}; |
|
0
|
|
|
|
|
0
|
|
23
|
|
|
|
|
|
|
} else { |
24
|
0
|
|
|
|
|
0
|
die "unexpected option '$cmd'"; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new { |
30
|
|
|
|
|
|
|
|
31
|
4
|
|
|
4
|
0
|
16
|
my $this = { |
32
|
|
|
|
|
|
|
priority => 200, |
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $that = Morpheus::Plugin::Simple->new(sub { |
36
|
|
|
|
|
|
|
|
37
|
4
|
|
|
4
|
|
59
|
my $loaded = {}; |
38
|
|
|
|
|
|
|
|
39
|
4
|
|
|
|
|
14
|
for my $path (@$BOOTSTRAP_PATH) { |
40
|
31
|
|
|
|
|
1819
|
for my $file (glob "$path/Morpheus/Bootstrap/*.pm") { |
41
|
14
|
50
|
|
|
|
167
|
$file =~ m{/([^/]+)\.pm$} or die; |
42
|
14
|
|
|
|
|
40
|
my $name = "Bootstrap::$1"; |
43
|
14
|
100
|
|
|
|
57
|
next if $loaded->{$name}; |
44
|
8
|
|
|
|
|
8735
|
require $file; |
45
|
8
|
|
|
|
|
43
|
my $object = "Morpheus::$name"; |
46
|
8
|
50
|
|
|
|
123
|
$object = $object->new() if $object->can('new'); |
47
|
8
|
|
|
|
|
58
|
$loaded->{$name} = { |
48
|
|
|
|
|
|
|
priority => 300, |
49
|
|
|
|
|
|
|
object => $object, |
50
|
|
|
|
|
|
|
}; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
return { |
55
|
4
|
|
|
|
|
58
|
"morpheus" => { |
56
|
|
|
|
|
|
|
"plugins" => { |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Bootstrap => $this, |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
%$loaded, |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
}; |
64
|
4
|
|
|
|
|
80
|
}); |
65
|
|
|
|
|
|
|
|
66
|
4
|
|
|
|
|
24
|
$this->{object} = $that; #FIXME: weaken? |
67
|
|
|
|
|
|
|
|
68
|
4
|
|
|
|
|
28
|
return $that; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |