line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Amon2::Plugin::ShareDir; |
2
|
2
|
|
|
2
|
|
2622
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
77
|
|
3
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
66
|
|
4
|
2
|
|
|
2
|
|
104
|
use 5.008005; |
|
2
|
|
|
|
|
19
|
|
|
2
|
|
|
|
|
184
|
|
5
|
2
|
|
|
2
|
|
4256
|
use version; our $VERSION = version->declare("v0.0.7"); |
|
2
|
|
|
|
|
5136
|
|
|
2
|
|
|
|
|
12
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
172
|
use File::Spec; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
64
|
|
8
|
2
|
|
|
2
|
|
1121
|
use File::ShareDir; |
|
2
|
|
|
|
|
9814
|
|
|
2
|
|
|
|
|
125
|
|
9
|
2
|
|
|
2
|
|
1288
|
use if $] < 5.009_005, 'MRO::Compat'; |
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
16
|
|
10
|
2
|
|
|
2
|
|
76
|
use List::Util qw(first); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
201
|
|
11
|
2
|
|
|
2
|
|
906
|
use Amon2::Util; |
|
2
|
|
|
|
|
43156
|
|
|
2
|
|
|
|
|
640
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub init { |
14
|
1
|
|
|
1
|
0
|
10
|
my ($class, $c, $conf) = @_; |
15
|
1
|
|
|
|
|
6
|
Amon2::Util::add_method($c, 'share_dir', \&_share_dir); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our %SHARE_DIR_CACHE; |
19
|
|
|
|
|
|
|
sub _share_dir { |
20
|
3
|
|
|
3
|
|
28
|
my $c = shift; |
21
|
3
|
|
33
|
|
|
12
|
my $klass = ref $c || $c; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$SHARE_DIR_CACHE{$klass} ||= sub { |
24
|
3
|
|
|
3
|
|
12
|
my $d1 = File::Spec->catfile($c->base_dir, 'share'); |
25
|
3
|
100
|
|
|
|
100
|
return $d1 if -d $d1; |
26
|
|
|
|
|
|
|
|
27
|
1
|
100
|
66
|
|
|
4
|
my $dist = first { $_ ne 'Amon2' && $_ ne 'Amon2::Web' && $_->isa('Amon2') } reverse @{mro::get_linear_isa(ref $c || $c)}; |
|
2
|
|
33
|
|
|
21
|
|
|
1
|
|
|
|
|
21
|
|
28
|
1
|
|
|
|
|
6
|
$dist =~ s!::!-!g; |
29
|
1
|
|
|
|
|
4
|
my $d2 = File::ShareDir::dist_dir($dist); |
30
|
1
|
50
|
|
|
|
28
|
return $d2 if -d $d2; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
Carp::croak "Cannot find assets path($d1, $d2)."; |
33
|
3
|
|
33
|
|
|
21
|
}->(); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
__END__ |