SRS/Types.pm

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