API.pm

filter: Statementstmt 20.4% 38 / 186 Branchbran 0.0% 0 / 70 Conditioncond 0.0% 0 / 15 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 37.5% 12 / 32 Podpod 88.2% 15 / 17 totaltotal 19.7% 65 / 329 SCAR 71.1
CC
43
Cov
14%
sendline
72.0
list
56.0
block_allocate
56.0
CRAP 1218.2
↑ Summary API/Emergency.pm »
1 package Magrathea::API;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use version 0.77; our $VERSION = qv('v1.4.0');
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use Net::Telnet;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Phone::Number;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Email::Address;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Magrathea::API::Status;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Magrathea::API::Emergency;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Attribute::Boolean;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 our @CARP_NOT = qw{ Net::Telnet };
20  
21 =encoding utf8
22  
23 =head2 NAME
24  
25 Magrathea::API - Easier access to the Magrathea NTS API
26  
27 =head2 VERSION
28  
29 Version 1.4.0
30  
31 Please note that this software is currently beta.
32  
33 =head2 SYNOPSIS
34  
35 use Magrathea::API;
36 my $mt = new Magrathea::API;
37 my $number = $mt->allocate('01792');
38 $mt->deactivate($number);
39 my @list = $mt->list('01792');
40 my @numbers = $mt->block_allocate('01792', 10);
41 $mt->fax2email($numbers[2], 'user@host.com');
42 $mt->divert($number[3], '+5716027171');
43 $emerg = $mt->emergency_info;
44  
45 =head2 DESCRIPTION
46  
47 This module implements most of the
48 L<Magrathea NTS API|https://www.magrathea-telecom.co.uk/assets/Client-Downloads/Numbering-API-Instructions.pdf>
49 in a simple format.
50  
51 =head2 EXPORT
52  
53 Nothing Exported.
54  
55 =cut
56  
57 #################################################################
58 ##
59 ## Local Prototyped Functions
60 ##
61 #################################################################
62  
63 sub catch(;$)
64 {
65 0 ▶ local $_ = $@;
Subroutine catch: not called CC=4 SCAR=30.0
Pod undocumented
66 0 ▶ return undef unless $_;
Branch: 1 branch
BranchTrueFalseTotal
unless $_ 0 0 0
67 0 chomp;
68 0 my $re = shift;
69 0 ▶ return true if ref $re eq 'Regexp' and $_ =~ $re;
Branch: 1 branch
BranchTrueFalseTotal
if ref $re eq "Regexp" and $_ =~ /$re/ 0 0 0
Condition0%0/3
ref $re eq "Regexp" and $_ =~ /$re/
!ll&&!rl&&r
000
MC/DC0%0/2
ref $re eq "Regexp" and $_ =~ /$re/
ref $re eq "Regexp" $_ =~ /$re/
Truth table0%0/3
A and B
A= ref $re eq "Regexp"B= $_ =~ /$re/
ABresult
0X0
100
111
70 0 croak $_;
71 }
72  
73 #################################################################
74 ##
75 ## Private Instance Functions
76 ##
77 #################################################################
78  
79 sub sendline
80 {
81 0 ▶ my $self = shift;
Subroutine sendline: not called CC=8 SCAR=42.8
Pod undocumented
82 0 ▶ my $message = shift // '';
Condition0%0/2
shift() // ""
l!l
00
MC/DC0%0/1
shift() // ""
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
83 0 ▶ say ">> $message" if $self->{params}{debug} && $message;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"params"}{"debug"} and $message 0 0 0
Condition0%0/3
$self->{"params"}{"debug"} and $message
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"params"}{"debug"} and $message
$self->{"params"}{"debug"} $message
Truth table0%0/3
A and B
A= $self->{"params"}{"debug"}B= $message
ABresult
0X0
100
111
84 0 ▶ $self->{telnet}->print($message) if $message;
Branch: 1 branch
BranchTrueFalseTotal
if $message 0 0 0
85 0 my $response = $self->{telnet}->getline;
86 0 chomp $response;
87 0 my ($val, $msg) = $response =~ /^(\d)\s+(.*)/;
88 0 ▶ croak qq(Unknown response: "$response") unless defined $val;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $val 0 0 0
89 0 ▶ say "<<$val $msg" if $self->{params}{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"params"}{"debug"} 0 0 0
90 0 ▶ croak "$msg" unless $val == 0;
Branch: 1 branch
BranchTrueFalseTotal
unless $val == 0 0 0 0
91 0 return $val, $msg;
92 }
93  
94 #################################################################
95 ##
96 ## Class Functions
97 ##
98 #################################################################
99  
100 =head2 MAIN API METHODS
101  
102 =head2 Constructor
103  
104 =head3 new
105  
106 This will create a new Magrathea object and open at telnet
107 session to the server. If authorisation fails, it will croak.
108  
109 my $mt = new Magrathea::API(
110 username => 'myuser',
111 password => 'mypass',
112 );
113  
114 =head4 Parameters:
115  
116 =over
117  
118 =item username
119  
120 =item password
121  
122 The username and password allocated by Magrathea.
123  
124 =item host
125  
126 Defaults to I<api.magrathea-telecom.co.uk> but could be overridden.
127  
128 =item port
129  
130 Defaults to I<777>.
131  
132 =item timeout
133  
134 In seconds. Defaults to I<10>.
135  
136 =item debug
137  
138 If set to a true value, this will output the conversation between the API
139 and Magrathea's server. Be careful as this will also echo the username
140 and password.
141  
142 =back
143  
144 =cut
145  
146 sub new
147 {
148 0 ▶ my $class = shift;
Subroutine new: not called CC=3 SCAR=24.8
Pod documented
149 0 my %defaults = (
150 host => 'api.magrathea-telecom.co.uk',
151 port => 777,
152 timeout => 10,
153 debug => false,
154 );
155 0 my %params = (%defaults, @_);
156 croak "Username & Password Required"
157 0 ▶ unless $params{username} && $params{password};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"username"} and $params{"password"} 0 0 0
Condition0%0/3
$params{"username"} and $params{"password"}
!ll&&!rl&&r
000
MC/DC0%0/2
$params{"username"} and $params{"password"}
$params{"username"} $params{"password"}
Truth table0%0/3
A and B
A= $params{"username"}B= $params{"password"}
ABresult
0X0
100
111
158 my $telnet = new Net::Telnet(
159 Host => $params{host},
160 Port => $params{port},
161 Timeout => $params{timeout},
162 Errmode => sub {
163 0 ▶ croak shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
164 },
165 0 );
166 0 my $self = {
167 params => \%params,
168 telnet => $telnet,
169 };
170 0 bless $self, $class;
171 0 $self->sendline;
172 0 eval {
173 0 $self->auth(@params{qw(username password)});
174 };
175 0 catch;
176 0 return $self;
177 }
178  
179 #################################################################
180 ##
181 ## Instance Functions
182 ##
183 #################################################################
184  
185 =head2 Allocation Methods
186  
187 In all cases where C<$number> is passed, this may be a string
188 containing a number in National format (I<020 1234 5678>) or
189 in International format (I<+44 20 1234 5678>). Spaces are ignored.
190 Also, L<Phone::Number> objects may be passed.
191  
192 When a number is returned, it will always be in the for of a
193 L<Phone::Number> object.
194  
195 =head3 allocate
196  
197 Passed a prefix, this will allocate and activate a number. You do not need
198 to add the C<_> characters. If a number can be found, this routine
199 will return a L<Phone::Number> object. If no match is found, this
200 routine will return C<undef>. It will croak on any other error from
201 Magrathea.
202  
203 =cut
204  
205 sub allocate
206 {
207 0 ▶ my $self = shift;
Subroutine allocate: not called CC=4 SCAR=30.0
Pod documented
208 0 my $number = shift;
209 0 $number = substr $number . '_' x 11, 0, 11;
210 0 ▶ for (my $tries = 0; $tries < 5; $tries++)
Branch: 1 branch
BranchTrueFalseTotal
if ($tries < 5) 0 0 0
211 {
212 0 eval {
213 0 my $result = $self->allo($number);
214 0 ($number = $result) =~ s/\s.*$//;
215 };
216 0 ▶ return undef if catch qr/^No number found for allocation/;
Branch: 1 branch
BranchTrueFalseTotal
if &catch(qr/^No number found for allocation/) 0 0 0
217 0 eval {
218 0 $self->acti($number);
219 };
220 0 ▶ unless (catch qr/^Number not activated/) # $@ is ''
Branch: 1 branch
BranchTrueFalseTotal
unless (&catch(qr/^Number not activated/)) 0 0 0
221 {
222 0 return new Phone::Number($number);
223 }
224 }
225 0 return undef; # Failed after 5 attempts.
226 }
227  
228 =head3 deactivate
229  
230 Passed a number as a string or a L<Phone::Number>, this deactivates
231 the number.
232  
233 =cut
234  
235 sub deactivate
236 {
237 0 ▶ my $self = shift;
Subroutine deactivate: not called CC=1 SCAR=6.9
Pod documented
238 0 my $number = new Phone::Number(shift);
239 0 $self->deac($number->packed);
240 }
241  
242 =head3 reactivate
243  
244 Reactivates a number that has previously been deactivated.
245  
246 =cut
247  
248 sub reactivate
249 {
250 0 ▶ my $self = shift;
Subroutine reactivate: not called CC=1 SCAR=6.9
Pod documented
251 0 my $number = new Phone::Number(shift);
252 0 $self->reac($number->packed);
253 }
254  
255 =head3 list
256  
257 This should be passed a prefix and possibly a quantity (defaulting
258 to 10. It will return a sorted random list of available numbers matching
259 the prefix. These are returned as an array (or an arrayref) of
260 L<Phone::Number>. None of the numbers is allocated by this method.
261  
262 If none are available, the method will return an empty array.
263  
264 =cut
265  
266 sub list
267 {
268 0 ▶ my $self = shift;
Subroutine list: not called CC=7 SCAR=40.3
Pod documented
269 0 my $prefix = shift;
270 0 ▶ my $qty = shift // 10;
Condition0%0/2
shift() // 10
l!l
00
MC/DC0%0/1
shift() // 10
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
271 0 local $_;
272 0 my @results;
273 0 eval {
274 0 push @results, new Phone::Number($self->alist($prefix, $qty));
275 };
276 0 ▶ unless (catch qr/^No range found for allocation/) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&catch(qr/^No range found for allocation/)) 0 0 0
277 0 ▶ while (true) {
Branch: 1 branch
BranchTrueFalseTotal
if (&true()) 0 0 0
278 0 my $response = $self->{telnet}->getline;
279 0 chomp $response;
280 0 my ($val, $msg) = $response =~ /^(\d)\s+(.*)/;
281 0 ▶ say "<<$val $msg" if $self->{params}{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"params"}{"debug"} 0 0 0
282 0 ▶ last if $val != 0;
Branch: 1 branch
BranchTrueFalseTotal
if $val != 0 0 0 0
283 0 push @results, new Phone::Number($msg);
284 }
285 0 @results = sort { $a->plain cmp $b->plain } @results;
286 }
287 0 ▶ return wantarray ? @results : \@results;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
288  
289 }
290  
291 =head2 Block Methods
292  
293 =head3 block_allocate
294  
295 This should be passed a prefix (without any C<_> characters) and an
296 optional block size (defaulting to 10). It will attempt to allocate
297 and activate a block of numbers.
298  
299 If a block can be found, this routine
300 should return an array or arrayref of L<Phone::Number> objects. Under odd
301 circumstances, it is possible that fewer than the requested quantity
302 of numbers will be returned;
303  
304 If no range is found is found, this routine will return C<undef> in scalar
305 context or an empty array in list context. It will croak
306 on any other error from Magrathea.
307  
308 =cut
309  
310 sub block_allocate
311 {
312 0 ▶ my $self = shift;
Subroutine block_allocate: not called CC=7 SCAR=40.3
Pod documented
313 0 my $range = shift;
314 0 ▶ my $qty = shift // 10;
Condition0%0/2
shift() // 10
l!l
00
MC/DC0%0/1
shift() // 10
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
315 0 local $_;
316 0 ▶ croak "Block size must be a number" unless $qty =~ /^\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $qty =~ /^\d+$/ 0 0 0
317 0 my $alloc = eval {
318 0 $self->blkacti($range, $qty);
319 };
320 0 ▶ if (catch qr/^No range found for allocation/) {
Branch: 1 branch
BranchTrueFalseTotal
if (&catch(qr/^No range found for allocation/)) 0 0 0
321 0 ▶ return wantarray ? () : undef;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
322 }
323 0 my ($first, $last) = split ' ', $alloc;
324 0 my @numbers;
325 0 ▶ while ($first le $last) {
Branch: 1 branch
BranchTrueFalseTotal
if ($first le $last) 0 0 0
326 0 push @numbers, new Phone::Number($first++);
327 }
328 0 ▶ return wantarray ? @numbers : \@numbers;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
329 }
330  
331 =head3 block_info
332  
333 This should be passed a number (string or L<Phone::Number>)
334 to check whether that number is part of a block.
335  
336 If it is, the size of the block will be returned in scalar context;
337 In list context, the response will be an array of all the numbers
338 in that block.
339  
340 If it is not a block, this will return C<undef> or an empty
341 array.
342  
343 =cut
344  
345 sub block_info
346 {
347 0 ▶ my $self = shift;
Subroutine block_info: not called CC=5 SCAR=34.0
Pod documented
348 0 my $number = new Phone::Number(shift);
349 0 my $block = eval {
350 0 $self->blkinfo($number->packed);
351 };
352 0 ▶ if (catch qr/^Account not ACTIve/) {
Branch: 1 branch
BranchTrueFalseTotal
if (&catch(qr/^Account not ACTIve/)) 0 0 0
353 0 ▶ return wantarray ? () : undef;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
354 }
355 0 my ($first, $qty) = split ' ', $block;
356 0 ▶ return 0 + $qty unless wantarray;
Branch: 1 branch
BranchTrueFalseTotal
unless wantarray 0 0 0
357 0 my @numbers;
358 0 ▶ for (; $qty > 0; $qty--) {
Branch: 1 branch
BranchTrueFalseTotal
if ($qty > 0) 0 0 0
359 0 push @numbers, new Phone::Number($first++);
360 }
361 0 return @numbers;
362 }
363  
364 =head3 block_deactivate
365  
366 This should be passed the first number in a block. It will
367 deactivate and return the block of numbers.
368  
369 =cut
370  
371 sub block_deactivate
372 {
373 0 ▶ my $self = shift;
Subroutine block_deactivate: not called CC=1 SCAR=6.9
Pod documented
374 0 my $number = new Phone::Number(shift);
375 0 $self->blkdeac($number->packed);
376 }
377  
378 =head3 block_reactivate
379  
380 This should be passed the first number in a block. It will
381 reactivate the block and return the size of the block in scalar
382 context or an array of the numbers in list context.
383  
384 If the block is not available, this method will croak.
385  
386 In testing, this method has never worked correctly.
387  
388 =cut
389  
390 sub block_reactivate
391 {
392 0 ▶ my $self = shift;
Subroutine block_reactivate: not called CC=1 SCAR=6.9
Pod documented
393 0 my $number = new Phone::Number(shift);
394 0 $self->blkreac($number->packed);
395 }
396  
397 =head2 Service Methods
398  
399 =head3 fax2email
400  
401 Sets a number as a fax to email.
402  
403 $mt->fax2email($number, $email_address);
404  
405 =cut
406  
407 sub fax2email
408 {
409 0 ▶ my $self = shift;
Subroutine fax2email: not called CC=2 SCAR=17.9
Pod documented
410 0 my $number = new Phone::Number(shift);
411 0 my $email = shift;
412 0 my @email = parse Email::Address($email);
413 0 ▶ croak "One email address required" if @email != 1;
Branch: 1 branch
BranchTrueFalseTotal
if @email != 1 0 0 0
414 0 $self->set($number->packed, 1, "F:$email[0]");
415 }
416  
417 =head3 voice2email
418  
419 Sets a number as a voice to email.
420  
421 $mt->voice2email($number, $email_address);
422  
423 =cut
424  
425 sub voice2email
426 {
427 0 ▶ my $self = shift;
Subroutine voice2email: not called CC=2 SCAR=17.9
Pod documented
428 0 my $number = new Phone::Number(shift);
429 0 my $email = shift;
430 0 my @email = parse Email::Address($email);
431 0 ▶ croak "One email address required" if @email != 1;
Branch: 1 branch
BranchTrueFalseTotal
if @email != 1 0 0 0
432 0 $self->set($number->packed, 1, "V:$email[0]");
433 }
434  
435 =head3 sip
436  
437 $mt->sip($number, $host, [$username, [$inband]]);
438  
439 Passed a number and a host, will set an inbound sip link
440 to the international number (minus leading +) @ the host.
441 If username is defined, it will be used instead of the number.
442 If inband is true, it will force inband DTMF. The default is
443 RFC2833 DTMF.
444  
445 =cut
446  
447 sub sip
448 {
449 0 ▶ my $self = shift;
Subroutine sip: not called CC=4 SCAR=30.0
Pod documented
450 0 my $number = new Phone::Number(shift);
451 0 my ($host, $username, $inband) = @_;
452 0 ▶ croak "Domain required" unless $host;
Branch: 1 branch
BranchTrueFalseTotal
unless $host 0 0 0
453 0 ▶ $username = $number->plain unless $username;
Branch: 1 branch
BranchTrueFalseTotal
unless $username 0 0 0
454 0 ▶ my $sip = $inband ? "s" : "S";
Branch: 1 branch
BranchTrueFalseTotal
$inband ? : 0 0 0
455 0 $self->set($number->packed, 1, "$sip:$username\@$host");
456 }
457  
458 =head3 divert
459  
460 $mt->divert($number, $to_number);
461  
462 =cut
463  
464 sub divert
465 {
466 0 ▶ my $self = shift;
Subroutine divert: not called CC=1 SCAR=6.9
Pod documented
467 0 my $number = new Phone::Number(shift);
468 0 my $to = new Phone::Number(shift);
469 0 $self->set($number->packed, 1, $to->plain);
470 }
471  
472  
473 =head3 status
474  
475 Returns the status for a given number.
476  
477 my $status = $mt->status($number);
478 my @status = $mt->status($number);
479  
480 In scalar context, returns the first (and usually only) status as
481 a L<Magrathea::API::Status> object. In list context, returns up to
482 three statuses representing the three possible setups created with
483 ORDE.
484  
485 If the number is not allocated to us and activated, this routine
486 returns C<undef> in scalar context and an empty list in list context.
487  
488 The L<Magrathea::API::Status> object has the following calls:
489  
490 =over
491  
492 =item C<< $status->number >>
493  
494 A L<Phone::Number> object representing the number to which this
495 status refers.
496  
497 =item C<< $status->active >>
498  
499 Boolean.
500  
501 =item C<< $status->expiry >>
502  
503 The date this number expires in the form C<YYYY-MM-DD>.
504  
505 =item C<< $status->type >>
506  
507 One of sip, fax2email, voice2email, divert or unallocated.
508  
509 =item C<< $status->target >>
510  
511 The target email or phone number for this number;
512  
513 =item C<< $status->entry >>
514  
515 The entry number (1, 2 or 3) for this status;
516  
517 =back
518  
519 In addition, it overloads '""' to provide as tring comprising
520 the type and the target, separated by a space.
521  
522 =cut
523  
524 sub status
525 {
526 0 ▶ my $self = shift;
Subroutine status: not called CC=6 SCAR=37.4
Pod documented
527 0 my $number = new Phone::Number(shift);
528 0 my $status = eval {
529 0 $self->stat($number->packed);
530 };
531 0 ▶ return wantarray ? () : undef if $@;
Branch: 2 branches
BranchTrueFalseTotal
if $@ 0 0 0
wantarray ? : 0 0 0
532 0 my @statuses = split /\|/, $status;
533 0 my @retval;
534 0 for my $i (0 .. 2)
535 {
536 0 my $stat = new Magrathea::API::Status($statuses[$i]);
537 0 ▶ return $stat unless wantarray;
Branch: 1 branch
BranchTrueFalseTotal
unless wantarray 0 0 0
538 0 ▶ next unless $stat;
Branch: 1 branch
BranchTrueFalseTotal
unless $stat 0 0 0
539 0 $stat->entry($i + 1);
540 0 push @retval, $stat;
541 }
542 0 return @retval;
543 }
544  
545 =head2 Emergency Methods
546  
547 =head3 emergency_info
548  
549 Passed a phone number, this method returns a
550 L<Magrathea::API::Emergency> object with the current 999
551 information.
552  
553 =cut
554  
555 sub emergency_info
556 {
557 0 ▶ my $self = shift;
Subroutine emergency_info: not called CC=1 SCAR=6.9
Pod documented
558 0 my $number = new Phone::Number(shift);
559 0 return new Magrathea::API::Emergency($self, $number);
560 }
561  
562 =head2 Low Level Methods
563  
564 All the Magrathea low level calls are available. These are
565 simply passed an array of strings which are joined to create
566 the command string. They return the raw response
567 on success (minus the leading 0) and die on failure. C<$@>
568 will contain the error.
569  
570 See the L<Magrathea documentation|http://www.magrathea-telecom.co.uk/assets/Client-Downloads/Numbering-API-Instructions.pdf>.
571  
572 The functions are:
573  
574 =over
575  
576 =item auth
577  
578 This is called by L</new> and should not be called directly.
579  
580 $mt->auth('username', 'password');
581  
582 =item quit
583  
584 This is called automatically upon the Magrathea::API object
585 going out of scope and should not be called directly.
586  
587 =item allo
588  
589 $mt->allo('0201235___');
590  
591 =item acti
592  
593 $mt->acti('02012345678');
594  
595 =item deac
596  
597 $mt->deac('02012345678');
598  
599 =item reac
600  
601 $mt->reac('02012345678');
602  
603 =item stat
604  
605 $mt->stat('02012345678');
606  
607 =item set
608  
609 $mt->set('02012345678 1 441189999999');
610 $mt->set('02012345678 1 F:fax@mydomain.com');
611 $mt->set('02012345678 1 V:voicemail@mydomain.com');
612 $mt->set('02012345678 1 S:username@sip.com');
613 $mt->set('02012345678 1 I:username:password@iaxhost.com');
614  
615 =item spin
616  
617 $mt->set('02012345678 [pin]');
618  
619 =item feat
620  
621 $mt->feat('02012345678 D');
622 $mt->feat('02012345678 J');
623  
624 =item orde
625  
626 $mt->orde('02012345678 1 0000');
627  
628 =item info
629  
630 $mt->info('02012345678 GEN Magrathea, 14 Shute End, RG40 1BJ');
631  
632 =back
633  
634 It will not usually be necessary to call these functions directly.
635  
636 =cut
637  
638 sub AUTOLOAD
639 {
640 0 ▶ my $self = shift;
Subroutine AUTOLOAD: not called CC=2 SCAR=17.9
641 0 my $commands = qr{^(?:
642 AUTH|QUIT|ALLO|ACTI|DEAC|REAC|STAT|SET|SPIN|FEAT|ORDE|INFO|ALIST|
643 BLKACTI|BLKINFO|BLKDEAC|BLKREAC
644 )$}x;
645 0 (my $name = our $AUTOLOAD) =~ s/.*://;
646 0 my $cmd = uc $name;
647 0 ▶ croak "Unknown Command: $name" unless $cmd =~ $commands;
Branch: 1 branch
BranchTrueFalseTotal
unless $cmd =~ /$commands/ 0 0 0
648 0 return $self->sendline("$cmd @_");
649 }
650  
651 sub DESTROY
652 {
653 0 ▶ my $self = shift;
Subroutine DESTROY: not called CC=1 SCAR=6.9
654 0 eval {
655 0 $self->quit;
656 };
657 }
658  
659 1 1;
660  
661 __END__
↑ Summary API/Emergency.pm »