blib/lib/Bot/Cobalt/Core/ContextMeta/Auth.pm

filter: Statementstmt 28.3% 15 / 53 Branchbran 0.0% 0 / 24 Conditioncond 0.0% 0 / 83 MC/DCmcdc 0.0% 0 / 36 Subroutinesub 33.3% 5 / 15 Podpod 88.8% 8 / 9 totaltotal 12.7% 28 / 220 CC 43 SCAR 34.9
CC
43
Cov
9%
__ANON__
42.0
level
42.0
set_flag
42.0
CRAP 32.9
« blib/lib/Bot/Cobalt/Plugin/Version.pm ↑ Summary blib/lib/Bot/Cobalt/IRC/Role/UserEvents.pm »
1 package Bot::Cobalt::Core::ContextMeta::Auth;
2 $Bot::Cobalt::Core::ContextMeta::Auth::VERSION = '0.021003';
3 2 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Bot::Cobalt::Common ':types';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8  
9 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 extends 'Bot::Cobalt::Core::ContextMeta';
11  
12  
13 0 ▶around add => sub {
Subroutine __ANON__: not called CC=6 SCAR=37.4
14 0 my ($orig, $self) = splice @_, 0, 2;
15 ## auth->add(
16 ## Context => $context,
17 ## Username => $username,
18 ## Host => $host,
19 ## Level => $level,
20 ## Flags => $flags,
21 ## Alias => $plugin_alias
22 ## )
23 0 my %args = @_;
24 0 $args{lc $_} = delete $args{$_} for keys %args;
25
26 0 for my $required (qw/context nickname username host level/) {
27 0 ▶ unless (defined $args{$required}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{$required}) 0 0 0
28 0 carp "add() missing mandatory opt $required";
29 return
30 0 }
31 }
32
33 0 ▶ $args{alias} = scalar caller unless defined $args{alias};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"alias"} 0 0 0
34 0 ▶ $args{flags} = {} unless defined $args{flags};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"flags"} 0 0 0
35
36 my $meta = {
37 Alias => $args{alias},
38 Username => $args{username},
39 Host => $args{host},
40 Level => $args{level},
41 Flags => $args{flags},
42 0 };
43  
44 0 $self->$orig($args{context}, $args{nickname}, $meta)
45 };
46  
47 0 ▶sub level {
Subroutine level: not called CC=6 SCAR=37.4
Pod documented
48 0 my ($self, $context, $nickname) = @_;
49  
50 return 0
51 unless defined $context
52 and defined $nickname
53 and exists $self->_list->{$context}
54 0 ▶ and ref $self->_list->{$context}->{$nickname};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $context and defined $nickname and exists $self->_list->{$context} and ref $self->_list->{$context}{$nickname} 0 0 0
Condition0%0/9
defined $context and defined $nickname and exists $self->_list->{$context} and ref $self->_list->{$context}{$nickname}
!ll&&!rl&&r
000
defined $context and defined $nickname and exists $self->_list->{$context}
!ll&&!rl&&r
000
defined $context and defined $nickname
!ll&&!rl&&r
000
MC/DC0%0/4
defined $context and defined $nickname and exists $self->_list->{$context} and ref $self->_list->{$context}{$nickname}
defined $context defined $nickname exists $self->_list->{$context} ref $self->_list->{$context}{$nickname}
Truth table0%0/5
A and B and C and D
A= defined $contextB= defined $nicknameC= exists $self->_list->{$context}D= ref $self->_list->{$context}{$nickname}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
55
56 0 ▶ $self->_list->{$context}->{$nickname}->{Level} // 0
Condition0%0/2
$self->_list->{$context}{$nickname}{"Level"} // 0
l!l
00
MC/DC0%0/1
$self->_list->{$context}{$nickname}{"Level"} // 0
$self->_list->{$context}{$nickname}{"Level"}
Truth table0%0/2
A
A= $self->_list->{$context}{$nickname}{"Level"}
Aresult
11
00
57 }
58  
59 0 ▶sub set_flag {
Subroutine set_flag: not called CC=6 SCAR=37.4
Pod documented
60 0 my ($self, $context, $nickname, $flag) = @_;
61  
62 return
63 unless defined $context
64 and defined $nickname
65 and $flag
66 and exists $self->_list->{$context}
67 0 ▶ and exists $self->_list->{$context}->{$nickname};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $context and defined $nickname and $flag and exists $self->_list->{$context} and exists $self->_list->{$context}{$nickname} 0 0 0
Condition0%0/12
defined $context and defined $nickname and $flag and exists $self->_list->{$context} and exists $self->_list->{$context}{$nickname}
!ll&&!rl&&r
000
defined $context and defined $nickname and $flag and exists $self->_list->{$context}
!ll&&!rl&&r
000
defined $context and defined $nickname and $flag
!ll&&!rl&&r
000
defined $context and defined $nickname
!ll&&!rl&&r
000
MC/DC0%0/5
defined $context and defined $nickname and $flag and exists $self->_list->{$context} and exists $self->_list->{$context}{$nickname}
defined $context defined $nickname $flag exists $self->_list->{$context} exists $self->_list->{$context}{$nickname}
Truth table0%0/6
A and B and C and D and E
A= defined $contextB= defined $nicknameC= $flagD= exists $self->_list->{$context}E= exists $self->_list->{$context}{$nickname}
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
68
69 0 $self->_list->{$context}->{$nickname}->{Flags}->{$flag} = 1
70 }
71  
72 0 ▶sub drop_flag {
Subroutine drop_flag: not called CC=6 SCAR=37.4
Pod documented
73 0 my ($self, $context, $nickname, $flag) = @_;
74  
75 return
76 unless defined $context
77 and defined $nickname
78 and $flag
79 and exists $self->_list->{$context}
80 0 ▶ and exists $self->_list->{$context}->{$nickname};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $context and defined $nickname and $flag and exists $self->_list->{$context} and exists $self->_list->{$context}{$nickname} 0 0 0
Condition0%0/12
defined $context and defined $nickname and $flag and exists $self->_list->{$context} and exists $self->_list->{$context}{$nickname}
!ll&&!rl&&r
000
defined $context and defined $nickname and $flag and exists $self->_list->{$context}
!ll&&!rl&&r
000
defined $context and defined $nickname and $flag
!ll&&!rl&&r
000
defined $context and defined $nickname
!ll&&!rl&&r
000
MC/DC0%0/5
defined $context and defined $nickname and $flag and exists $self->_list->{$context} and exists $self->_list->{$context}{$nickname}
defined $context defined $nickname $flag exists $self->_list->{$context} exists $self->_list->{$context}{$nickname}
Truth table0%0/6
A and B and C and D and E
A= defined $contextB= defined $nicknameC= $flagD= exists $self->_list->{$context}E= exists $self->_list->{$context}{$nickname}
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
81  
82 0 delete $self->_list->{$context}->{$nickname}->{Flags}->{$flag}
83 }
84  
85 0 ▶sub has_flag {
Subroutine has_flag: not called CC=6 SCAR=37.4
Pod documented
86 0 my ($self, $context, $nickname, $flag) = @_;
87  
88 return
89 unless defined $context
90 and defined $nickname
91 and $flag
92 and exists $self->_list->{$context}
93 0 ▶ and exists $self->_list->{$context}->{$nickname};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $context and defined $nickname and $flag and exists $self->_list->{$context} and exists $self->_list->{$context}{$nickname} 0 0 0
Condition0%0/12
defined $context and defined $nickname and $flag and exists $self->_list->{$context} and exists $self->_list->{$context}{$nickname}
!ll&&!rl&&r
000
defined $context and defined $nickname and $flag and exists $self->_list->{$context}
!ll&&!rl&&r
000
defined $context and defined $nickname and $flag
!ll&&!rl&&r
000
defined $context and defined $nickname
!ll&&!rl&&r
000
MC/DC0%0/5
defined $context and defined $nickname and $flag and exists $self->_list->{$context} and exists $self->_list->{$context}{$nickname}
defined $context defined $nickname $flag exists $self->_list->{$context} exists $self->_list->{$context}{$nickname}
Truth table0%0/6
A and B and C and D and E
A= defined $contextB= defined $nicknameC= $flagD= exists $self->_list->{$context}E= exists $self->_list->{$context}{$nickname}
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
94  
95 0 $self->_list->{$context}->{$nickname}->{Flags}->{$flag}
96 }
97  
98 0 ▶sub flags {
Subroutine flags: not called CC=5 SCAR=34.0
Pod documented
99 0 my ($self, $context, $nickname) = @_;
100  
101 return +{} unless exists $self->_list->{$context}
102 and ref $self->_list->{$context}->{$nickname}
103 and ref $self->_list->{$context}->{$nickname}->{Flags}
104 0 ▶ and reftype $self->_list->{$context}->{$nickname}->{Flags} eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->_list->{$context} and ref $self->_list->{$context}{$nickname} and ref $self->_list->{$context}{$nickname}{"Flags"} and $self->reftype->_list->{$context}{$nickname}{"Flags"} eq "HASH" 0 0 0
Condition0%0/9
exists $self->_list->{$context} and ref $self->_list->{$context}{$nickname} and ref $self->_list->{$context}{$nickname}{"Flags"} and $self->reftype->_list->{$context}{$nickname}{"Flags"} eq "HASH"
!ll&&!rl&&r
000
exists $self->_list->{$context} and ref $self->_list->{$context}{$nickname} and ref $self->_list->{$context}{$nickname}{"Flags"}
!ll&&!rl&&r
000
exists $self->_list->{$context} and ref $self->_list->{$context}{$nickname}
!ll&&!rl&&r
000
MC/DC0%0/4
exists $self->_list->{$context} and ref $self->_list->{$context}{$nickname} and ref $self->_list->{$context}{$nickname}{"Flags"} and $self->reftype->_list->{$context}{$nickname}{"Flags"} eq "HASH"
exists $self->_list->{$context} ref $self->_list->{$context}{$nickname} ref $self->_list->{$context}{$nickname}{"Flags"} $self->reftype->_list->{$context}{$nickname}{"Flags"} eq "HASH"
Truth table0%0/5
A and B and C and D
A= exists $self->_list->{$context}B= ref $self->_list->{$context}{$nickname}C= ref $self->_list->{$context}{$nickname}{"Flags"}D= $self->reftype->_list->{$context}{$nickname}{"Flags"} eq "HASH"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
105  
106 $self->_list->{$context}->{$nickname}->{Flags}
107 0 }
108  
109 1 ▶{ no warnings 'once'; *user = *username }
Subroutine BEGIN: called CC=1 SCAR=0.0
110 0 ▶sub username {
Subroutine username: not called CC=5 SCAR=34.0
Pod documented
111 0 my ($self, $context, $nickname) = @_;
112
113 return
114 unless defined $context
115 and defined $nickname
116 and exists $self->_list->{$context}
117 0 ▶ and ref $self->_list->{$context}->{$nickname};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $context and defined $nickname and exists $self->_list->{$context} and ref $self->_list->{$context}{$nickname} 0 0 0
Condition0%0/9
defined $context and defined $nickname and exists $self->_list->{$context} and ref $self->_list->{$context}{$nickname}
!ll&&!rl&&r
000
defined $context and defined $nickname and exists $self->_list->{$context}
!ll&&!rl&&r
000
defined $context and defined $nickname
!ll&&!rl&&r
000
MC/DC0%0/4
defined $context and defined $nickname and exists $self->_list->{$context} and ref $self->_list->{$context}{$nickname}
defined $context defined $nickname exists $self->_list->{$context} ref $self->_list->{$context}{$nickname}
Truth table0%0/5
A and B and C and D
A= defined $contextB= defined $nicknameC= exists $self->_list->{$context}D= ref $self->_list->{$context}{$nickname}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
118  
119 $self->_list->{$context}->{$nickname}->{Username}
120 0 }
121  
122 0 ▶sub host {
Subroutine host: not called CC=5 SCAR=34.0
Pod documented
123 0 my ($self, $context, $nickname) = @_;
124
125 return
126 unless defined $context
127 and defined $nickname
128 and exists $self->_list->{$context}
129 0 ▶ and ref $self->_list->{$context}->{$nickname};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $context and defined $nickname and exists $self->_list->{$context} and ref $self->_list->{$context}{$nickname} 0 0 0
Condition0%0/9
defined $context and defined $nickname and exists $self->_list->{$context} and ref $self->_list->{$context}{$nickname}
!ll&&!rl&&r
000
defined $context and defined $nickname and exists $self->_list->{$context}
!ll&&!rl&&r
000
defined $context and defined $nickname
!ll&&!rl&&r
000
MC/DC0%0/4
defined $context and defined $nickname and exists $self->_list->{$context} and ref $self->_list->{$context}{$nickname}
defined $context defined $nickname exists $self->_list->{$context} ref $self->_list->{$context}{$nickname}
Truth table0%0/5
A and B and C and D
A= defined $contextB= defined $nicknameC= exists $self->_list->{$context}D= ref $self->_list->{$context}{$nickname}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
130  
131 $self->_list->{$context}->{$nickname}->{Host}
132 0 }
133  
134 0 ▶sub alias {
Subroutine alias: not called CC=5 SCAR=34.0
Pod undocumented
135 0 my ($self, $context, $nickname) = @_;
136  
137 return
138 unless defined $context
139 and defined $nickname
140 and exists $self->_list->{$context}
141 0 ▶ and ref $self->_list->{$context}->{$nickname};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $context and defined $nickname and exists $self->_list->{$context} and ref $self->_list->{$context}{$nickname} 0 0 0
Condition0%0/9
defined $context and defined $nickname and exists $self->_list->{$context} and ref $self->_list->{$context}{$nickname}
!ll&&!rl&&r
000
defined $context and defined $nickname and exists $self->_list->{$context}
!ll&&!rl&&r
000
defined $context and defined $nickname
!ll&&!rl&&r
000
MC/DC0%0/4
defined $context and defined $nickname and exists $self->_list->{$context} and ref $self->_list->{$context}{$nickname}
defined $context defined $nickname exists $self->_list->{$context} ref $self->_list->{$context}{$nickname}
Truth table0%0/5
A and B and C and D
A= defined $contextB= defined $nicknameC= exists $self->_list->{$context}D= ref $self->_list->{$context}{$nickname}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
142  
143 $self->_list->{$context}->{$nickname}->{Alias}
144 0 }
145  
146 0 ▶sub move {
Subroutine move: not called CC=2 SCAR=17.9
Pod documented
147 0 my ($self, $context, $old, $new) = @_;
148 ## User changed nicks, f.ex
149
150 0 ▶ return unless exists $self->_list->{$context}->{$old};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->_list->{$context}{$old} 0 0 0
151
152 $self->_list->{$context}->{$new}
153 0 = delete $self->_list->{$context}->{$old}
154 }
155  
156  
157 1;
158 __END__
« blib/lib/Bot/Cobalt/Plugin/Version.pm ↑ Summary blib/lib/Bot/Cobalt/IRC/Role/UserEvents.pm »