Session.pm

filter: Statementstmt 20.0% 19 / 95 Branchbran 0.0% 0 / 34 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 16.6% 5 / 30 Podpod 85.7% 12 / 14 totaltotal 20.2% 36 / 178 CC 19 SCAR 17.5
CC
19
Cov
14%
clear
12.0
update
12.0
__ANON__
12.0
CRAP 5.8
« Search.pm ↑ Summary User.pm »
1 # E2::Session
2 # Jose M. Weeks <jose@joseweeks.com>
3 # 29 June 2003
4 #
5 # See bottom for pod documentation.
6  
7 package E2::Session;
8  
9 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use E2::Ticker;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 our $VERSION = "0.33";
17 1 our @ISA = qw(E2::Ticker);
18 1 our $DEBUG; *DEBUG = *E2::Interface::DEBUG;
19  
20 sub new;
21 sub clear;
22  
23 sub update;
24  
25 sub time;
26  
27 sub votes;
28 sub cools;
29 sub karma;
30 sub experience;
31 sub writeups;
32 sub borged;
33 sub forbidden;
34  
35 sub xpchange;
36 sub nextlevel;
37  
38 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
39 0 my $arg = shift;
40 0 ▶ my $class = ref( $arg ) || $arg;
Condition0%0/3
ref $arg || $arg
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $arg || $arg
ref $arg $arg
Truth table0%0/3
A || B
A= ref $argB= $arg
ABresult
1X1
011
000
41 0 my $self = $class->SUPER::new();
42  
43 0 return bless ($self, $class);
44 }
45  
46 0 ▶sub clear {
Subroutine clear: not called CC=3 SCAR=24.8
Pod documented
47 0 ▶ my $self = shift or croak "Usage: clear E2SESSION";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: clear E2SESSION") 0 0 0
48  
49 0 ▶ warn "E2::Session::clear\n" if $DEBUG > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $E2::Session::DEBUG > 1 0 0 0
50  
51 0 $self->{votes} = undef;
52 0 $self->{cools} = undef;
53 0 $self->{karma} = undef;
54 0 $self->{experience} = undef;
55 0 $self->{writeups} = undef;
56 0 $self->{borged} = undef;
57 0 $self->{forbidden} = undef;
58  
59 0 $self->{time} = undef;
60  
61 0 $self->{xpchange} = undef;
62 0 $self->{nextlevel} = {};
63  
64 0 @{ $self->{personal} } = ();
65  
66 0 return 1;
67 }
68  
69 0 ▶sub votes {
Subroutine votes: not called CC=2 SCAR=17.9
Pod documented
70 0 ▶ my $self = shift or croak "Usage: votes E2SESSION";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: votes E2SESSION") 0 0 0
71 0 return $self->{votes};
72 }
73  
74 0 ▶sub cools {
Subroutine cools: not called CC=2 SCAR=17.9
Pod documented
75 0 ▶ my $self = shift or croak "Usage: cools E2SESSION";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: cools E2SESSION") 0 0 0
76 0 return $self->{cools};
77 }
78  
79 0 ▶sub karma {
Subroutine karma: not called CC=2 SCAR=17.9
Pod undocumented
80 0 ▶ my $self = shift or croak "Usage: karma E2SESSION";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: karma E2SESSION") 0 0 0
81 0 return $self->{karma};
82 }
83  
84 0 ▶sub experience {
Subroutine experience: not called CC=2 SCAR=17.9
Pod documented
85 0 ▶ my $self = shift or croak "Usage: experience E2SESSION";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: experience E2SESSION") 0 0 0
86 0 return $self->{experience};
87 }
88  
89 0 ▶sub writeups {
Subroutine writeups: not called CC=2 SCAR=17.9
Pod documented
90 0 ▶ my $self = shift or croak "Usage: writeups E2SESSION";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: writeups E2SESSION") 0 0 0
91 0 return $self->{writeups};
92 }
93  
94 0 ▶sub borged {
Subroutine borged: not called CC=2 SCAR=17.9
Pod documented
95 0 ▶ my $self = shift or croak "Usage: borged E2SESSION";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: borged E2SESSION") 0 0 0
96 0 return $self->{borged};
97 }
98  
99 0 ▶sub forbidden {
Subroutine forbidden: not called CC=2 SCAR=17.9
Pod documented
100 0 ▶ my $self = shift or croak "Usage: forbidden E2SESSION";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: forbidden E2SESSION") 0 0 0
101 0 return $self->{forbidden};
102 }
103  
104 0 ▶sub time {
Subroutine time: not called CC=2 SCAR=17.9
Pod documented
105 0 ▶ my $self = shift or croak "Usage: time E2SESSION";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: time E2SESSION") 0 0 0
106 0 return $self->{time};
107 }
108  
109 0 ▶sub xpchange {
Subroutine xpchange: not called CC=2 SCAR=17.9
Pod documented
110 0 ▶ my $self = shift or croak "Usage: xpchange E2SESSION";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: xpchange E2SESSION") 0 0 0
111 0 return $self->{xpchange};
112 }
113  
114 0 ▶sub nextlevel {
Subroutine nextlevel: not called CC=2 SCAR=17.9
Pod documented
115 0 ▶ my $self = shift or croak "Usage: nextlevel E2SESSION";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: nextlevel E2SESSION") 0 0 0
116 0 return $self->{nextlevel};
117 }
118  
119 0 ▶sub list_personal_nodes {
Subroutine list_personal_nodes: not called CC=2 SCAR=17.9
Pod undocumented
120 0 ▶ my $self = shift or croak "Usage: list_personal_nodes E2SESSION";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: list_personal_nodes E2SESSION") 0 0 0
121 0 return @{ $self->{personal} };
122 }
123  
124 0 ▶sub update {
Subroutine update: not called CC=3 SCAR=24.8
Pod documented
125 0 ▶ my $self = shift or croak "Usage: update E2SESSION";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: update E2SESSION") 0 0 0
126  
127 0 ▶ warn "E2::Session::update\n" if $DEBUG > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $E2::Session::DEBUG > 1 0 0 0
128  
129 my $handlers = {
130 0 ▶ 'currentuser' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
131 0 (my $a, my $b) = @_;
132 0 ${$self->{this_username}} = $b->text;
133 0 ${$self->{this_user_id}} = $b->{att}->{user_id};
134 },
135 0 ▶ 'servertime' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
136 0 (my $a, my $b) = @_;
137 0 $self->{time} = $b->text;
138 },
139 0 ▶ 'borgstatus' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
140 0 (my $a, my $b) = @_;
141 0 $self->{borged} = $b->{att}->{value};
142 },
143 0 ▶ 'cools' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
144 0 (my $a, my $b) = @_;
145 0 $self->{cools} = $b->text;
146 },
147 0 ▶ 'votesleft' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
148 0 (my $a, my $b) = @_;
149 0 $self->{votes} = $b->text;
150 },
151 0 ▶ 'karma' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
152 0 (my $a, my $b) = @_;
153 0 $self->{karma} = $b->text;
154 },
155 0 ▶ 'experience' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
156 0 (my $a, my $b) = @_;
157 0 $self->{experience} = $b->text;
158 },
159 0 ▶ 'numwriteups' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
160 0 (my $a, my $b) = @_;
161 0 $self->{writeups} = $b->text;
162 },
163 0 ▶ 'forbiddance' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
164 0 (my $a, my $b) = @_;
165 0 $self->{forbidden} = $b->text;
166 },
167 0 ▶ 'xpinfo' => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
168 0 (my $a, my $b) = @_;
169 0 ▶ if( my $c = $b->first_child('xpchange') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $c = $b->first_child("xpchange")) 0 0 0
170 0 $self->{xpchange} = $c->text;
171 }
172 0 ▶ if( my $c = $b->first_child('nextlevel') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $c = $b->first_child("nextlevel")) 0 0 0
173 $self->{nextlevel} = {
174 experience => $c->{att}->
175 {experience},
176 writeups => $c->{att}->
177 {writeups},
178 0 level => $c->text
179 };
180 }
181 },
182 0 ▶ 'personalnodes/e2node' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
183 0 (my $a, my $b) = @_;
184 0 push @{ $self->{personal} }, {
185 title => $b->text,
186 id => $b->{att}->{node_id}
187 0 };
188 }
189 0 };
190  
191 0 $self->clear;
192  
193 0 $self->parse( 'session', $handlers, [ 1 ] );
194 }
195  
196 1 1;
197 __END__
« Search.pm ↑ Summary User.pm »