DRI/Data/RegistryObject.pm

filter: Statementstmt 28.9% 11 / 38 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 21 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 50.0% 3 / 6 Podpod 0.0% 0 / 2 totaltotal 14.7% 14 / 95 CC 16 SCAR 44.0
CC
16
Cov
15%
AUTOLOAD
132.0
new
42.0
target
2.0
CRAP 81.4
« DRI/Protocol/EPP/Extensions/E164Validation.pm ↑ Summary DRI/Transport/HTTP/XMLRPCLite.pm »
1 ## Domain Registry Interface, RegistryObject
2 ##
3 ## Copyright (c) 2005,2013 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
4 ##
5 ## This file is part of Net::DRI
6 ##
7 ## Net::DRI is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; either version 2 of the License, or
10 ## (at your option) any later version.
11 ##
12 ## See the LICENSE file that comes with this distribution for more details.
13 #########################################################################################
14  
15 package Net::DRI::Data::RegistryObject;
16  
17 86 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 86 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 86 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 86 our $AUTOLOAD;
23  
24 =pod
25  
26 =head1 NAME
27  
28 Net::DRI::Data::RegistryObject - Additional API for Net::DRI operations
29  
30 =head1 SYNOPSYS
31  
32 my $dri=Net::DRI->new();
33 my $nsg=$dri->remote_object('nsgroup');
34 $nsg->create(...);
35 $nsg->update(...);
36 $nsg->whatever(...);
37  
38 Also:
39 my $nsg=$dri->remote_object('nsgroup','name');
40  
41 =head1 DESCRIPTION
42  
43 For objects other than domains, hosts, or contacts, Net::DRI::Data::RegistryObject
44 can be used to apply actions.
45  
46 Net::DRI::remote_object is used to create a new Net::DRI::Data::RegistryObject
47 with either only one parameter (the object type) or two parameters (the object
48 type and the object name)
49  
50 If the object name is not passed at creation it will need to be passed for all
51 later actions as first parameter.
52  
53 All calls are handled by an AUTOLOAD, except target() which is the same as in Net::DRI.
54  
55 All calls need either two array references (protocol parameters and transport parameters)
56 or a list (protocol parameters only).
57  
58 =head1 SUPPORT
59  
60 For now, support questions should be sent to:
61  
62 E<lt>netdri@dotandco.comE<gt>
63  
64 Please also see the SUPPORT file in the distribution.
65  
66 =head1 SEE ALSO
67  
68 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
69  
70 =head1 AUTHOR
71  
72 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
73  
74 =head1 COPYRIGHT
75  
76 Copyright (c) 2005,2013 Patrick Mevzek <netdri@dotandco.com>.
77 All rights reserved.
78  
79 This program is free software; you can redistribute it and/or modify
80 it under the terms of the GNU General Public License as published by
81 the Free Software Foundation; either version 2 of the License, or
82 (at your option) any later version.
83  
84 See the LICENSE file that comes with this distribution for more details.
85  
86 =cut
87  
88  
89 ###########################################################################################################
90  
91 sub new
92 {
93 0 ▶ my ($class,$p,$type,$name)=@_; ## $name (object name) not necessarily defined
Subroutine new: not called CC=6 SCAR=37.4
Pod undocumented
94  
95 0 ▶ Net::DRI::Exception::err_invalid_parameters() unless (defined($p) && ((ref($p) eq 'Net::DRI') || (ref($p) eq 'Net::DRI::Registry')));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p and ref $p eq "Net::DRI" || ref $p eq "Net::DRI::Registry" 0 0 0
Condition0%0/6
defined $p and ref $p eq "Net::DRI" || ref $p eq "Net::DRI::Registry"
!ll&&!rl&&r
000
ref $p eq "Net::DRI" or ref $p eq "Net::DRI::Registry"
l!l&&r!l&&!r
000
MC/DC0%0/3
defined $p and ref $p eq "Net::DRI" || ref $p eq "Net::DRI::Registry"
defined $p ref $p eq "Net::DRI" ref $p eq "Net::DRI::Registry"
Truth table0%0/4
A and B or C
A= defined $pB= ref $p eq "Net::DRI"C= ref $p eq "Net::DRI::Registry"
ABCresult
0XX0
1000
11X1
1011
96 0 ▶ Net::DRI::Exception::err_insufficient_parameters() unless (defined($type) && $type);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type and $type 0 0 0
Condition0%0/3
defined $type and $type
!ll&&!rl&&r
000
MC/DC0%0/2
defined $type and $type
defined $type $type
Truth table0%0/3
A and B
A= defined $typeB= $type
ABresult
0X0
100
111
97  
98 0 my $self={
99 p => $p,
100 type => $type,
101 name => $name,
102 };
103  
104 0 bless($self,$class);
105 0 return $self;
106 }
107  
108 sub target
109 {
110 0 ▶ my ($self,@args)=@_;
Subroutine target: not called CC=1 SCAR=6.9
Pod undocumented
111 0 $self->{p}->target(@args);
112 0 return $self;
113 }
114  
115 sub AUTOLOAD ## no critic (Subroutines::RequireFinalReturn)
116 {
117 0 ▶ my ($self,@args)=@_;
Subroutine AUTOLOAD: not called CC=11 SCAR=48.8
118 0 my $attr=$AUTOLOAD; ## this is the action wanted on the object
119 0 $attr=~s/.*:://;
120 0 ▶ return unless $attr=~m/[^A-Z]/; ## skip DESTROY and all-cap methods
Branch: 1 branch
BranchTrueFalseTotal
unless $attr =~ /[^A-Z]/ 0 0 0
121  
122 0 my $name=$self->{name};
123 0 my ($rp,$rt);
124 0 ▶ if (@args==2 && (ref $args[0] eq 'ARRAY') && (ref $args[1] eq 'ARRAY'))
Branch: 1 branch
BranchTrueFalseTotal
if (@args == 2 and ref $args[0] eq 'ARRAY' and ref $args[1] eq 'ARRAY') { } 0 0 0
Condition0%0/6
@args == 2 and ref $args[0] eq "ARRAY" and ref $args[1] eq "ARRAY"
!ll&&!rl&&r
000
@args == 2 and ref $args[0] eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/3
@args == 2 and ref $args[0] eq "ARRAY" and ref $args[1] eq "ARRAY"
@args == 2 ref $args[0] eq "ARRAY" ref $args[1] eq "ARRAY"
Truth table0%0/4
A and B and C
A= @args == 2B= ref $args[0] eq "ARRAY"C= ref $args[1] eq "ARRAY"
ABCresult
0XX0
10X0
1100
1111
125 {
126 0 $rp=$args[0];
127 0 ▶ $rp=[ $self->{name}, @$rp ] if (defined $name && $name);
Branch: 1 branch
BranchTrueFalseTotal
if defined $name and $name 0 0 0
Condition0%0/3
defined $name and $name
!ll&&!rl&&r
000
MC/DC0%0/2
defined $name and $name
defined $name $name
Truth table0%0/3
A and B
A= defined $nameB= $name
ABresult
0X0
100
111
128 0 $rt=$args[1];
129 } else
130 {
131 0 ▶ $rp=(defined $name && $name)? [ $name, @args ] : [ @args ];
Branch: 1 branch
BranchTrueFalseTotal
defined $name && $name ? : 0 0 0
Condition0%0/3
defined $name and $name
!ll&&!rl&&r
000
MC/DC0%0/2
defined $name and $name
defined $name $name
Truth table0%0/3
A and B
A= defined $nameB= $name
ABresult
0X0
100
111
132 0 $rt=[];
133 }
134  
135 0 my $p=$self->{p};
136 0 ▶ if (ref $p eq 'Net::DRI::Registry')
Branch: 2 branches
BranchTrueFalseTotal
if (ref $p eq 'Net::DRI::Registry') { } 0 0 0
elsif (ref $p eq 'Net::DRI') { } 0 0 0
137 {
138 0 return $p->process($self->{type},$attr,$rp,$rt);
139 } elsif (ref $p eq 'Net::DRI')
140 {
141 0 my $c=$self->{type}.'_'.$attr;
142 0 return $p->$c->(@$rp);
143 } else
144 {
145 0 Net::DRI::Exception::err_assert('case not handled: '.ref($p));
146 }
147 }
148  
149 ###########################################################################################################
150 86 1;
« DRI/Protocol/EPP/Extensions/E164Validation.pm ↑ Summary DRI/Transport/HTTP/XMLRPCLite.pm »