blib/lib/Acme/Terror/UK.pm

filter: Statementstmt 82.0% 41 / 50 Branchbran 18.7% 3 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 13 / 13 Podpod 100% 3 / 3 totaltotal 73.1% 60 / 82 CC 9 SCAR 25.0
CC
9
Cov
67%
level
33.8
fetch
2.2
new
2.0
CRAP 12.2
↑ Summary
1 package Acme::Terror::UK;
2  
3 ## Get and return the current UK terrorist threat status.
4 ## Robert Price - http://www.robertprice.co.uk/
5  
6 1 ▶use 5.00503;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use LWP::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 $VERSION = '0.06';
13  
14 1 ▶use constant UNKNOWN => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use constant CRITICAL => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use constant SEVERE => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use constant SUBSTANTIAL => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use constant MODERATE => 4;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use constant LOW => 5;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21  
22 1 ▶sub new {
Subroutine new: called CC=2 SCAR=7.1
Pod documented
23 1 my ($class, %args) = @_;
24 1 ▶ $class = ref($class) if (ref $class);
Branch: 1 branch
BranchTrueFalseTotal
if ref $class 0 1 1
25 1 return bless(\%args, $class);
26 }
27  
28 1 ▶sub fetch {
Subroutine fetch: called CC=2 SCAR=7.9
Pod documented
29 1 my $self = shift;
30 1 my $url = 'http://www.mi5.gov.uk/';
31 1 my $html = get($url);
32 1 ▶ return undef unless ($html);
Branch: 1 branch
BranchTrueFalseTotal
unless $html 1 0 1
33 0 my ($lvl) = ($html =~ m!</a>Current UK threat level</strong></p>.+?<h3><font style="FONT-SIZE: 12pt">(.+?)</font></h3>!sgi);
34 0 return $lvl;
35 }
36  
37 1 ▶sub level {
Subroutine level: called CC=7 SCAR=35.2
Pod documented
38 1 my $self = shift;
39 1 my $level = $self->fetch();
40 1 ▶ return UNKNOWN unless ($level);
Branch: 1 branch
BranchTrueFalseTotal
unless $level 1 0 1
41 0 ▶ if ($level eq 'CRITICAL') {
Branch: 5 branches
BranchTrueFalseTotal
if ($level eq 'CRITICAL') { } 0 0 0
elsif ($level eq 'SEVERE') { } 0 0 0
elsif ($level eq 'SUBSTANTIAL') { } 0 0 0
elsif ($level eq 'MODERATE') { } 0 0 0
elsif ($level eq 'LOW') { } 0 0 0
42 0 return CRITICAL;
43 } elsif ($level eq 'SEVERE') {
44 0 return SEVERE;
45 } elsif ($level eq 'SUBSTANTIAL') {
46 0 return SUBSTANTIAL;
47 } elsif ($level eq 'MODERATE') {
48 0 return MODERATE;
49 } elsif ($level eq 'LOW') {
50 0 return LOW;
51 } else {
52 0 return UNKNOWN;
53 }
54 }
55  
56  
57 1 1;
58 __END__
↑ Summary