YMSG/Buddy.pm

filter: Statementstmt 56.8% 58 / 102 Branchbran 0.0% 0 / 36 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 63.3% 19 / 30 Podpod 0.0% 0 / 11 totaltotal 40.7% 77 / 189 CC 21 SCAR 27.1
CC
21
Cov
40%
status
42.0
get_status_message
42.0
to_string
30.0
CRAP 15.0
« YMSG/EventFactory.pm ↑ Summary YMSG/ReceiveMessage.pm »
1 package Net::YMSG::Buddy;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 ▶use constant IM_AVAILABLE => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use constant BE_RIGHT_BACK => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use constant BUSY => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use constant NOT_AT_HOME => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use constant NOT_AT_MY_DESK => 4;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use constant NOT_IN_THE_OFFICE => 5;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use constant ON_THE_PHONE => 6;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use constant ON_VACATION => 7;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use constant OUT_TO_LUNCH => 8;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use constant STEPPED_OUT => 9;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use constant CUSTOM_STATUS => 99;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use constant SLEEP => 999;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 ▶use constant ICON_AVAILABLE => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use constant ICON_BUSY => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use constant ICON_SLEEP => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use constant STATUS_MESSAGE => [
Subroutine BEGIN: called CC=1 SCAR=0.0
22 "I'm Available",
23 'Be Right Back',
24 'Busy',
25 'Not At Home',
26 'Not At My Desk',
27 'Not In The Office',
28 'On The Phone',
29 'On Vacation',
30 'Out To Lunch',
31 'Stepped Out',
32 1 ];
33  
34 1 ▶use constant IS_ONLINE => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 1 ▶use constant IS_OFFLINE => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 sub new
38 0 ▶{
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
39 0 my $class = shift;
40 0 bless {
41 name => 'nobody',
42 status => IM_AVAILABLE,
43 custom_status => '',
44 busy => ICON_AVAILABLE,
45 online => IS_OFFLINE,
46 session_id => 0,
47 }, $class;
48 }
49  
50  
51 sub name
52 0 ▶{
Subroutine name: not called CC=2 SCAR=17.9
Pod undocumented
53 0 my $self = shift;
54 0 ▶ $self->{name} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
55 0 $self->{name};
56 }
57  
58  
59 sub status
60 0 ▶{
Subroutine status: not called CC=6 SCAR=37.4
Pod undocumented
61 0 my $self = shift;
62 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
63 0 $self->{status} = shift;
64 0 ▶ $self->busy(ICON_BUSY) if $self->{status} <= STEPPED_OUT;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"status"} <= 9 0 0 0
65 0 ▶ $self->busy(ICON_SLEEP) if $self->{status} == SLEEP;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"status"} == 999 0 0 0
66 $self->busy(ICON_AVAILABLE) if $self->{status} == CUSTOM_STATUS
67 0 ▶ || $self->{status} == IM_AVAILABLE;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"status"} == 99 or $self->{"status"} == 0 0 0 0
Condition0%0/3
$self->{"status"} == 99 or $self->{"status"} == 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"status"} == 99 or $self->{"status"} == 0
$self->{"status"} == 99 $self->{"status"} == 0
Truth table0%0/3
A or B
A= $self->{"status"} == 99B= $self->{"status"} == 0
ABresult
1X1
011
000
68 }
69 0 $self->{status};
70 }
71  
72  
73 sub custom_status
74 0 ▶{
Subroutine custom_status: not called CC=2 SCAR=17.9
Pod undocumented
75 0 my $self = shift;
76 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
77 0 $self->{custom_status} = shift;
78 0 $self->status(CUSTOM_STATUS);
79 }
80 0 $self->{custom_status};
81 }
82  
83  
84 sub busy
85 0 ▶{
Subroutine busy: not called CC=2 SCAR=17.9
Pod undocumented
86 0 my $self = shift;
87 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
88 0 $self->{busy} = shift;
89 }
90 0 $self->{busy};
91 }
92  
93  
94 sub online
95 0 ▶{
Subroutine online: not called CC=2 SCAR=17.9
Pod undocumented
96 0 my $self = shift;
97 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
98 0 $self->{online} = shift;
99 }
100 0 $self->{online};
101 }
102  
103  
104 sub session_id
105 0 ▶{
Subroutine session_id: not called CC=2 SCAR=17.9
Pod undocumented
106 0 my $self = shift;
107 0 ▶ $self->{session_id} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
108 0 $self->{session_id};
109 }
110  
111  
112 sub is_online
113 0 ▶{
Subroutine is_online: not called CC=1 SCAR=6.9
Pod undocumented
114 0 my $self = shift;
115 0 $self->online;
116 }
117  
118  
119 sub get_status_message
120 0 ▶{
Subroutine get_status_message: not called CC=6 SCAR=37.4
Pod undocumented
121 0 my $self = shift;
122 0 ▶ return unless $self->is_online;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_online 0 0 0
123  
124 0 ▶ if ($self->status == SLEEP) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->status == 999) { } 0 0 0
elsif ($self->status == 99) { } 0 0 0
elsif ($self->status >= 0 and $self->status <= 9) { } 0 0 0
125 0 return sprintf '%s',
126 'Sleep';
127 }
128 elsif ($self->status == CUSTOM_STATUS) {
129 0 return sprintf '%s',
130 $self->custom_status;
131 }
132 ▶ elsif ($self->status >= IM_AVAILABLE && $self->status <= STEPPED_OUT) {
Condition0%0/3
$self->status >= 0 and $self->status <= 9
!ll&&!rl&&r
000
MC/DC0%0/2
$self->status >= 0 and $self->status <= 9
$self->status >= 0 $self->status <= 9
Truth table0%0/3
A and B
A= $self->status >= 0B= $self->status <= 9
ABresult
0X0
100
111
133 0 return sprintf '%s',
134 STATUS_MESSAGE->[$self->status];
135 }
136 else {
137 0 return 'Unknown';
138 }
139 }
140  
141  
142  
143 sub to_string
144 0 ▶{
Subroutine to_string: not called CC=5 SCAR=34.0
Pod undocumented
145 0 my $self = shift;
146 0 ▶ if ($self->is_online) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_online) { } 0 0 0
147 0 ▶ return sprintf "%s %s (%s)",
Branch: 3 branches
BranchTrueFalseTotal
$self->busy == 0 ? : 0 0 0
$self->busy == 1 ? : 0 0 0
$self->busy == 2 ? : 0 0 0
148 $self->busy == ICON_AVAILABLE ? ':->'
149 : $self->busy == ICON_BUSY ? ':-@'
150 : $self->busy == ICON_SLEEP ? ':-Z'
151 : '?',
152 $self->name,
153 $self->get_status_message;
154 } else {
155 0 return sprintf "%s %s (%s)",
156 ' ',
157 $self->name,
158 'Not online';
159 }
160 }
161  
162 sub to_string_curses
163 0 ▶{
Subroutine to_string_curses: not called CC=2 SCAR=17.9
Pod undocumented
164 0 my $self = shift;
165 0 ▶ if ($self->is_online) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_online) 0 0 0
166 0 return sprintf "[%s]",
167 $self->name;
168 }
169 }
170 1 1;
171 __END__
« YMSG/EventFactory.pm ↑ Summary YMSG/ReceiveMessage.pm »