Continental/Zone.pm

filter: Statementstmt 93.3% 28 / 30 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 84.6% 11 / 13 Podpod 85.7% 6 / 7 totaltotal 87.0% 47 / 54 SCAR 11.0
CC
3
Cov
88%
tld
2.1
nerd_response
2.0
in_nerddk
2.0
CRAP 3.0
« Continental.pm ↑ Summary
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 package Net::Continental::Zone;
5 # ABSTRACT: a zone of IP space
6 1 $Net::Continental::Zone::VERSION = '0.016';
7 1 ▶use Locale::Codes::Country 3.29 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Net::Domain::TLD ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 #pod =method new
11 #pod
12 #pod B<Achtung!> There is no C<new> method for you to use. Instead, do this:
13 #pod
14 #pod my $zone = Net::Continental->zone('au');
15 #pod
16 #pod =cut
17  
18 5 ▶sub _new { bless $_[1] => $_[0] }
Subroutine _new: called CC=1 SCAR=0.0
19  
20 #pod =method code
21 #pod
22 #pod This returns the zone's zone code.
23 #pod
24 #pod =method in_nerddk
25 #pod
26 #pod This is true if the nerd.dk country blacklist is capable, using its encoding
27 #pod scheme, of indicating a hit from this country.
28 #pod
29 #pod =method nerd_response
30 #pod
31 #pod This returns the response that will be given by the nerd.dk country blacklist
32 #pod for IPs in this zone, if one is defined.
33 #pod
34 #pod =method continent
35 #pod
36 #pod This returns the continent in which the zone has been placed. These are
37 #pod subject to change, for now, and there may be a method by which to define your
38 #pod own classifications. I do not want to get angry email from people in Georgia!
39 #pod
40 #pod =method description
41 #pod
42 #pod This is a short description of the zone, like "United States" or "Soviet
43 #pod Union."
44 #pod
45 #pod =method is_tld
46 #pod
47 #pod This returns true if the zone code is also a country code TLD.
48 #pod
49 #pod =cut
50  
51 10 ▶sub code { $_[0][0] }
Subroutine code: called CC=1 SCAR=0.0
Pod documented
52  
53 sub in_nerddk {
54 0 ▶ return defined $_[0]->nerd_response;
Subroutine in_nerddk: not called CC=1 SCAR=6.9
Pod documented
55 }
56  
57 sub nerd_response {
58 4 ▶ my ($self) = @_;
Subroutine nerd_response: called CC=2 SCAR=7.0
Pod documented
59  
60 4 my $n = Locale::Codes::Country::country_code2code(
61 $self->code,
62 'alpha-2',
63 'numeric',
64 );
65  
66 4 ▶ return unless $n;
Branch: 1 branch
BranchTrueFalseTotal
unless $n 0 4 4
67 4 my $top = $n >> 8;
68 4 my $bot = $n % 256;
69 4 return "127.0.$top.$bot";
70 }
71  
72 0 ▶sub continent { $Net::Continental::Continent{ $_[0][1] } }
Subroutine continent: not called CC=1 SCAR=6.9
Pod documented
73 5 ▶sub description { $_[0][2] }
Subroutine description: called CC=1 SCAR=0.0
Pod documented
74 5 ▶sub is_tld { Net::Domain::TLD::tld_exists($_[0][0], 'cc'); }
Subroutine is_tld: called CC=1 SCAR=0.0
Pod documented
75  
76 sub tld {
77 2 ▶ return $_[0][3] if Net::Domain::TLD::tld_exists($_[0][3], 'cc');
Subroutine tld: called CC=2 SCAR=7.6
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if Net::Domain::TLD::tld_exists($_[0][3], "cc") 2 0 2
78 }
79  
80 1 1;
81  
82 __END__
« Continental.pm ↑ Summary