User.pm

filter: Statementstmt 37.2% 48 / 129 Branchbran 6.0% 3 / 50 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 20.4% 9 / 44 Podpod 87.5% 21 / 24 totaltotal 32.5% 82 / 252 CC 27 SCAR 16.0
CC
27
Cov
29%
groups
12.0
bookmarks
12.0
name
6.0
CRAP 5.0
« Session.pm ↑ Summary Usergroup.pm »
1 # E2::User
2 # Jose M. Weeks <jose@joseweeks.com>
3 # 05 June 2003
4 #
5 # See bottom for pod documentation.
6  
7 package E2::User;
8  
9 2 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 ▶use E2::Node;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 2 our $VERSION = "0.32";
17 2 our @ISA = qw(E2::Node);
18 2 our $DEBUG; *DEBUG = *E2::Interface::DEBUG;
19  
20 sub new;
21 sub clear;
22  
23 sub name;
24 sub id;
25 sub alias;
26 sub alias_id;
27 sub text;
28 sub lasttime;
29 sub experience;
30 sub level;
31 sub level_string;
32 sub writeup_count;
33 sub cool_count;
34 sub image_url;
35 sub lastnode;
36 sub lastnode_id;
37 sub mission;
38 sub specialties;
39 sub motto;
40 sub employment;
41  
42 sub groups;
43 sub bookmarks;
44  
45 1 ▶sub new {
Subroutine new: called CC=2 SCAR=7.2
Pod documented
46 1 my $arg = shift;
47 1 ▶ my $class = ref( $arg ) || $arg;
Condition33%1/3
ref $arg || $arg
l!l&&r!l&&!r
010
MC/DC0%0/2
ref $arg || $arg
ref $arg $arg
Truth table33%1/3
A || B
A= ref $argB= $arg
ABresult
1X1
011
000
48 1 my $self = $class->SUPER::new();
49  
50 1 $self->clear;
51 1 return $self;
52 }
53  
54 3 ▶sub clear {
Subroutine clear: called CC=3 SCAR=11.0
Pod undocumented
55 3 ▶ my $self = shift or croak "Usage: clear E2USER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: clear E2USER") 3 0 3
56  
57 3 ▶ warn "E2::User::clear\n" if $DEBUG > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $E2::User::DEBUG > 1 0 3 3
58  
59 3 $self->{alias} = undef;
60 3 $self->{alias_id} = undef;
61 3 $self->{text} = undef; # Homenode text
62 3 $self->{lasttime} = undef;
63 3 $self->{experience} = undef;
64 3 $self->{level} = undef; # Integer
65 3 $self->{level_string} = undef; # Ex: "3 (Acolyte)"
66 3 $self->{writeup_num} = undef;
67 3 $self->{cool_num} = undef;
68 3 $self->{image} = undef; # Relative URL
69 3 $self->{lastnode} = undef;
70 3 $self->{lastnode_id} = undef;
71 3 $self->{mission} = undef;
72 3 $self->{specialties} = undef;
73 3 $self->{motto} = undef;
74 3 $self->{employment} = undef;
75 3 $self->{groups} = (); # these are lists of hashrefs
76 3 $self->{bookmarks} = (); # with the following keys:
77 # o title
78 # o id
79  
80 3 return $self->SUPER::clear;
81 }
82  
83 1 ▶sub type_as_string {
Subroutine type_as_string: called CC=1 SCAR=0.0
Pod undocumented
84 1 return 'user';
85 };
86  
87 1 ▶sub twig_handlers {
Subroutine twig_handlers: called CC=2 SCAR=16.4
Pod undocumented
88 1 ▶ my $self = shift or croak "Usage: twig_handlers E2USER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: twig_handlers E2USER") 1 0 1
89  
90 return (
91 0 ▶ 'useralias/e2link' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
92 0 (my $a, my $b) = @_;
93 0 $self->{alias} = $b->text;
94 0 $self->{alias_id} = $b->{att}->{node_id};
95 },
96 0 ▶ 'node/doctext' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
97 0 (my $a, my $b) = @_;
98 0 $self->{text} = $b->text;
99 },
100 0 ▶ 'experience' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
101 0 (my $a, my $b) = @_;
102 0 $self->{experience} = $b->text;
103 },
104 0 ▶ 'lasttime' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
105 0 (my $a, my $b) = @_;
106 0 $self->{lasttime} = $b->text;
107 },
108 0 ▶ 'level' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
109 0 (my $a, my $b) = @_;
110 0 $self->{level} = $b->{att}->{value};
111 0 $self->{level_string} = $b->text;
112 },
113 0 ▶ 'writeups' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
114 0 (my $a, my $b) = @_;
115 0 $self->{writeup_num} = $b->text;
116 },
117 0 ▶ 'image' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
118 0 (my $a, my $b) = @_;
119 0 $self->{image} = $b->text;
120 },
121 0 ▶ 'lastnoded/e2link' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
122 0 (my $a, my $b) = @_;
123 0 $self->{lastnode} = $b->text;
124 0 $self->{lastnode_id} = $b->{att}->{node_id};
125 },
126 0 ▶ 'cools' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
127 0 (my $a, my $b) = @_;
128 0 $self->{cool_num} = $b->text;
129 },
130 0 ▶ 'userstrings/mission' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
131 0 (my $a, my $b) = @_;
132 0 $self->{mission} = $b->text;
133 },
134 0 ▶ 'userstrings/specialties' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
135 0 (my $a, my $b) = @_;
136 0 $self->{specialties} = $b->text;
137 },
138 0 ▶ 'userstrings/motto' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
139 0 (my $a, my $b) = @_;
140 0 $self->{motto} = $b->text;
141 },
142 0 ▶ 'userstrings/employment' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
143 0 (my $a, my $b) = @_;
144 0 $self->{employment} = $b->text;
145 },
146 0 ▶ 'groupmembership/e2link' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
147 0 (my $a, my $b) = @_;
148 0 push @{ $self->{groups} }, {
149 title => $b->text,
150 id => $b->{att}->{node_id}
151 0 };
152 },
153 0 ▶ 'bookmarks/e2link' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
154 0 (my $a, my $b) = @_;
155 0 push @{ $self->{bookmarks} }, {
156 title => $b->text,
157 id => $b->{att}->{node_id}
158 0 };
159 }
160 1 );
161 }
162  
163 #---------------
164 # Access Members
165 #---------------
166  
167 0 ▶sub name {
Subroutine name: not called CC=2 SCAR=17.9
Pod documented
168 0 ▶ my $self = shift or croak "Usage: name E2USER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: name E2USER") 0 0 0
169  
170 0 return $self->title;
171 }
172  
173 0 ▶sub id {
Subroutine id: not called CC=2 SCAR=17.9
Pod documented
174 0 ▶ my $self = shift or croak "Usage: id E2USER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: id E2USER") 0 0 0
175  
176 0 return $self->node_id;
177 }
178  
179 0 ▶sub alias {
Subroutine alias: not called CC=2 SCAR=17.9
Pod documented
180 0 ▶ my $self = shift or croak "Usage: alias E2USER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: alias E2USER") 0 0 0
181  
182 0 return $self->{alias};
183 }
184  
185 0 ▶sub alias_id {
Subroutine alias_id: not called CC=2 SCAR=17.9
Pod documented
186 0 ▶ my $self = shift or croak "Usage: alias_id E2USER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: alias_id E2USER") 0 0 0
187  
188 0 return $self->{alias_id};
189 }
190  
191 0 ▶sub text {
Subroutine text: not called CC=2 SCAR=17.9
Pod documented
192 0 ▶ my $self = shift or croak "Usage: text E2USER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: text E2USER") 0 0 0
193  
194 0 return $self->{text};
195 }
196  
197 0 ▶sub lasttime {
Subroutine lasttime: not called CC=2 SCAR=17.9
Pod documented
198 0 ▶ my $self = shift or croak "Usage: lasttime E2USER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: lasttime E2USER") 0 0 0
199  
200 0 return $self->{lasttime};
201 }
202  
203 0 ▶sub experience {
Subroutine experience: not called CC=2 SCAR=17.9
Pod documented
204 0 ▶ my $self = shift or croak "Usage: experience E2USER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: experience E2USER") 0 0 0
205  
206 0 return $self->{experience};
207 }
208  
209 0 ▶sub level {
Subroutine level: not called CC=2 SCAR=17.9
Pod documented
210 0 ▶ my $self = shift or croak "Usage: level E2USER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: level E2USER") 0 0 0
211  
212 0 return $self->{level};
213 }
214  
215 0 ▶sub level_string {
Subroutine level_string: not called CC=2 SCAR=17.9
Pod documented
216 0 ▶ my $self = shift or croak "Usage: level_string E2USER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: level_string E2USER") 0 0 0
217  
218 0 return $self->{level_string};
219 }
220  
221 0 ▶sub writeup_count {
Subroutine writeup_count: not called CC=2 SCAR=17.9
Pod documented
222 0 ▶ my $self = shift or croak "Usage: writeup_count E2USER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: writeup_count E2USER") 0 0 0
223  
224 0 return $self->{writeup_num};
225 }
226  
227 0 ▶sub cool_count {
Subroutine cool_count: not called CC=2 SCAR=17.9
Pod documented
228 0 ▶ my $self = shift or croak "Usage: cool_count E2USER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: cool_count E2USER") 0 0 0
229  
230 0 return $self->{cool_num};
231 }
232  
233 0 ▶sub image_url {
Subroutine image_url: not called CC=2 SCAR=17.9
Pod documented
234 0 ▶ my $self = shift or croak "Usage: image_url E2USER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: image_url E2USER") 0 0 0
235  
236 0 return $self->{image};
237 }
238  
239 0 ▶sub lastnode {
Subroutine lastnode: not called CC=2 SCAR=17.9
Pod documented
240 0 ▶ my $self = shift or croak "Usage: lastnode E2USER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: lastnode E2USER") 0 0 0
241  
242 0 return $self->{lastnode};
243 }
244  
245 0 ▶sub lastnode_id {
Subroutine lastnode_id: not called CC=2 SCAR=17.9
Pod documented
246 0 ▶ my $self = shift or croak "Usage: lastnode_id E2USER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: lastnode_id E2USER") 0 0 0
247  
248 0 return $self->{lastnode_id};
249 }
250  
251 0 ▶sub mission {
Subroutine mission: not called CC=2 SCAR=17.9
Pod documented
252 0 ▶ my $self = shift or croak "Usage: mission E2USER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: mission E2USER") 0 0 0
253  
254 0 return $self->{mission};
255 }
256  
257 0 ▶sub specialties {
Subroutine specialties: not called CC=2 SCAR=17.9
Pod documented
258 0 ▶ my $self = shift or croak "Usage: specialties E2USER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: specialties E2USER") 0 0 0
259  
260 0 return $self->{specialties};
261 }
262  
263 0 ▶sub motto {
Subroutine motto: not called CC=2 SCAR=17.9
Pod documented
264 0 ▶ my $self = shift or croak "Usage: motto E2USER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: motto E2USER") 0 0 0
265  
266 0 return $self->{motto};
267 }
268  
269 0 ▶sub employment {
Subroutine employment: not called CC=2 SCAR=17.9
Pod documented
270 0 ▶ my $self = shift or croak "Usage: employment E2USER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: employment E2USER") 0 0 0
271  
272 0 return $self->{employment};
273 }
274  
275 0 ▶sub groups {
Subroutine groups: not called CC=3 SCAR=24.8
Pod documented
276 0 ▶ my $self = shift or croak "Usage: groups E2USER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: groups E2USER") 0 0 0
277 0 ▶ if( ! defined $self->{groups} ) { return (); }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"groups"}) 0 0 0
278 0 return @{ $self->{groups} };
279 }
280  
281 0 ▶sub bookmarks {
Subroutine bookmarks: not called CC=3 SCAR=24.8
Pod documented
282 0 ▶ my $self = shift or croak "Usage: bookmarks E2USER";
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("Usage: bookmarks E2USER") 0 0 0
283 0 ▶ if( ! defined $self->{bookmarks} ) { return (); }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"bookmarks"}) 0 0 0
284 0 return @{ $self->{bookmarks} };
285 }
286  
287 2 1;
288 __END__
« Session.pm ↑ Summary Usergroup.pm »