| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Role::Commons; |
|
2
|
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
22639
|
use 5.008; |
|
|
9
|
|
|
|
|
30
|
|
|
|
9
|
|
|
|
|
371
|
|
|
4
|
9
|
|
|
9
|
|
48
|
use strict; |
|
|
9
|
|
|
|
|
17
|
|
|
|
9
|
|
|
|
|
243
|
|
|
5
|
9
|
|
|
9
|
|
45
|
use warnings; |
|
|
9
|
|
|
|
|
21
|
|
|
|
9
|
|
|
|
|
394
|
|
|
6
|
9
|
|
|
9
|
|
47
|
use Carp qw[ carp croak ]; |
|
|
9
|
|
|
|
|
17
|
|
|
|
9
|
|
|
|
|
787
|
|
|
7
|
9
|
|
|
9
|
|
9395
|
use Module::Runtime qw[ use_package_optimistically ]; |
|
|
9
|
|
|
|
|
18349
|
|
|
|
9
|
|
|
|
|
62
|
|
|
8
|
9
|
|
|
9
|
|
9365
|
use Moo::Role qw[]; |
|
|
9
|
|
|
|
|
279421
|
|
|
|
9
|
|
|
|
|
390
|
|
|
9
|
9
|
|
|
9
|
|
9723
|
use Types::TypeTiny qw[ HashLike ArrayLike ]; |
|
|
9
|
|
|
|
|
33690
|
|
|
|
9
|
|
|
|
|
50
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
BEGIN { |
|
12
|
9
|
|
|
9
|
|
41611
|
$Role::Commons::AUTHORITY = 'cpan:TOBYINK'; |
|
13
|
9
|
|
|
|
|
4198
|
$Role::Commons::VERSION = '0.102'; |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my @ALL = qw( |
|
17
|
|
|
|
|
|
|
Authority |
|
18
|
|
|
|
|
|
|
ObjectID |
|
19
|
|
|
|
|
|
|
Tap |
|
20
|
|
|
|
|
|
|
); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub parse_arguments |
|
23
|
|
|
|
|
|
|
{ |
|
24
|
17
|
|
|
17
|
1
|
32
|
my $class = shift; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Translate "-all". |
|
27
|
17
|
|
|
|
|
61
|
my $all = 0; |
|
28
|
17
|
100
|
|
|
|
33
|
my @args = grep { /^\-all$/i ? do { $all++; 0 } : 1 } @_; |
|
|
42
|
|
|
|
|
180
|
|
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
3
|
|
|
29
|
17
|
100
|
|
|
|
62
|
unshift @args, @ALL if $all; |
|
30
|
|
|
|
|
|
|
|
|
31
|
17
|
|
|
|
|
26
|
my %roles; |
|
32
|
|
|
|
|
|
|
my %options; |
|
33
|
17
|
|
|
|
|
60
|
while (my $name = shift @args) |
|
34
|
|
|
|
|
|
|
{ |
|
35
|
32
|
|
|
|
|
76
|
my $details; |
|
36
|
32
|
100
|
100
|
|
|
226
|
if ($name =~ /^-/ or ref $args[0]) |
|
37
|
12
|
|
|
|
|
24
|
{ $details = shift @args } |
|
38
|
|
|
|
|
|
|
|
|
39
|
32
|
100
|
|
|
|
96
|
if ($name =~ /^\-(.+)$/i) |
|
40
|
10
|
|
|
|
|
63
|
{ $options{ lc $1 } = $details } |
|
41
|
|
|
|
|
|
|
else |
|
42
|
22
|
|
|
|
|
92
|
{ $roles{ $name } = $details } |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
17
|
50
|
66
|
|
|
100
|
carp "Role::Commons - no roles specified" |
|
46
|
|
|
|
|
|
|
if keys %options && !keys %roles; |
|
47
|
|
|
|
|
|
|
|
|
48
|
17
|
|
|
|
|
63
|
return(\%roles, \%options); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub import |
|
52
|
|
|
|
|
|
|
{ |
|
53
|
9
|
|
|
9
|
|
27
|
my $class = shift; |
|
54
|
9
|
|
|
|
|
40
|
my ($roles, $options) = $class->parse_arguments(@_); |
|
55
|
9
|
100
|
|
|
|
40
|
$options->{into} = caller unless exists $options->{into}; |
|
56
|
|
|
|
|
|
|
|
|
57
|
9
|
|
|
|
|
38
|
foreach my $role (sort keys %$roles) |
|
58
|
|
|
|
|
|
|
{ |
|
59
|
11
|
|
|
|
|
91
|
use_package_optimistically( join q[::], $class, $role ); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
'Moo::Role'->apply_roles_to_package( |
|
63
|
11
|
|
|
|
|
103
|
$options->{into}, |
|
64
|
9
|
|
|
|
|
1445
|
map { join q[::], $class, $_ } sort keys %$roles, |
|
65
|
|
|
|
|
|
|
); |
|
66
|
|
|
|
|
|
|
|
|
67
|
9
|
|
|
|
|
10251
|
foreach my $role (sort keys %$roles) |
|
68
|
|
|
|
|
|
|
{ |
|
69
|
11
|
|
|
|
|
34
|
my $role_pkg = join q[::], $class, $role; |
|
70
|
11
|
|
|
|
|
27
|
my $details = $roles->{$role}; |
|
71
|
11
|
50
|
|
|
|
20
|
my $setup_method = do { |
|
72
|
9
|
|
|
9
|
|
212
|
no strict 'refs'; |
|
|
9
|
|
|
|
|
22
|
|
|
|
9
|
|
|
|
|
2417
|
|
|
73
|
11
|
|
|
|
|
16
|
${"$role_pkg\::setup_for_class"}; |
|
|
11
|
|
|
|
|
80
|
|
|
74
|
|
|
|
|
|
|
} or next; |
|
75
|
11
|
50
|
|
|
|
63
|
$role_pkg->$setup_method( |
|
|
|
100
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
$options->{into}, |
|
77
|
|
|
|
|
|
|
HashLike->check($details) |
|
78
|
|
|
|
|
|
|
? %$details |
|
79
|
|
|
|
|
|
|
: ( ArrayLike->check($details) ? @$details : (option => $details) ), |
|
80
|
|
|
|
|
|
|
); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub apply_roles_to_object |
|
85
|
|
|
|
|
|
|
{ |
|
86
|
0
|
0
|
|
0
|
1
|
|
my $class = shift unless blessed($_[0]); |
|
87
|
0
|
|
|
|
|
|
my $object = shift; |
|
88
|
0
|
|
|
|
|
|
my ($roles, $options) = $class->parse_arguments(@_); |
|
89
|
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
foreach my $role (sort keys %$roles) |
|
91
|
|
|
|
|
|
|
{ |
|
92
|
0
|
|
|
|
|
|
use_package_optimistically( join q[::], $class, $role ); |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
'Moo::Role'->apply_roles_to_object( |
|
96
|
0
|
|
|
|
|
|
$object, |
|
97
|
0
|
|
|
|
|
|
map { join q[::], $class, $_ } sort keys %$roles, |
|
98
|
|
|
|
|
|
|
); |
|
99
|
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
foreach my $role (sort keys %$roles) |
|
101
|
|
|
|
|
|
|
{ |
|
102
|
0
|
|
|
|
|
|
my $role_pkg = join q[::], $class, $role; |
|
103
|
0
|
|
|
|
|
|
my $details = $roles->{$role}; |
|
104
|
|
|
|
|
|
|
my $setup_method = do { |
|
105
|
9
|
|
|
9
|
|
55
|
no strict 'refs'; |
|
|
9
|
|
|
|
|
16
|
|
|
|
9
|
|
|
|
|
1146
|
|
|
106
|
|
|
|
|
|
|
${"$role_pkg\::setup_for_class"}; |
|
107
|
0
|
|
0
|
0
|
|
|
} || sub { 0 }; |
|
|
0
|
|
|
|
|
|
|
|
108
|
0
|
0
|
|
|
|
|
$role_pkg->$setup_method( |
|
|
|
0
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
ref($object), |
|
110
|
|
|
|
|
|
|
HashLike->check($details) |
|
111
|
|
|
|
|
|
|
? %$details |
|
112
|
|
|
|
|
|
|
: ( ArrayLike->check($details) ? @$details : (option => $details) ), |
|
113
|
|
|
|
|
|
|
); |
|
114
|
0
|
0
|
|
|
|
|
$setup_method = do { |
|
115
|
9
|
|
|
9
|
|
53
|
no strict 'refs'; |
|
|
9
|
|
|
|
|
16
|
|
|
|
9
|
|
|
|
|
1439
|
|
|
116
|
0
|
|
|
|
|
|
${"$role_pkg\::setup_for_object"}; |
|
|
0
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
} or next; |
|
118
|
0
|
0
|
|
|
|
|
$role_pkg->$setup_method( |
|
|
|
0
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
$object, |
|
120
|
|
|
|
|
|
|
HashLike->check($details) |
|
121
|
|
|
|
|
|
|
? %$details |
|
122
|
|
|
|
|
|
|
: ( ArrayLike->check($details) ? @$details : (option => $details) ), |
|
123
|
|
|
|
|
|
|
); |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
1; |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
__END__ |