SRS/Types.pm

filter: Statementstmt 82.8% 63 / 76 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 31.5% 6 / 19 Podpod n/a totaltotal 71.1% 69 / 97 SCAR 7.1
CC
2
Cov
81%
__ANON__
3.7
__ANON__
2.0
__ANON__
2.0
CRAP 2.0
« SRS/Version.pm ↑ Summary SRS/Request.pm »
1  
2 package XML::SRS::Types;
3  
4 6 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 6 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use PRANG::XMLSchema::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 6 ▶use Regexp::Common qw(net);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 6 our $PKG = "XML::SRS";
13 6 subtype "${PKG}::Number"
14 => as "PRANG::XMLSchema::nonNegativeInteger";
15 6 subtype "${PKG}::RegistrarId"
16 => as "PRANG::XMLSchema::positiveInteger";
17 6 subtype "${PKG}::Term"
18 => as "PRANG::XMLSchema::positiveInteger";
19 subtype "${PKG}::token_OTHERS"
20 => as "Str",
21 0 ▶ => where { $_ eq "OTHERS" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
22 6 subtype "${PKG}::RegistrarIdOrOTHERS"
23 => as "${PKG}::RegistrarId|${PKG}::token_OTHERS";
24  
25 subtype "${PKG}::Dollars"
26 => as "PRANG::XMLSchema::decimal"
27 => where {
28 0 ▶ ($_ - sprintf("%.2f",$_)) < 0.0000001;
Subroutine __ANON__: not called CC=1 SCAR=6.9
29 6 };
30 6 subtype "${PKG}::UID"
31 => as "Str"; # XXX - any other constraints on ActionIDs?
32  
33 # a non-IDN domain name
34 6 our $RR_re = qr/[a-zA-Z0-9](:?[a-zA-Z0-9\-]*[a-zA-Z0-9])?/;
35 6 our $DNS_name_re = qr/(?:$RR_re\.)+$RR_re/;
36 subtype "${PKG}::DomainName"
37 => as "Str"
38 => where {
39 0 ▶ m{\A$DNS_name_re\Z};
Subroutine __ANON__: not called CC=1 SCAR=6.9
40 6 };
41  
42 subtype "${PKG}::UDAI"
43 => as "Str"
44 => where {
45 0 ▶ $_ =~ m{ \A [abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ23456789]{8} \z }xms;
Subroutine __ANON__: not called CC=1 SCAR=6.9
46 6 };
47  
48 subtype "${PKG}::HandleId"
49 => as "PRANG::XMLSchema::token"
50 => where {
51 # this is a subset of the EPP handle ID specification,
52 # which allows for 3-16 characters. Here we just
53 # restrict it to "word" characters, which still allows
54 # a whole bunch of Unicode characters. And hyphens.
55 0 ▶ m{\A[\p{IsWord}\- ]{3,16}\Z};
Subroutine __ANON__: not called CC=1 SCAR=6.9
56 6 };
57  
58 subtype "${PKG}::Email"
59 => as "Str"
60 => where {
61 # kept as-is for historical reasons
62 0 ▶ m{\A(?:[^@\s]+|".*")\@$DNS_name_re\Z};
Subroutine __ANON__: not called CC=1 SCAR=6.9
63 6 };
64  
65 subtype "${PKG}::IPv4"
66 => as "Str"
67 => where {
68 0 ▶ $_ =~ m{ \A $RE{net}{IPv4} \z }xms;
Subroutine __ANON__: not called CC=1 SCAR=6.9
69 6 };
70  
71 # IPv6 : from Regexp::IPv6
72 # http://search.cpan.org/~salva/Regexp-IPv6-0.02/lib/Regexp/IPv6.pm
73 # http://cpansearch.perl.org/src/SALVA/Regexp-IPv6-0.02/lib/Regexp/IPv6.pm
74 6 my $IPv4 = "(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))";
75 6 my $G = "[\\da-f]{1,4}";
76 6 my @tail = ( ":", ":(?:$G)?", "(?:(?::$G){1,2}|:$IPv4?)", "(?::$G)?(?:(?::$G){1,2}|:$IPv4?)", "(?::$G){0,2}(?:(?::$G){1,2}|:$IPv4?)", "(?::$G){0,3}(?:(?::$G){1,2}|:$IPv4?)", "(?::$G){0,4}(?:(?::$G){1,2}|:$IPv4?)" );
77 6 my $IPv6_re = $G;
78 6 $IPv6_re = "$G:(?:$IPv6_re|$_)" for @tail;
79 6 $IPv6_re = qr/:(?::$G){0,5}(?:(?::$G){1,2}|:$IPv4)|$IPv6_re/i;
80  
81 subtype "${PKG}::IPv6"
82 => as "Str"
83 => where {
84 0 ▶ $_ =~ m{ \A $IPv6_re \z }xms;
Subroutine __ANON__: not called CC=1 SCAR=6.9
85 6 };
86  
87 6 our @Boolean = qw(0 1);
88 subtype "${PKG}::Boolean"
89 => as "Bool"
90 => where {
91 0 ▶ $_ ~~ @Boolean;
Subroutine __ANON__: not called CC=1 SCAR=6.9
92 6 };
93 coerce "${PKG}::Boolean"
94 => from "Bool"
95 0 ▶ => via { $_ ? 1 : 0 };
Subroutine __ANON__: not called CC=2 SCAR=13.0
Branch: 1 branch
BranchTrueFalseTotal
$_ ? : 0 0 0
96 coerce "${PKG}::Dollars"
97 => from "PRANG::XMLSchema::decimal"
98 => via {
99 0 ▶ sprintf("%.2f",$_);
Subroutine __ANON__: not called CC=1 SCAR=6.9
100 6 };
101  
102 6 our @AccountingAction = qw(Credit Debit);
103 subtype "${PKG}::token_OTHERS"
104 => as "Str",
105 0 ▶ => where { $_ ~~ @AccountingAction };
Subroutine __ANON__: not called CC=1 SCAR=1.2
106  
107 6 enum "${PKG}::DomainWriteAction" =>
108 qw(DomainCreate DomainUpdate);
109  
110 6 enum "${PKG}::DomainQueryAction" =>
111 qw(Whois DomainDetailsQry ActionDetailsQry UDAIValidQry);
112  
113 6 enum "${PKG}::HandleWriteAction" =>
114 qw(HandleCreate HandleUpdate);
115  
116 subtype "${PKG}::HandleQueryAction"
117 => as "Str",
118 => where {
119 0 ▶ $_ eq qw(HandleDetailsQry);
Subroutine __ANON__: not called CC=1 SCAR=6.9
120 6 };
121  
122 6 enum "${PKG}::RegistrarWriteAction" =>
123 qw(RegistrarCreate RegistrarUpdate AckMessage);
124  
125 6 enum "${PKG}::RegistrarQueryAction" =>
126 qw(RegistrarDetailsQry RegistrarAccountQry GetMessages);
127  
128 6 enum "${PKG}::RegistryAction" =>
129 qw(SysParamsUpdate SysParamsQry RunLogCreate RunLogQry
130 ScheduleCreate ScheduleCancel ScheduleQry ScheduleUpdate
131 BillingExtract SetBillingAmount BillingAmountQry
132 DeferredIncomeSummaryQry DeferredIncomeDetailQry
133 BilledUntilAdjustment BuildDnsZoneFiles GenerateDomainReport
134 AdjustRegistrarAccount AccessControlListQry
135 AccessControlListAdd AccessControlListRemove);
136  
137 subtype "${PKG}::ActionName" =>
138 6 as join("|", map { "${PKG}::$_" }
139 qw(DomainWriteAction DomainQueryAction
140 HandleWriteAction HandleQueryAction
141 RegistrarWriteAction RegistrarQueryAction
142 RegistryAction));
143  
144 6 enum "${PKG}::ActionEtcExtra" =>
145 qw(UnknownTransaction DomainTransfer);
146  
147 6 enum "${PKG}::RegDomainStatus" =>
148 qw(Active PendingRelease);
149 6 enum "${PKG}::DomainStatus" =>
150 qw(Active PendingRelease Available);
151  
152 6 subtype "${PKG}::ActionEtc"
153 => as "${PKG}::ActionName|${PKG}::ActionEtcExtra";
154  
155 6 enum "${PKG}::RoleName" =>
156 qw( Registrar Registry Whois Query CreateDomain UpdateDomain
157 TransferDomain CancelDomain UncancelDomain UpdateRegistrar
158 Administer Supervisor Connect ReleaseDomain QueryACL
159 UpdateACL );
160  
161 # Domain Statuses
162 6 enum "${PKG}::RegDomainStatus" =>
163 qw(Active PendingRelease);
164  
165 6 enum "${PKG}::DomainStatus" =>
166 qw(Active PendingRelease Available);
167  
168 6 enum "${PKG}::BillStatus" =>
169 qw(PendingConfirmation Confirmed);
170  
171 6 1;
« SRS/Version.pm ↑ Summary SRS/Request.pm »