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