line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Badger; |
2
|
|
|
|
|
|
|
|
3
|
70
|
|
|
70
|
|
4222
|
use 5.008; |
|
70
|
|
|
|
|
236
|
|
4
|
70
|
|
|
70
|
|
342
|
use Carp; |
|
70
|
|
|
|
|
125
|
|
|
70
|
|
|
|
|
3808
|
|
5
|
70
|
|
|
70
|
|
2567
|
use lib; |
|
70
|
|
|
|
|
3908
|
|
|
70
|
|
|
|
|
443
|
|
6
|
70
|
|
|
70
|
|
33158
|
use Badger::Hub; |
|
70
|
|
|
|
|
197
|
|
|
70
|
|
|
|
|
5555
|
|
7
|
|
|
|
|
|
|
use Badger::Class |
8
|
|
|
|
|
|
|
debug => 0, |
9
|
|
|
|
|
|
|
base => 'Badger::Base', |
10
|
|
|
|
|
|
|
import => 'class', |
11
|
|
|
|
|
|
|
words => 'HUB', |
12
|
|
|
|
|
|
|
constants => 'PKG ARRAY DELIMITER', |
13
|
|
|
|
|
|
|
filesystem => 'Bin', |
14
|
|
|
|
|
|
|
exports => { |
15
|
|
|
|
|
|
|
hooks => { |
16
|
70
|
|
|
|
|
743
|
lib => [ sub { $_[0]->lib($_[3]) }, 1], |
|
4
|
|
|
|
|
16
|
|
17
|
|
|
|
|
|
|
}, |
18
|
|
|
|
|
|
|
fail => \&_export_handler, |
19
|
70
|
|
|
70
|
|
439
|
}; |
|
70
|
|
|
|
|
121
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = 0.16; |
22
|
|
|
|
|
|
|
our $HUB = 'Badger::Hub::Badger'; |
23
|
|
|
|
|
|
|
our $AUTOLOAD; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _export_handler { |
27
|
|
|
|
|
|
|
# TODO: we should be able to refactor this down, now that Badger::Exporter |
28
|
|
|
|
|
|
|
# can handle this argument shifting |
29
|
13
|
|
|
13
|
|
29
|
my ($class, $target, $key, $symbols) = @_; |
30
|
13
|
50
|
|
|
|
29
|
croak "You didn't specify a value for the '$key' load option." |
31
|
|
|
|
|
|
|
unless @$symbols; |
32
|
13
|
|
|
|
|
45
|
my $module = join(PKG, $class, $key); |
33
|
13
|
|
|
|
|
21
|
my $option = shift @$symbols; |
34
|
13
|
|
|
|
|
34
|
class($module)->load; |
35
|
13
|
|
|
|
|
68
|
$module->export($target, $option); |
36
|
13
|
|
|
|
|
37
|
return 1; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub init { |
41
|
1
|
|
|
1
|
1
|
4
|
my ($self, $config) = @_; |
42
|
1
|
|
33
|
|
|
8
|
my $hub = $config->{ hub } || $self->class->any_var(HUB); |
43
|
1
|
50
|
|
|
|
6
|
unless (ref $hub) { |
44
|
1
|
|
|
|
|
6
|
class($hub)->load; |
45
|
1
|
|
|
|
|
11
|
$hub = $hub->new($config); |
46
|
|
|
|
|
|
|
} |
47
|
1
|
|
|
|
|
6
|
$self->{ hub } = $hub; |
48
|
1
|
|
|
|
|
2
|
return $self; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub lib { |
52
|
7
|
|
|
7
|
1
|
19
|
my ($self, $lib) = @_; |
53
|
7
|
50
|
|
|
|
65
|
$lib = [split(DELIMITER, $lib)] |
54
|
|
|
|
|
|
|
unless ref $lib eq ARRAY; |
55
|
7
|
|
|
|
|
20
|
foreach (@$lib) { |
56
|
|
|
|
|
|
|
# resolve directories relative to current working directory so that |
57
|
|
|
|
|
|
|
# relative paths Just Work[tm], e.g. ../perl/lib as well as absolute |
58
|
|
|
|
|
|
|
# paths. e.g. /full/path/to/perl/lib |
59
|
9
|
|
|
|
|
322
|
my $dir = Bin->dir($_)->must_exist; |
60
|
9
|
|
|
|
|
80
|
$self->debug("adding lib: $dir") if DEBUG; |
61
|
9
|
|
|
|
|
46
|
lib->import($dir->absolute); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub hub { |
66
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
67
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
if (ref $self) { |
69
|
|
|
|
|
|
|
return @_ |
70
|
|
|
|
|
|
|
? ($self->{ hub } = shift) |
71
|
0
|
0
|
|
|
|
|
: $self->{ hub }; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
else { |
74
|
|
|
|
|
|
|
return @_ |
75
|
0
|
0
|
|
|
|
|
? $self->class->var(HUB => shift) |
76
|
|
|
|
|
|
|
: $self->class->var(HUB) |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub codec { |
81
|
0
|
|
|
0
|
1
|
|
shift->hub->codec(@_); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub config { |
86
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
87
|
0
|
|
|
|
|
|
return $self->hub->config; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# TODO: AUTOLOAD method which polls hub to see what it supports |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__END__ |