Elive/Entity.pm

filter: Statementstmt 85.7% 66 / 77 Branchbran 76.4% 26 / 34 Conditioncond 53.3% 8 / 15 MC/DCmcdc 33.3% 3 / 9 Subroutinesub 80.0% 8 / 10 Podpod 100% 3 / 3 totaltotal 77.0% 114 / 148 CC 24 SCAR 21.6
CC
24
Cov
79%
_unpack_results
13.2
connect
12.0
_unpack_as_list
7.7
CRAP 8.6
« Elive/Entity/Participants.pm ↑ Summary Elive/Connection/SDK.pm »
1 package Elive::Entity;
2 37 ▶use warnings; use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 37 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 37 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 37 extends 'Elive::DAO';
8  
9 37 our $VERSION = '1.36';
10  
11 =head1 NAME
12  
13 Elive::Entity - Base class for Elive Entities
14  
15 =head1 DESCRIPTION
16  
17 This is the base class for Elluminate C<Live!> Command Toolkit entity
18 specific classes.
19  
20 =cut
21  
22 =head2 data_classes
23  
24 returns a list of all entity instance classes
25  
26 =cut
27  
28 sub data_classes {
29 0 ▶ my $class = shift;
Subroutine data_classes: not called CC=1 SCAR=6.9
Pod documented
30 0 return qw(
31 Elive::Entity::Group
32 Elive::Entity::MeetingParameters
33 Elive::Entity::Meeting
34 Elive::Entity::ParticipantList
35 Elive::Entity::Preload
36 Elive::Entity::Recording
37 Elive::Entity::Report
38 Elive::Entity::ServerDetails
39 Elive::Entity::ServerParameters
40 Elive::View::Session
41 Elive::Entity::User
42 );
43 }
44  
45 =head2 connect
46  
47 Elive::Entity->connect('https://myServer.com/test', some_user => 'some_pass');
48 my $connection = Elive::Entity->connection;
49  
50 Connects to an Elluminate server instance. Dies if the connection could not
51 be established. If, for example, the SOAP connection or user login failed.
52  
53 The login user must either be an Elluminate I<Live!> system administrator
54 account, or a user that has been configured to access the Command Toolkit
55 via web services.
56  
57 =cut
58  
59 sub connect {
60 0 ▶ my ($class, $url, $login_name, $pass, %opts) = @_;
Subroutine connect: not called CC=3 SCAR=24.8
Pod documented
61  
62 0 ▶ Carp::croak("usage: ${class}->connect(url, [login_name] [, pass])")
Branch: 1 branch
BranchTrueFalseTotal
unless $class and $url 0 0 0
Condition0%0/3
$class and $url
!ll&&!rl&&r
000
MC/DC0%0/2
$class and $url
$class $url
Truth table0%0/3
A and B
A= $classB= $url
ABresult
0X0
100
111
63 unless ($class && $url);
64  
65 0 require Elive::Connection::SDK;
66  
67 0 my $connection = Elive::Connection::SDK->connect(
68 $url,
69 $login_name => $pass,
70 debug => $class->debug,
71 %opts,
72 );
73  
74 0 $class->_connection($connection);
75  
76 0 return $connection;
77 }
78  
79 #
80 # Normalise our data and reconstruct arrays.
81 #
82 # See t/dao-unpack.t for examples and further explanation.
83 #
84  
85 sub _get_results {
86 98 ▶ my $class = shift;
Subroutine _get_results: called CC=1 SCAR=0.0
87 98 my $som = shift;
88 98 my $connection = shift;
89  
90 98 $connection->_check_for_errors($som);
91  
92 98 my $results_list = $class->_unpack_as_list($som->result);
93  
94 98 return $results_list;
95 }
96  
97 sub _unpack_as_list {
98 105 ▶ my $class = shift;
Subroutine _unpack_as_list: called CC=7 SCAR=20.4
99 105 my $result = shift;
100  
101 105 $result = $class->_unpack_results($result);
102  
103 105 my $reftype = Elive::Util::_reftype($result);
104  
105 105 my $results_list;
106  
107 105 ▶ if ($reftype eq 'HASH') {
Branch: 3 branches
BranchTrueFalseTotal
if ($reftype eq 'HASH') { } 95 10 105
elsif ($reftype eq 'ARRAY') { } 3 7 10
elsif ($reftype) { } 0 7 7
108  
109 95 $results_list = [ $result ];
110  
111 }
112 elsif ($reftype eq 'ARRAY') {
113  
114 3 $results_list = $result;
115  
116 }
117 elsif ($reftype) {
118 0 Carp::croak "unknown type in result set: $reftype";
119 }
120 else {
121  
122 7 ▶ $results_list = defined($result) && $result ne ''
Branch: 1 branch
BranchTrueFalseTotal
defined $result && $result ne '' ? : 0 7 7
Condition33%1/3
defined $result and $result ne ""
!ll&&!rl&&r
070
MC/DC0%0/2
defined $result and $result ne ""
defined $result $result ne ""
Truth table33%1/3
A and B
A= defined $resultB= $result ne ""
ABresult
0X0
100
111
123 ? [ $result ]
124 : [];
125  
126 }
127  
128 105 ▶ warn "$class result: ".YAML::Syck::Dump($result)
Branch: 1 branch
BranchTrueFalseTotal
if $class->debug >= 2 0 105 105
129 if ($class->debug >= 2);
130  
131 105 return $results_list;
132 }
133  
134 sub _unpack_results {
135 862 ▶ my $class = shift;
Subroutine _unpack_results: called CC=13 SCAR=25.8
136 862 my $results = shift;
137  
138 862 my $results_type = Elive::Util::_reftype($results);
139  
140 862 ▶ if (!$results_type) {
Branch: 3 branches
BranchTrueFalseTotal
if (not $results_type) { } 503 359 862
elsif ($results_type eq 'ARRAY') { } 12 347 359
elsif ($results_type eq 'HASH') { } 347 0 347
141 503 return $results;
142 }
143 elsif ($results_type eq 'ARRAY') {
144 12 return [map {$class->_unpack_results($_)} @$results];
145 }
146 elsif ($results_type eq 'HASH') {
147 #
148 # Convert some SOAP/XML constructs to their perl equivalents
149 #
150 347 foreach my $key (keys %$results) {
151 719 my $value = $results->{$key};
152  
153 719 ▶ if ($key eq 'Collection') {
Branch: 2 branches
BranchTrueFalseTotal
if ($key eq 'Collection') { } 6 713 719
elsif ($key eq 'Map') { } 3 710 713
154  
155 6 ▶ if (Elive::Util::_reftype($value) eq 'HASH'
Branch: 1 branch
BranchTrueFalseTotal
if (Elive::Util::_reftype($value) eq 'HASH' and exists $value->{'Entry'}) { } 5 1 6
Condition66%2/3
Elive::Util::_reftype($value) eq "HASH" and exists $value->{"Entry"}
!ll&&!rl&&r
105
MC/DC50%1/2
Elive::Util::_reftype($value) eq "HASH" and exists $value->{"Entry"}
Elive::Util::_reftype($value) eq "HASH" exists $value->{"Entry"}
Truth table66%2/3
A and B
A= Elive::Util::_reftype($value) eq "HASH"B= exists $value->{"Entry"}
ABresult
0X0
100
111
156 && exists ($value->{Entry})) {
157 5 $value = $value->{Entry};
158  
159 5 my %parent = %$results;
160 5 delete $parent{Collection};
161 5 ▶ if (keys %parent) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %parent) 1 4 5
162 #
163 # merge in with the parent
164 #
165 1 $parent{Entry} = $value;
166 1 $value = \%parent;
167 }
168 }
169 else {
170 1 $value = [];
171 }
172 #
173 # Throw away our parse of this struct. It only exists to
174 # house this collection
175 #
176 6 return $class->_unpack_results($value);
177 }
178 elsif ($key eq 'Map') {
179  
180 3 ▶ if (Elive::Util::_reftype($value) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (Elive::Util::_reftype($value) eq 'HASH') { } 3 0 3
181  
182 3 ▶ if (exists ($value->{Entry})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $value->{"Entry"}) 3 0 3
183  
184 3 $value = $value->{Entry};
185 #
186 # Looks like we've got Key, Value pairs.
187 # Throw array the key and reference the value,
188 # that's all we're interested in.
189 #
190 3 ▶ if (Elive::Util::_reftype ($value) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (Elive::Util::_reftype($value) eq 'ARRAY') { } 2 1 3
191
192 2 $value = [map {$_->{Value}} @$value];
193 }
194 else {
195 1 $value = $value->{Value};
196 }
197 }
198 }
199 else {
200 0 $value = [];
201 }
202 #
203 # Throw away our parse of this struct it only exists to
204 # house this collection
205 #
206 3 return $class->_unpack_results($value);
207 }
208  
209 710 $results->{$key} = $class->_unpack_results($value);
210 }
211
212 }
213 else {
214 0 die "Unhandled type in response body: $results_type";
215 }
216  
217 338 return $results;
218 }
219  
220 =head2 quote
221  
222 This is a utility method for quoting literal arguments to C<list> filter
223 expressions:
224  
225 my $users = Elive::Entity::User->list(
226 filter => "surname=".Elive::Entity::User->quote("O'Reilly"),
227 );
228  
229 =cut
230  
231 sub quote {
232 5 ▶ my $class = shift;
Subroutine quote: called CC=4 SCAR=13.9
Pod documented
233 5 my $str = shift;
234  
235 5 ▶ return $str
Branch: 1 branch
BranchTrueFalseTotal
if not defined $str or $str eq "" or $str =~ /^ \w+ $/x 2 3 5
Condition83%5/6
not defined $str or $str eq "" or $str =~ /^ \w+ $/x
l!l&&r!l&&!r
113
not defined $str or $str eq ""
l!l&&r!l&&!r
014
MC/DC66%2/3
not defined $str or $str eq "" or $str =~ /^ \w+ $/x
not defined $str $str eq "" $str =~ /^ \w+ $/x
Truth table75%3/4
not(A) or B or C
A= not defined $strB= $str eq ""C= $str =~ /^ \w+ $/x
ABCresult
1XX1
01X1
0011
0000
236 if !defined $str
237 or $str eq ''
238 or $str =~ m{^ \w+ $}x;
239  
240 3 $str =~ s{'}{''}g;
241  
242 3 return "'$str'";
243 }
244  
245 =head1 SEE ALSO
246  
247 =head2 Ancestor Classes
248  
249 =over 4
250  
251 =item L<Elive::DAO> - base class
252  
253 =item L<Mouse> - Middle-weight L<Moose> like class system
254  
255 =back
256  
257 =head2 Derived Classes
258  
259 =over 4
260  
261 =item Elive::Entity::Group
262  
263 =item Elive::Entity::MeetingParameters
264  
265 =item Elive::Entity::Meeting
266  
267 =item Elive::Entity::ParticipantList
268  
269 =item Elive::Entity::Preload
270  
271 =item Elive::Entity::Recording
272  
273 =item Elive::Entity::Report
274  
275 =item Elive::Entity::ServerDetails
276  
277 =item Elive::Entity::ServerParameters
278  
279 =item Elive::Entity::Session
280  
281 =item Elive::View::Session
282  
283 =item Elive::Entity::User
284  
285 =back
286  
287 =cut
288  
289 37 1;
« Elive/Entity/Participants.pm ↑ Summary Elive/Connection/SDK.pm »