| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Copyright (c) 2025 Philipp Schafft |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# licensed under Artistic License 2.0 (see LICENSE file) |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: generic module for extracting information from user accounts |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package User::Information::Path; |
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
10
|
use v5.20; |
|
|
1
|
|
|
|
|
2
|
|
|
11
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
25
|
|
|
12
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
32
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
10
|
use parent 'Data::Identifier::Interface::Userdata'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
4
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
75
|
use Data::Identifier; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
17
|
|
|
17
|
1
|
|
|
1
|
|
681
|
use Data::Identifier::Generate; |
|
|
1
|
|
|
|
|
4809
|
|
|
|
1
|
|
|
|
|
37
|
|
|
18
|
1
|
|
|
1
|
|
9
|
use User::Information; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
17
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
462
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = v0.05; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my %_registered; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new { |
|
28
|
2
|
|
|
2
|
1
|
6
|
my ($pkg, @args) = @_; |
|
29
|
2
|
|
|
|
|
2
|
my @elements; |
|
30
|
2
|
|
|
|
|
10
|
my $self = bless {elements => \@elements}, $pkg; |
|
31
|
2
|
|
|
|
|
7
|
my $root; |
|
32
|
|
|
|
|
|
|
my $sub; |
|
33
|
2
|
|
|
|
|
0
|
my $hashkey; |
|
34
|
|
|
|
|
|
|
|
|
35
|
2
|
50
|
|
|
|
9
|
if (!(scalar(@args) & 1)) { |
|
36
|
0
|
|
|
|
|
0
|
$root = shift(@args); |
|
37
|
|
|
|
|
|
|
} |
|
38
|
2
|
|
|
|
|
3
|
$sub = shift(@args); |
|
39
|
|
|
|
|
|
|
|
|
40
|
2
|
50
|
|
|
|
5
|
if (ref $sub) { |
|
|
|
0
|
|
|
|
|
|
|
41
|
2
|
|
|
|
|
3
|
@elements = @{$sub}; |
|
|
2
|
|
|
|
|
5
|
|
|
42
|
|
|
|
|
|
|
} elsif (defined $sub) { |
|
43
|
0
|
|
|
|
|
0
|
@elements = ($sub); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
2
|
50
|
|
|
|
4
|
croak 'No elements given' unless scalar @elements; |
|
47
|
|
|
|
|
|
|
|
|
48
|
2
|
50
|
|
|
|
6
|
if (defined $root) { |
|
49
|
0
|
|
|
|
|
0
|
unshift(@elements, $root->_elements); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
2
|
|
|
|
|
7
|
foreach my $el (@elements) { |
|
53
|
4
|
|
|
|
|
8
|
$el = _mk_element($el); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
2
|
50
|
|
|
|
115
|
croak 'Stray options passed' if scalar @args; |
|
57
|
|
|
|
|
|
|
|
|
58
|
2
|
|
|
|
|
8
|
$hashkey = join('/', map {$_->ise} @elements); # no need to escape as we do not accept chars that need to be escaped to begin with |
|
|
4
|
|
|
|
|
67
|
|
|
59
|
|
|
|
|
|
|
|
|
60
|
2
|
50
|
|
|
|
53
|
if (defined $_registered{$hashkey}) { |
|
61
|
0
|
|
|
|
|
0
|
return $_registered{$hashkey}; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
2
|
|
|
|
|
7
|
$_registered{$hashkey} = $self; |
|
65
|
2
|
|
|
|
|
10
|
$self->{hashkey} = $hashkey; |
|
66
|
|
|
|
|
|
|
|
|
67
|
2
|
|
|
|
|
2334
|
return $self; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub displayname { |
|
72
|
0
|
|
|
0
|
1
|
0
|
my ($self, %opts) = @_; |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
0
|
delete $opts{default}; |
|
75
|
0
|
|
|
|
|
0
|
delete $opts{no_defaults}; |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
0
|
|
|
|
0
|
croak 'Stray options passed' if scalar keys %opts; |
|
78
|
0
|
|
|
|
|
0
|
return $self->{displayname} = join('/', map {$_->displayname} $self->_elements); |
|
|
0
|
|
|
|
|
0
|
|
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# ---- Private helpers ---- |
|
82
|
|
|
|
|
|
|
sub _elements { |
|
83
|
0
|
|
|
0
|
|
0
|
my ($self) = @_; |
|
84
|
0
|
|
|
|
|
0
|
return @{$self->{elements}}; |
|
|
0
|
|
|
|
|
0
|
|
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub _last_element_id { |
|
88
|
0
|
|
|
0
|
|
0
|
my ($self) = @_; |
|
89
|
0
|
|
|
|
|
0
|
return $self->{elements}[-1]->id; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub _hashkey { |
|
93
|
0
|
|
|
0
|
|
0
|
my ($self) = @_; |
|
94
|
0
|
|
|
|
|
0
|
return $self->{hashkey}; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub _mk_element { |
|
98
|
4
|
|
|
4
|
|
7
|
my ($val) = @_; |
|
99
|
4
|
|
|
|
|
20
|
my $ret; |
|
100
|
|
|
|
|
|
|
|
|
101
|
4
|
50
|
|
|
|
9
|
return $val->Data::Identifier::as('Data::Identifier') if ref $val; |
|
102
|
|
|
|
|
|
|
|
|
103
|
4
|
|
|
|
|
38
|
$ret = Data::Identifier->new(User::Information->PATH_ELEMENT_TYPE => $val); |
|
104
|
4
|
|
|
|
|
283
|
$ret->{id_cache}{Data::Identifier->WK_UUID()} = Data::Identifier::Generate->_uuid_v5(User::Information->PATH_ELEMENT_NS, $val); |
|
105
|
|
|
|
|
|
|
|
|
106
|
4
|
|
|
|
|
3377
|
$ret->register; |
|
107
|
|
|
|
|
|
|
|
|
108
|
4
|
|
|
|
|
2228
|
return $ret; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
__END__ |