line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Morpheus::Key; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Morpheus::Key::VERSION = '0.46'; |
4
|
|
|
|
|
|
|
} |
5
|
7
|
|
|
7
|
|
32543
|
use strict; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
2020
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: class representing config key |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use overload |
11
|
603
|
|
|
603
|
|
1278
|
'eq' => sub { @_ = upgrade(@_); ${$_[0]} eq ${$_[1]} }, |
|
603
|
|
|
|
|
863
|
|
|
603
|
|
|
|
|
928
|
|
|
603
|
|
|
|
|
4754
|
|
12
|
|
|
|
|
|
|
'lt' => \&less, |
13
|
58
|
100
|
|
58
|
|
148
|
'le' => sub { @_ = upgrade(@_); $_[0] lt $_[1] or $_[0] eq $_[1] }, |
|
58
|
|
|
|
|
146
|
|
14
|
1006
|
|
|
1006
|
|
2100
|
'gt' => sub { @_ = upgrade(@_); $_[1] lt $_[0] }, |
|
1006
|
|
|
|
|
2380
|
|
15
|
589
|
100
|
|
589
|
|
1183
|
'ge' => sub { @_ = upgrade(@_); $_[1] lt $_[0] or $_[0] eq $_[1] }, #ATTN 'not $x < $y' does not mean '$x >= $y' |
|
589
|
|
|
|
|
1372
|
|
16
|
|
|
|
|
|
|
|
17
|
11252
|
|
|
11252
|
|
11959
|
'""' => sub { ${$_[0]} }, |
|
11252
|
|
|
|
|
37026
|
|
18
|
7
|
|
|
7
|
|
13179
|
'@{}' => \&parts; |
|
7
|
|
|
|
|
18921
|
|
|
7
|
|
|
|
|
141
|
|
19
|
|
|
|
|
|
|
|
20
|
7
|
|
|
7
|
|
1707
|
use base qw(Exporter); |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
4408
|
|
21
|
|
|
|
|
|
|
our @EXPORT_OK = qw(key); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new { |
24
|
6765
|
|
|
6765
|
0
|
8543
|
my $class = shift; |
25
|
6765
|
|
|
|
|
10463
|
my $key = shift; |
26
|
|
|
|
|
|
|
|
27
|
6765
|
|
|
|
|
30338
|
$key =~ s{/+}{/}g; |
28
|
6765
|
|
|
|
|
19601
|
$key =~ s{^/*}{/}; #TODO: support relative keys? |
29
|
6765
|
|
|
|
|
19535
|
$key =~ s{/+$}{}; |
30
|
|
|
|
|
|
|
|
31
|
6765
|
|
|
|
|
34968
|
bless \$key => $class; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub upgrade { |
35
|
3912
|
100
|
|
3912
|
0
|
15952
|
map { ref $_ ? $_ : __PACKAGE__->new($_) } @_; |
|
11736
|
|
|
|
|
32084
|
|
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub less ($$) { |
39
|
1656
|
|
|
1656
|
0
|
3161
|
@_ = upgrade(@_); |
40
|
1656
|
|
|
|
|
3245
|
my ($key1, $key2) = @_; |
41
|
1656
|
|
|
|
|
2947
|
$key1 = "$key1"; |
42
|
1656
|
|
|
|
|
2924
|
$key2 = "$key2"; |
43
|
1656
|
|
100
|
|
|
15149
|
return length $key1 < length $key2 && substr($key2, 0, 1 + length $key1) eq "$key1/"; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub parts ($) { |
47
|
1075
|
|
|
1075
|
1
|
1610
|
my ($key) = @_; |
48
|
1075
|
|
|
|
|
3682
|
$key = "$key"; |
49
|
1075
|
|
|
|
|
10077
|
$key =~ s{^/}{}; |
50
|
1075
|
|
|
|
|
13994
|
return [split qr{/}, $key]; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub key { |
54
|
2241
|
|
|
2241
|
1
|
5990
|
__PACKAGE__->new($_[0]); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |